Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-17 02:47:09

0001 // -*- C++ -*-
0002 //
0003 // Class:      EcalTPDBAnalyzer
0004 //
0005 /**\class EcalTPDBAnalyzer
0006 
0007  Description: test of the output of EcalTPDBProducer
0008 
0009 */
0010 //
0011 //
0012 // Original Author:  Ursula Berthon
0013 //         Created:  Wed Oct 15  11:38:38 CEST 2008
0014 //
0015 //
0016 //
0017 
0018 // system include files
0019 #include <memory>
0020 #include <utility>
0021 #include <vector>
0022 
0023 // user include files
0024 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
0025 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
0026 
0027 #include "SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTPCondAnalyzer.h"
0028 
0029 EcalTPCondAnalyzer::EcalTPCondAnalyzer(const edm::ParameterSet &iConfig)
0030     : tokenEndcapGeom_(esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "EcalEndcap"))),
0031       tokenBarrelGeom_(esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "EcalBarrel"))),
0032       tokenEcalTPGPhysics_(esConsumes<edm::Transition::BeginRun>()),
0033       tokenEcalTPGLinearization_(esConsumes<edm::Transition::BeginRun>()),
0034       tokenEcalTPGPedestals_(esConsumes<edm::Transition::BeginRun>()),
0035       tokenEcalTPGWeightIdMap_(esConsumes<edm::Transition::BeginRun>()),
0036       tokenEcalTPGFineGrainEBIdMap_(esConsumes<edm::Transition::BeginRun>()),
0037       tokenEcalTPGLutIdMap_(esConsumes<edm::Transition::BeginRun>()),
0038       tokenEcalTPGSlidingWindow_(esConsumes<edm::Transition::BeginRun>()),
0039       tokenEcalTPGFineGrainStripEE_(esConsumes<edm::Transition::BeginRun>()),
0040       tokenEcalTPGWeightGroup_(esConsumes<edm::Transition::BeginRun>()),
0041       tokenEcalTPGLutGroup_(esConsumes<edm::Transition::BeginRun>()),
0042       tokenEcalTPGFineGrainEBGroup_(esConsumes<edm::Transition::BeginRun>()),
0043       tokenEcalTPGSpike_(esConsumes<edm::Transition::BeginRun>()),
0044       tokenEcalTPGFineGrainTowerEE_(esConsumes<edm::Transition::BeginRun>()) {}
0045 
0046 void EcalTPCondAnalyzer::beginRun(const edm::Run &run, edm::EventSetup const &evtSetup) {
0047   // get geometry
0048   theEndcapGeometry_ = &evtSetup.getData(tokenEndcapGeom_);
0049   theBarrelGeometry_ = &evtSetup.getData(tokenBarrelGeom_);
0050 
0051   cacheID_ = this->getRecords(evtSetup);
0052 }
0053 
0054 void EcalTPCondAnalyzer::beginJob() {}
0055 
0056 EcalTPCondAnalyzer::~EcalTPCondAnalyzer() {}
0057 
0058 unsigned long long EcalTPCondAnalyzer::getRecords(edm::EventSetup const &setup) {
0059   //
0060   // get Eventsetup records and print them
0061   //
0062   printComment();
0063 
0064   const auto ecaltpPhysConst = &setup.getData(tokenEcalTPGPhysics_);
0065   printEcalTPGPhysicsConst(ecaltpPhysConst);
0066 
0067   // for EcalFenixStrip...
0068   // get parameter records for xtals
0069   const auto *ecaltpLin = &setup.getData(tokenEcalTPGLinearization_);
0070   const auto *ecaltpPed = &setup.getData(tokenEcalTPGPedestals_);
0071   printCRYSTAL(ecaltpPed, ecaltpLin);
0072 
0073   // weight
0074   const auto *ecaltpgWeightMap = &setup.getData(tokenEcalTPGWeightIdMap_);
0075   printWEIGHT(ecaltpgWeightMap);
0076 
0077   // .. and for EcalFenixTcp
0078   const auto *ecaltpgFineGrainEB = &setup.getData(tokenEcalTPGFineGrainEBIdMap_);
0079   printEcalTPGFineGrainEBIdMap(ecaltpgFineGrainEB);
0080 
0081   const auto *ecaltpgLut = &setup.getData(tokenEcalTPGLutIdMap_);
0082   printEcalTPGLutIdMap(ecaltpgLut);
0083 
0084   // for strips
0085   const auto *ecaltpgSlidW = &setup.getData(tokenEcalTPGSlidingWindow_);
0086   const auto *ecaltpgFgStripEE = &setup.getData(tokenEcalTPGFineGrainStripEE_);
0087   const auto *ecaltpgWeightGroup = &setup.getData(tokenEcalTPGWeightGroup_);
0088   printSTRIP(ecaltpgSlidW, ecaltpgWeightGroup, ecaltpgFgStripEE);
0089 
0090   // get parameter records for towers
0091   const auto *ecaltpgLutGroup = &setup.getData(tokenEcalTPGLutGroup_);
0092   const auto *ecaltpgFgEBGroup = &setup.getData(tokenEcalTPGFineGrainEBGroup_);
0093   const auto *ecaltpgSpikeTh = &setup.getData(tokenEcalTPGSpike_);
0094   const auto *ecaltpgFineGrainTowerEE = &setup.getData(tokenEcalTPGFineGrainTowerEE_);
0095 
0096   printTOWEREB(ecaltpgSpikeTh, ecaltpgFgEBGroup, ecaltpgLutGroup);
0097   printTOWEREE(ecaltpgFineGrainTowerEE, ecaltpgLutGroup);
0098 
0099   edm::LogVerbatim("EcalTPCondAnalyzer") << "EOF";
0100 
0101   return setup.get<EcalTPGFineGrainTowerEERcd>().cacheIdentifier();
0102 }
0103 
0104 // ------------ method called to analyze the data  ------------
0105 void EcalTPCondAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {}
0106 
0107 void EcalTPCondAnalyzer::endJob() {}
0108 
0109 void EcalTPCondAnalyzer::endRun(edm::Run const &, edm::EventSetup const &) {}
0110 
0111 void EcalTPCondAnalyzer::printEcalTPGPhysicsConst(const EcalTPGPhysicsConst *ecaltpgPhysConst) const {
0112   EcalTPGPhysicsConstMapIterator it;
0113   const EcalTPGPhysicsConstMap &mymap = ecaltpgPhysConst->getMap();
0114   for (it = mymap.begin(); it != mymap.end(); ++it) {
0115     if (it == mymap.begin()) {
0116       edm::LogVerbatim("EcalTPCondAnalyzer") << "\nPHYSICS_EB " << (*it).first;
0117     } else {
0118       edm::LogVerbatim("EcalTPCondAnalyzer") << "\nPHYSICS_EE " << (*it).first;
0119     }
0120     edm::LogVerbatim("EcalTPCondAnalyzer")
0121         << (*it).second.EtSat << " " << (*it).second.ttf_threshold_Low << " " << (*it).second.ttf_threshold_High;
0122     edm::LogVerbatim("EcalTPCondAnalyzer") << (*it).second.FG_lowThreshold << " " << (*it).second.FG_highThreshold
0123                                            << " " << (*it).second.FG_lowRatio << " " << (*it).second.FG_highRatio;
0124   }
0125 }
0126 
0127 void EcalTPCondAnalyzer::printSTRIP(const EcalTPGSlidingWindow *slWin,
0128                                     const EcalTPGWeightGroup *ecaltpgWeightGroup,
0129                                     const EcalTPGFineGrainStripEE *ecaltpgFgStripEE) const {
0130   // print STRIP information
0131   const EcalTPGSlidingWindowMap &slwinmap = slWin->getMap();
0132   const EcalTPGFineGrainStripEEMap &fgstripEEmap = ecaltpgFgStripEE->getMap();
0133   EcalTPGSlidingWindowMapIterator it;
0134   const EcalTPGGroups::EcalTPGGroupsMap &gMap = ecaltpgWeightGroup->getMap();
0135   EcalTPGGroups::EcalTPGGroupsMapItr groupId;
0136 
0137   edm::LogVerbatim("EcalTPCondAnalyzer");
0138   for (int mysub = 1; mysub <= 2; ++mysub) {
0139     edm::LogVerbatim("EcalTPCondAnalyzer");
0140     for (it = slwinmap.begin(); it != slwinmap.end(); ++it) {
0141       EcalTriggerElectronicsId elid((*it).first);
0142       groupId = gMap.find((*it).first);
0143       int subdet = elid.subdet();
0144       if (subdet == mysub) {
0145         if (subdet == 1) {
0146           edm::LogVerbatim("EcalTPCondAnalyzer") << "STRIP_EB " << std::dec << (*it).first << "\n"
0147                                                  << std::hex << "0x" << (*it).second << "\n"
0148                                                  << "" << (*groupId).second;  // weightgroupid
0149           EcalTPGFineGrainStripEEMapIterator it2 = fgstripEEmap.find((*it).first);
0150           if (it2 == fgstripEEmap.end()) {
0151             edm::LogWarning("EcalTPGCondAnalyzer") << " could not find strip Id " << (*it).first
0152                                                    << ", given in sliding window, inside the "
0153                                                       "EcalTPGFineGranStripEEMap!!!";
0154           } else {
0155             EcalTPGFineGrainStripEE::Item item = (*it2).second;
0156             edm::LogVerbatim("EcalTPCondAnalyzer") << std::hex << "0x" << item.threshold << " 0x" << item.lut;
0157           }
0158         } else if (subdet == 2) {
0159           edm::LogVerbatim("EcalTPCondAnalyzer") << "STRIP_EE " << std::dec << (*it).first << "\n"
0160                                                  << std::hex << "0x" << (*it).second << "\n"
0161                                                  << " " << (*groupId).second;  // weightgroupid
0162           EcalTPGFineGrainStripEEMapIterator it2 = fgstripEEmap.find((*it).first);
0163           if (it2 == fgstripEEmap.end()) {
0164             edm::LogWarning("EcalTPGCondAnalyzer") << " could not find strip Id " << (*it).first
0165                                                    << ", given in sliding window, inside the "
0166                                                       "EcalTPGFineGranStripEEMap!!!";
0167           } else {
0168             EcalTPGFineGrainStripEE::Item item = (*it2).second;
0169             edm::LogVerbatim("EcalTPCondAnalyzer") << std::hex << "0x" << item.threshold << " 0x" << item.lut;
0170           }
0171         }
0172       }
0173     }
0174   }
0175 }
0176 
0177 void EcalTPCondAnalyzer::printWEIGHT(const EcalTPGWeightIdMap *ecaltpgWeightIdMap) const {
0178   edm::LogVerbatim("EcalTPCondAnalyzer");
0179   EcalTPGWeightIdMap::EcalTPGWeightMapItr it;
0180   uint32_t w0, w1, w2, w3, w4;
0181   const EcalTPGWeightIdMap::EcalTPGWeightMap &map = ecaltpgWeightIdMap->getMap();
0182   for (it = map.begin(); it != map.end(); ++it) {
0183     edm::LogVerbatim("EcalTPCondAnalyzer") << "WEIGHT " << (*it).first;
0184     (*it).second.getValues(w0, w1, w2, w3, w4);
0185     edm::LogVerbatim("EcalTPCondAnalyzer")
0186         << std::hex << "0x" << w0 << " 0x" << w1 << " 0x" << w2 << " 0x" << w3 << " 0x" << w4 << " \n\n\n";
0187   }
0188 }
0189 
0190 void EcalTPCondAnalyzer::printEcalTPGFineGrainEBIdMap(const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB) const {
0191   EcalTPGFineGrainEBIdMap::EcalTPGFineGrainEBMapItr it;
0192   const EcalTPGFineGrainEBIdMap::EcalTPGFineGrainEBMap &map = ecaltpgFineGrainEB->getMap();
0193   uint32_t ThresholdETLow, ThresholdETHigh, RatioLow, RatioHigh, LUT;
0194 
0195   for (it = map.begin(); it != map.end(); ++it) {
0196     edm::LogVerbatim("EcalTPCondAnalyzer") << "FG " << (*it).first;
0197     (*it).second.getValues(ThresholdETLow, ThresholdETHigh, RatioLow, RatioHigh, LUT);
0198     edm::LogVerbatim("EcalTPCondAnalyzer") << std::hex << "0x" << ThresholdETLow << " 0x" << ThresholdETHigh << " 0x"
0199                                            << RatioLow << " 0x" << RatioHigh << " 0x" << LUT;
0200   }
0201 }
0202 
0203 void EcalTPCondAnalyzer::printEcalTPGLutIdMap(const EcalTPGLutIdMap *ecaltpgLut) const {
0204   EcalTPGLutIdMap::EcalTPGLutMapItr it;
0205   const EcalTPGLutIdMap::EcalTPGLutMap &map = ecaltpgLut->getMap();
0206 
0207   edm::LogVerbatim("EcalTPCondAnalyzer");
0208   for (it = map.begin(); it != map.end(); ++it) {
0209     edm::LogVerbatim("EcalTPCondAnalyzer") << "LUT " << (*it).first;
0210     const unsigned int *lut = (*it).second.getLut();
0211     for (unsigned int i = 0; i < 1024; ++i)
0212       edm::LogVerbatim("EcalTPCondAnalyzer") << std::hex << "0x" << *lut++;
0213   }
0214 }
0215 
0216 void EcalTPCondAnalyzer::printCRYSTAL(const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin) {
0217   edm::LogVerbatim("EcalTPCondAnalyzer");
0218   const EcalTPGPedestalsMap &pedMap = ecaltpPed->getMap();
0219   const EcalTPGLinearizationConstMap &linMap = ecaltpLin->getMap();
0220 
0221   const std::vector<DetId> &ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
0222 
0223   edm::LogVerbatim("EcalTPCondAnalyzer") << "COMMENT ====== barrel crystals ====== ";
0224   for (std::vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
0225     EBDetId id(*it);
0226     edm::LogVerbatim("EcalTPCondAnalyzer") << "CRYSTAL " << std::dec << id.rawId();
0227     const EcalTPGPedestal &ped = pedMap[id.rawId()];
0228     const EcalTPGLinearizationConstant &lin = linMap[id.rawId()];
0229     edm::LogVerbatim("EcalTPCondAnalyzer")
0230         << std::hex << " 0x" << ped.mean_x12 << " 0x" << lin.mult_x12 << " 0x" << lin.shift_x12 << "\n"
0231         << std::hex << " 0x" << ped.mean_x6 << " 0x" << lin.mult_x6 << " 0x" << lin.shift_x6 << "\n"
0232         << std::hex << " 0x" << ped.mean_x1 << " 0x" << lin.mult_x1 << " 0x" << lin.shift_x1;
0233   }
0234 
0235   const std::vector<DetId> &eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
0236   edm::LogVerbatim("EcalTPCondAnalyzer") << "COMMENT ====== endcap crystals ====== ";
0237   for (std::vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
0238     EEDetId id(*it);
0239     edm::LogVerbatim("EcalTPCondAnalyzer") << "CRYSTAL " << std::dec << id.rawId();
0240     const EcalTPGPedestal &ped = pedMap[id.rawId()];
0241     const EcalTPGLinearizationConstant &lin = linMap[id.rawId()];
0242     edm::LogVerbatim("EcalTPCondAnalyzer")
0243         << std::hex << " 0x" << ped.mean_x12 << " 0x" << lin.mult_x12 << " 0x" << lin.shift_x12 << "\n"
0244         << std::hex << " 0x" << ped.mean_x6 << " 0x" << lin.mult_x6 << " 0x" << lin.shift_x6 << "\n"
0245         << std::hex << " 0x" << ped.mean_x1 << " 0x" << lin.mult_x1 << " 0x" << lin.shift_x1;
0246   }
0247 }
0248 void EcalTPCondAnalyzer::printComment() const {
0249   edm::LogVerbatim("EcalTPCondAnalyzer") << "COMMENT put your comments here\n"
0250                                          << "COMMENT =================================\n"
0251                                          << "COMMENT           physics EB structure\n"
0252                                          << "COMMENT\n"
0253                                          << "COMMENT  EtSaturation (GeV), ttf_threshold_Low (GeV), "
0254                                             "ttf_threshold_High (GeV)\n"
0255                                          << "COMMENT  FG_lowThreshold (GeV), FG_highThreshold (GeV), "
0256                                             "FG_lowRatio, FG_highRatio\n"
0257                                          << "COMMENT =================================\n"
0258                                          << "COMMENT\n"
0259                                          << "COMMENT =================================\n"
0260                                          << "COMMENT           physics EE structure\n"
0261                                          << "COMMENT\n"
0262                                          << "COMMENT  EtSaturation (GeV), ttf_threshold_Low (GeV), "
0263                                             "ttf_threshold_High (GeV)\n"
0264                                          << "COMMENT  FG_Threshold (GeV), dummy, dummy, dummy\n"
0265                                          << "COMMENT =================================\n"
0266                                          << "COMMENT\n"
0267                                          << "COMMENT =================================\n"
0268                                          << "COMMENT           crystal structure (same for EB and EE)\n"
0269                                          << "COMMENT\n"
0270                                          << "COMMENT  ped, mult, shift [gain12]\n"
0271                                          << "COMMENT  ped, mult, shift [gain6]\n"
0272                                          << "COMMENT  ped, mult, shift [gain1]\n"
0273                                          << "COMMENT =================================\n"
0274                                          << "COMMENT\n"
0275                                          << "COMMENT =================================\n"
0276                                          << "COMMENT           strip EB structure\n"
0277                                          << "COMMENT\n"
0278                                          << "COMMENT  sliding_window\n"
0279                                          << "COMMENT  weightGroupId\n"
0280                                          << "COMMENT  threshold_sfg lut_sfg\n"
0281                                          << "COMMENT =================================\n"
0282                                          << "COMMENT\n"
0283                                          << "COMMENT =================================\n"
0284                                          << "COMMENT           strip EE structure\n"
0285                                          << "COMMENT\n"
0286                                          << "COMMENT  sliding_window\n"
0287                                          << "COMMENT  weightGroupId\n"
0288                                          << "COMMENT  threshold_fg lut_fg\n"
0289                                          << "COMMENT =================================\n"
0290                                          << "COMMENT\n"
0291                                          << "COMMENT =================================\n"
0292                                          << "COMMENT           tower EB structure\n"
0293                                          << "COMMENT\n"
0294                                          << "COMMENT  LUTGroupId\n"
0295                                          << "COMMENT  FgGroupId\n"
0296                                          << "COMMENT  spike_killing_threshold\n"
0297                                          << "COMMENT =================================\n"
0298                                          << "COMMENT\n"
0299                                          << "COMMENT =================================\n"
0300                                          << "COMMENT           tower EE structure\n"
0301                                          << "COMMENT\n"
0302                                          << "COMMENT  LUTGroupId\n"
0303                                          << "COMMENT  tower_lut_fg\n"
0304                                          << "COMMENT =================================\n"
0305                                          << "COMMENT\n"
0306                                          << "COMMENT =================================\n"
0307                                          << "COMMENT           Weight structure\n"
0308                                          << "COMMENT\n"
0309                                          << "COMMENT  weightGroupId\n"
0310                                          << "COMMENT  w0, w1, w2, w3, w4\n"
0311                                          << "COMMENT =================================\n"
0312                                          << "COMMENT\n"
0313                                          << "COMMENT =================================\n"
0314                                          << "COMMENT           lut structure\n"
0315                                          << "COMMENT\n"
0316                                          << "COMMENT  LUTGroupId\n"
0317                                          << "COMMENT  LUT[1-1024]\n"
0318                                          << "COMMENT =================================\n"
0319                                          << "COMMENT\n"
0320                                          << "COMMENT =================================\n"
0321                                          << "COMMENT           fg EB structure\n"
0322                                          << "COMMENT\n"
0323                                          << "COMMENT  FgGroupId\n"
0324                                          << "COMMENT  el, eh, tl, th, lut_fg\n"
0325                                          << "COMMENT =================================\n"
0326                                          << "COMMENT";
0327 }
0328 
0329 void EcalTPCondAnalyzer::printTOWEREB(const EcalTPGSpike *ecaltpgSpikeTh,
0330                                       const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup,
0331                                       const EcalTPGLutGroup *ecaltpgLutGroup) const {
0332   const EcalTPGGroups::EcalTPGGroupsMap &lutMap = ecaltpgLutGroup->getMap();
0333   EcalTPGGroups::EcalTPGGroupsMapItr lutGroupId;
0334   const EcalTPGGroups::EcalTPGGroupsMap &fgMap = ecaltpgFgEBGroup->getMap();
0335   EcalTPGGroups::EcalTPGGroupsMapItr it;
0336 
0337   const EcalTPGSpike::EcalTPGSpikeMap &spikeThMap = ecaltpgSpikeTh->getMap();
0338   EcalTPGSpike::EcalTPGSpikeMapIterator itSpikeTh;
0339 
0340   edm::LogVerbatim("EcalTPCondAnalyzer");
0341   for (it = fgMap.begin(); it != fgMap.end(); ++it) {
0342     edm::LogVerbatim("EcalTPCondAnalyzer") << "TOWER_EB " << std::dec << (*it).first;
0343     lutGroupId = lutMap.find((*it).first);
0344     itSpikeTh = spikeThMap.find((*it).first);
0345     edm::LogVerbatim("EcalTPCondAnalyzer") << " " << (*it).second << "\n"
0346                                            << " " << (*lutGroupId).second << "\n"
0347                                            << " " << (*itSpikeTh).second;
0348   }
0349 }
0350 
0351 void EcalTPCondAnalyzer::printTOWEREE(const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE,
0352                                       const EcalTPGLutGroup *ecaltpgLutGroup) const {
0353   EcalTPGFineGrainTowerEEMapIterator it;
0354   const EcalTPGFineGrainTowerEEMap &map = ecaltpgFineGrainTowerEE->getMap();
0355   const EcalTPGGroups::EcalTPGGroupsMap &lutMap = ecaltpgLutGroup->getMap();
0356   EcalTPGGroups::EcalTPGGroupsMapItr lutGroupId;
0357 
0358   edm::LogVerbatim("EcalTPCondAnalyzer");
0359   for (it = map.begin(); it != map.end(); ++it) {
0360     edm::LogVerbatim("EcalTPCondAnalyzer") << "TOWER_EE " << std::dec << (*it).first;
0361     lutGroupId = lutMap.find((*it).first);
0362     edm::LogVerbatim("EcalTPCondAnalyzer") << " " << (*lutGroupId).second << "\n" << std::hex << "0x" << (*it).second;
0363   }
0364 }