Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:40

0001 #include "DQM/SiStripCommissioningSummary/interface/CalibrationSummaryFactory.h"
0002 #include "CondFormats/SiStripObjects/interface/CalibrationAnalysis.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include <iostream>
0006 #include <sstream>
0007 
0008 using namespace sistrip;
0009 
0010 // -----------------------------------------------------------------------------
0011 //
0012 void CalibrationSummaryFactory::extract(Iterator iter) {
0013   CalibrationAnalysis* anal = dynamic_cast<CalibrationAnalysis*>(iter->second);
0014   if (!anal) {
0015     return;
0016   }
0017 
0018   std::vector<float> temp(128, 1. * sistrip::invalid_);
0019   std::vector<std::vector<float> > amplitude(2, temp);
0020   std::vector<std::vector<float> > baseline(2, temp);
0021   std::vector<std::vector<float> > riseTime(2, temp);
0022   std::vector<std::vector<float> > turnOn(2, temp);
0023   std::vector<std::vector<float> > peakTime(2, temp);
0024   std::vector<std::vector<float> > undershoot(2, temp);
0025   std::vector<std::vector<float> > tail(2, temp);
0026   std::vector<std::vector<float> > decayTime(2, temp);
0027   std::vector<std::vector<float> > smearing(2, temp);
0028   std::vector<std::vector<float> > chi2(2, temp);
0029 
0030   std::vector<std::vector<float> > value(2, temp);
0031 
0032   amplitude[0] = anal->amplitude()[0];
0033   amplitude[1] = anal->amplitude()[1];
0034   baseline[0] = anal->baseline()[0];
0035   baseline[1] = anal->baseline()[1];
0036   tail[0] = anal->tail()[0];
0037   tail[1] = anal->tail()[1];
0038   riseTime[0] = anal->riseTime()[0];
0039   riseTime[1] = anal->riseTime()[1];
0040   decayTime[0] = anal->decayTime()[0];
0041   decayTime[1] = anal->decayTime()[1];
0042   peakTime[0] = anal->peakTime()[0];
0043   peakTime[1] = anal->peakTime()[1];
0044   turnOn[0] = anal->turnOn()[0];
0045   turnOn[1] = anal->turnOn()[1];
0046   undershoot[0] = anal->undershoot()[0];
0047   undershoot[1] = anal->undershoot()[1];
0048   smearing[0] = anal->smearing()[0];
0049   smearing[1] = anal->smearing()[1];
0050   chi2[0] = anal->chi2()[0];
0051   chi2[1] = anal->chi2()[1];
0052 
0053   SiStripFecKey lldKey = SiStripFecKey(iter->first);
0054 
0055   uint32_t key1 = SiStripFecKey(lldKey.fecCrate(),
0056                                 lldKey.fecSlot(),
0057                                 lldKey.fecRing(),
0058                                 lldKey.ccuAddr(),
0059                                 lldKey.ccuChan(),
0060                                 lldKey.lldChan(),
0061                                 lldKey.i2cAddr(lldKey.lldChan(), true))
0062                       .key();
0063 
0064   uint32_t key2 = SiStripFecKey(lldKey.fecCrate(),
0065                                 lldKey.fecSlot(),
0066                                 lldKey.fecRing(),
0067                                 lldKey.ccuAddr(),
0068                                 lldKey.ccuChan(),
0069                                 lldKey.lldChan(),
0070                                 lldKey.i2cAddr(lldKey.lldChan(), false))
0071                       .key();
0072 
0073   bool all_strips = false;
0074   if (mon_ == sistrip::CALIBRATION_AMPLITUDE_ALL_STRIPS) {
0075     all_strips = true;
0076     uint16_t bins = amplitude[amplitude[0].size() < amplitude[1].size() ? 1 : 0].size();
0077     for (uint16_t i = 0; i < bins; i++) {
0078       value[0][i] = amplitude[0][i];
0079       value[1][i] = amplitude[1][i];
0080     }
0081   } else if (mon_ == sistrip::CALIBRATION_BASELINE_ALL_STRIPS) {
0082     all_strips = true;
0083     uint16_t bins = baseline[baseline[0].size() < baseline[1].size() ? 1 : 0].size();
0084     for (uint16_t i = 0; i < bins; i++) {
0085       value[0][i] = baseline[0][i];
0086       value[1][i] = baseline[1][i];
0087     }
0088   } else if (mon_ == sistrip::CALIBRATION_TURNON_ALL_STRIPS) {
0089     all_strips = true;
0090     uint16_t bins = turnOn[turnOn[0].size() < turnOn[1].size() ? 1 : 0].size();
0091     for (uint16_t i = 0; i < bins; i++) {
0092       value[0][i] = turnOn[0][i];
0093       value[1][i] = turnOn[1][i];
0094     }
0095   } else if (mon_ == sistrip::CALIBRATION_RISETIME_ALL_STRIPS) {
0096     all_strips = true;
0097     uint16_t bins = riseTime[riseTime[0].size() < riseTime[1].size() ? 1 : 0].size();
0098     for (uint16_t i = 0; i < bins; i++) {
0099       value[0][i] = riseTime[0][i];
0100       value[1][i] = riseTime[1][i];
0101     }
0102   } else if (mon_ == sistrip::CALIBRATION_DECAYTIME_ALL_STRIPS) {
0103     all_strips = true;
0104     uint16_t bins = decayTime[decayTime[0].size() < decayTime[1].size() ? 1 : 0].size();
0105     for (uint16_t i = 0; i < bins; i++) {
0106       value[0][i] = decayTime[0][i];
0107       value[1][i] = decayTime[1][i];
0108     }
0109   } else if (mon_ == sistrip::CALIBRATION_PEAKTIME_ALL_STRIPS) {
0110     all_strips = true;
0111     uint16_t bins = peakTime[peakTime[0].size() < peakTime[1].size() ? 1 : 0].size();
0112     for (uint16_t i = 0; i < bins; i++) {
0113       value[0][i] = peakTime[0][i];
0114       value[1][i] = peakTime[1][i];
0115     }
0116   } else if (mon_ == sistrip::CALIBRATION_UNDERSHOOT_ALL_STRIPS) {
0117     all_strips = true;
0118     uint16_t bins = undershoot[undershoot[0].size() < undershoot[1].size() ? 1 : 0].size();
0119     for (uint16_t i = 0; i < bins; i++) {
0120       value[0][i] = undershoot[0][i];
0121       value[1][i] = undershoot[1][i];
0122     }
0123   } else if (mon_ == sistrip::CALIBRATION_TAIL_ALL_STRIPS) {
0124     all_strips = true;
0125     uint16_t bins = tail[tail[0].size() < tail[1].size() ? 1 : 0].size();
0126     for (uint16_t i = 0; i < bins; i++) {
0127       value[0][i] = tail[0][i];
0128       value[1][i] = tail[1][i];
0129     }
0130   } else if (mon_ == sistrip::CALIBRATION_SMEARING_ALL_STRIPS) {
0131     all_strips = true;
0132     uint16_t bins = smearing[smearing[0].size() < smearing[1].size() ? 1 : 0].size();
0133     for (uint16_t i = 0; i < bins; i++) {
0134       value[0][i] = smearing[0][i];
0135       value[1][i] = smearing[1][i];
0136     }
0137   } else if (mon_ == sistrip::CALIBRATION_CHI2_ALL_STRIPS) {
0138     all_strips = true;
0139     uint16_t bins = chi2[chi2[0].size() < chi2[1].size() ? 1 : 0].size();
0140     for (uint16_t i = 0; i < bins; i++) {
0141       value[0][i] = chi2[0][i];
0142       value[1][i] = chi2[1][i];
0143     }
0144   }
0145   //////
0146   else if (mon_ == sistrip::CALIBRATION_AMPLITUDE_MEAN) {
0147     value[0][0] = anal->amplitudeMean()[0];
0148     value[1][0] = anal->amplitudeMean()[1];
0149   } else if (mon_ == sistrip::CALIBRATION_BASELINE_MEAN) {
0150     value[0][0] = anal->baselineMean()[0];
0151     value[1][0] = anal->baselineMean()[1];
0152   } else if (mon_ == sistrip::CALIBRATION_TURNON_MEAN) {
0153     value[0][0] = anal->turnOnMean()[0];
0154     value[1][0] = anal->turnOnMean()[1];
0155   } else if (mon_ == sistrip::CALIBRATION_RISETIME_MEAN) {
0156     value[0][0] = anal->riseTimeMean()[0];
0157     value[1][0] = anal->riseTimeMean()[1];
0158   } else if (mon_ == sistrip::CALIBRATION_DECAYTIME_MEAN) {
0159     value[0][0] = anal->decayTimeMean()[0];
0160     value[1][0] = anal->decayTimeMean()[1];
0161   } else if (mon_ == sistrip::CALIBRATION_PEAKTIME_MEAN) {
0162     value[0][0] = anal->peakTimeMean()[0];
0163     value[1][0] = anal->peakTimeMean()[1];
0164   } else if (mon_ == sistrip::CALIBRATION_UNDERSHOOT_MEAN) {
0165     value[0][0] = anal->undershootMean()[0];
0166     value[1][0] = anal->undershootMean()[1];
0167   } else if (mon_ == sistrip::CALIBRATION_TAIL_MEAN) {
0168     value[0][0] = anal->tailMean()[0];
0169     value[1][0] = anal->tailMean()[1];
0170   } else if (mon_ == sistrip::CALIBRATION_SMEARING_MEAN) {
0171     value[0][0] = anal->smearingMean()[0];
0172     value[1][0] = anal->smearingMean()[1];
0173   } else if (mon_ == sistrip::CALIBRATION_CHI2_MEAN) {
0174     value[0][0] = anal->chi2Mean()[0];
0175     value[1][0] = anal->chi2Mean()[1];
0176   }
0177   //////
0178   else if (mon_ == sistrip::CALIBRATION_AMPLITUDE_MIN) {
0179     value[0][0] = anal->amplitudeMin()[0];
0180     value[1][0] = anal->amplitudeMin()[1];
0181   } else if (mon_ == sistrip::CALIBRATION_BASELINE_MIN) {
0182     value[0][0] = anal->baselineMin()[0];
0183     value[1][0] = anal->baselineMin()[1];
0184   } else if (mon_ == sistrip::CALIBRATION_TURNON_MIN) {
0185     value[0][0] = anal->turnOnMin()[0];
0186     value[1][0] = anal->turnOnMin()[1];
0187   } else if (mon_ == sistrip::CALIBRATION_RISETIME_MIN) {
0188     value[0][0] = anal->riseTimeMin()[0];
0189     value[1][0] = anal->riseTimeMin()[1];
0190   } else if (mon_ == sistrip::CALIBRATION_DECAYTIME_MIN) {
0191     value[0][0] = anal->decayTimeMin()[0];
0192     value[1][0] = anal->decayTimeMin()[1];
0193   } else if (mon_ == sistrip::CALIBRATION_PEAKTIME_MIN) {
0194     value[0][0] = anal->peakTimeMin()[0];
0195     value[1][0] = anal->peakTimeMin()[1];
0196   } else if (mon_ == sistrip::CALIBRATION_UNDERSHOOT_MIN) {
0197     value[0][0] = anal->undershootMin()[0];
0198     value[1][0] = anal->undershootMin()[1];
0199   } else if (mon_ == sistrip::CALIBRATION_TAIL_MIN) {
0200     value[0][0] = anal->tailMin()[0];
0201     value[1][0] = anal->tailMin()[1];
0202   } else if (mon_ == sistrip::CALIBRATION_SMEARING_MIN) {
0203     value[0][0] = anal->smearingMin()[0];
0204     value[1][0] = anal->smearingMin()[1];
0205   } else if (mon_ == sistrip::CALIBRATION_CHI2_MIN) {
0206     value[0][0] = anal->chi2Min()[0];
0207     value[1][0] = anal->chi2Min()[1];
0208   }
0209   //////
0210   else if (mon_ == sistrip::CALIBRATION_AMPLITUDE_MAX) {
0211     value[0][0] = anal->amplitudeMax()[0];
0212     value[1][0] = anal->amplitudeMax()[1];
0213   } else if (mon_ == sistrip::CALIBRATION_BASELINE_MAX) {
0214     value[0][0] = anal->baselineMax()[0];
0215     value[1][0] = anal->baselineMax()[1];
0216   } else if (mon_ == sistrip::CALIBRATION_TURNON_MAX) {
0217     value[0][0] = anal->turnOnMax()[0];
0218     value[1][0] = anal->turnOnMax()[1];
0219   } else if (mon_ == sistrip::CALIBRATION_RISETIME_MAX) {
0220     value[0][0] = anal->riseTimeMax()[0];
0221     value[1][0] = anal->riseTimeMax()[1];
0222   } else if (mon_ == sistrip::CALIBRATION_DECAYTIME_MAX) {
0223     value[0][0] = anal->decayTimeMax()[0];
0224     value[1][0] = anal->decayTimeMax()[1];
0225   } else if (mon_ == sistrip::CALIBRATION_PEAKTIME_MAX) {
0226     value[0][0] = anal->peakTimeMax()[0];
0227     value[1][0] = anal->peakTimeMax()[1];
0228   } else if (mon_ == sistrip::CALIBRATION_UNDERSHOOT_MAX) {
0229     value[0][0] = anal->undershootMax()[0];
0230     value[1][0] = anal->undershootMax()[1];
0231   } else if (mon_ == sistrip::CALIBRATION_TAIL_MAX) {
0232     value[0][0] = anal->tailMax()[0];
0233     value[1][0] = anal->tailMax()[1];
0234   } else if (mon_ == sistrip::CALIBRATION_SMEARING_MAX) {
0235     value[0][0] = anal->smearingMax()[0];
0236     value[1][0] = anal->smearingMax()[1];
0237   } else if (mon_ == sistrip::CALIBRATION_CHI2_MAX) {
0238     value[0][0] = anal->chi2Max()[0];
0239     value[1][0] = anal->chi2Max()[1];
0240   }
0241   //////
0242   else if (mon_ == sistrip::CALIBRATION_AMPLITUDE_SPREAD) {
0243     value[0][0] = anal->amplitudeSpread()[0];
0244     value[1][0] = anal->amplitudeSpread()[1];
0245   } else if (mon_ == sistrip::CALIBRATION_BASELINE_SPREAD) {
0246     value[0][0] = anal->baselineSpread()[0];
0247     value[1][0] = anal->baselineSpread()[1];
0248   } else if (mon_ == sistrip::CALIBRATION_TURNON_SPREAD) {
0249     value[0][0] = anal->turnOnSpread()[0];
0250     value[1][0] = anal->turnOnSpread()[1];
0251   } else if (mon_ == sistrip::CALIBRATION_RISETIME_SPREAD) {
0252     value[0][0] = anal->riseTimeSpread()[0];
0253     value[1][0] = anal->riseTimeSpread()[1];
0254   } else if (mon_ == sistrip::CALIBRATION_DECAYTIME_SPREAD) {
0255     value[0][0] = anal->decayTimeSpread()[0];
0256     value[1][0] = anal->decayTimeSpread()[1];
0257   } else if (mon_ == sistrip::CALIBRATION_PEAKTIME_SPREAD) {
0258     value[0][0] = anal->peakTimeSpread()[0];
0259     value[1][0] = anal->peakTimeSpread()[1];
0260   } else if (mon_ == sistrip::CALIBRATION_UNDERSHOOT_SPREAD) {
0261     value[0][0] = anal->undershootSpread()[0];
0262     value[1][0] = anal->undershootSpread()[1];
0263   } else if (mon_ == sistrip::CALIBRATION_TAIL_SPREAD) {
0264     value[0][0] = anal->tailSpread()[0];
0265     value[1][0] = anal->tailSpread()[1];
0266   } else if (mon_ == sistrip::CALIBRATION_SMEARING_SPREAD) {
0267     value[0][0] = anal->smearingSpread()[0];
0268     value[1][0] = anal->smearingSpread()[1];
0269   } else if (mon_ == sistrip::CALIBRATION_CHI2_SPREAD) {
0270     value[0][0] = anal->chi2Spread()[0];
0271     value[1][0] = anal->chi2Spread()[1];
0272   } else {
0273     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactory::" << __func__ << "]"
0274                                      << " Unexpected monitorable: "
0275                                      << SiStripEnumsAndStrings::monitorable(SummaryPlotFactoryBase::mon_);
0276     return;
0277   }
0278 
0279   if (!all_strips) {
0280     SummaryPlotFactoryBase::generator_->fillMap(
0281         SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, key1, value[0][0]);
0282 
0283     SummaryPlotFactoryBase::generator_->fillMap(
0284         SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, key2, value[1][0]);
0285   } else {
0286     for (uint16_t istr = 0; istr < value[0].size(); istr++)
0287       SummaryPlotFactoryBase::generator_->fillMap(
0288           SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, key1, value[0][istr]);
0289 
0290     for (uint16_t istr = 0; istr < value[1].size(); istr++)
0291       SummaryPlotFactoryBase::generator_->fillMap(
0292           SummaryPlotFactoryBase::level_, SummaryPlotFactoryBase::gran_, key2, value[1][istr]);
0293   }
0294 
0295   format();
0296 }
0297 
0298 //------------------------------------------------------------------------------
0299 //
0300 void CalibrationSummaryFactory::format() {
0301   // Histogram formatting
0302   if (mon_ == sistrip::CALIBRATION_AMPLITUDE_MEAN or mon_ == sistrip::CALIBRATION_AMPLITUDE_ALL_STRIPS or
0303       mon_ == sistrip::CALIBRATION_AMPLITUDE_MIN or mon_ == sistrip::CALIBRATION_AMPLITUDE_MAX or
0304       mon_ == sistrip::CALIBRATION_AMPLITUDE_SPREAD)
0305     generator_->axisLabel("Amplitude (ADC)");
0306 
0307   else if (mon_ == sistrip::CALIBRATION_BASELINE_MEAN or mon_ == sistrip::CALIBRATION_BASELINE_ALL_STRIPS or
0308            mon_ == sistrip::CALIBRATION_BASELINE_MIN or mon_ == sistrip::CALIBRATION_BASELINE_MAX or
0309            mon_ == sistrip::CALIBRATION_BASELINE_SPREAD)
0310     generator_->axisLabel("Baseline (ADC)");
0311 
0312   else if (mon_ == sistrip::CALIBRATION_TURNON_MEAN or mon_ == sistrip::CALIBRATION_TURNON_ALL_STRIPS or
0313            mon_ == sistrip::CALIBRATION_TURNON_MIN or mon_ == sistrip::CALIBRATION_TURNON_MAX or
0314            mon_ == sistrip::CALIBRATION_TURNON_SPREAD)
0315     generator_->axisLabel("Turn-On (ns)");
0316 
0317   else if (mon_ == sistrip::CALIBRATION_TAIL_MEAN or mon_ == sistrip::CALIBRATION_TAIL_ALL_STRIPS or
0318            mon_ == sistrip::CALIBRATION_TAIL_MIN or mon_ == sistrip::CALIBRATION_TAIL_MAX or
0319            mon_ == sistrip::CALIBRATION_TAIL_SPREAD)
0320     generator_->axisLabel("Tail (%)");
0321 
0322   else if (mon_ == sistrip::CALIBRATION_RISETIME_MEAN or mon_ == sistrip::CALIBRATION_RISETIME_ALL_STRIPS or
0323            mon_ == sistrip::CALIBRATION_RISETIME_MIN or mon_ == sistrip::CALIBRATION_RISETIME_MAX or
0324            mon_ == sistrip::CALIBRATION_RISETIME_SPREAD)
0325     generator_->axisLabel("Rise Time (ns)");
0326 
0327   else if (mon_ == sistrip::CALIBRATION_PEAKTIME_MEAN or mon_ == sistrip::CALIBRATION_PEAKTIME_ALL_STRIPS or
0328            mon_ == sistrip::CALIBRATION_PEAKTIME_MIN or mon_ == sistrip::CALIBRATION_PEAKTIME_MAX or
0329            mon_ == sistrip::CALIBRATION_PEAKTIME_SPREAD)
0330     generator_->axisLabel("Peak Time (ns)");
0331 
0332   else if (mon_ == sistrip::CALIBRATION_DECAYTIME_MEAN or mon_ == sistrip::CALIBRATION_DECAYTIME_ALL_STRIPS or
0333            mon_ == sistrip::CALIBRATION_DECAYTIME_MIN or mon_ == sistrip::CALIBRATION_DECAYTIME_MAX or
0334            mon_ == sistrip::CALIBRATION_DECAYTIME_SPREAD)
0335     generator_->axisLabel("Decay Time (ns)");
0336 
0337   else if (mon_ == sistrip::CALIBRATION_SMEARING_MEAN or mon_ == sistrip::CALIBRATION_SMEARING_ALL_STRIPS or
0338            mon_ == sistrip::CALIBRATION_SMEARING_MIN or mon_ == sistrip::CALIBRATION_SMEARING_MAX or
0339            mon_ == sistrip::CALIBRATION_SMEARING_SPREAD)
0340     generator_->axisLabel("Smearing (ns)");
0341 
0342   else if (mon_ == sistrip::CALIBRATION_CHI2_MEAN or mon_ == sistrip::CALIBRATION_CHI2_ALL_STRIPS or
0343            mon_ == sistrip::CALIBRATION_CHI2_MIN or mon_ == sistrip::CALIBRATION_CHI2_MAX or
0344            mon_ == sistrip::CALIBRATION_CHI2_SPREAD)
0345     generator_->axisLabel("Chi2/ndf");
0346 
0347   else if (mon_ == sistrip::CALIBRATION_UNDERSHOOT_MEAN or mon_ == sistrip::CALIBRATION_UNDERSHOOT_ALL_STRIPS or
0348            mon_ == sistrip::CALIBRATION_UNDERSHOOT_MIN or mon_ == sistrip::CALIBRATION_UNDERSHOOT_MAX or
0349            mon_ == sistrip::CALIBRATION_UNDERSHOOT_SPREAD)
0350     generator_->axisLabel("Undershoot (%)");
0351 
0352   else {
0353     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactory::" << __func__ << "]"
0354                                      << " Unexpected SummaryHisto value:"
0355                                      << SiStripEnumsAndStrings::monitorable(SummaryPlotFactoryBase::mon_);
0356   }
0357 }