Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-18 02:24:49

0001 /****************************************************************************

0002 * Authors: 

0003 *  Jan Kašpar (jan.kaspar@gmail.com) 

0004 *  Mateusz Kocot (mateuszkocot99@gmail.com)

0005 ****************************************************************************/
0006 
0007 #include "CondFormats/PPSObjects/interface/PPSAlignmentConfiguration.h"
0008 
0009 #include <iostream>
0010 #include <cmath>
0011 #include <iomanip>
0012 
0013 // -------------------------------- PPSAlignmentConfiguration getters --------------------------------

0014 
0015 const PPSAlignmentConfiguration::SectorConfig& PPSAlignmentConfiguration::sectorConfig45() const {
0016   return sectorConfig45_;
0017 }
0018 const PPSAlignmentConfiguration::SectorConfig& PPSAlignmentConfiguration::sectorConfig56() const {
0019   return sectorConfig56_;
0020 }
0021 
0022 double PPSAlignmentConfiguration::x_ali_sh_step() const { return x_ali_sh_step_; }
0023 
0024 double PPSAlignmentConfiguration::y_mode_sys_unc() const { return y_mode_sys_unc_; }
0025 double PPSAlignmentConfiguration::chiSqThreshold() const { return chiSqThreshold_; }
0026 double PPSAlignmentConfiguration::y_mode_unc_max_valid() const { return y_mode_unc_max_valid_; }
0027 double PPSAlignmentConfiguration::y_mode_max_valid() const { return y_mode_max_valid_; }
0028 
0029 double PPSAlignmentConfiguration::minRPTracksSize() const { return minRPTracksSize_; }
0030 double PPSAlignmentConfiguration::maxRPTracksSize() const { return maxRPTracksSize_; }
0031 double PPSAlignmentConfiguration::n_si() const { return n_si_; }
0032 
0033 const std::map<unsigned int, std::vector<PPSAlignmentConfiguration::PointErrors>>&
0034 PPSAlignmentConfiguration::matchingReferencePoints() const {
0035   return matchingReferencePoints_;
0036 }
0037 const std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>&
0038 PPSAlignmentConfiguration::matchingShiftRanges() const {
0039   return matchingShiftRanges_;
0040 }
0041 
0042 const std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>&
0043 PPSAlignmentConfiguration::alignment_x_meth_o_ranges() const {
0044   return alignment_x_meth_o_ranges_;
0045 }
0046 unsigned int PPSAlignmentConfiguration::fitProfileMinBinEntries() const { return fitProfileMinBinEntries_; }
0047 unsigned int PPSAlignmentConfiguration::fitProfileMinNReasonable() const { return fitProfileMinNReasonable_; }
0048 unsigned int PPSAlignmentConfiguration::methOGraphMinN() const { return methOGraphMinN_; }
0049 double PPSAlignmentConfiguration::methOUncFitRange() const { return methOUncFitRange_; }
0050 
0051 const std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>&
0052 PPSAlignmentConfiguration::alignment_x_relative_ranges() const {
0053   return alignment_x_relative_ranges_;
0054 }
0055 unsigned int PPSAlignmentConfiguration::nearFarMinEntries() const { return nearFarMinEntries_; }
0056 
0057 const std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>& PPSAlignmentConfiguration::alignment_y_ranges()
0058     const {
0059   return alignment_y_ranges_;
0060 }
0061 unsigned int PPSAlignmentConfiguration::modeGraphMinN() const { return modeGraphMinN_; }
0062 unsigned int PPSAlignmentConfiguration::multSelProjYMinEntries() const { return multSelProjYMinEntries_; }
0063 
0064 const PPSAlignmentConfiguration::Binning& PPSAlignmentConfiguration::binning() const { return binning_; }
0065 
0066 const std::vector<double>& PPSAlignmentConfiguration::extraParams() const { return extraParams_; }
0067 
0068 // -------------------------------- PPSAlignmentConfiguration setters --------------------------------

0069 
0070 void PPSAlignmentConfiguration::setSectorConfig45(PPSAlignmentConfiguration::SectorConfig& sectorConfig45) {
0071   sectorConfig45_ = sectorConfig45;
0072 }
0073 void PPSAlignmentConfiguration::setSectorConfig56(PPSAlignmentConfiguration::SectorConfig& sectorConfig56) {
0074   sectorConfig56_ = sectorConfig56;
0075 }
0076 
0077 void PPSAlignmentConfiguration::setX_ali_sh_step(double x_ali_sh_step) { x_ali_sh_step_ = x_ali_sh_step; }
0078 
0079 void PPSAlignmentConfiguration::setY_mode_sys_unc(double y_mode_sys_unc) { y_mode_sys_unc_ = y_mode_sys_unc; }
0080 void PPSAlignmentConfiguration::setChiSqThreshold(double chiSqThreshold) { chiSqThreshold_ = chiSqThreshold; }
0081 void PPSAlignmentConfiguration::setY_mode_unc_max_valid(double y_mode_unc_max_valid) {
0082   y_mode_unc_max_valid_ = y_mode_unc_max_valid;
0083 }
0084 void PPSAlignmentConfiguration::setY_mode_max_valid(double y_mode_max_valid) { y_mode_max_valid_ = y_mode_max_valid; }
0085 
0086 void PPSAlignmentConfiguration::setMinRPTracksSize(unsigned int minRPTracksSize) { minRPTracksSize_ = minRPTracksSize; }
0087 void PPSAlignmentConfiguration::setMaxRPTracksSize(unsigned int maxRPTracksSize) { maxRPTracksSize_ = maxRPTracksSize; }
0088 void PPSAlignmentConfiguration::setN_si(double n_si) { n_si_ = n_si; }
0089 
0090 void PPSAlignmentConfiguration::setMatchingReferencePoints(
0091     std::map<unsigned int, std::vector<PPSAlignmentConfiguration::PointErrors>>& matchingReferencePoints) {
0092   matchingReferencePoints_ = matchingReferencePoints;
0093 }
0094 void PPSAlignmentConfiguration::setMatchingShiftRanges(
0095     std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>& matchingShiftRanges) {
0096   matchingShiftRanges_ = matchingShiftRanges;
0097 }
0098 
0099 void PPSAlignmentConfiguration::setAlignment_x_meth_o_ranges(
0100     std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>& alignment_x_meth_o_ranges) {
0101   alignment_x_meth_o_ranges_ = alignment_x_meth_o_ranges;
0102 }
0103 void PPSAlignmentConfiguration::setFitProfileMinBinEntries(unsigned int fitProfileMinBinEntries) {
0104   fitProfileMinBinEntries_ = fitProfileMinBinEntries;
0105 }
0106 void PPSAlignmentConfiguration::setFitProfileMinNReasonable(unsigned int fitProfileMinNReasonable) {
0107   fitProfileMinNReasonable_ = fitProfileMinNReasonable;
0108 }
0109 void PPSAlignmentConfiguration::setMethOGraphMinN(unsigned int methOGraphMinN) { methOGraphMinN_ = methOGraphMinN; }
0110 void PPSAlignmentConfiguration::setMethOUncFitRange(double methOUncFitRange) { methOUncFitRange_ = methOUncFitRange; }
0111 
0112 void PPSAlignmentConfiguration::setAlignment_x_relative_ranges(
0113     std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>& alignment_x_relative_ranges) {
0114   alignment_x_relative_ranges_ = alignment_x_relative_ranges;
0115 }
0116 void PPSAlignmentConfiguration::setNearFarMinEntries(unsigned int nearFarMinEntries) {
0117   nearFarMinEntries_ = nearFarMinEntries;
0118 }
0119 
0120 void PPSAlignmentConfiguration::setAlignment_y_ranges(
0121     std::map<unsigned int, PPSAlignmentConfiguration::SelectionRange>& alignment_y_ranges) {
0122   alignment_y_ranges_ = alignment_y_ranges;
0123 }
0124 void PPSAlignmentConfiguration::setModeGraphMinN(unsigned int modeGraphMinN) { modeGraphMinN_ = modeGraphMinN; }
0125 void PPSAlignmentConfiguration::setMultSelProjYMinEntries(unsigned int multSelProjYMinEntries) {
0126   multSelProjYMinEntries_ = multSelProjYMinEntries;
0127 }
0128 
0129 void PPSAlignmentConfiguration::setBinning(PPSAlignmentConfiguration::Binning& binning) { binning_ = binning; }
0130 
0131 void PPSAlignmentConfiguration::setExtraParams(std::vector<double>& extraParams) { extraParams_ = extraParams; }
0132 
0133 // -------------------------------- << operators --------------------------------

0134 
0135 std::ostream& operator<<(std::ostream& os, const PPSAlignmentConfiguration::RPConfig& rc) {
0136   os << std::fixed << std::setprecision(3);
0137   os << "    " << rc.name_ << ", id = " << rc.id_ << ", position = " << rc.position_ << ":\n";
0138   os << "        slope = " << rc.slope_ << ", sh_x = " << rc.sh_x_ << "\n";
0139   os << "        x_min_fit_mode = " << rc.x_min_fit_mode_ << ", x_max_fit_mode = " << rc.x_max_fit_mode_ << "\n";
0140   os << "        y_max_fit_mode = " << rc.y_max_fit_mode_ << "\n";
0141   os << "        y_cen_add = " << rc.y_cen_add_ << ", y_width_mult = " << rc.y_width_mult_ << "\n";
0142   os << std::setprecision(2);
0143   os << "        x slices: min = " << rc.x_slice_min_ << ", w = " << rc.x_slice_w_ << ", n = " << rc.x_slice_n_;
0144 
0145   return os;
0146 }
0147 
0148 std::ostream& operator<<(std::ostream& os, const PPSAlignmentConfiguration::SectorConfig& sc) {
0149   os << std::fixed << std::setprecision(3);
0150   os << sc.name_ << ":\n";
0151   os << sc.rp_N_ << "\n" << sc.rp_F_ << "\n";
0152   os << std::setprecision(3);
0153   os << "    slope = " << sc.slope_ << "\n";
0154   os << "    cut_h: apply = " << std::boolalpha << sc.cut_h_apply_ << ", a = " << sc.cut_h_a_ << ", c = " << sc.cut_h_c_
0155      << ", si = " << sc.cut_h_si_ << "\n";
0156   os << "    cut_v: apply = " << std::boolalpha << sc.cut_v_apply_ << ", a = " << sc.cut_v_a_ << ", c = " << sc.cut_v_c_
0157      << ", si = " << sc.cut_v_si_ << "\n";
0158 
0159   return os;
0160 }
0161 
0162 std::ostream& operator<<(std::ostream& os, const PPSAlignmentConfiguration::Binning& b) {
0163   os << "    bin_size_x = " << b.bin_size_x_ << ", n_bins_x = " << b.n_bins_x_ << "\n";
0164   os << "    pixel_x_offset = " << b.pixel_x_offset_ << "\n";
0165   os << "    n_bins_y = " << b.n_bins_y_ << ", y_min = " << b.y_min_ << ", y_max = " << b.y_max_ << "\n";
0166   os << "    diff far-near:"
0167      << "\n";
0168   os << "        n_bins_x = " << b.diffFN_n_bins_x_ << ", x_min = " << b.diffFN_x_min_
0169      << ", x_max = " << b.diffFN_x_max_ << "\n";
0170   os << "    slice plots:"
0171      << "\n";
0172   os << "        n_bins_x = " << b.slice_n_bins_x_ << ", x_min = " << b.slice_x_min_ << ", x_max = " << b.slice_x_max_
0173      << "\n";
0174   os << "        n_bins_y = " << b.slice_n_bins_y_ << ", y_min = " << b.slice_y_min_ << ", y_max = " << b.slice_y_max_;
0175 
0176   return os;
0177 }
0178 
0179 std::ostream& operator<<(std::ostream& os, const PPSAlignmentConfiguration& c) {
0180   os << "* " << c.sectorConfig45_ << "\n\n";
0181   os << "* " << c.sectorConfig56_ << "\n\n";
0182 
0183   std::map<unsigned int, std::string> rpTags = {{c.sectorConfig45_.rp_F_.id_, c.sectorConfig45_.rp_F_.name_},
0184                                                 {c.sectorConfig45_.rp_N_.id_, c.sectorConfig45_.rp_N_.name_},
0185                                                 {c.sectorConfig56_.rp_N_.id_, c.sectorConfig56_.rp_N_.name_},
0186                                                 {c.sectorConfig56_.rp_F_.id_, c.sectorConfig56_.rp_F_.name_}};
0187 
0188   os << "* x alignment shift step\n";
0189   os << "    x_ali_sh_step = " << c.x_ali_sh_step_ << "\n\n";
0190 
0191   os << "* mode graph parameters\n";
0192   os << "    y_mode_sys_unc = " << c.y_mode_sys_unc_ << "\n";
0193   os << "    chiSqThreshold = " << c.chiSqThreshold_ << "\n";
0194   os << "    y_mode_unc_max_valid = " << c.y_mode_unc_max_valid_ << "\n";
0195   os << "    y_mode_max_valid = " << c.y_mode_max_valid_ << "\n\n";
0196 
0197   os << "* selection\n";
0198   os << "    min_RP_tracks_size = " << c.minRPTracksSize_ << "\n";
0199   os << "    max_RP_tracks_size = " << c.maxRPTracksSize_ << "\n\n";
0200 
0201   os << "* cuts\n";
0202   os << "    n_si = " << c.n_si_ << "\n\n";
0203 
0204   os << "* matching\n" << std::setprecision(3);
0205 
0206   os << "    shift ranges:\n";
0207   for (const auto& p : c.matchingShiftRanges_)
0208     os << "        RP " << rpTags[p.first] << " (" << std::setw(3) << p.first << "): sh_min = " << p.second.x_min_
0209        << ", sh_max = " << p.second.x_max_ << "\n";
0210 
0211   os << "    reference points:\n";
0212   for (const auto& pm : c.matchingReferencePoints_) {
0213     os << "        " << std::setw(3) << pm.first << ": ";
0214     for (unsigned int i = 0; i < pm.second.size(); i++) {
0215       const auto& p = pm.second[i];
0216       if (i % 5 == 0 && i > 0)
0217         os << "\n             ";
0218       os << "(" << std::setw(6) << p.x_ << " +- " << p.ex_ << ", " << std::setw(6) << p.y_ << " +- " << p.ey_ << "), ";
0219     }
0220     os << "\n";
0221   }
0222 
0223   os << "\n"
0224      << "* alignment_x_meth_o\n";
0225   for (const auto& p : c.alignment_x_meth_o_ranges_)
0226     os << "    RP " << rpTags[p.first] << " (" << std::setw(3) << p.first << "): sh_min = " << p.second.x_min_
0227        << ", sh_max = " << p.second.x_max_ << "\n";
0228   os << "    fit_profile_min_bin_entries = " << c.fitProfileMinBinEntries_ << "\n";
0229   os << "    fit_profile_min_N_reasonable = " << c.fitProfileMinNReasonable_ << "\n";
0230   os << "    meth_o_graph_min_N = " << c.methOGraphMinN_ << "\n";
0231   os << "    meth_o_unc_fit_range = " << c.methOUncFitRange_ << "\n";
0232 
0233   os << "\n"
0234      << "* alignment_x_relative\n";
0235   for (const auto& p : c.alignment_x_relative_ranges_)
0236     if (p.first == c.sectorConfig45_.rp_N_.id_ || p.first == c.sectorConfig56_.rp_N_.id_) {  // only near RPs

0237       os << "    RP " << rpTags[p.first] << " (" << std::setw(3) << p.first << "): sh_min = " << p.second.x_min_
0238          << ", sh_max = " << p.second.x_max_ << "\n";
0239     }
0240   os << "    near_far_min_entries = " << c.nearFarMinEntries_ << "\n";
0241 
0242   os << "\n"
0243      << "* alignment_y\n";
0244   for (const auto& p : c.alignment_y_ranges_)
0245     os << "    RP " << rpTags[p.first] << " (" << std::setw(3) << p.first << "): sh_min = " << p.second.x_min_
0246        << ", sh_max = " << p.second.x_max_ << "\n";
0247   os << "    mode_graph_min_N = " << c.modeGraphMinN_ << "\n";
0248   os << "    mult_sel_proj_y_min_entries = " << c.multSelProjYMinEntries_ << "\n";
0249 
0250   os << "\n"
0251      << "* binning\n";
0252   os << c.binning_ << "\n";
0253 
0254   if (!c.extraParams_.empty()) {
0255     os << "\n";
0256     os << "extra_params:\n";
0257     for (size_t i = 0; i < c.extraParams_.size(); i++) {
0258       os << std::setw(5) << i << ": " << c.extraParams_[i] << "\n";
0259     }
0260   }
0261 
0262   return os;
0263 }