diff --git a/CalibPPS/AlignmentGlobal/README.md b/CalibPPS/AlignmentGlobal/README.md index 74f93ad42810a..2ed157af113b5 100644 --- a/CalibPPS/AlignmentGlobal/README.md +++ b/CalibPPS/AlignmentGlobal/README.md @@ -1,125 +1,133 @@ # PPSAlignmentWorker -## Config example: -[`ppsAlignmentWorker_cfi.py`](python/ppsAlignmentWorker_cfi.py) ## Parameters: | Name | Type | Description | |-------------|----------------|--------------------------------------------------------------------------| -| `tagTracks` | `cms.InputTag` | Should be set to `"ctppsLocalTrackLiteProducer"`. | +| `tagTracks` | `cms.InputTag` | Should be set to `"ctppsLocalTrackLiteProducer"`. | | `folder` | `cms.string` | Should be the same as the `folder` parameter in DQM configuration. | | `label` | `cms.string` | Label for EventSetup | | `debug` | `cms.bool` | When set to `True`, the worker will produce some extra debug histograms. | # PPSAlignmentHarvester -## Config example: -[`ppsAlignmentHarvester_cfi.py`](python/ppsAlignmentHarvester_cfi.py) ## Parameters: -| Name | Type | Description | -|----------|--------------|---------------------------------------------------------------------------------------| -| `folder` | `cms.string` | Should be the same as the `folder` parameter in DQM configuration. | -| `debug` | `cms.bool` | When set to `True`, the harvester will produce an extra ROOT file with debug plots. | +| Name | Type | Description | +|-------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +| `folder` | `cms.string` | Should be the same as the `folder` parameter in DQM configuration. | +| `sequence` | `cms.vstring` | Determines order of the alignment methods: `"x_alignemnt"`, `"x_alignment_relative"`, `"y_alignment"`. | +| `overwrite_sh_x` | `cms.bool` | If set to `True`, `x alignment` will overwrite horizontal shift passed in the configuration. | +| `test_results_path` | `cms.string` | Path of a file with the results. If empty (`""`), the file will not be created. | +| `write_sqlite_results` | `cms.bool` | When set to `True`, the harvester will try to use PoolDBOutputService to save the final results. | +| `x_ali_rel_final_slope_fixed` | `cms.bool` | `True`: the harvester will use the x relative alignment results with fixed slope to prepare final merged results. `False`: results without fixed slope. | +| `y_ali_final_slope_fixed` | `cms.bool` | `True`: the harvester will use the y alignment results with fixed slope to prepare final merged results. `False`: results without fixed slope. | +| `debug` | `cms.bool` | When set to `True`, the harvester will produce an extra ROOT file with debug plots. | # Event Setup Default values come from the `fillDescriptions` method in `CalibPPS/ESProducers/plugins/PPSAlignmentConfigESSource.cc`.
NB: Parameters here are written in snake_case. Many of them are in camelCase in the code (as PPSAlignmentConfig getters). -| Name | Type | Default | Description | -|------------------------|---------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------| -| `debug` | `cms.bool` | `False` | When set to `True`, the ESProducer will produce an extra ROOT file with debug plots (from reference run). | -| `label` | `cms.string` | `""` | label to distinguish reference and test fill configs. Should be set either to `""` (test) or `"reference"` | -| `sequence` | `cms.vstring` | empty vector | Determines order of the alignment methods: `"x_alignemnt"`, `"x_alignment_relative"`, `"y_alignment"`. | -| `results_dir` | `cms.string` | `"./alignment_results.txt"` | Directory of a file with the results. If empty (`""`), the file will not be created. | -| `sector_45` | `cms.PSet` | [details below](#Sector-config) | Configuration of sector 45. [Details below](#Sector-config) | -| `sector_56` | `cms.PSet` | [details below](#Sector-config) | Configuration of sector 56. [Details below](#Sector-config) | -| `x_ali_sh_step` | `cms.double` | `0.01` | Step for x alignment algorithm | -| `y_mode_sys_unc` | `cms.double` | `0.03` | Squared is an element of y mode uncertainty in y alignment. | -| `chiSqThreshold` | `cms.double` | `50.` | Chi-square threshold of y mode | -| `y_mode_unc_max_valid` | `cms.double` | `5.` | Maximal valid y mode uncertainty | -| `y_mode_max_valid` | `cms.double` | `20.` | Maximal valid y mode | -| `max_RP_tracks_size` | `cms.uint32` | `2.` | Maximal tracksUp or tracksDw size to avoid crowded events | -| `n_si` | `cms.double` | `4.` | Element of checking whether the cuts passed | -| `matching` | `cms.PSet` | [details below](#matching) | Reference dataset parameters. [Details below](#matching) | -| `x_alignment_meth_o` | `cms.PSet` | [details below](#x_alignment_meth_o) | X alignment parameters. (Details below)[#x_alignment_meth_o] | -| `x_alignment_relative` | `cms.PSet` | [details below](#x_alignment_relative) | Relative x alignment parameters. [Details below](#x_aligmment_relative) | -| `y_alignment` | `cms.PSet` | [details below](#y_alignment) | Y alignment parameters. [Details below](#y_alignment) | -| `binning` | `cms.PSet` | [details below](#binning) | Binning parameters for worker. [Details below](#binning) | +| Name | Type | Default | Description | +|------------------------|---------------|----------------------------------------|------------------------------------------------------------------------------------------------------------| +| `debug` | `cms.bool` | `False` | When set to `True`, the ESProducer will produce an extra ROOT file with debug plots (from reference run). | +| `label` | `cms.string` | `""` | label to distinguish reference and test fill configs. Should be set either to `""` (test) or `"reference"` | +| `sector_45` | `cms.PSet` | [details below](#Sector-config) | Configuration of sector 45. [Details below](#Sector-config) | +| `sector_56` | `cms.PSet` | [details below](#Sector-config) | Configuration of sector 56. [Details below](#Sector-config) | +| `x_ali_sh_step` | `cms.double` | `0.01` | Step for x alignment algorithm [mm] | +| `y_mode_sys_unc` | `cms.double` | `0.03` | Squared is an element of y mode uncertainty in y alignment. | +| `chiSqThreshold` | `cms.double` | `50.` | Chi-square threshold of y mode | +| `y_mode_unc_max_valid` | `cms.double` | `5.` | Maximum valid y mode uncertainty | +| `y_mode_max_valid` | `cms.double` | `20.` | Maximum valid y mode | +| `min_RP_tracks_size` | `cms.uint32` | `1` | Minimum number of tracks in each RP | +| `max_RP_tracks_size` | `cms.uint32` | `1` | Maximum number of tracks in each RP | +| `n_si` | `cms.double` | `4.` | Element of checking whether the cuts passed | +| `matching` | `cms.PSet` | [details below](#matching) | Reference dataset parameters. [Details below](#matching) | +| `x_alignment_meth_o` | `cms.PSet` | [details below](#x_alignment_meth_o) | X alignment parameters. [Details below](#x_alignment_meth_o) | +| `x_alignment_relative` | `cms.PSet` | [details below](#x_alignment_relative) | Relative x alignment parameters. [Details below](#x_aligmment_relative) | +| `y_alignment` | `cms.PSet` | [details below](#y_alignment) | Y alignment parameters. [Details below](#y_alignment) | +| `binning` | `cms.PSet` | [details below](#binning) | Binning parameters for worker. [Details below](#binning) | +| `extraParams` | `cms.vdouble` | empty vector | Extra vector of doubles added in case new parameters need to be added in the future | ## Sector config -| Name | Type | Default (s_45) | Default (s_56) | Description | -|---------------|--------------|-------------------------------|-------------------------------|------------------------------------------------------| -| `rp_N` | `cms.PSet` | [details below](#RP-config) | [details below](#RP-config) | Near RP configuration. [Details below](#RP-config) | -| `rp_F` | `cms.PSet` | [details below](#RP-config) | [details below](#RP-config) | Far RP configuration. [Details below](#RP-config) | -| `slope` | `cms.double` | `0.006` | `-0.015` | Base slope value | -| `cut_h_apply` | `cms.bool` | `True` | `True` | If set to `True`, cut_h is applied | -| `cut_h_a` | `cms.double` | `-1.` | `-1.` | cut_h parameter | -| `cut_h_c` | `cms.double` | `-38.55` | `-39.26` | cut_h parameter | -| `cut_h_si` | `cms.double` | `0.2` | `0.2` | cut_h parameter | -| `cut_v_apply` | `cms.bool` | `True` | `True` | If set to `True`, cut_v is applied | -| `cut_v_a` | `cms.double` | `-1.07` | `-1.07` | cut_v parameter | -| `cut_v_c` | `cms.double` | `1.63` | `1.49` | cut_v parameter | -| `cut_v_si` | `cms.double` | `0.15` | `0.15` | cut_v parameter | +| Name | Type | Default (s_45) | Default (s_56) | Description | +|---------------|--------------|-----------------------------|-----------------------------|----------------------------------------------------| +| `rp_N` | `cms.PSet` | [details below](#RP-config) | [details below](#RP-config) | Near RP configuration. [Details below](#RP-config) | +| `rp_F` | `cms.PSet` | [details below](#RP-config) | [details below](#RP-config) | Far RP configuration. [Details below](#RP-config) | +| `slope` | `cms.double` | `0.006` | `-0.015` | Base slope value | +| `cut_h_apply` | `cms.bool` | `True` | `True` | If set to `True`, cut_h is applied | +| `cut_h_a` | `cms.double` | `-1.` | `-1.` | cut_h parameter | +| `cut_h_c` | `cms.double` | `-38.55` | `-39.26` | cut_h parameter | +| `cut_h_si` | `cms.double` | `0.2` | `0.2` | cut_h parameter | +| `cut_v_apply` | `cms.bool` | `True` | `True` | If set to `True`, cut_v is applied | +| `cut_v_a` | `cms.double` | `-1.07` | `-1.07` | cut_v parameter | +| `cut_v_c` | `cms.double` | `1.63` | `1.49` | cut_v parameter | +| `cut_v_si` | `cms.double` | `0.15` | `0.15` | cut_v parameter | ### RP config -| Name | Type | Default (s_45, rp_N) | Default (s_45, rp_F) | Default (s_56, rp_N) | Default (s_56, rp_F) | Description | -|------------------|--------------|----------------------|----------------------|----------------------|----------------------|---------------------------------------------------------------------------------------------------------------------------------| -| `name` | `cms.string` | `"L_1_F"` | `"L_2_F"` | `"R_1_F"` | `"R_2_F"` | Name of the RP | -| `id` | `cms.int32` | `3` | `23` | `103` | `123` | ID of the RP | -| `slope` | `cms.double` | `0.19` | `0.19` | `0.40` | `0.39` | Base slope value | -| `sh_x` | `cms.double` | `-3.6` | `-42.` | `-2.8` | `-41.9` | Base sh_x value. X alignment method overwrites it. | +| Name | Type | Default (s_45, rp_N) | Default (s_45, rp_F) | Default (s_56, rp_N) | Default (s_56, rp_F) | Description | +|------------------|--------------|----------------------|----------------------|----------------------|----------------------|-------------------------------------------------------------------------------------------------------------------------------| +| `name` | `cms.string` | `"L_1_F"` | `"L_2_F"` | `"R_1_F"` | `"R_2_F"` | Name of the RP | +| `id` | `cms.int32` | `3` | `23` | `103` | `123` | ID of the RP | +| `slope` | `cms.double` | `0.19` | `0.19` | `0.40` | `0.39` | Base slope value | +| `sh_x` | `cms.double` | `-3.6` | `-42.` | `-2.8` | `-41.9` | Base sh_x value [mm]. X alignment method overwrites it. | | `x_min_fit_mode` | `cms.double` | `2.` | `2.` | `2.` | `2.` | Mode graph parameter. See [buildModeGraph](plugins/PPSAlignmentHarvester.cc#L648). | | `x_max_fit_mode` | `cms.double` | `7.` | `7.5` | `7.4` | `8.` | Mode graph parameter. See [buildModeGraph](plugins/PPSAlignmentHarvester.cc#L648). | | `y_max_fit_mode` | `cms.double` | `7.` | `7.5` | `7.4` | `8.` | Mode graph parameter (in 2018 the same value as x_max_fit_mode). See [buildModeGraph](plugins/PPSAlignmentHarvester.cc#L654). | -| `y_cen_add` | `cms.double` | `-0.3` | `-0.3` | `-0.8` | `-0.8` | The value is added to y_cen (mean of y) while constructing a graph in x alignment. | -| `y_width_mult` | `cms.double` | `1.1` | `1.1` | `1.0` | `1.` | y_width (RMS of y) is multiplied by the value when constructing a graph in x alignment. | -| `x_slice_min` | `cms.double` | `7.` | `46.` | `6.` | `45.` | Min x for slice plots (x alignment) | -| `x_slice_max` | `cms.double` | `19.` | `58.` | `17.` | `57.` | Max x for slice plots (x alignment) | -| `x_slice_w` | `cms.double` | `0.2` | `0.2` | `0.2` | `0.2` | X width for slice plots (x alignment) | +| `y_cen_add` | `cms.double` | `-0.3` | `-0.3` | `-0.8` | `-0.8` | The value is added to y_cen (mean of y) while constructing a graph in x alignment. | +| `y_width_mult` | `cms.double` | `1.1` | `1.1` | `1.0` | `1.` | y_width (RMS of y) is multiplied by the value when constructing a graph in x alignment. | +| `x_slice_min` | `cms.double` | `7.` | `46.` | `6.` | `45.` | Min x for slice plots (x alignment) | +| `x_slice_max` | `cms.double` | `19.` | `58.` | `17.` | `57.` | Max x for slice plots (x alignment) | +| `x_slice_w` | `cms.double` | `0.2` | `0.2` | `0.2` | `0.2` | X width for slice plots (x alignment) | ## matching -Should be set in the reference config! -| Name | Type | Default | Description | -|---------------------|--------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `reference_dataset` | `cms.string` | `""` | Directory of the file with reference dataset histograms. Should be empty when running the worker for the reference dataset. After that, should be set to the name of the created ROOT file. | -| `rp_L_F` | `cms.PSet` | `-43.` - `-41.` | Left far RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment | -| `rp_L_N` | `cms.PSet` | `-4.2` - `-2.4` | Left near RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment | -| `rp_R_N` | `cms.PSet` | `-3.6` - `-1.8` | Right near RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment | -| `rp_R_F` | `cms.PSet` | `-43.2` - `-41.2` | Right far RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment | +| Name | Type | Default | Description | +|---------------------|--------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `reference_dataset` | `cms.string` | `""` | Directory of the file with reference dataset histograms. Should be empty when running the worker for the reference dataset. After that, should be set to the name of the created ROOT file (in the reference config). | +| `rp_L_F` | `cms.PSet` | `-43.` - `-41.` | Left far RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment [mm] | +| `rp_L_N` | `cms.PSet` | `-4.2` - `-2.4` | Left near RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment [mm] | +| `rp_R_N` | `cms.PSet` | `-3.6` - `-1.8` | Right near RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment [mm] | +| `rp_R_F` | `cms.PSet` | `-43.2` - `-41.2` | Right far RP. Contains two parameters of type `cms.double`: `sh_min` and `sh_max` - shift range for x alignment [mm] | ## x_alignment_meth_o -| Name | Type | Default | Description | -|--------------------------------|--------------|----------------|--------------------------------------------------------------------------------------------------------------| -| `rp_L_F` | `cms.PSet` | `47.` - `56.5` | Left far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | -| `rp_L_N` | `cms.PSet` | `9.` - `18.5` | Left near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | -| `rp_R_N` | `cms.PSet` | `7.` - `15.` | Right near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | -| `rp_R_F` | `cms.PSet` | `46.` - `54.` | Right far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | -| `fit_profile_min_bin_entries` | `cms.uint32` | `5` | Minimal number of entries in each bin in fitProfile method | -| `fit_profile_min_N_reasonable` | `cms.uint32` | `10` | Minimal number of valid bins in fitProfile method | -| `meth_o_graph_min_N` | `cms.uint32` | `5` | Minimal number of points in each of reference and test graph | -| `meth_o_unc_fit_range` | `cms.double` | `0.5` | Fit range for chi-square graph. | +| Name | Type | Default | Description | +|--------------------------------|--------------|----------------|------------------------------------------------------------------------------------------------------------| +| `rp_L_F` | `cms.PSet` | `47.` - `56.5` | Left far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | +| `rp_L_N` | `cms.PSet` | `9.` - `18.5` | Left near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | +| `rp_R_N` | `cms.PSet` | `7.` - `15.` | Right near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | +| `rp_R_F` | `cms.PSet` | `46.` - `54.` | Right far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for x alignment | +| `fit_profile_min_bin_entries` | `cms.uint32` | `5` | Minimum number of entries in each bin in fitProfile method | +| `fit_profile_min_N_reasonable` | `cms.uint32` | `10` | Minimum number of valid bins in fitProfile method | +| `meth_o_graph_min_N` | `cms.uint32` | `5` | Minimum number of points in each of reference and test graph | +| `meth_o_unc_fit_range` | `cms.double` | `0.5` | Fit range for chi-square graph. | ## x_alignment_relative -| Name | Type | Default | Description | -|------------------------|--------------|---------------|-----------------------------------------------------------------------------------------------------------------------| -| `rp_L_F` | `cms.PSet` | `0.` - `0.` | Left far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for relative x alignment | -| `rp_L_N` | `cms.PSet` | `7.5` - `12.` | Left near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for relative x alignment | -| `rp_R_N` | `cms.PSet` | `6.` - `10.` | Right near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for relative x alignment | -| `rp_R_F` | `cms.PSet` | `0.` - `0.` | Right far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for relative x alignment | -| `near_far_min_entries` | `cms.uint32` | `100` | Minimal number of entries in near_far histograms | +| Name | Type | Default | Description | +|------------------------|--------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| +| `rp_L_N` | `cms.PSet` | `7.5` - `12.` | Sector 45 alignment x relative ranges configuration. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for relative x alignment | +| `rp_R_N` | `cms.PSet` | `6.` - `10.` | Sector 56 alignment x relative ranges configuration. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for relative x alignment | +| `near_far_min_entries` | `cms.uint32` | `100` | Minimum number of entries in n+A97:D100ear_far histograms | ## y_alignment -| Name | Type | Default | Description | -|-------------------------------|--------------|----------------|--------------------------------------------------------------------------------------------------------------| -| `rp_L_F` | `cms.PSet` | `44.5` - `49.` | Left far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | -| `rp_L_N` | `cms.PSet` | `6.7` - `11.` | Left near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | -| `rp_R_N` | `cms.PSet` | `5.9` - `10.` | Right near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | -| `rp_R_F` | `cms.PSet` | `44.5` - `49.` | Right far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | -| `mode_graph_min_N` | `cms.uint32` | `5` | Minimal number of points in mode graph | -| `mult_sel_proj_y_min_entries` | `cms.uint32` | `300` | Minimal number of entries in y projection of multiplicity selection histograms | +| Name | Type | Default | Description | +|-------------------------------|--------------|----------------|------------------------------------------------------------------------------------------------------------| +| `rp_L_F` | `cms.PSet` | `44.5` - `49.` | Left far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | +| `rp_L_N` | `cms.PSet` | `6.7` - `11.` | Left near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | +| `rp_R_N` | `cms.PSet` | `5.9` - `10.` | Right near RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | +| `rp_R_F` | `cms.PSet` | `44.5` - `49.` | Right far RP. Contains two parameters of type `cms.double`: `x_min` and `x_max` - x range for y alignment | +| `mode_graph_min_N` | `cms.uint32` | `5` | Minimum number of points in mode graph | +| `mult_sel_proj_y_min_entries` | `cms.uint32` | `300` | Minimum number of entries in y projection of multiplicity selection histograms | ## binning -| Name | Type | Default | Description | -|------------------|--------------|---------------|-----------------------------------| -| `bin_size_x` | `cms.double` | `142.3314E-3` | X bin size | -| `n_bins_x` | `cms.uint32` | `210` | Number of bins in many histograms | -| `pixel_x_offset` | `cms.double` | `40.` | Pixel x offset | -| `n_bins_y` | `cms.uint32` | `400` | Number of bins in many histograms | -| `y_min` | `cms.double` | `-20.` | Min y for 2D histograms | -| `y_max` | `cms.double` | `20.` | Min y for 2D histograms | \ No newline at end of file +| Name | Type | Default | Description | +|-------------------|--------------|---------------|------------------------------------------| +| `bin_size_x` | `cms.double` | `142.3314E-3` | X bin size | +| `n_bins_x` | `cms.uint32` | `210` | Number of bins in many histograms | +| `pixel_x_offset` | `cms.double` | `40.` | Pixel x offset | +| `n_bins_y` | `cms.uint32` | `400` | Number of bins in many histograms | +| `y_min` | `cms.double` | `-20.` | Min y for 2D histograms | +| `y_max` | `cms.double` | `20.` | Max y for 2D histograms | +| `diffFN_n_bins_x` | `cms.uint32` | `100` | Number of bins in near-far profiles | +| `diffFN_x_min` | `cms.double` | `0.` | X axis min for near-far profiles | +| `diffFN_x_max` | `cms.double` | `20.` | X axis max for near-far profiles | +| `slice_n_bins_x` | `cms.uint32` | `100` | Number of bins in x axis for slice plots | +| `slice_x_min` | `cms.double` | `-10.` | X axis min for slice plots | +| `slice_x_max` | `cms.double` | `10.` | X axis max for slice plots | +| `slice_n_bins_y` | `cms.uint32` | `100` | Number of bins in y axis for slice plots | +| `slice_y_min` | `cms.double` | `-2.` | Y axis min for slice plots | +| `slice_y_max` | `cms.double` | `2.` | Y axis max for slice plots | \ No newline at end of file diff --git a/CalibPPS/AlignmentGlobal/plugins/BuildFile.xml b/CalibPPS/AlignmentGlobal/plugins/BuildFile.xml index 7c6e8f93db3ab..aa1c70dbc725d 100644 --- a/CalibPPS/AlignmentGlobal/plugins/BuildFile.xml +++ b/CalibPPS/AlignmentGlobal/plugins/BuildFile.xml @@ -4,10 +4,12 @@ + + - \ No newline at end of file + diff --git a/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc b/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc index 3d86df5cc99ea..1abb7cdd09ecf 100644 --- a/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc +++ b/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc @@ -1,14 +1,8 @@ /**************************************************************************** - * - * CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc - * - * Description : PPS Alignment DQM harvester - * - * Authors: - * - Jan Kašpar - * - Mateusz Kocot - * - ****************************************************************************/ +* Authors: +* Jan Kašpar (jan.kaspar@gmail.com) +* Mateusz Kocot (mateuszkocot99@gmail.com) +****************************************************************************/ #include "DQMServices/Core/interface/DQMEDHarvester.h" #include "DQMServices/Core/interface/DQMStore.h" @@ -18,13 +12,18 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionData.h" #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h" +#include "CondFormats/DataRecord/interface/CTPPSRPAlignmentCorrectionsDataRcd.h" -#include "CondFormats/PPSObjects/interface/PPSAlignmentConfig.h" -#include "CondFormats/DataRecord/interface/PPSAlignmentConfigRcd.h" +#include "CondFormats/PPSObjects/interface/PPSAlignmentConfiguration.h" +#include "CondFormats/DataRecord/interface/PPSAlignmentConfigurationRcd.h" +#include #include #include #include @@ -49,90 +48,292 @@ class PPSAlignmentHarvester : public DQMEDHarvester { public: - PPSAlignmentHarvester(const edm::ParameterSet &iConfig); + PPSAlignmentHarvester(const edm::ParameterSet& iConfig); + ~PPSAlignmentHarvester() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - void dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override; - void dqmEndRun(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - edm::Run const &iRun, - edm::EventSetup const &iSetup) override; + void dqmEndJob(DQMStore::IBooker& iBooker, DQMStore::IGetter& iGetter) override; + void dqmEndRun(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + edm::Run const& iRun, + edm::EventSetup const& iSetup) override; // ------------ x alignment ------------ - static int fitProfile(TProfile *p, + static int fitProfile(TProfile* p, double x_mean, double x_rms, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable, - double &sl, - double &sl_unc); - TGraphErrors *buildGraphFromVector(const std::vector &pv); - TGraphErrors *buildGraphFromMonitorElements(DQMStore::IGetter &iGetter, - const RPConfig &rpd, - const std::vector &mes, - unsigned int fitProfileMinBinEntries, - unsigned int fitProfileMinNReasonable); - void doMatch(DQMStore::IBooker &iBooker, - const PPSAlignmentConfig &cfg, - const RPConfig &rpd, - TGraphErrors *g_ref, - TGraphErrors *g_test, - const SelectionRange &range_ref, + double& sl, + double& sl_unc); + std::unique_ptr buildGraphFromVector(const std::vector& pv); + std::unique_ptr buildGraphFromMonitorElements(DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration::RPConfig& rpc, + const std::vector& mes, + unsigned int fitProfileMinBinEntries, + unsigned int fitProfileMinNReasonable); + void doMatch(DQMStore::IBooker& iBooker, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration::RPConfig& rpc, + TGraphErrors* g_ref, + TGraphErrors* g_test, + const PPSAlignmentConfiguration::SelectionRange& range_ref, double sh_min, double sh_max, - double &sh_best, - double &sh_best_unc); + double& sh_best, + double& sh_best_unc); - void xAlignment(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - const PPSAlignmentConfig &cfg, - const PPSAlignmentConfig &cfg_ref, + void xAlignment(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration& cfg_ref, int seqPos); - std::map sh_x_map; + std::map sh_x_map_; // ------------ x alignment relative ------------ - void xAlignmentRelative(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - const PPSAlignmentConfig &cfg, + void xAlignmentRelative(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration& cfg, int seqPos); // ------------ y alignment ------------ - static double findMax(TF1 *ff_fit); - TGraphErrors *buildModeGraph(DQMStore::IBooker &iBooker, - MonitorElement *h2_y_vs_x, - const PPSAlignmentConfig &cfg, - const RPConfig &rpd); - - void yAlignment(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, int seqPos); + static double findMax(TF1* ff_fit); + TH1D* buildModeGraph(DQMStore::IBooker& iBooker, + MonitorElement* h2_y_vs_x, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration::RPConfig& rpc); + + void yAlignment(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration& cfg, + int seqPos); // ------------ other member data and methods ------------ - static TH1D *getTH1DFromTGraphErrors(TGraphErrors *graph, - std::string title = "", - std::string labels = "", - int n = -1, - double binWidth = -1., - double min = -1.); - - edm::ESGetToken esTokenTest_; - edm::ESGetToken esTokenReference_; - + static void writeCutPlot(TH2D* h, double a, double c, double si, double n_si, const std::string& label); + static std::unique_ptr getTH1DFromTGraphErrors(TGraphErrors* graph, + std::string title = "", + std::string labels = "", + int n = -1, + double binWidth = -1., + double min = -1.); + + edm::ESGetToken esTokenTest_; + edm::ESGetToken esTokenReference_; + + // variables from parameters const std::string folder_; + const std::vector sequence_; + bool overwriteShX_; + const bool writeSQLiteResults_; + const bool xAliRelFinalSlopeFixed_; + const bool yAliFinalSlopeFixed_; const bool debug_; - TFile *debugFile_; - std::ofstream resultsFile_; + + // other class variables + std::unique_ptr debugFile_; + std::ofstream textResultsFile_; + + CTPPSRPAlignmentCorrectionsData xAliResults_; + + CTPPSRPAlignmentCorrectionsData xAliRelResults_; + CTPPSRPAlignmentCorrectionsData xAliRelResultsSlopeFixed_; + + CTPPSRPAlignmentCorrectionsData yAliResults_; + CTPPSRPAlignmentCorrectionsData yAliResultsSlopeFixed_; }; +// -------------------------------- DQMEDHarvester methods -------------------------------- + +PPSAlignmentHarvester::PPSAlignmentHarvester(const edm::ParameterSet& iConfig) + : esTokenTest_(esConsumes( + edm::ESInputTag("", ""))), + esTokenReference_(esConsumes( + edm::ESInputTag("", "reference"))), + folder_(iConfig.getParameter("folder")), + sequence_(iConfig.getParameter>("sequence")), + overwriteShX_(iConfig.getParameter("overwrite_sh_x")), + writeSQLiteResults_(iConfig.getParameter("write_sqlite_results")), + xAliRelFinalSlopeFixed_(iConfig.getParameter("x_ali_rel_final_slope_fixed")), + yAliFinalSlopeFixed_(iConfig.getParameter("y_ali_final_slope_fixed")), + debug_(iConfig.getParameter("debug")) { + auto textResultsPath = iConfig.getParameter("text_results_path"); + if (!textResultsPath.empty()) { + textResultsFile_.open(textResultsPath, std::ios::out | std::ios::trunc); + } + if (debug_) { + debugFile_ = std::make_unique("debug_harvester.root", "recreate"); + } + + edm::LogInfo("PPS").log([&](auto& li) { + li << "[harvester] parameters:\n"; + li << "* folder: " << folder_ << "\n"; + li << "* sequence:\n"; + for (unsigned int i = 0; i < sequence_.size(); i++) { + li << " " << i + 1 << ": " << sequence_[i] << "\n"; + } + li << "* overwrite_sh_x: " << std::boolalpha << overwriteShX_ << "\n"; + li << "* text_results_path: " << textResultsPath << "\n"; + li << "* write_sqlite_results: " << std::boolalpha << writeSQLiteResults_ << "\n"; + li << "* x_ali_rel_final_slope_fixed: " << std::boolalpha << xAliRelFinalSlopeFixed_ << "\n"; + li << "* y_ali_final_slope_fixed: " << std::boolalpha << yAliFinalSlopeFixed_ << "\n"; + li << "* debug: " << std::boolalpha << debug_; + }); +} + +PPSAlignmentHarvester::~PPSAlignmentHarvester() { + if (textResultsFile_.is_open()) { + textResultsFile_.close(); + } +} + +void PPSAlignmentHarvester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + + desc.add("folder", "CalibPPS/Common"); + desc.add>("sequence", {"x_alignment", "x_alignment_relative", "y_alignment"}); + desc.add("overwrite_sh_x", true); + desc.add("text_results_path", "./alignment_results.txt"); + desc.add("write_sqlite_results", false); + desc.add("x_ali_rel_final_slope_fixed", true); + desc.add("y_ali_final_slope_fixed", true); + desc.add("debug", false); + + descriptions.addWithDefaultLabel(desc); +} + +void PPSAlignmentHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMStore::IGetter& iGetter) {} + +void PPSAlignmentHarvester::dqmEndRun(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + const auto& cfg = iSetup.getData(esTokenTest_); + + const auto& cfg_ref = iSetup.getData(esTokenReference_); + + // setting default sh_x values from config + for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { + for (const auto& rpc : {sc.rp_N_, sc.rp_F_}) { + sh_x_map_[rpc.id_] = rpc.sh_x_; + } + } + edm::LogInfo("PPS").log([&](auto& li) { + li << "[harvester] Setting sh_x from config of:\n"; + for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { + for (const auto& rpc : {sc.rp_N_, sc.rp_F_}) { + li << " " << rpc.name_ << " to " << std::fixed << std::setprecision(3) << rpc.sh_x_; + if (rpc.name_ != "R_2_F") + li << "\n"; + } + } + }); + + bool doXAli = false, doXAliRel = false, doYAli = false; + for (unsigned int i = 0; i < sequence_.size(); i++) { + if (sequence_[i] == "x_alignment") { + xAlignment(iBooker, iGetter, cfg, cfg_ref, i); + doXAli = true; + } else if (sequence_[i] == "x_alignment_relative") { + xAlignmentRelative(iBooker, iGetter, cfg, i); + doXAliRel = true; + } else if (sequence_[i] == "y_alignment") { + yAlignment(iBooker, iGetter, cfg, i); + doYAli = true; + } else + edm::LogError("PPS") << "[harvester] " << sequence_[i] << " is a wrong method name."; + } + + // merge results from all the specified methods + CTPPSRPAlignmentCorrectionsData finalResults; + if (doXAli) { // x alignment + finalResults.addCorrections(xAliResults_); + if (doXAliRel) { // merge with x alignment relative + for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { + // extract shifts + double d_x_N = xAliResults_.getRPCorrection(sc.rp_N_.id_).getShX(); + double d_x_F = xAliResults_.getRPCorrection(sc.rp_F_.id_).getShX(); + + double d_x_rel_N, d_x_rel_F; + if (xAliRelFinalSlopeFixed_) { + d_x_rel_N = xAliRelResultsSlopeFixed_.getRPCorrection(sc.rp_N_.id_).getShX(); + d_x_rel_F = xAliRelResultsSlopeFixed_.getRPCorrection(sc.rp_F_.id_).getShX(); + } else { + d_x_rel_N = xAliRelResults_.getRPCorrection(sc.rp_N_.id_).getShX(); + d_x_rel_F = xAliRelResults_.getRPCorrection(sc.rp_F_.id_).getShX(); + } + + // merge the results + double b = d_x_rel_N - d_x_rel_F; + double xCorrRel = b + d_x_F - d_x_N; + + CTPPSRPAlignmentCorrectionData corrRelN(xCorrRel / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); + finalResults.addRPCorrection(sc.rp_N_.id_, corrRelN); + CTPPSRPAlignmentCorrectionData corrRelF(-xCorrRel / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); + finalResults.addRPCorrection(sc.rp_F_.id_, corrRelF); + } + } + } + if (doYAli) { // y alignment + if (yAliFinalSlopeFixed_) { + finalResults.addCorrections(yAliResultsSlopeFixed_); + } else { + finalResults.addCorrections(yAliResults_); + } + } + + // print the text results + edm::LogInfo("PPS") << "final merged results:\n" << finalResults; + + if (textResultsFile_.is_open()) { + textResultsFile_ << "final merged results:\n" << finalResults; + } + + // if requested, store the results in a DB object + if (writeSQLiteResults_) { + edm::Service poolDbService; + if (poolDbService.isAvailable()) { + poolDbService->writeOneIOV(finalResults, poolDbService->currentTime(), "CTPPSRPAlignmentCorrectionsDataRcd"); + } else { + edm::LogWarning("PPS") << "Could not store the results in a DB object. PoolDBService not available."; + } + } + + // if debug_, save nice-looking cut plots with the worker data in the debug ROOT file + if (debug_) { + TDirectory* cutsDir = debugFile_->mkdir("cuts"); + for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { + TDirectory* sectorDir = cutsDir->mkdir(sc.name_.c_str()); + + gDirectory = sectorDir->mkdir("cut_h"); + auto* h2_cut_h_bef_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_h/h2_cut_h_bef"); + auto* h2_cut_h_aft_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_h/h2_cut_h_aft"); + writeCutPlot( + h2_cut_h_bef_monitor->getTH2D(), sc.cut_h_a_, sc.cut_h_c_, cfg.n_si(), sc.cut_h_si_, "canvas_before"); + writeCutPlot(h2_cut_h_aft_monitor->getTH2D(), sc.cut_h_a_, sc.cut_h_c_, cfg.n_si(), sc.cut_h_si_, "canvas_after"); + + gDirectory = sectorDir->mkdir("cut_v"); + auto* h2_cut_v_bef_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_v/h2_cut_v_bef"); + auto* h2_cut_v_aft_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_v/h2_cut_v_aft"); + writeCutPlot( + h2_cut_v_bef_monitor->getTH2D(), sc.cut_v_a_, sc.cut_v_c_, cfg.n_si(), sc.cut_v_si_, "canvas_before"); + writeCutPlot(h2_cut_v_aft_monitor->getTH2D(), sc.cut_v_a_, sc.cut_v_c_, cfg.n_si(), sc.cut_v_si_, "canvas_after"); + } + } +} + // -------------------------------- x alignment methods -------------------------------- -// Fits a linear function to a TProfile (similar method in PPSAlignmentConfigESSource). -int PPSAlignmentHarvester::fitProfile(TProfile *p, +// Fits a linear function to a TProfile (similar method in PPSAlignmentConfigurationESSource). +int PPSAlignmentHarvester::fitProfile(TProfile* p, double x_mean, double x_rms, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable, - double &sl, - double &sl_unc) { + double& sl, + double& sl_unc) { unsigned int n_reasonable = 0; for (int bi = 1; bi <= p->GetNbinsX(); bi++) { if (p->GetBinEntries(bi) < fitProfileMinBinEntries) { @@ -146,12 +347,12 @@ int PPSAlignmentHarvester::fitProfile(TProfile *p, if (n_reasonable < fitProfileMinNReasonable) return 1; - double xMin = x_mean - x_rms, xMax = x_mean + x_rms; + double x_min = x_mean - x_rms, x_max = x_mean + x_rms; - TF1 *ff_pol1 = new TF1("ff_pol1", "[0] + [1]*x"); + auto ff_pol1 = std::make_unique("ff_pol1", "[0] + [1]*x"); ff_pol1->SetParameter(0., 0.); - p->Fit(ff_pol1, "Q", "", xMin, xMax); + p->Fit(ff_pol1.get(), "Q", "", x_min, x_max); sl = ff_pol1->GetParameter(1); sl_unc = ff_pol1->GetParError(1); @@ -160,11 +361,12 @@ int PPSAlignmentHarvester::fitProfile(TProfile *p, } // Builds graph from a vector of points (with errors). -TGraphErrors *PPSAlignmentHarvester::buildGraphFromVector(const std::vector &pv) { - TGraphErrors *g = new TGraphErrors(); +std::unique_ptr PPSAlignmentHarvester::buildGraphFromVector( + const std::vector& pv) { + auto g = std::make_unique(); for (unsigned int i = 0; i < pv.size(); i++) { - const auto &p = pv[i]; + const auto& p = pv[i]; g->SetPoint(i, p.x_, p.y_); g->SetPointError(i, p.ex_, p.ey_); } @@ -174,14 +376,15 @@ TGraphErrors *PPSAlignmentHarvester::buildGraphFromVector(const std::vector &mes, - unsigned int fitProfileMinBinEntries, - unsigned int fitProfileMinNReasonable) { - TGraphErrors *g = new TGraphErrors(); - - for (auto *me : mes) { +std::unique_ptr PPSAlignmentHarvester::buildGraphFromMonitorElements( + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration::RPConfig& rpc, + const std::vector& mes, + unsigned int fitProfileMinBinEntries, + unsigned int fitProfileMinNReasonable) { + auto g = std::make_unique(); + + for (auto* me : mes) { if (me->getName() == "h_y") // find "h_y" { // retrieve parent directory @@ -189,24 +392,24 @@ TGraphErrors *PPSAlignmentHarvester::buildGraphFromMonitorElements(DQMStore::IGe size_t parentPos = parentPath.substr(0, parentPath.size() - 1).find_last_of('/') + 1; std::string parentName = parentPath.substr(parentPos); size_t d = parentName.find('-'); - const double xMin = std::stod(parentName.substr(0, d)); - const double xMax = std::stod(parentName.substr(d + 1)); + const double x_min = std::stod(parentName.substr(0, d)); + const double x_max = std::stod(parentName.substr(d + 1)); - TH1D *h_y = me->getTH1D(); + TH1D* h_y = me->getTH1D(); // collect "p_y_diffFN_vs_y" corresponding to found "h_y" - auto *p_y_diffFN_vs_y_monitor = iGetter.get(parentPath + "p_y_diffFN_vs_y"); + auto* p_y_diffFN_vs_y_monitor = iGetter.get(parentPath + "p_y_diffFN_vs_y"); if (p_y_diffFN_vs_y_monitor == nullptr) { edm::LogWarning("PPS") << "[x_alignment] could not find p_y_diffFN_vs_y in: " << parentPath; continue; } - TProfile *p_y_diffFN_vs_y = p_y_diffFN_vs_y_monitor->getTProfile(); + TProfile* p_y_diffFN_vs_y = p_y_diffFN_vs_y_monitor->getTProfile(); double y_cen = h_y->GetMean(); double y_width = h_y->GetRMS(); - y_cen += rpd.y_cen_add_; - y_width *= rpd.y_width_mult_; + y_cen += rpc.y_cen_add_; + y_width *= rpc.y_width_mult_; double sl = 0., sl_unc = 0.; int fr = @@ -218,8 +421,8 @@ TGraphErrors *PPSAlignmentHarvester::buildGraphFromMonitorElements(DQMStore::IGe p_y_diffFN_vs_y->Write(parentName.c_str()); int idx = g->GetN(); - g->SetPoint(idx, (xMax + xMin) / 2., sl); - g->SetPointError(idx, (xMax - xMin) / 2., sl_unc); + g->SetPoint(idx, (x_max + x_min) / 2., sl); + g->SetPointError(idx, (x_max - x_min) / 2., sl_unc); } } g->Sort(); @@ -228,17 +431,17 @@ TGraphErrors *PPSAlignmentHarvester::buildGraphFromMonitorElements(DQMStore::IGe } // Matches reference data with test data. -void PPSAlignmentHarvester::doMatch(DQMStore::IBooker &iBooker, - const PPSAlignmentConfig &cfg, - const RPConfig &rpd, - TGraphErrors *g_ref, - TGraphErrors *g_test, - const SelectionRange &range_ref, +void PPSAlignmentHarvester::doMatch(DQMStore::IBooker& iBooker, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration::RPConfig& rpc, + TGraphErrors* g_ref, + TGraphErrors* g_test, + const PPSAlignmentConfiguration::SelectionRange& range_ref, double sh_min, double sh_max, - double &sh_best, - double &sh_best_unc) { - const auto range_test = cfg.alignment_x_meth_o_ranges().at(rpd.id_); + double& sh_best, + double& sh_best_unc) { + const auto range_test = cfg.alignment_x_meth_o_ranges().at(rpc.id_); // print config edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] " @@ -246,16 +449,16 @@ void PPSAlignmentHarvester::doMatch(DQMStore::IBooker &iBooker, << "test: x_min = " << range_test.x_min_ << ", x_max = " << range_test.x_max_; // make spline from g_ref - TSpline3 *s_ref = new TSpline3("s_ref", g_ref->GetX(), g_ref->GetY(), g_ref->GetN()); + auto s_ref = std::make_unique("s_ref", g_ref->GetX(), g_ref->GetY(), g_ref->GetN()); // book match-quality graphs - TGraph *g_n_points = new TGraph(); + auto g_n_points = std::make_unique(); g_n_points->SetName("g_n_points"); g_n_points->SetTitle(";sh;N"); - TGraph *g_chi_sq = new TGraph(); + auto g_chi_sq = std::make_unique(); g_chi_sq->SetName("g_chi_sq"); g_chi_sq->SetTitle(";sh;S2"); - TGraph *g_chi_sq_norm = new TGraph(); + auto g_chi_sq_norm = std::make_unique(); g_chi_sq_norm->SetName("g_chi_sq_norm"); g_chi_sq_norm->SetTitle(";sh;S2 / N"); @@ -318,26 +521,25 @@ void PPSAlignmentHarvester::doMatch(DQMStore::IBooker &iBooker, g_chi_sq_norm->SetPoint(idx, sh, S2_norm); } - TF1 *ff_pol2 = new TF1("ff_pol2", "[0] + [1]*x + [2]*x*x"); + auto ff_pol2 = std::make_unique("ff_pol2", "[0] + [1]*x + [2]*x*x"); // determine uncertainty double fit_range = cfg.methOUncFitRange(); - g_chi_sq->Fit(ff_pol2, "Q", "", sh_best - fit_range, sh_best + fit_range); + g_chi_sq->Fit(ff_pol2.get(), "Q", "", sh_best - fit_range, sh_best + fit_range); sh_best_unc = 1. / sqrt(ff_pol2->GetParameter(2)); // print results edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] " << "sh_best = (" << sh_best << " +- " << sh_best_unc << ") mm"; - TGraphErrors *g_test_shifted = new TGraphErrors(*g_test); + auto g_test_shifted = std::make_unique(*g_test); for (int i = 0; i < g_test_shifted->GetN(); ++i) { g_test_shifted->GetX()[i] += sh_best; } - iBooker.book1DD( - "h_test_shifted", - getTH1DFromTGraphErrors( - g_test_shifted, "test_shifted", ";x (mm);S", rpd.x_slice_n_, rpd.x_slice_w_, rpd.x_slice_min_ + sh_best)); + std::unique_ptr histPtr = getTH1DFromTGraphErrors( + g_test_shifted.get(), "test_shifted", ";x (mm);S", rpc.x_slice_n_, rpc.x_slice_w_, rpc.x_slice_min_ + sh_best); + iBooker.book1DD("h_test_shifted", histPtr.get()); if (debug_) { // save graphs @@ -348,7 +550,7 @@ void PPSAlignmentHarvester::doMatch(DQMStore::IBooker &iBooker, g_test_shifted->Write("g_test_shifted"); // save results - TGraph *g_results = new TGraph(); + auto g_results = std::make_unique(); g_results->SetName("g_results"); g_results->SetPoint(0, sh_best, sh_best_unc); g_results->SetPoint(1, range_ref.x_min_, range_ref.x_max_); @@ -356,7 +558,7 @@ void PPSAlignmentHarvester::doMatch(DQMStore::IBooker &iBooker, g_results->Write(); // save debug canvas - TCanvas *c_cmp = new TCanvas("c_cmp"); + auto c_cmp = std::make_unique("c_cmp"); g_ref->SetLineColor(1); g_ref->SetName("g_ref"); g_ref->Draw("apl"); @@ -370,72 +572,68 @@ void PPSAlignmentHarvester::doMatch(DQMStore::IBooker &iBooker, g_test_shifted->Draw("pl"); c_cmp->Write(); - - delete c_cmp; } - - // clean up - delete s_ref; } // method o -void PPSAlignmentHarvester::xAlignment(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - const PPSAlignmentConfig &cfg, - const PPSAlignmentConfig &cfg_ref, +void PPSAlignmentHarvester::xAlignment(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration& cfg_ref, int seqPos) { - TDirectory *xAliDir = nullptr; + TDirectory* xAliDir = nullptr; if (debug_) xAliDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": x alignment").c_str()); - // prepare results - CTPPSRPAlignmentCorrectionsData results; + for (const auto& scPair : {std::make_pair(cfg.sectorConfig45(), cfg_ref.sectorConfig45()), + std::make_pair(cfg.sectorConfig56(), cfg_ref.sectorConfig56())}) { + const auto& sc = scPair.first; + const auto& sc_ref = scPair.second; - for (const auto &sdp : {std::make_pair(cfg.sectorConfig45(), cfg_ref.sectorConfig45()), - std::make_pair(cfg.sectorConfig56(), cfg_ref.sectorConfig56())}) { - const auto &sd = sdp.first; - for (const auto &rpdp : {std::make_pair(sd.rp_F_, sdp.second.rp_F_), std::make_pair(sd.rp_N_, sdp.second.rp_N_)}) { - const auto &rpd = rpdp.first; + for (const auto& rpcPair : {std::make_pair(sc.rp_F_, sc_ref.rp_F_), std::make_pair(sc.rp_N_, sc_ref.rp_N_)}) { + const auto& rpc = rpcPair.first; + const auto& rpc_ref = rpcPair.second; - auto mes_test = iGetter.getAllContents(folder_ + "/worker/" + sd.name_ + "/near_far/x slices, " + rpd.position_); + auto mes_test = iGetter.getAllContents(folder_ + "/worker/" + sc.name_ + "/near_far/x slices, " + rpc.position_); if (mes_test.empty()) { - edm::LogWarning("PPS") << "[x_alignment] " << rpd.name_ << ": could not load mes_test"; + edm::LogWarning("PPS") << "[x_alignment] " << rpc.name_ << ": could not load mes_test"; continue; } - TDirectory *rpDir = nullptr; + TDirectory* rpDir = nullptr; if (debug_) - rpDir = xAliDir->mkdir(rpd.name_.c_str()); + rpDir = xAliDir->mkdir(rpc.name_.c_str()); - auto vec_ref = cfg_ref.matchingReferencePoints().at(rpd.id_); + auto vec_ref = cfg_ref.matchingReferencePoints().at(rpc.id_); if (vec_ref.empty()) { - edm::LogInfo("PPS") << "[x_alignment] " << rpd.name_ << ": reference points vector is empty"; + edm::LogInfo("PPS") << "[x_alignment] " << rpc.name_ << ": reference points vector is empty"; continue; } - TGraphErrors *g_ref = buildGraphFromVector(vec_ref); + std::unique_ptr g_ref = buildGraphFromVector(vec_ref); if (debug_) gDirectory = rpDir->mkdir("fits_test"); - TGraphErrors *g_test = buildGraphFromMonitorElements( - iGetter, rpd, mes_test, cfg.fitProfileMinBinEntries(), cfg.fitProfileMinNReasonable()); + std::unique_ptr g_test = buildGraphFromMonitorElements( + iGetter, rpc, mes_test, cfg.fitProfileMinBinEntries(), cfg.fitProfileMinNReasonable()); // require minimal number of points if (g_ref->GetN() < (int)cfg.methOGraphMinN() || g_test->GetN() < (int)cfg.methOGraphMinN()) { - edm::LogWarning("PPS") << "[x_alignment] " << rpd.name_ << ": insufficient data, skipping (g_ref " + edm::LogWarning("PPS") << "[x_alignment] " << rpc.name_ << ": insufficient data, skipping (g_ref " << g_ref->GetN() << "/" << cfg.methOGraphMinN() << ", g_test " << g_test->GetN() << "/" << cfg.methOGraphMinN() << ")"; continue; } - iBooker.setCurrentFolder(folder_ + "/harvester/x alignment/" + rpd.name_); - iBooker.book1DD( - "h_ref", - getTH1DFromTGraphErrors( - g_ref, "ref", ";x (mm);S", rpdp.second.x_slice_n_, rpdp.second.x_slice_w_, rpdp.second.x_slice_min_)); - iBooker.book1DD( - "h_test", - getTH1DFromTGraphErrors(g_test, "test", ";x (mm);S", rpd.x_slice_n_, rpd.x_slice_w_, rpd.x_slice_min_)); + iBooker.setCurrentFolder(folder_ + "/harvester/x alignment/" + rpc.name_); + + std::unique_ptr histPtr = getTH1DFromTGraphErrors( + g_ref.get(), "ref", ";x (mm);S", rpc_ref.x_slice_n_, rpc_ref.x_slice_w_, rpc_ref.x_slice_min_); + iBooker.book1DD("h_ref", histPtr.get()); + + histPtr = + getTH1DFromTGraphErrors(g_test.get(), "test", ";x (mm);S", rpc.x_slice_n_, rpc.x_slice_w_, rpc.x_slice_min_); + iBooker.book1DD("h_test", histPtr.get()); if (debug_) { gDirectory = rpDir; @@ -445,116 +643,124 @@ void PPSAlignmentHarvester::xAlignment(DQMStore::IBooker &iBooker, g_test->Write("g_test"); } - const auto &shiftRange = cfg_ref.matchingShiftRanges().at(rpd.id_); + const auto& shiftRange = cfg.matchingShiftRanges().at(rpc.id_); double sh = 0., sh_unc = 0.; + + // matching doMatch(iBooker, cfg, - rpd, - g_ref, - g_test, - cfg_ref.alignment_x_meth_o_ranges().at(rpd.id_), + rpc, + g_ref.get(), + g_test.get(), + cfg_ref.alignment_x_meth_o_ranges().at(rpc.id_), shiftRange.x_min_, shiftRange.x_max_, sh, sh_unc); + // save the results CTPPSRPAlignmentCorrectionData rpResult(sh, sh_unc, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); - results.setRPCorrection(rpd.id_, rpResult); + xAliResults_.setRPCorrection(rpc.id_, rpResult); edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] " - << "Setting sh_x of " << rpd.name_ << " to " << sh; - sh_x_map[rpd.id_] = sh; + << "Setting sh_x of " << rpc.name_ << " to " << sh; + + // update the shift + if (overwriteShX_) { + sh_x_map_[rpc.id_] = sh; + } } } - edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment:\n" << results; + edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment:\n" << xAliResults_; - if (resultsFile_.is_open()) - resultsFile_ << seqPos + 1 << ": x_alignment:\n" << results << "\n\n"; + if (textResultsFile_.is_open()) + textResultsFile_ << seqPos + 1 << ": x_alignment:\n" << xAliResults_ << "\n\n"; } // -------------------------------- x alignment relative methods -------------------------------- -void PPSAlignmentHarvester::xAlignmentRelative(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - const PPSAlignmentConfig &cfg, +void PPSAlignmentHarvester::xAlignmentRelative(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration& cfg, int seqPos) { - TDirectory *xAliRelDir = nullptr; + TDirectory* xAliRelDir = nullptr; if (debug_) xAliRelDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": x_alignment_relative").c_str()); - // prepare results - CTPPSRPAlignmentCorrectionsData results; - CTPPSRPAlignmentCorrectionsData results_sl_fix; - - TF1 *ff = new TF1("ff", "[0] + [1]*(x - [2])"); - TF1 *ff_sl_fix = new TF1("ff_sl_fix", "[0] + [1]*(x - [2])"); + auto ff = std::make_unique("ff", "[0] + [1]*(x - [2])"); + auto ff_sl_fix = std::make_unique("ff_sl_fix", "[0] + [1]*(x - [2])"); // processing - for (const auto &sd : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { - TDirectory *sectorDir = nullptr; + for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { + TDirectory* sectorDir = nullptr; if (debug_) { - sectorDir = xAliRelDir->mkdir(sd.name_.c_str()); + sectorDir = xAliRelDir->mkdir(sc.name_.c_str()); gDirectory = sectorDir; } - auto *p_x_diffFN_vs_x_N_monitor = iGetter.get(folder_ + "/worker/" + sd.name_ + "/near_far/p_x_diffFN_vs_x_N"); + auto* p_x_diffFN_vs_x_N_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/near_far/p_x_diffFN_vs_x_N"); if (p_x_diffFN_vs_x_N_monitor == nullptr) { - edm::LogWarning("PPS") << "[x_alignment_relative] " << sd.name_ << ": cannot load data, skipping"; + edm::LogWarning("PPS") << "[x_alignment_relative] " << sc.name_ << ": cannot load data, skipping"; continue; } - TProfile *p_x_diffFN_vs_x_N = p_x_diffFN_vs_x_N_monitor->getTProfile(); + TProfile* p_x_diffFN_vs_x_N = p_x_diffFN_vs_x_N_monitor->getTProfile(); if (p_x_diffFN_vs_x_N->GetEntries() < cfg.nearFarMinEntries()) { - edm::LogWarning("PPS") << "[x_alignment_relative] " << sd.name_ << ": insufficient data, skipping (near_far " + edm::LogWarning("PPS") << "[x_alignment_relative] " << sc.name_ << ": insufficient data, skipping (near_far " << p_x_diffFN_vs_x_N->GetEntries() << "/" << cfg.nearFarMinEntries() << ")"; continue; } - const double xMin = cfg.alignment_x_relative_ranges().at(sd.rp_N_.id_).x_min_; - const double xMax = cfg.alignment_x_relative_ranges().at(sd.rp_N_.id_).x_max_; + const double x_min = cfg.alignment_x_relative_ranges().at(sc.rp_N_.id_).x_min_; + const double x_max = cfg.alignment_x_relative_ranges().at(sc.rp_N_.id_).x_max_; - const double sh_x_N = sh_x_map[sd.rp_N_.id_]; - double slope = sd.slope_; + const double sh_x_N = sh_x_map_[sc.rp_N_.id_]; + double slope = sc.slope_; ff->SetParameters(0., slope, 0.); ff->FixParameter(2, -sh_x_N); ff->SetLineColor(2); - p_x_diffFN_vs_x_N->Fit(ff, "Q", "", xMin, xMax); + p_x_diffFN_vs_x_N->Fit(ff.get(), "Q", "", x_min, x_max); const double a = ff->GetParameter(1), a_unc = ff->GetParError(1); const double b = ff->GetParameter(0), b_unc = ff->GetParError(0); - edm::LogInfo("PPS") << "[x_alignment_relative] " << sd.name_ << ":\n" - << std::fixed << std::setprecision(3) << " x_min = " << xMin << ", x_max = " << xMax << "\n" + edm::LogInfo("PPS") << "[x_alignment_relative] " << sc.name_ << ":\n" + << std::fixed << std::setprecision(3) << " x_min = " << x_min << ", x_max = " << x_max + << "\n" << " sh_x_N = " << sh_x_N << ", slope (fix) = " << slope << ", slope (fitted) = " << a; CTPPSRPAlignmentCorrectionData rpResult_N(+b / 2., b_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); - results.setRPCorrection(sd.rp_N_.id_, rpResult_N); + xAliRelResults_.setRPCorrection(sc.rp_N_.id_, rpResult_N); CTPPSRPAlignmentCorrectionData rpResult_F(-b / 2., b_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); - results.setRPCorrection(sd.rp_F_.id_, rpResult_F); + xAliRelResults_.setRPCorrection(sc.rp_F_.id_, rpResult_F); ff_sl_fix->SetParameters(0., slope, 0.); ff_sl_fix->FixParameter(1, slope); ff_sl_fix->FixParameter(2, -sh_x_N); ff_sl_fix->SetLineColor(4); - p_x_diffFN_vs_x_N->Fit(ff_sl_fix, "Q+", "", xMin, xMax); + p_x_diffFN_vs_x_N->Fit(ff_sl_fix.get(), "Q+", "", x_min, x_max); const double b_fs = ff_sl_fix->GetParameter(0), b_fs_unc = ff_sl_fix->GetParError(0); CTPPSRPAlignmentCorrectionData rpResult_sl_fix_N(+b_fs / 2., b_fs_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); - results_sl_fix.setRPCorrection(sd.rp_N_.id_, rpResult_sl_fix_N); + xAliRelResultsSlopeFixed_.setRPCorrection(sc.rp_N_.id_, rpResult_sl_fix_N); CTPPSRPAlignmentCorrectionData rpResult_sl_fix_F(-b_fs / 2., b_fs_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.); - results_sl_fix.setRPCorrection(sd.rp_F_.id_, rpResult_sl_fix_F); + xAliRelResultsSlopeFixed_.setRPCorrection(sc.rp_F_.id_, rpResult_sl_fix_F); edm::LogInfo("PPS") << "[x_alignment_relative] " << std::fixed << std::setprecision(3) << "ff: " << ff->GetParameter(0) << " + " << ff->GetParameter(1) << " * (x - " << ff->GetParameter(2) << "), ff_sl_fix: " << ff_sl_fix->GetParameter(0) << " + " << ff_sl_fix->GetParameter(1) << " * (x - " << ff_sl_fix->GetParameter(2) << ")"; + // rebook the diffFN plot in the harvester + iBooker.setCurrentFolder(folder_ + "/harvester/x_alignment_relative/" + sc.name_); + iBooker.bookProfile("p_x_diffFN_vs_x_N", p_x_diffFN_vs_x_N); + if (debug_) { p_x_diffFN_vs_x_N->Write("p_x_diffFN_vs_x_N"); - TGraph *g_results = new TGraph(); + auto g_results = std::make_unique(); g_results->SetPoint(0, sh_x_N, 0.); g_results->SetPoint(1, a, a_unc); g_results->SetPoint(2, b, b_unc); @@ -565,18 +771,18 @@ void PPSAlignmentHarvester::xAlignmentRelative(DQMStore::IBooker &iBooker, // write results edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment_relative:\n" - << results << seqPos + 1 << ": x_alignment_relative_sl_fix:\n" - << results_sl_fix; + << xAliRelResults_ << seqPos + 1 << ": x_alignment_relative_sl_fix:\n" + << xAliRelResultsSlopeFixed_; - if (resultsFile_.is_open()) { - resultsFile_ << seqPos + 1 << ": x_alignment_relative:\n" << results << "\n"; - resultsFile_ << seqPos + 1 << ": x_alignment_relative_sl_fix:\n" << results_sl_fix << "\n\n"; + if (textResultsFile_.is_open()) { + textResultsFile_ << seqPos + 1 << ": x_alignment_relative:\n" << xAliRelResults_ << "\n"; + textResultsFile_ << seqPos + 1 << ": x_alignment_relative_sl_fix:\n" << xAliRelResultsSlopeFixed_ << "\n\n"; } } // -------------------------------- y alignment methods -------------------------------- -double PPSAlignmentHarvester::findMax(TF1 *ff_fit) { +double PPSAlignmentHarvester::findMax(TF1* ff_fit) { const double mu = ff_fit->GetParameter(1); const double si = ff_fit->GetParameter(2); @@ -584,30 +790,28 @@ double PPSAlignmentHarvester::findMax(TF1 *ff_fit) { if (si > 25. || std::fabs(mu) > 100.) return 1E100; - double xMax = 1E100; - double yMax = -1E100; + double x_max = 1E100; + double y_max = -1E100; for (double x = mu - si; x <= mu + si; x += 0.001) { double y = ff_fit->Eval(x); - if (y > yMax) { - xMax = x; - yMax = y; + if (y > y_max) { + x_max = x; + y_max = y; } } - return xMax; + return x_max; } -TGraphErrors *PPSAlignmentHarvester::buildModeGraph(DQMStore::IBooker &iBooker, - MonitorElement *h2_y_vs_x, - const PPSAlignmentConfig &cfg, - const RPConfig &rpd) { - TDirectory *d_top = nullptr; +TH1D* PPSAlignmentHarvester::buildModeGraph(DQMStore::IBooker& iBooker, + MonitorElement* h2_y_vs_x, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration::RPConfig& rpc) { + TDirectory* d_top = nullptr; if (debug_) d_top = gDirectory; - TF1 *ff_fit = new TF1("ff_fit", "[0] * exp(-(x-[1])*(x-[1])/2./[2]/[2]) + [3] + [4]*x"); - - TGraphErrors *g_y_mode_vs_x = new TGraphErrors(); + auto ff_fit = std::make_unique("ff_fit", "[0] * exp(-(x-[1])*(x-[1])/2./[2]/[2]) + [3] + [4]*x"); int h_n = h2_y_vs_x->getNbinsX(); double diff = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinWidth(1) / 2.; @@ -619,11 +823,10 @@ TGraphErrors *PPSAlignmentHarvester::buildModeGraph(DQMStore::IBooker &iBooker, for (int bix = 1; bix <= h_n; bix++) { const double x = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(bix); - const double x_unc = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinWidth(bix) / 2.; char buf[100]; sprintf(buf, "h_y_x=%.3f", x); - TH1D *h_y = h2_y_vs_x->getTH2D()->ProjectionY(buf, bix, bix); + TH1D* h_y = h2_y_vs_x->getTH2D()->ProjectionY(buf, bix, bix); if (h_y->GetEntries() < cfg.multSelProjYMinEntries()) continue; @@ -645,20 +848,20 @@ TGraphErrors *PPSAlignmentHarvester::buildModeGraph(DQMStore::IBooker &iBooker, ff_fit->SetParameters(conMax, conMax_x, h_y->GetRMS() * 0.75, 0., 0.); ff_fit->FixParameter(4, 0.); - double xMin = rpd.x_min_fit_mode_, xMax = rpd.x_max_fit_mode_; - h_y->Fit(ff_fit, "Q", "", xMin, xMax); + double x_min = rpc.x_min_fit_mode_, x_max = rpc.x_max_fit_mode_; + h_y->Fit(ff_fit.get(), "Q", "", x_min, x_max); ff_fit->ReleaseParameter(4); double w = std::min(4., 2. * ff_fit->GetParameter(2)); - xMin = ff_fit->GetParameter(1) - w; - xMax = std::min(rpd.y_max_fit_mode_, ff_fit->GetParameter(1) + w); + x_min = ff_fit->GetParameter(1) - w; + x_max = std::min(rpc.y_max_fit_mode_, ff_fit->GetParameter(1) + w); - h_y->Fit(ff_fit, "Q", "", xMin, xMax); + h_y->Fit(ff_fit.get(), "Q", "", x_min, x_max); if (debug_) h_y->Write("h_y"); - double y_mode = findMax(ff_fit); + double y_mode = findMax(ff_fit.get()); const double y_mode_fit_unc = ff_fit->GetParameter(2) / 10; const double y_mode_sys_unc = cfg.y_mode_sys_unc(); double y_mode_unc = std::sqrt(y_mode_fit_unc * y_mode_fit_unc + y_mode_sys_unc * y_mode_sys_unc); @@ -670,7 +873,7 @@ TGraphErrors *PPSAlignmentHarvester::buildModeGraph(DQMStore::IBooker &iBooker, ff_fit->GetChisquare() / ff_fit->GetNDF() > chiSqThreshold); if (debug_) { - TGraph *g_data = new TGraph(); + auto g_data = std::make_unique(); g_data->SetPoint(0, y_mode, y_mode_unc); g_data->SetPoint(1, ff_fit->GetChisquare(), ff_fit->GetNDF()); g_data->SetPoint(2, valid, 0.); @@ -680,90 +883,82 @@ TGraphErrors *PPSAlignmentHarvester::buildModeGraph(DQMStore::IBooker &iBooker, if (!valid) continue; - int idx = g_y_mode_vs_x->GetN(); - g_y_mode_vs_x->SetPoint(idx, x, y_mode); - g_y_mode_vs_x->SetPointError(idx, x_unc, y_mode_unc); - h_mode->Fill(x, y_mode); h_mode->setBinError(bix, y_mode_unc); } - return g_y_mode_vs_x; + return h_mode->getTH1D(); } -void PPSAlignmentHarvester::yAlignment(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - const PPSAlignmentConfig &cfg, +void PPSAlignmentHarvester::yAlignment(DQMStore::IBooker& iBooker, + DQMStore::IGetter& iGetter, + const PPSAlignmentConfiguration& cfg, int seqPos) { - TDirectory *yAliDir = nullptr; + TDirectory* yAliDir = nullptr; if (debug_) yAliDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": y_alignment").c_str()); - // prepare results - CTPPSRPAlignmentCorrectionsData results; - CTPPSRPAlignmentCorrectionsData results_sl_fix; - - TF1 *ff = new TF1("ff", "[0] + [1]*(x - [2])"); - TF1 *ff_sl_fix = new TF1("ff_sl_fix", "[0] + [1]*(x - [2])"); + auto ff = std::make_unique("ff", "[0] + [1]*(x - [2])"); + auto ff_sl_fix = std::make_unique("ff_sl_fix", "[0] + [1]*(x - [2])"); // processing - for (const auto &sd : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { - for (const auto &rpd : {sd.rp_F_, sd.rp_N_}) { - TDirectory *rpDir = nullptr; + for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { + for (const auto& rpc : {sc.rp_F_, sc.rp_N_}) { + TDirectory* rpDir = nullptr; if (debug_) { - rpDir = yAliDir->mkdir(rpd.name_.c_str()); + rpDir = yAliDir->mkdir(rpc.name_.c_str()); gDirectory = rpDir->mkdir("x"); } - auto *h2_y_vs_x = - iGetter.get(folder_ + "/worker/" + sd.name_ + "/multiplicity selection/" + rpd.name_ + "/h2_y_vs_x"); + auto* h2_y_vs_x = + iGetter.get(folder_ + "/worker/" + sc.name_ + "/multiplicity selection/" + rpc.name_ + "/h2_y_vs_x"); if (h2_y_vs_x == nullptr) { - edm::LogWarning("PPS") << "[y_alignment] " << rpd.name_ << ": cannot load data, skipping"; + edm::LogWarning("PPS") << "[y_alignment] " << rpc.name_ << ": cannot load data, skipping"; continue; } - iBooker.setCurrentFolder(folder_ + "/harvester/y alignment/" + rpd.name_); - auto *g_y_cen_vs_x = buildModeGraph(iBooker, h2_y_vs_x, cfg, rpd); + iBooker.setCurrentFolder(folder_ + "/harvester/y alignment/" + rpc.name_); + auto* h_y_cen_vs_x = buildModeGraph(iBooker, h2_y_vs_x, cfg, rpc); - if ((unsigned int)g_y_cen_vs_x->GetN() < cfg.modeGraphMinN()) { - edm::LogWarning("PPS") << "[y_alignment] " << rpd.name_ << ": insufficient data, skipping (mode graph " - << g_y_cen_vs_x->GetN() << "/" << cfg.modeGraphMinN() << ")"; + if ((unsigned int)h_y_cen_vs_x->GetEntries() < cfg.modeGraphMinN()) { + edm::LogWarning("PPS") << "[y_alignment] " << rpc.name_ << ": insufficient data, skipping (mode graph " + << h_y_cen_vs_x->GetEntries() << "/" << cfg.modeGraphMinN() << ")"; continue; } - const double xMin = cfg.alignment_y_ranges().at(rpd.id_).x_min_; - const double xMax = cfg.alignment_y_ranges().at(rpd.id_).x_max_; + const double x_min = cfg.alignment_y_ranges().at(rpc.id_).x_min_; + const double x_max = cfg.alignment_y_ranges().at(rpc.id_).x_max_; - const double sh_x = sh_x_map[rpd.id_]; - double slope = rpd.slope_; + const double sh_x = sh_x_map_[rpc.id_]; + double slope = rpc.slope_; ff->SetParameters(0., 0., 0.); ff->FixParameter(2, -sh_x); ff->SetLineColor(2); - g_y_cen_vs_x->Fit(ff, "Q", "", xMin, xMax); + h_y_cen_vs_x->Fit(ff.get(), "Q", "", x_min, x_max); const double a = ff->GetParameter(1), a_unc = ff->GetParError(1); const double b = ff->GetParameter(0), b_unc = ff->GetParError(0); - edm::LogInfo("PPS") << "[y_alignment] " << rpd.name_ << ":\n" - << std::fixed << std::setprecision(3) << " x_min = " << xMin << ", x_max = " << xMax + edm::LogInfo("PPS") << "[y_alignment] " << rpc.name_ << ":\n" + << std::fixed << std::setprecision(3) << " x_min = " << x_min << ", x_max = " << x_max << "\n" << " sh_x = " << sh_x << ", slope (fix) = " << slope << ", slope (fitted) = " << a; CTPPSRPAlignmentCorrectionData rpResult(0., 0., b, b_unc, 0., 0., 0., 0., 0., 0., 0., 0.); - results.setRPCorrection(rpd.id_, rpResult); + yAliResults_.setRPCorrection(rpc.id_, rpResult); ff_sl_fix->SetParameters(0., 0., 0.); ff_sl_fix->FixParameter(1, slope); ff_sl_fix->FixParameter(2, -sh_x); ff_sl_fix->SetLineColor(4); - g_y_cen_vs_x->Fit(ff_sl_fix, "Q+", "", xMin, xMax); + h_y_cen_vs_x->Fit(ff_sl_fix.get(), "Q+", "", x_min, x_max); const double b_fs = ff_sl_fix->GetParameter(0), b_fs_unc = ff_sl_fix->GetParError(0); CTPPSRPAlignmentCorrectionData rpResult_sl_fix(0., 0., b_fs, b_fs_unc, 0., 0., 0., 0., 0., 0., 0., 0.); - results_sl_fix.setRPCorrection(rpd.id_, rpResult_sl_fix); + yAliResultsSlopeFixed_.setRPCorrection(rpc.id_, rpResult_sl_fix); edm::LogInfo("PPS") << "[y_alignment] " << std::fixed << std::setprecision(3) << "ff: " << ff->GetParameter(0) << " + " << ff->GetParameter(1) << " * (x - " << ff->GetParameter(2) @@ -773,10 +968,10 @@ void PPSAlignmentHarvester::yAlignment(DQMStore::IBooker &iBooker, if (debug_) { gDirectory = rpDir; - g_y_cen_vs_x->SetTitle(";x (mm); mode of y (mm)"); - g_y_cen_vs_x->Write("g_y_cen_vs_x"); + h_y_cen_vs_x->SetTitle(";x (mm); mode of y (mm)"); + h_y_cen_vs_x->Write("h_y_cen_vs_x"); - TGraph *g_results = new TGraph(); + auto g_results = std::make_unique(); g_results->SetPoint(0, sh_x, 0.); g_results->SetPoint(1, a, a_unc); g_results->SetPoint(2, b, b_unc); @@ -788,33 +983,60 @@ void PPSAlignmentHarvester::yAlignment(DQMStore::IBooker &iBooker, // write results edm::LogInfo("PPS") << seqPos + 1 << ": y_alignment:\n" - << results << seqPos + 1 << ": y_alignment_sl_fix:\n" - << results_sl_fix; + << yAliResults_ << seqPos + 1 << ": y_alignment_sl_fix:\n" + << yAliResultsSlopeFixed_; - if (resultsFile_.is_open()) { - resultsFile_ << seqPos + 1 << ": y_alignment:\n" << results << "\n"; - resultsFile_ << seqPos + 1 << ": y_alignment_sl_fix:\n" << results_sl_fix << "\n\n"; + if (textResultsFile_.is_open()) { + textResultsFile_ << seqPos + 1 << ": y_alignment:\n" << yAliResults_ << "\n"; + textResultsFile_ << seqPos + 1 << ": y_alignment_sl_fix:\n" << yAliResultsSlopeFixed_ << "\n\n"; } } -// -------------------------------- PPSAlignmentHarvester methods -------------------------------- +// -------------------------------- other methods -------------------------------- + +void PPSAlignmentHarvester::writeCutPlot(TH2D* h, double a, double c, double n_si, double si, const std::string& label) { + auto canvas = std::make_unique(); + canvas->SetName(label.c_str()); + canvas->SetLogz(1); + + h->Draw("colz"); + + double x_min = -30.; + double x_max = 30.; + + auto g_up = std::make_unique(); + g_up->SetName("g_up"); + g_up->SetPoint(0, x_min, -a * x_min - c + n_si * si); + g_up->SetPoint(1, x_max, -a * x_max - c + n_si * si); + g_up->SetLineColor(1); + g_up->Draw("l"); + + auto g_down = std::make_unique(); + g_down->SetName("g_down"); + g_down->SetPoint(0, x_min, -a * x_min - c - n_si * si); + g_down->SetPoint(1, x_max, -a * x_max - c - n_si * si); + g_down->SetLineColor(1); + g_down->Draw("l"); + + canvas->Write(); +} // Points in TGraph should be sorted (TGraph::Sort()) // if n, binWidth, or min is set to -1, method will find it on its own -TH1D *PPSAlignmentHarvester::getTH1DFromTGraphErrors( - TGraphErrors *graph, std::string title, std::string labels, int n, double binWidth, double min) { - TH1D *hist; +std::unique_ptr PPSAlignmentHarvester::getTH1DFromTGraphErrors( + TGraphErrors* graph, std::string title, std::string labels, int n, double binWidth, double min) { + std::unique_ptr hist; if (n == 0) { - hist = new TH1D(title.c_str(), labels.c_str(), 0, -10., 10.); + hist = std::make_unique(title.c_str(), labels.c_str(), 0, -10., 10.); } else if (n == 1) { - hist = new TH1D(title.c_str(), labels.c_str(), 1, graph->GetPointX(0) - 5., graph->GetPointX(0) + 5.); + hist = std::make_unique(title.c_str(), labels.c_str(), 1, graph->GetPointX(0) - 5., graph->GetPointX(0) + 5.); } else { n = n == -1 ? graph->GetN() : n; binWidth = binWidth == -1 ? graph->GetPointX(1) - graph->GetPointX(0) : binWidth; double diff = binWidth / 2.; min = min == -1 ? graph->GetPointX(0) - diff : min; double max = min + n * binWidth; - hist = new TH1D(title.c_str(), labels.c_str(), n, min, max); + hist = std::make_unique(title.c_str(), labels.c_str(), n, min, max); } for (int i = 0; i < graph->GetN(); i++) { @@ -826,55 +1048,4 @@ TH1D *PPSAlignmentHarvester::getTH1DFromTGraphErrors( return hist; } -PPSAlignmentHarvester::PPSAlignmentHarvester(const edm::ParameterSet &iConfig) - : esTokenTest_( - esConsumes(edm::ESInputTag("", ""))), - esTokenReference_(esConsumes( - edm::ESInputTag("", "reference"))), - folder_(iConfig.getParameter("folder")), - debug_(iConfig.getParameter("debug")) {} - -void PPSAlignmentHarvester::dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) {} - -void PPSAlignmentHarvester::dqmEndRun(DQMStore::IBooker &iBooker, - DQMStore::IGetter &iGetter, - edm::Run const &iRun, - edm::EventSetup const &iSetup) { - const auto &cfg = iSetup.getData(esTokenTest_); - - const auto &cfg_ref = iSetup.getData(esTokenReference_); - - if (debug_) - debugFile_ = new TFile("debug_harvester.root", "recreate"); - - if (!cfg.resultsDir().empty()) - resultsFile_.open(cfg.resultsDir(), std::ios::out | std::ios::trunc); - - // setting default sh_x values from config - for (const auto &sd : {cfg.sectorConfig45(), cfg.sectorConfig56()}) { - for (const auto &rpd : {sd.rp_N_, sd.rp_F_}) { - edm::LogInfo("PPS") << "[harvester] " << std::fixed << std::setprecision(3) << "Setting sh_x of " << rpd.name_ - << " to " << rpd.sh_x_; - sh_x_map[rpd.id_] = rpd.sh_x_; - } - } - - for (unsigned int i = 0; i < cfg.sequence().size(); i++) { - if (cfg.sequence()[i] == "x_alignment") - xAlignment(iBooker, iGetter, cfg, cfg_ref, i); - else if (cfg.sequence()[i] == "x_alignment_relative") - xAlignmentRelative(iBooker, iGetter, cfg, i); - else if (cfg.sequence()[i] == "y_alignment") - yAlignment(iBooker, iGetter, cfg, i); - else - edm::LogError("PPS") << "[harvester] " << cfg.sequence()[i] << " is a wrong method name."; - } - - if (debug_) - delete debugFile_; - - if (resultsFile_.is_open()) - resultsFile_.close(); -} - -DEFINE_FWK_MODULE(PPSAlignmentHarvester); \ No newline at end of file +DEFINE_FWK_MODULE(PPSAlignmentHarvester); diff --git a/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentWorker.cc b/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentWorker.cc index 00844dbeb85d8..0c4c29f063091 100644 --- a/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentWorker.cc +++ b/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentWorker.cc @@ -1,14 +1,8 @@ /**************************************************************************** - * - * CalibPPS/AlignmentGlobal/plugins/PPSAlignmentWorker.cc - * - * Description : PPS Alignment DQM worker - * - * Authors: - * - Jan Kašpar - * - Mateusz Kocot - * - ****************************************************************************/ +* Authors: +* Jan Kašpar (jan.kaspar@gmail.com) +* Mateusz Kocot (mateuszkocot99@gmail.com) +****************************************************************************/ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/DQMStore.h" @@ -25,12 +19,13 @@ #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" -#include "CondFormats/PPSObjects/interface/PPSAlignmentConfig.h" -#include "CondFormats/DataRecord/interface/PPSAlignmentConfigRcd.h" +#include "CondFormats/PPSObjects/interface/PPSAlignmentConfiguration.h" +#include "CondFormats/DataRecord/interface/PPSAlignmentConfigurationRcd.h" #include #include #include +#include #include "TH2D.h" #include "TGraph.h" @@ -39,86 +34,151 @@ class PPSAlignmentWorker : public DQMEDAnalyzer { public: - PPSAlignmentWorker(const edm::ParameterSet &iConfig); + PPSAlignmentWorker(const edm::ParameterSet& iConfig); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - void bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, edm::EventSetup const &iSetup) override; - void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override; + void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&, edm::EventSetup const& iSetup) override; + void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; // ------------ structures ------------ struct SectorData { - SectorConfig scfg; + PPSAlignmentConfiguration::SectorConfig scfg_; // hit distributions - std::map m_h2_y_vs_x_bef_sel; + std::map m_h2_y_vs_x_bef_sel; - std::map m_h2_y_vs_x_mlt_sel; + std::map m_h2_y_vs_x_mlt_sel; - std::map m_h2_y_vs_x_aft_sel; + std::map m_h2_y_vs_x_aft_sel; // cut plots - MonitorElement *h_q_cut_h_bef, *h_q_cut_h_aft; - MonitorElement *h2_cut_h_bef, *h2_cut_h_aft; + MonitorElement* h_q_cut_h_bef; + MonitorElement* h_q_cut_h_aft; + MonitorElement* h2_cut_h_bef; + MonitorElement* h2_cut_h_aft; - MonitorElement *h_q_cut_v_bef, *h_q_cut_v_aft; - MonitorElement *h2_cut_v_bef, *h2_cut_v_aft; + MonitorElement* h_q_cut_v_bef; + MonitorElement* h_q_cut_v_aft; + MonitorElement* h2_cut_v_bef; + MonitorElement* h2_cut_v_aft; // near-far plots - MonitorElement *p_x_diffFN_vs_x_N; - MonitorElement *p_y_diffFN_vs_y_F; + MonitorElement* p_x_diffFN_vs_x_N; + MonitorElement* p_y_diffFN_vs_y_F; struct SlicePlots { - MonitorElement *h_y; - MonitorElement *h2_y_diffFN_vs_y; - MonitorElement *p_y_diffFN_vs_y; + MonitorElement* h_y; + MonitorElement* h2_y_diffFN_vs_y; + MonitorElement* p_y_diffFN_vs_y; SlicePlots(); - SlicePlots(DQMStore::IBooker &iBooker, bool debug); + SlicePlots(DQMStore::IBooker& iBooker, const PPSAlignmentConfiguration& cfg, bool debug); }; std::map x_slice_plots_N, x_slice_plots_F; - void init(DQMStore::IBooker &iBooker, - const PPSAlignmentConfig &cfg, - const SectorConfig &_scfg, - const std::string &folder, + void init(DQMStore::IBooker& iBooker, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration::SectorConfig& scfg, + const std::string& folder, bool debug); - unsigned int process(const CTPPSLocalTrackLiteCollection &tracks, const PPSAlignmentConfig &cfg, bool debug); + unsigned int process(const CTPPSLocalTrackLiteCollection& tracks, const PPSAlignmentConfiguration& cfg, bool debug); }; // ------------ member data ------------ - edm::ESGetToken esTokenBookHistograms_; - edm::ESGetToken esTokenAnalyze_; + edm::ESGetToken esTokenBookHistograms_; + edm::ESGetToken esTokenAnalyze_; edm::EDGetTokenT tracksToken_; - SectorData sectorData45; - SectorData sectorData56; + SectorData sectorData45_; + SectorData sectorData56_; std::string folder_; bool debug_; }; +// -------------------------------- DQMEDAnalyzer methods -------------------------------- + +PPSAlignmentWorker::PPSAlignmentWorker(const edm::ParameterSet& iConfig) + : esTokenBookHistograms_( + esConsumes( + edm::ESInputTag("", iConfig.getParameter("label")))), + esTokenAnalyze_(esConsumes( + edm::ESInputTag("", iConfig.getParameter("label")))), + tracksToken_(consumes(iConfig.getParameter("tagTracks"))), + folder_(iConfig.getParameter("folder")), + debug_(iConfig.getParameter("debug")) { + edm::LogInfo("PPS").log([&](auto& li) { + li << "[worker] parameters:\n"; + li << "* label: " << iConfig.getParameter("label") << "\n"; + li << "* tagTracks: " << iConfig.getParameter("tagTracks") << "\n"; + li << "* folder: " << folder_ << "\n"; + li << "* debug: " << std::boolalpha << debug_; + }); +} + +void PPSAlignmentWorker::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&, edm::EventSetup const& iSetup) { + const auto& cfg = iSetup.getData(esTokenBookHistograms_); + + sectorData45_.init(iBooker, cfg, cfg.sectorConfig45(), folder_ + "/worker", debug_); + sectorData56_.init(iBooker, cfg, cfg.sectorConfig56(), folder_ + "/worker", debug_); +} + +void PPSAlignmentWorker::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + const auto& tracks = iEvent.get(tracksToken_); + + const auto& cfg = iSetup.getData(esTokenAnalyze_); + + sectorData45_.process(tracks, cfg, debug_); + sectorData56_.process(tracks, cfg, debug_); +} + +void PPSAlignmentWorker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + + desc.add("label", ""); + desc.add("tagTracks", edm::InputTag("ctppsLocalTrackLiteProducer")); + desc.add("folder", "CalibPPS/Common"); + desc.add("debug", false); + + descriptions.addWithDefaultLabel(desc); +} + // -------------------------------- SectorData and SlicePlots methods -------------------------------- PPSAlignmentWorker::SectorData::SlicePlots::SlicePlots() {} -PPSAlignmentWorker::SectorData::SlicePlots::SlicePlots(DQMStore::IBooker &iBooker, bool debug) { - h_y = iBooker.book1DD("h_y", ";y", 100, -10., 10.); - auto *tmp = new TProfile("", ";y;x_{F} - y_{N}", 100, -10., 10.); - p_y_diffFN_vs_y = iBooker.bookProfile("p_y_diffFN_vs_y", tmp); +PPSAlignmentWorker::SectorData::SlicePlots::SlicePlots(DQMStore::IBooker& iBooker, + const PPSAlignmentConfiguration& cfg, + bool debug) { + h_y = iBooker.book1DD( + "h_y", ";y", cfg.binning().slice_n_bins_x_, cfg.binning().slice_x_min_, cfg.binning().slice_x_max_); + + auto profilePtr = std::make_unique( + "", ";y;y_{F} - y_{N}", cfg.binning().slice_n_bins_x_, cfg.binning().slice_x_min_, cfg.binning().slice_x_max_); + p_y_diffFN_vs_y = iBooker.bookProfile("p_y_diffFN_vs_y", profilePtr.get()); if (debug) - h2_y_diffFN_vs_y = iBooker.book2DD("h2_y_diffFN_vs_y", ";y;x_{F} - y_{N}", 100, -10., 10., 100, -2., 2.); + h2_y_diffFN_vs_y = iBooker.book2DD("h2_y_diffFN_vs_y", + ";y;y_{F} - y_{N}", + cfg.binning().slice_n_bins_x_, + cfg.binning().slice_x_min_, + cfg.binning().slice_x_max_, + cfg.binning().slice_n_bins_y_, + cfg.binning().slice_y_min_, + cfg.binning().slice_y_max_); } -void PPSAlignmentWorker::SectorData::init(DQMStore::IBooker &iBooker, - const PPSAlignmentConfig &cfg, - const SectorConfig &_scfg, - const std::string &folder, +void PPSAlignmentWorker::SectorData::init(DQMStore::IBooker& iBooker, + const PPSAlignmentConfiguration& cfg, + const PPSAlignmentConfiguration::SectorConfig& scfg, + const std::string& folder, bool debug) { - scfg = _scfg; + scfg_ = scfg; // binning const double bin_size_x = cfg.binning().bin_size_x_; @@ -133,29 +193,29 @@ void PPSAlignmentWorker::SectorData::init(DQMStore::IBooker &iBooker, const double y_min = cfg.binning().y_min_, y_max = cfg.binning().y_max_; // hit distributions - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/before selection/" + scfg.rp_N_.name_); - m_h2_y_vs_x_bef_sel[scfg.rp_N_.id_] = + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/before selection/" + scfg_.rp_N_.name_); + m_h2_y_vs_x_bef_sel[scfg_.rp_N_.id_] = iBooker.book2DD("h2_y_vs_x", ";x;y", n_bins_x, x_min_str, x_max_str, n_bins_y, y_min, y_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/before selection/" + scfg.rp_F_.name_); - m_h2_y_vs_x_bef_sel[scfg.rp_F_.id_] = + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/before selection/" + scfg_.rp_F_.name_); + m_h2_y_vs_x_bef_sel[scfg_.rp_F_.id_] = iBooker.book2DD("h2_y_vs_x", ";x;y", n_bins_x, x_min_pix, x_max_pix, n_bins_y, y_min, y_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/multiplicity selection/" + scfg.rp_N_.name_); - m_h2_y_vs_x_mlt_sel[scfg.rp_N_.id_] = + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/multiplicity selection/" + scfg_.rp_N_.name_); + m_h2_y_vs_x_mlt_sel[scfg_.rp_N_.id_] = iBooker.book2DD("h2_y_vs_x", ";x;y", n_bins_x, x_min_str, x_max_str, n_bins_y, y_min, y_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/multiplicity selection/" + scfg.rp_F_.name_); - m_h2_y_vs_x_mlt_sel[scfg.rp_F_.id_] = + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/multiplicity selection/" + scfg_.rp_F_.name_); + m_h2_y_vs_x_mlt_sel[scfg_.rp_F_.id_] = iBooker.book2DD("h2_y_vs_x", ";x;y", n_bins_x, x_min_pix, x_max_pix, n_bins_y, y_min, y_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/after selection/" + scfg.rp_N_.name_); - m_h2_y_vs_x_aft_sel[scfg.rp_N_.id_] = + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/after selection/" + scfg_.rp_N_.name_); + m_h2_y_vs_x_aft_sel[scfg_.rp_N_.id_] = iBooker.book2DD("h2_y_vs_x", ";x;y", n_bins_x, x_min_str, x_max_str, n_bins_y, y_min, y_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/after selection/" + scfg.rp_F_.name_); - m_h2_y_vs_x_aft_sel[scfg.rp_F_.id_] = + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/after selection/" + scfg_.rp_F_.name_); + m_h2_y_vs_x_aft_sel[scfg_.rp_F_.id_] = iBooker.book2DD("h2_y_vs_x", ";x;y", n_bins_x, x_min_pix, x_max_pix, n_bins_y, y_min, y_max); // cut plots - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/cuts/cut_h"); + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/cuts/cut_h"); h_q_cut_h_bef = iBooker.book1DD("h_q_cut_h_bef", ";cq_h", 400, -2., 2.); h_q_cut_h_aft = iBooker.book1DD("h_q_cut_h_aft", ";cq_h", 400, -2., 2.); h2_cut_h_bef = @@ -163,119 +223,105 @@ void PPSAlignmentWorker::SectorData::init(DQMStore::IBooker &iBooker, h2_cut_h_aft = iBooker.book2DD("h2_cut_h_aft", ";x_up;x_dw", n_bins_x, x_min_str, x_max_str, n_bins_x, x_min_pix, x_max_pix); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/cuts/cut_v"); + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/cuts/cut_v"); h_q_cut_v_bef = iBooker.book1DD("h_q_cut_v_bef", ";cq_v", 400, -2., 2.); h_q_cut_v_aft = iBooker.book1DD("h_q_cut_v_aft", ";cq_v", 400, -2., 2.); h2_cut_v_bef = iBooker.book2DD("h2_cut_v_bef", ";y_up;y_dw", n_bins_y, y_min, y_max, n_bins_y, y_min, y_max); h2_cut_v_aft = iBooker.book2DD("h2_cut_v_aft", ";y_up;y_dw", n_bins_y, y_min, y_max, n_bins_y, y_min, y_max); // near-far plots - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/near_far"); - auto *tmp = new TProfile("", ";x_{N};x_{F} - x_{N}", 100, 0., 20.); - p_x_diffFN_vs_x_N = iBooker.bookProfile("p_x_diffFN_vs_x_N", tmp); + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/near_far"); - for (int i = 0; i < scfg.rp_N_.x_slice_n_; i++) { - const double xMin = scfg.rp_N_.x_slice_min_ + i * scfg.rp_N_.x_slice_w_; - const double xMax = scfg.rp_N_.x_slice_min_ + (i + 1) * scfg.rp_N_.x_slice_w_; + auto profilePtr = std::make_unique("", + ";x_{N};x_{F} - x_{N}", + cfg.binning().diffFN_n_bins_x_, + cfg.binning().diffFN_x_min_, + cfg.binning().diffFN_x_max_); + p_x_diffFN_vs_x_N = iBooker.bookProfile("p_x_diffFN_vs_x_N", profilePtr.get()); + + for (int i = 0; i < scfg_.rp_N_.x_slice_n_; i++) { + const double x_min = scfg_.rp_N_.x_slice_min_ + i * scfg_.rp_N_.x_slice_w_; + const double x_max = scfg_.rp_N_.x_slice_min_ + (i + 1) * scfg_.rp_N_.x_slice_w_; char buf[100]; - sprintf(buf, "%.1f-%.1f", xMin, xMax); + sprintf(buf, "%.1f-%.1f", x_min, x_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/near_far/x slices, N/" + buf); - x_slice_plots_N.insert({i, SlicePlots(iBooker, debug)}); + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/near_far/x slices, N/" + buf); + x_slice_plots_N.insert({i, SlicePlots(iBooker, cfg, debug)}); } - for (int i = 0; i < scfg.rp_F_.x_slice_n_; i++) { - const double xMin = scfg.rp_F_.x_slice_min_ + i * scfg.rp_F_.x_slice_w_; - const double xMax = scfg.rp_F_.x_slice_min_ + (i + 1) * scfg.rp_F_.x_slice_w_; + for (int i = 0; i < scfg_.rp_F_.x_slice_n_; i++) { + const double x_min = scfg_.rp_F_.x_slice_min_ + i * scfg_.rp_F_.x_slice_w_; + const double x_max = scfg_.rp_F_.x_slice_min_ + (i + 1) * scfg_.rp_F_.x_slice_w_; char buf[100]; - sprintf(buf, "%.1f-%.1f", xMin, xMax); + sprintf(buf, "%.1f-%.1f", x_min, x_max); - iBooker.setCurrentFolder(folder + "/" + scfg.name_ + "/near_far/x slices, F/" + buf); - x_slice_plots_F.insert({i, SlicePlots(iBooker, debug)}); + iBooker.setCurrentFolder(folder + "/" + scfg_.name_ + "/near_far/x slices, F/" + buf); + x_slice_plots_F.insert({i, SlicePlots(iBooker, cfg, debug)}); } } -unsigned int PPSAlignmentWorker::SectorData::process(const CTPPSLocalTrackLiteCollection &tracks, - const PPSAlignmentConfig &cfg, +unsigned int PPSAlignmentWorker::SectorData::process(const CTPPSLocalTrackLiteCollection& tracks, + const PPSAlignmentConfiguration& cfg, bool debug) { CTPPSLocalTrackLiteCollection tracksUp, tracksDw; - for (const auto &tr : tracks) { + for (const auto& tr : tracks) { CTPPSDetId rpId(tr.rpId()); unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - if (rpDecId != scfg.rp_N_.id_ && rpDecId != scfg.rp_F_.id_) + if (rpDecId != scfg_.rp_N_.id_ && rpDecId != scfg_.rp_F_.id_) continue; - double x = tr.x(); - double y = tr.y(); - - // re-build track object - CTPPSLocalTrackLite trCorr(tr.rpId(), - x, - 0., - y, - 0., - tr.tx(), - tr.txUnc(), - tr.ty(), - tr.tyUnc(), - tr.chiSquaredOverNDF(), - tr.pixelTrackRecoInfo(), - tr.numberOfPointsUsedForFit(), - tr.time(), - tr.timeUnc()); - - // store corrected track into the right collection - if (rpDecId == scfg.rp_N_.id_) - tracksUp.push_back(trCorr); - if (rpDecId == scfg.rp_F_.id_) - tracksDw.push_back(trCorr); + // store the track in the right collection + if (rpDecId == scfg_.rp_N_.id_) + tracksUp.push_back(tr); + if (rpDecId == scfg_.rp_F_.id_) + tracksDw.push_back(tr); } // update plots before selection - for (const auto &tr : tracksUp) - m_h2_y_vs_x_bef_sel[scfg.rp_N_.id_]->Fill(tr.x(), tr.y()); + for (const auto& tr : tracksUp) + m_h2_y_vs_x_bef_sel[scfg_.rp_N_.id_]->Fill(tr.x(), tr.y()); - for (const auto &tr : tracksDw) - m_h2_y_vs_x_bef_sel[scfg.rp_F_.id_]->Fill(tr.x(), tr.y()); + for (const auto& tr : tracksDw) + m_h2_y_vs_x_bef_sel[scfg_.rp_F_.id_]->Fill(tr.x(), tr.y()); - // skip crowded events - if (tracksUp.size() > cfg.maxRPTracksSize()) + // skip crowded events (multiplicity selection) + if (tracksUp.size() < cfg.minRPTracksSize() || tracksUp.size() > cfg.maxRPTracksSize()) return 0; - if (tracksDw.size() > cfg.maxRPTracksSize()) + if (tracksDw.size() < cfg.minRPTracksSize() || tracksDw.size() > cfg.maxRPTracksSize()) return 0; // update plots with multiplicity selection - for (const auto &tr : tracksUp) - m_h2_y_vs_x_mlt_sel[scfg.rp_N_.id_]->Fill(tr.x(), tr.y()); + for (const auto& tr : tracksUp) + m_h2_y_vs_x_mlt_sel[scfg_.rp_N_.id_]->Fill(tr.x(), tr.y()); - for (const auto &tr : tracksDw) - m_h2_y_vs_x_mlt_sel[scfg.rp_F_.id_]->Fill(tr.x(), tr.y()); + for (const auto& tr : tracksDw) + m_h2_y_vs_x_mlt_sel[scfg_.rp_F_.id_]->Fill(tr.x(), tr.y()); // do the selection unsigned int pairsSelected = 0; - for (const auto &trUp : tracksUp) { - for (const auto &trDw : tracksDw) { + for (const auto& trUp : tracksUp) { + for (const auto& trDw : tracksDw) { h2_cut_h_bef->Fill(trUp.x(), trDw.x()); h2_cut_v_bef->Fill(trUp.y(), trDw.y()); - const double cq_h = trDw.x() + scfg.cut_h_a_ * trUp.x() + scfg.cut_h_c_; + const double cq_h = trDw.x() + scfg_.cut_h_a_ * trUp.x() + scfg_.cut_h_c_; h_q_cut_h_bef->Fill(cq_h); - const bool cv_h = (std::fabs(cq_h) < cfg.n_si() * scfg.cut_h_si_); + const bool cv_h = (std::fabs(cq_h) < cfg.n_si() * scfg_.cut_h_si_); - const double cq_v = trDw.y() + scfg.cut_v_a_ * trUp.y() + scfg.cut_v_c_; + const double cq_v = trDw.y() + scfg_.cut_v_a_ * trUp.y() + scfg_.cut_v_c_; h_q_cut_v_bef->Fill(cq_v); - const bool cv_v = (std::fabs(cq_v) < cfg.n_si() * scfg.cut_v_si_); + const bool cv_v = (std::fabs(cq_v) < cfg.n_si() * scfg_.cut_v_si_); bool cutsPassed = true; - if (scfg.cut_h_apply_) + if (scfg_.cut_h_apply_) cutsPassed &= cv_h; - if (scfg.cut_v_apply_) + if (scfg_.cut_v_apply_) cutsPassed &= cv_v; if (cutsPassed) { @@ -287,21 +333,21 @@ unsigned int PPSAlignmentWorker::SectorData::process(const CTPPSLocalTrackLiteCo h2_cut_h_aft->Fill(trUp.x(), trDw.x()); h2_cut_v_aft->Fill(trUp.y(), trDw.y()); - m_h2_y_vs_x_aft_sel[scfg.rp_N_.id_]->Fill(trUp.x(), trUp.y()); - m_h2_y_vs_x_aft_sel[scfg.rp_F_.id_]->Fill(trDw.x(), trDw.y()); + m_h2_y_vs_x_aft_sel[scfg_.rp_N_.id_]->Fill(trUp.x(), trUp.y()); + m_h2_y_vs_x_aft_sel[scfg_.rp_F_.id_]->Fill(trDw.x(), trDw.y()); p_x_diffFN_vs_x_N->Fill(trUp.x(), trDw.x() - trUp.x()); - int idx = (trUp.x() - scfg.rp_N_.x_slice_min_) / scfg.rp_N_.x_slice_w_; - if (idx >= 0 && idx < scfg.rp_N_.x_slice_n_) { + int idx = (trUp.x() - scfg_.rp_N_.x_slice_min_) / scfg_.rp_N_.x_slice_w_; + if (idx >= 0 && idx < scfg_.rp_N_.x_slice_n_) { x_slice_plots_N[idx].h_y->Fill(trUp.y()); x_slice_plots_N[idx].p_y_diffFN_vs_y->Fill(trUp.y(), trDw.y() - trUp.y()); if (debug) x_slice_plots_N[idx].h2_y_diffFN_vs_y->Fill(trUp.y(), trDw.y() - trUp.y()); } - idx = (trDw.x() - scfg.rp_F_.x_slice_min_) / scfg.rp_F_.x_slice_w_; - if (idx >= 0 && idx < scfg.rp_F_.x_slice_n_) { + idx = (trDw.x() - scfg_.rp_F_.x_slice_min_) / scfg_.rp_F_.x_slice_w_; + if (idx >= 0 && idx < scfg_.rp_F_.x_slice_n_) { x_slice_plots_F[idx].h_y->Fill(trDw.y()); x_slice_plots_F[idx].p_y_diffFN_vs_y->Fill(trDw.y(), trDw.y() - trUp.y()); if (debug) @@ -314,31 +360,4 @@ unsigned int PPSAlignmentWorker::SectorData::process(const CTPPSLocalTrackLiteCo return pairsSelected; } -// -------------------------------- PPSAlignmentWorker methods -------------------------------- - -PPSAlignmentWorker::PPSAlignmentWorker(const edm::ParameterSet &iConfig) - : esTokenBookHistograms_(esConsumes( - edm::ESInputTag("", iConfig.getParameter("label")))), - esTokenAnalyze_(esConsumes( - edm::ESInputTag("", iConfig.getParameter("label")))), - tracksToken_(consumes(iConfig.getParameter("tagTracks"))), - folder_(iConfig.getParameter("folder")), - debug_(iConfig.getParameter("debug")) {} - -void PPSAlignmentWorker::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, edm::EventSetup const &iSetup) { - const auto &cfg = iSetup.getData(esTokenBookHistograms_); - - sectorData45.init(iBooker, cfg, cfg.sectorConfig45(), folder_ + "/worker", debug_); - sectorData56.init(iBooker, cfg, cfg.sectorConfig56(), folder_ + "/worker", debug_); -} - -void PPSAlignmentWorker::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - const auto &tracks = iEvent.get(tracksToken_); - - const auto &cfg = iSetup.getData(esTokenAnalyze_); - - sectorData45.process(tracks, cfg, debug_); - sectorData56.process(tracks, cfg, debug_); -} - -DEFINE_FWK_MODULE(PPSAlignmentWorker); \ No newline at end of file +DEFINE_FWK_MODULE(PPSAlignmentWorker); diff --git a/CalibPPS/AlignmentGlobal/python/ALCARECOPPSAlignment_Output_cff.py b/CalibPPS/AlignmentGlobal/python/ALCARECOPPSAlignment_Output_cff.py new file mode 100644 index 0000000000000..8ff556699bdaf --- /dev/null +++ b/CalibPPS/AlignmentGlobal/python/ALCARECOPPSAlignment_Output_cff.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +OutALCARECOPPSAlignment_noDrop = cms.PSet( + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOPPSAlignment') + ), + outputCommands = cms.untracked.vstring( + 'keep *_MEtoEDMConvertPPSAlignment_*_*', + ) +) + +OutALCARECOPPSAlignment = OutALCARECOPPSAlignment_noDrop.clone() +OutALCARECOPPSAlignment.outputCommands.insert(0, 'drop *') diff --git a/CalibPPS/AlignmentGlobal/python/ALCARECOPPSAlignment_cff.py b/CalibPPS/AlignmentGlobal/python/ALCARECOPPSAlignment_cff.py new file mode 100644 index 0000000000000..3b01706270500 --- /dev/null +++ b/CalibPPS/AlignmentGlobal/python/ALCARECOPPSAlignment_cff.py @@ -0,0 +1,16 @@ +import FWCore.ParameterSet.Config as cms + +from CalibPPS.AlignmentGlobal.ppsAlignmentWorker_cfi import ppsAlignmentWorker + +MEtoEDMConvertPPSAlignment = cms.EDProducer('MEtoEDMConverter', + Name=cms.untracked.string('MEtoEDMConverter'), + Verbosity=cms.untracked.int32(0), + Frequency=cms.untracked.int32(50), + MEPathToSave=cms.untracked.string('AlCaReco/PPSAlignment'), + deleteAfterCopy=cms.untracked.bool(True) +) + +taskALCARECOPPSAlignment = cms.Task( + ppsAlignmentWorker, + MEtoEDMConvertPPSAlignment +) diff --git a/CalibPPS/AlignmentGlobal/python/PPSAlignmentHarvester_cff.py b/CalibPPS/AlignmentGlobal/python/PPSAlignmentHarvester_cff.py new file mode 100644 index 0000000000000..8a18d949c8b1d --- /dev/null +++ b/CalibPPS/AlignmentGlobal/python/PPSAlignmentHarvester_cff.py @@ -0,0 +1,6 @@ +from CalibPPS.AlignmentGlobal.ppsAlignmentHarvester_cfi import * + +ppsAlignmentHarvester.text_results_path = cms.string("") +ppsAlignmentHarvester.write_sqlite_results = cms.bool(True) +ppsAlignmentHarvester.x_ali_rel_final_slope_fixed = cms.bool(False) +ppsAlignmentHarvester.y_ali_final_slope_fixed = cms.bool(False) diff --git a/CalibPPS/AlignmentGlobal/python/ppsAlignmentHarvester_cfi.py b/CalibPPS/AlignmentGlobal/python/ppsAlignmentHarvester_cfi.py deleted file mode 100644 index 35214114e8d3d..0000000000000 --- a/CalibPPS/AlignmentGlobal/python/ppsAlignmentHarvester_cfi.py +++ /dev/null @@ -1,7 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from DQMServices.Core.DQMEDHarvester import DQMEDHarvester - -ppsAlignmentHarvester = DQMEDHarvester("PPSAlignmentHarvester", - folder = cms.string("CalibPPS/Common"), - debug = cms.bool(True) -) \ No newline at end of file diff --git a/CalibPPS/AlignmentGlobal/python/ppsAlignmentWorker_cfi.py b/CalibPPS/AlignmentGlobal/python/ppsAlignmentWorker_cfi.py deleted file mode 100644 index 163a7f943f498..0000000000000 --- a/CalibPPS/AlignmentGlobal/python/ppsAlignmentWorker_cfi.py +++ /dev/null @@ -1,9 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer - -ppsAlignmentWorker = DQMEDAnalyzer("PPSAlignmentWorker", - tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), - folder = cms.string("CalibPPS/Common"), - label = cms.string(""), - debug = cms.bool(False) -) \ No newline at end of file diff --git a/CalibPPS/AlignmentGlobal/test/README.md b/CalibPPS/AlignmentGlobal/test/README.md index abbfe07f85ada..85392e1bc019a 100644 --- a/CalibPPS/AlignmentGlobal/test/README.md +++ b/CalibPPS/AlignmentGlobal/test/README.md @@ -13,38 +13,47 @@ ## Running instructions ``` -cmsRun run_distributions_reference_cfg.py -cmsRun run_distributions_cfg.py -cmsRun run_analysis_manual_cfg.py +cmsRun run_distributions_reference_cfg.py && cmsRun run_distributions_cfg.py && cmsRun run_analysis_cfg.py ``` -## Expected results -### x_alignment - - RP 3: x = -3690.0 +- 17.9 um - - RP 23: x = -41690.0 +- 17.2 um - - RP 103: x = -2700.0 +- 16.9 um - - RP 123: x = -41830.0 +- 16.0 um - -### x_alignment_relative: - - RP 3: x = 18985.6 +- 1.0 um - - RP 23: x = -18985.6 +- 1.0 um - - RP 103: x = 19484.1 +- 1.2 um - - RP 123: x = -19484.1 +- 1.2 um - -### x_alignment_relative_sl_fix: - - RP 3: x = 18983.7 +- 0.2 um - - RP 23: x = -18983.7 +- 0.2 um - - RP 103: x = 19486.6 +- 0.3 um - - RP 123: x = -19486.6 +- 0.3 um - -### y_alignment: - - RP 3: y = 3468.8 +- 44.1 um - - RP 23: y = 4097.6 +- 44.8 um - - RP 103: y = 3025.5 +- 77.8 um - - RP 123: y = 3344.0 +- 66.1 um - -### y_alignment_sl_fix: - - RP 3: y = 3491.7 +- 10.7 um - - RP 23: y = 4167.4 +- 11.6 um - - RP 103: y = 2753.5 +- 18.2 um - - RP 123: y = 3390.2 +- 17.3 um \ No newline at end of file +## Expected results (alignment_results.txt) +``` +1: x_alignment: +RP 3: shift (um) x = -3670.0 +- 19.8, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 23: shift (um) x = -41710.0 +- 20.6, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 103: shift (um) x = -2700.0 +- 18.8, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 123: shift (um) x = -41840.0 +- 19.5, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 + + +2: x_alignment_relative: +RP 3: shift (um) x = 18984.6 +- 1.2, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 23: shift (um) x = -18984.6 +- 1.2, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 103: shift (um) x = 19485.3 +- 1.5, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 123: shift (um) x = -19485.3 +- 1.5, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 + +2: x_alignment_relative_sl_fix: +RP 3: shift (um) x = 18983.8 +- 0.3, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 23: shift (um) x = -18983.8 +- 0.3, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 103: shift (um) x = 19486.8 +- 0.3, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 123: shift (um) x = -19486.8 +- 0.3, y = 0.0 +- 0.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 + + +3: y_alignment: +RP 3: shift (um) x = 0.0 +- 0.0, y = 3443.3 +- 101.7, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 23: shift (um) x = 0.0 +- 0.0, y = 4190.3 +- 87.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 103: shift (um) x = 0.0 +- 0.0, y = 2885.9 +- 66.2, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 123: shift (um) x = 0.0 +- 0.0, y = 3491.8 +- 129.5, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 + +3: y_alignment_sl_fix: +RP 3: shift (um) x = 0.0 +- 0.0, y = 3490.3 +- 16.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 23: shift (um) x = 0.0 +- 0.0, y = 4209.1 +- 15.8, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 103: shift (um) x = 0.0 +- 0.0, y = 2751.2 +- 16.1, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 123: shift (um) x = 0.0 +- 0.0, y = 3417.9 +- 23.9, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 + + +final merged results: +RP 3: shift (um) x = -3706.2 +- 19.8, y = 3490.3 +- 16.0, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 23: shift (um) x = -41673.8 +- 20.6, y = 4209.1 +- 15.8, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 103: shift (um) x = -2783.2 +- 18.8, y = 2751.2 +- 16.1, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +RP 123: shift (um) x = -41756.8 +- 19.5, y = 3417.9 +- 23.9, z = 0.0 +- 0.0, rotation (mrad) x = 0.0 +- 0.0, y = 0.0 +- 0.0, z = 0.0 +- 0.0 +``` diff --git a/CalibPPS/AlignmentGlobal/test/config_cff.py b/CalibPPS/AlignmentGlobal/test/config_cff.py index 4c8130f8f16ad..50e7763fdf1f4 100644 --- a/CalibPPS/AlignmentGlobal/test/config_cff.py +++ b/CalibPPS/AlignmentGlobal/test/config_cff.py @@ -1,12 +1,6 @@ import FWCore.ParameterSet.Config as cms -ppsAlignmentConfigESSource = cms.ESSource("PPSAlignmentConfigESSource", - sequence = cms.vstring( - "x_alignment", - "x_alignment_relative", - "y_alignment" - ), - +ppsAlignmentConfigESSource = cms.ESSource("PPSAlignmentConfigurationESSource", sector_45 = cms.PSet( rp_N = cms.PSet( x_max_fit_mode = cms.double(7.0), @@ -39,5 +33,17 @@ cut_h_c = cms.double(-39.26 + 0.33), cut_v_c = cms.double(1.49 - 1.80) + ), + + y_alignment = cms.PSet( + rp_L_F = cms.PSet( + x_min = cms.double(45.5) + ), + rp_L_N = cms.PSet( + x_min = cms.double(7.8) + ), + rp_R_F = cms.PSet( + x_min = cms.double(45.5) + ) ) -) \ No newline at end of file +) diff --git a/CalibPPS/AlignmentGlobal/test/config_reference_cff.py b/CalibPPS/AlignmentGlobal/test/config_reference_cff.py index f925b48787127..f2ee40ad3a18b 100644 --- a/CalibPPS/AlignmentGlobal/test/config_reference_cff.py +++ b/CalibPPS/AlignmentGlobal/test/config_reference_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms -ppsAlignmentConfigESSource = cms.ESSource("PPSAlignmentConfigESSource", +ppsAlignmentConfigESSource = cms.ESSource("PPSAlignmentConfigurationESSource", label = cms.string('reference'), sector_45 = cms.PSet( diff --git a/CalibPPS/AlignmentGlobal/test/run_analysis_cfg.py b/CalibPPS/AlignmentGlobal/test/run_analysis_cfg.py new file mode 100644 index 0000000000000..fceb4d3fab1c1 --- /dev/null +++ b/CalibPPS/AlignmentGlobal/test/run_analysis_cfg.py @@ -0,0 +1,111 @@ +########## Configuration ########## +# if set to True, a file with logs will be produced. +produce_logs = True + +# if set to True, the harvester will produce an extra ROOT file with some debug plots. +# Works only for one-run input. +harvester_debug = True + +# Path for a ROOT file with the histograms. +input_distributions = 'file:dqm_run_distributions_test.root' + +# Reference dataset path. +reference_dataset_path = 'DQM_V0001_CalibPPS_R000314273.root' + +# If set to True, the results will be also written to an SQLite file. +write_sqlite_results = False + +# Output database. Used only if write_sqlite_results is set to True. +output_conditions = 'sqlite_file:alignment_results.db' + +# Database tag. Used only if write_sqlite_results is set to True. +output_db_tag = 'CTPPSRPAlignmentCorrectionsData_test' +################################### + +import sys +import os +import FWCore.ParameterSet.Config as cms + +process = cms.Process('testDistributions') + +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load("DQMServices.Core.DQMStore_cfi") +process.load("CalibPPS.AlignmentGlobal.ppsAlignmentHarvester_cfi") + +if harvester_debug: + process.ppsAlignmentHarvester.debug = cms.bool(True) + +# Message Logger +if produce_logs: + process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('run_analysis', + 'cout' + ), + run_analysis = cms.untracked.PSet( + threshold = cms.untracked.string("INFO") + ), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) + ) +else: + process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) + ) + +# load DQM framework +process.load("DQMServices.Components.DQMEnvironment_cfi") +process.dqmEnv.subSystemFolder = "CalibPPS" +process.dqmSaver.convention = 'Offline' +process.dqmSaver.workflow = "/CalibPPS/AlignmentGlobal/CMSSW_12_1_0_pre1" +process.dqmSaver.saveByRun = -1 +process.dqmSaver.saveAtJobEnd = True +process.dqmSaver.forceRunNumber = 999999 + +# Source (histograms) +process.source = cms.Source("DQMRootSource", + fileNames = cms.untracked.vstring(input_distributions), +) + +# Event Setup (test) +from config_cff import ppsAlignmentConfigESSource as ppsAlignmentConfigESSourceTest +process.ppsAlignmentConfigESSourceTest = ppsAlignmentConfigESSourceTest + +# Event Setup (reference) +from config_reference_cff import ppsAlignmentConfigESSource as ppsAlignmentConfigESSourceReference +ppsAlignmentConfigESSourceReference.matching = cms.PSet( + reference_dataset = cms.string(reference_dataset_path) +) +process.ppsAlignmentConfigESSourceReference = ppsAlignmentConfigESSourceReference + +# SQLite results +if write_sqlite_results: + process.load("CondCore.CondDB.CondDB_cfi") + process.CondDB.connect = output_conditions + process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet( + record = cms.string('CTPPSRPAlignmentCorrectionsDataRcd'), + tag = cms.string(output_db_tag) + )) + ) + + # DB object maker parameters + process.ppsAlignmentHarvester.write_sqlite_results = cms.bool(True) + +process.path = cms.Path( + process.ppsAlignmentHarvester +) + +process.end_path = cms.EndPath( + process.dqmSaver +) + +process.schedule = cms.Schedule( + process.path, + process.end_path +) diff --git a/CalibPPS/AlignmentGlobal/test/run_analysis_manual_cfg.py b/CalibPPS/AlignmentGlobal/test/run_analysis_manual_cfg.py deleted file mode 100644 index a2537d6d3ea04..0000000000000 --- a/CalibPPS/AlignmentGlobal/test/run_analysis_manual_cfg.py +++ /dev/null @@ -1,58 +0,0 @@ -import sys -import os -import FWCore.ParameterSet.Config as cms - -from config_cff import ppsAlignmentConfigESSource as ppsAlignmentConfigESSourceTest -from config_reference_cff import ppsAlignmentConfigESSource as ppsAlignmentConfigESSourceReference -ppsAlignmentConfigESSourceReference.matching = cms.PSet( - reference_dataset = cms.string("DQM_V0001_CalibPPS_R000314273.root") -) - -process = cms.Process('testDistributions') - -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load("DQMServices.Core.DQMStore_cfi") -process.load("CalibPPS.AlignmentGlobal.ppsAlignmentHarvester_cfi") - -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring(# 'run_analysis_manual', - 'cout' - ), - # run_analysis_manual = cms.untracked.PSet( - # threshold = cms.untracked.string("INFO") - # ), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# load DQM framework -process.load("DQMServices.Components.DQMEnvironment_cfi") -process.dqmEnv.subSystemFolder = "CalibPPS" -process.dqmSaver.convention = 'Offline' -process.dqmSaver.workflow = "/CalibPPS/AlignmentGlobal/CMSSW_11_2_0_pre6" -process.dqmSaver.saveByRun = -1 -process.dqmSaver.saveAtJobEnd = True -process.dqmSaver.forceRunNumber = 999999 - -process.source = cms.Source("DQMRootSource", - fileNames = cms.untracked.vstring( - "file:dqm_run_distributions_test.root" - ), -) - -process.ppsAlignmentConfigESSourceReference = ppsAlignmentConfigESSourceReference -process.ppsAlignmentConfigESSourceTest = ppsAlignmentConfigESSourceTest - -process.path = cms.Path( - process.ppsAlignmentHarvester -) - -process.end_path = cms.EndPath( - process.dqmSaver -) - -process.schedule = cms.Schedule( - process.path, - process.end_path -) \ No newline at end of file diff --git a/CalibPPS/AlignmentGlobal/test/run_distributions_cfg.py b/CalibPPS/AlignmentGlobal/test/run_distributions_cfg.py index 3a029259a1fbe..3b841ed477084 100644 --- a/CalibPPS/AlignmentGlobal/test/run_distributions_cfg.py +++ b/CalibPPS/AlignmentGlobal/test/run_distributions_cfg.py @@ -1,7 +1,14 @@ +########## Configuration ########## +# if set to True, a file with logs will be produced. +produce_logs = False + +# Path for a ROOT file with the histograms +output_distributions = 'dqm_run_distributions_test.root' +################################### + import FWCore.ParameterSet.Config as cms from input_files_cff import input_files -from config_cff import ppsAlignmentConfigESSource process = cms.Process('testDistributions') @@ -10,39 +17,50 @@ process.load("DQMServices.Core.DQMStore_cfi") # Message Logger -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring(# 'run_distributions', - 'cout' - ), - # run_distributions = cms.untracked.PSet( - # threshold = cms.untracked.string("INFO") - # ), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) +if produce_logs: + process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('run_distributions', + 'cout' + ), + run_distributions = cms.untracked.PSet( + threshold = cms.untracked.string("INFO") + ), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) + ) +else: + process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) + ) +# Source process.source = cms.Source("PoolSource", - fileNames = input_files + fileNames = input_files ) process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) # Event Setup +from config_cff import ppsAlignmentConfigESSource process.ppsAlignmentConfigESSource = ppsAlignmentConfigESSource +# Output for the histograms process.dqmOutput = cms.OutputModule("DQMRootOutputModule", - fileName = cms.untracked.string("dqm_run_distributions_test.root") + fileName = cms.untracked.string(output_distributions) ) process.path = cms.Path( - process.ppsAlignmentWorker + process.ppsAlignmentWorker ) process.end_path = cms.EndPath( - process.dqmOutput + process.dqmOutput ) process.schedule = cms.Schedule( - process.path, - process.end_path -) \ No newline at end of file + process.path, + process.end_path +) diff --git a/CalibPPS/AlignmentGlobal/test/run_distributions_reference_cfg.py b/CalibPPS/AlignmentGlobal/test/run_distributions_reference_cfg.py index 7d15ba881b38d..d691ada99a77d 100644 --- a/CalibPPS/AlignmentGlobal/test/run_distributions_reference_cfg.py +++ b/CalibPPS/AlignmentGlobal/test/run_distributions_reference_cfg.py @@ -1,7 +1,14 @@ +########## Configuration ########## +# if set to True, a file with logs will be produced. +produce_logs = False + +# Source max processed events +max_events = 1000000 +################################### + import FWCore.ParameterSet.Config as cms from input_files_reference_cff import input_files -from config_reference_cff import ppsAlignmentConfigESSource process = cms.Process('referenceDistributions') @@ -10,33 +17,43 @@ process.load("DQMServices.Core.DQMStore_cfi") # Message Logger -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring(# 'run_distributions', - 'cout' - ), - # run_distributions = cms.untracked.PSet( - # threshold = cms.untracked.string("INFO") - # ), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# load DQM framework -process.load("DQM.Integration.config.environment_cfi") -process.dqmEnv.subSystemFolder = "CalibPPS" -process.dqmSaver.path = "" -process.dqmSaver.tag = "CalibPPS" +if produce_logs: + process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('run_distributions', + 'cout' + ), + run_distributions = cms.untracked.PSet( + threshold = cms.untracked.string("INFO") + ), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) + ) +else: + process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) + ) +# Source process.source = cms.Source("PoolSource", fileNames = input_files ) -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(2000000)) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(max_events)) # Event Setup +from config_reference_cff import ppsAlignmentConfigESSource process.ppsAlignmentConfigESSource = ppsAlignmentConfigESSource -# Worker config label +# load DQM framework +process.load("DQM.Integration.config.environment_cfi") +process.dqmEnv.subSystemFolder = "CalibPPS" +process.dqmSaver.path = "" +process.dqmSaver.tag = "CalibPPS" + +# Worker config label (for ES product label) process.ppsAlignmentWorker.label = cms.string("reference") process.path = cms.Path( @@ -50,4 +67,4 @@ process.schedule = cms.Schedule( process.path, process.end_path -) \ No newline at end of file +) diff --git a/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_Output_cff.py b/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_Output_cff.py index 20bee7ec6c60e..6a4171db20554 100644 --- a/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_Output_cff.py +++ b/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_Output_cff.py @@ -7,9 +7,8 @@ outputCommands = cms.untracked.vstring( 'keep *_ALCARECOPPSCalTrackBasedSel_*_*', 'keep *_ctppsDiamondRawToDigi_*_*', - 'keep *_totemTimingRawToDigi_*_*' - - # will be updated to add the spatial alignment required collections + 'keep *_totemTimingRawToDigi_*_*', + 'keep *_ctppsLocalTrackLiteProducer_*_*' ) ) diff --git a/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_cff.py b/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_cff.py index 27ad42bb7d8db..f92dda0ee8030 100644 --- a/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_cff.py +++ b/CalibPPS/TimingCalibration/python/ALCARECOPPSCalTrackBasedSel_cff.py @@ -15,27 +15,31 @@ # select events passing the filter on pixel tracks from HLTrigger.special.hltPPSPerPotTrackFilter_cfi import hltPPSPerPotTrackFilter as _filter -hltPPSPerPotTrackFilter = _filter.clone( +hltPPSPerPotTrackFilter_45 = _filter.clone( pixelFilter = cms.VPSet( cms.PSet( # sector 45, near pot detid = cms.uint32(2022703104), minTracks = cms.int32(1), - maxTracks = cms.int32(6), + maxTracks = cms.int32(1), ), cms.PSet( # sector 45, far pot detid = cms.uint32(2023227392), minTracks = cms.int32(1), - maxTracks = cms.int32(6), + maxTracks = cms.int32(1), ), + ) +) +hltPPSPerPotTrackFilter_56 = _filter.clone( + pixelFilter = cms.VPSet( cms.PSet( # sector 56, near pot detid = cms.uint32(2039480320), minTracks = cms.int32(1), - maxTracks = cms.int32(6), + maxTracks = cms.int32(1), ), cms.PSet( # sector 56, far pot detid = cms.uint32(2040004608), minTracks = cms.int32(1), - maxTracks = cms.int32(6), + maxTracks = cms.int32(1), ), ) ) @@ -44,5 +48,5 @@ ctppsRawToDigi * recoCTPPS * ALCARECOPPSCalTrackBasedSelHLT * - hltPPSPerPotTrackFilter + (hltPPSPerPotTrackFilter_45 + hltPPSPerPotTrackFilter_56) ) diff --git a/CondTools/CTPPS/plugins/RetrieveCTPPSRPAlignmentCorrectionsData.cc b/CondTools/CTPPS/plugins/RetrieveCTPPSRPAlignmentCorrectionsData.cc new file mode 100644 index 0000000000000..d039391e5a9f5 --- /dev/null +++ b/CondTools/CTPPS/plugins/RetrieveCTPPSRPAlignmentCorrectionsData.cc @@ -0,0 +1,43 @@ +/**************************************************************************** +* Author: +* Mateusz Kocot (mateuszkocot99@gmail.com) +****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h" +#include "CondFormats/DataRecord/interface/CTPPSRPAlignmentCorrectionsDataRcd.h" + +#include + +class RetrieveCTPPSRPAlignmentCorrectionsData : public edm::one::EDAnalyzer<> { +public: + explicit RetrieveCTPPSRPAlignmentCorrectionsData(const edm::ParameterSet &); + +private: + void analyze(const edm::Event &, const edm::EventSetup &) override; + + edm::ESGetToken esToken_; +}; + +RetrieveCTPPSRPAlignmentCorrectionsData::RetrieveCTPPSRPAlignmentCorrectionsData(const edm::ParameterSet &iConfig) + : esToken_(esConsumes()) {} + +void RetrieveCTPPSRPAlignmentCorrectionsData::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { + // get the data + const auto &ctppsRPAlignmentCorrectionsData = iSetup.getData(esToken_); + + edm::LogInfo("PPS") << ctppsRPAlignmentCorrectionsData; +} + +//define this as a plug-in +DEFINE_FWK_MODULE(RetrieveCTPPSRPAlignmentCorrectionsData); diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index fd7bcda098947..108c0b021056f 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -32,13 +32,13 @@ # GlobalTag for Run2 HI data 'run2_data_promptlike_hi' : '121X_dataRun2_PromptLike_HI_v5', # GlobalTag for Run3 HLT: it points to the online GT - 'run3_hlt' : '120X_dataRun3_HLT_v3', + 'run3_hlt' : '121X_dataRun3_HLT_v6', # GlobalTag with fixed snapshot time for Run2 HLT RelVals: customizations to run with fixed L1 Menu 'run2_hlt_relval' : '121X_dataRun2_HLT_relval_v5', # GlobalTag for Run3 data relvals (express GT) - 'run3_data_express' : '120X_dataRun3_Express_v2', + 'run3_data_express' : '121X_dataRun3_Express_v6', # GlobalTag for Run3 data relvals - 'run3_data_prompt' : '120X_dataRun3_Prompt_v2', + 'run3_data_prompt' : '121X_dataRun3_Prompt_v6', # GlobalTag for Run3 offline data reprocessing 'run3_data' : '121X_dataRun3_v5', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) diff --git a/Configuration/AlCa/python/autoPCL.py b/Configuration/AlCa/python/autoPCL.py index 0876ddef0fc4c..c39f1fadff178 100644 --- a/Configuration/AlCa/python/autoPCL.py +++ b/Configuration/AlCa/python/autoPCL.py @@ -10,5 +10,6 @@ 'PromptCalibProdEcalPedestals': 'EcalPedestals', 'PromptCalibProdLumiPCC': 'LumiPCC', 'PromptCalibProdPPS' : 'PPSTimingCalibration', - 'PromptCalibProdPPSDiamondSampic' : 'PPSDiamondSampicTimingCalibration' + 'PromptCalibProdPPSDiamondSampic' : 'PPSDiamondSampicTimingCalibration', + 'PromptCalibProdPPSAlig' : 'PPSAlignment' } diff --git a/Configuration/EventContent/python/AlCaRecoOutput_cff.py b/Configuration/EventContent/python/AlCaRecoOutput_cff.py index 611adb9ba5b4b..835c8b99eaf70 100644 --- a/Configuration/EventContent/python/AlCaRecoOutput_cff.py +++ b/Configuration/EventContent/python/AlCaRecoOutput_cff.py @@ -149,6 +149,7 @@ from CalibPPS.TimingCalibration.ALCARECOPPSCalTrackBasedSel_Output_cff import * from CalibPPS.TimingCalibration.ALCARECOPPSTimingCalib_Output_cff import * from CalibPPS.TimingCalibration.ALCARECOPPSDiamondSampicTimingCalib_Output_cff import * +from CalibPPS.AlignmentGlobal.ALCARECOPPSAlignment_Output_cff import * ############################################################### # stream for prompt-calibration @ Tier0 diff --git a/Configuration/PyReleaseValidation/python/relval_production.py b/Configuration/PyReleaseValidation/python/relval_production.py index f0f540b6cbc1a..0dd840730b0f2 100644 --- a/Configuration/PyReleaseValidation/python/relval_production.py +++ b/Configuration/PyReleaseValidation/python/relval_production.py @@ -26,6 +26,7 @@ workflows[1040.1] = ['',['RunExpressPhy2017F','TIER0EXPSIPIXELCAL','ALCASPLITSIPIXELCAL','ALCAHARVDSIPIXELCAL']] workflows[1041] = ['',['RunExpressPhy2017F','TIER0EXPPPSCAL','ALCASPLITPPSCAL','ALCAHARVDPPSCAL']] +workflows[1042] = ['',['RunExpressPhy2017F','TIER0EXPPPSCAL','ALCASPLITPPSALIG','ALCAHARVDPPSALIG']] ## MC production test #workflows[1100] = [ '',[]] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index af8689b01b987..8b0cbe1cf7289 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2126,6 +2126,16 @@ def lhegensim2018ml(fragment,howMuch): '--triggerResultsProcess':'RECO', } +steps['ALCASPLITPPSALIG']={'-s':'ALCAOUTPUT:PPSCalTrackBasedSel,ALCA:PPSAlignment', + '--scenario':'pp', + '--data':'', + '--era':'Run2_2017', + '--datatier':'ALCARECO', + '--eventcontent':'ALCARECO', + '--conditions':'auto:run3_data_express', + '--triggerResultsProcess':'RECO', + } + steps['ALCAHARVDHPBS']={'-s':'ALCAHARVEST:%s'%(autoPCL['PromptCalibProdBeamSpotHP']), #'--conditions':'auto:run2_data_promptlike', '--conditions':'auto:run3_data_express', # to replaced with line above once run2_data_promptlike will contain DropBoxMetadata @@ -2165,6 +2175,13 @@ def lhegensim2018ml(fragment,howMuch): '--era':'Run2_2017', '--filein':'file:PPSTimingCalib.root'} +steps['ALCAHARVDPPSALIG']={'-s':'ALCAHARVEST:%s'%(autoPCL['PromptCalibProdPPSAlig']), + '--conditions':'auto:run3_data_express', + '--scenario':'pp', + '--data':'', + '--era':'Run2_2017', + '--filein':'file:PPSAlignment.root'} + steps['RECOCOSD']=merge([{'--scenario':'cosmics', '-s':'RAW2DIGI,L1Reco,RECO,DQM', '--datatier':'RECO,DQMIO', # no miniAOD for cosmics diff --git a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py index 583a05feb7453..0050299b593dc 100644 --- a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py +++ b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py @@ -13,6 +13,7 @@ from CalibTracker.SiPixelQuality.DQMEventInfoSiPixelQuality_cff import * from CalibPPS.TimingCalibration.PPSTimingCalibrationHarvester_cff import * from CalibPPS.TimingCalibration.ALCARECOPPSDiamondSampicTimingCalibHarvester_cff import * +from CalibPPS.AlignmentGlobal.PPSAlignmentHarvester_cff import * from Calibration.TkAlCaRecoProducers.PCLMetadataWriter_cfi import * @@ -239,6 +240,12 @@ tag = cms.string('DiamondSampicCalibration'), timetype = cms.untracked.string('runnumber')) +ALCAHARVESTPPSAlignment = ppsAlignmentHarvester.clone() +ALCAHARVESTPPSAlignment_metadata = cms.PSet(record = cms.untracked.string('CTPPSRPAlignmentCorrectionsDataRcd')) +ALCAHARVESTPPSAlignment_dbOutput = cms.PSet(record = cms.string('CTPPSRPAlignmentCorrectionsDataRcd'), + tag = cms.string('CTPPSRPAlignment_real_pcl'), + timetype = cms.untracked.string('runnumber')) + # define all the paths BeamSpotByRun = cms.Path(ALCAHARVESTBeamSpotByRun) BeamSpotByLumi = cms.Path(ALCAHARVESTBeamSpotByLumi) @@ -256,6 +263,7 @@ SiPixelQuality = cms.Path(dqmEnvSiPixelQuality+ALCAHARVESTSiPixelQuality)#+siPixelPhase1DQMHarvester) PPSTimingCalibration = cms.Path(ALCAHARVESTPPSTimingCalibration) PPSDiamondSampicTimingCalibration = cms.Path(ALCAHARVESTPPSDiamondSampicTimingCalibration) +PPSAlignment = cms.Path(ALCAHARVESTPPSAlignment) ALCAHARVESTDQMSaveAndMetadataWriter = cms.Path(dqmSaver+pclMetadataWriter) diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index ce3ebcfb8cad7..ad3bc858f980b 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -133,6 +133,8 @@ from CalibPPS.TimingCalibration.ALCARECOPPSCalTrackBasedSel_cff import * from CalibPPS.TimingCalibration.ALCARECOPPSTimingCalib_cff import * from CalibPPS.TimingCalibration.ALCARECOPPSDiamondSampicTimingCalib_cff import * +# Alignment +from CalibPPS.AlignmentGlobal.ALCARECOPPSAlignment_cff import * ############################################################### # nonbeam alcas @@ -243,6 +245,7 @@ pathALCARECORpcCalHLT = cms.Path(seqALCARECORpcCalHLT) pathALCARECOPPSTimingCalib = cms.Path(taskALCARECOPPSTimingCalib) pathALCARECOPPSDiamondSampicTimingCalib = cms.Path(taskALCARECOPPSDiamondSampicTimingCalib) +pathALCARECOPPSAlignment = cms.Path(taskALCARECOPPSAlignment) pathALCARECOTkAlBeamHalo = cms.Path(seqALCARECOTkAlBeamHalo*ALCARECOTkAlBeamHaloDQM) pathALCARECOMuAlBeamHaloOverlaps = cms.Path(seqALCARECOMuAlBeamHaloOverlaps) pathALCARECOMuAlBeamHalo = cms.Path(seqALCARECOMuAlBeamHalo) @@ -903,6 +906,15 @@ dataTier = cms.untracked.string('ALCARECO') ) +ALCARECOStreamPPSAlignment = cms.FilteredStream( + responsible = 'Mateusz Kocot', + name = 'PPSAlignment', + paths = (pathALCARECOPPSAlignment), + content = OutALCARECOPPSAlignment.outputCommands, + selectEvents = OutALCARECOPPSAlignment.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') +) + ALCARECOStreamPromptCalibProd = cms.FilteredStream( responsible = 'Gianluca Cerminara', name = 'PromptCalibProd',