CMS 3D CMS Logo

EcalTPCondAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Class:      EcalTPDBAnalyzer
00004 //
00010 //
00011 //
00012 // Original Author:  Ursula Berthon
00013 //         Created:  Wed Oct 15  11:38:38 CEST 2008
00014 // $Id: EcalTPCondAnalyzer.cc,v 1.1 2008/10/15 15:51:15 uberthon Exp $
00015 //
00016 //
00017 //
00018 
00019 
00020 // system include files
00021 #include <memory>
00022 #include <utility>
00023 #include <iostream>
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/Framework/interface/MakerMacros.h"
00029 #include "FWCore/Framework/interface/ESHandle.h"
00030 
00031 #include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h"
00032 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBGroupRcd.h"
00033 #include "CondFormats/DataRecord/interface/EcalTPGLutGroupRcd.h"
00034 #include "CondFormats/DataRecord/interface/EcalTPGLutIdMapRcd.h"
00035 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBIdMapRcd.h"
00036 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainTowerEERcd.h"
00037 #include "CondFormats/DataRecord/interface/EcalTPGLinearizationConstRcd.h"
00038 #include "CondFormats/DataRecord/interface/EcalTPGPedestalsRcd.h"
00039 #include "CondFormats/DataRecord/interface/EcalTPGSlidingWindowRcd.h"
00040 #include "CondFormats/DataRecord/interface/EcalTPGWeightIdMapRcd.h"
00041 #include "CondFormats/DataRecord/interface/EcalTPGWeightGroupRcd.h"
00042 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainStripEERcd.h"
00043 
00044 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00045 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
00046 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00047 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00048 
00049 #include "SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTPCondAnalyzer.h"
00050 
00051 EcalTPCondAnalyzer::EcalTPCondAnalyzer(const edm::ParameterSet&  iConfig)
00052 
00053 {}
00054 
00055 void EcalTPCondAnalyzer::beginJob(edm::EventSetup const& evtSetup) {
00056 
00057   // get geometry
00058   
00059   edm::ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
00060   evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap",theEndcapGeometry_handle);
00061   evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel",theBarrelGeometry_handle);
00062   theEndcapGeometry_ = &(*theEndcapGeometry_handle);
00063   theBarrelGeometry_ = &(*theBarrelGeometry_handle);
00064 
00065   cacheID_=this->getRecords(evtSetup);
00066 }
00067 
00068 
00069 EcalTPCondAnalyzer::~EcalTPCondAnalyzer() {
00070 }
00071 
00072 unsigned long long  EcalTPCondAnalyzer::getRecords(edm::EventSetup const& setup) {
00073   //
00074   // get Eventsetup records and print them
00075   //
00076    printComment();
00077 
00078    edm::ESHandle<EcalTPGPhysicsConst> theEcalTPGPhysConst_handle;
00079   setup.get<EcalTPGPhysicsConstRcd>().get(theEcalTPGPhysConst_handle);
00080   const EcalTPGPhysicsConst * ecaltpPhysConst = theEcalTPGPhysConst_handle.product();
00081   printEcalTPGPhysicsConst(ecaltpPhysConst);
00082   // for EcalFenixStrip...
00083 
00084   // get parameter records for xtals
00085   edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
00086   setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
00087   const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product();
00088 
00089   edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
00090   setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
00091   const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product();
00092   printCRYSTAL(ecaltpPed,ecaltpLin );
00093 
00094 
00095   //weight
00096   edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
00097   setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
00098   const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
00099   printWEIGHT(ecaltpgWeightMap);
00100 
00101    // .. and for EcalFenixTcp
00102 
00103   edm::ESHandle<EcalTPGFineGrainEBIdMap> theEcalTPGFineGrainEBIdMap_handle;
00104   setup.get<EcalTPGFineGrainEBIdMapRcd>().get(theEcalTPGFineGrainEBIdMap_handle);
00105   const EcalTPGFineGrainEBIdMap * ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product();
00106   printEcalTPGFineGrainEBIdMap(ecaltpgFineGrainEB);
00107 
00108 
00109   edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
00110   setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
00111   const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product();
00112   printEcalTPGLutIdMap(ecaltpgLut);
00113 
00114   //for strips
00115   edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
00116   setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
00117   const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
00118   edm::ESHandle<EcalTPGFineGrainStripEE> theEcalTPGFineGrainStripEE_handle;
00119   setup.get<EcalTPGFineGrainStripEERcd>().get(theEcalTPGFineGrainStripEE_handle);
00120   const EcalTPGFineGrainStripEE * ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product();     
00121   edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
00122   setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
00123   const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
00124   printSTRIP(ecaltpgSlidW,ecaltpgWeightGroup,ecaltpgFgStripEE);
00125 
00126   // get parameter records for towers
00127   edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
00128   setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
00129   const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
00130 
00131   edm::ESHandle<EcalTPGFineGrainEBGroup> theEcalTPGFineGrainEBGroup_handle;
00132   setup.get<EcalTPGFineGrainEBGroupRcd>().get(theEcalTPGFineGrainEBGroup_handle);
00133   const EcalTPGFineGrainEBGroup * ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product();
00134   printTOWEREB(ecaltpgFgEBGroup,ecaltpgLutGroup);
00135   edm::ESHandle<EcalTPGFineGrainTowerEE> theEcalTPGFineGrainTowerEE_handle;
00136   setup.get<EcalTPGFineGrainTowerEERcd>().get(theEcalTPGFineGrainTowerEE_handle);
00137   const EcalTPGFineGrainTowerEE * ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product();
00138   printTOWEREE(ecaltpgFineGrainTowerEE,ecaltpgLutGroup);
00139 
00140   std::cout<<"EOF"<<std::endl;
00141 
00142   return setup.get<EcalTPGFineGrainTowerEERcd>().cacheIdentifier();
00143 }
00144 
00145 // ------------ method called to analyze the data  ------------
00146 void
00147 EcalTPCondAnalyzer::analyze(const edm::Event& iEvent, const  edm::EventSetup & iSetup){
00148 }
00149 
00150 void
00151 EcalTPCondAnalyzer::endJob(){
00152 }
00153 
00154 void EcalTPCondAnalyzer::printEcalTPGPhysicsConst(const EcalTPGPhysicsConst *ecaltpgPhysConst) const {
00155   EcalTPGPhysicsConstMapIterator it;
00156   const EcalTPGPhysicsConstMap mymap=ecaltpgPhysConst->getMap();
00157   for (it=mymap.begin();it!=mymap.end();++it) {
00158     if (it==mymap.begin()) {
00159       std::cout<<"\nPHYSICS_EB "<<(*it).first<<std::endl;
00160     } else {
00161       std::cout<<"\nPHYSICS_EE "<<(*it).first<<std::endl;
00162     }
00163     std::cout<<(*it).second.EtSat<<" "<<(*it).second.ttf_threshold_Low<<" "<<(*it).second.ttf_threshold_High<<std::endl;
00164     std::cout<<(*it).second.FG_lowThreshold<<" "<<(*it).second.FG_highThreshold<<" "<<(*it).second.FG_lowRatio<<" "<<(*it).second.FG_highRatio<<std::endl;
00165   }
00166 }
00167 
00168 void  EcalTPCondAnalyzer::printSTRIP(const EcalTPGSlidingWindow *slWin,const EcalTPGWeightGroup *ecaltpgWeightGroup,const EcalTPGFineGrainStripEE * ecaltpgFgStripEE) const {
00169   // print STRIP information
00170   const EcalTPGSlidingWindowMap &slwinmap = slWin -> getMap();
00171   const EcalTPGFineGrainStripEEMap &fgstripEEmap= ecaltpgFgStripEE->getMap();
00172   EcalTPGSlidingWindowMapIterator it;
00173   const EcalTPGGroups::EcalTPGGroupsMap &gMap=ecaltpgWeightGroup->getMap();
00174   EcalTPGGroups::EcalTPGGroupsMapItr groupId;
00175 
00176   std::cout<<std::endl;
00177   for (int mysub=1;mysub<=2;++mysub) {
00178     std::cout<<std::endl;
00179     for (it=slwinmap.begin();it!=slwinmap.end();++it) {
00180       EcalTriggerElectronicsId elid((*it).first);
00181       groupId=gMap.find((*it).first);
00182       int subdet =elid.subdet();
00183       if (subdet==mysub) {
00184         if (subdet==1) {
00185           std::cout<<"STRIP_EB "<<std::dec<<(*it).first<<std::endl;
00186           std::cout << std::hex << "0x" <<(*it).second<<std::endl ;
00187           std::cout  <<" " <<(*groupId).second<< std::endl ; //weightgroupid
00188         }else if (subdet==2) {
00189           std::cout<<"STRIP_EE "<<std::dec<<(*it).first<<std::endl;
00190           std::cout << std::hex << "0x" <<(*it).second<<std::endl ;
00191           std::cout <<" " <<(*groupId).second<<std::endl ;//weightgroupid
00192           EcalTPGFineGrainStripEEMapIterator it2=fgstripEEmap.find((*it).first);
00193           if (it2==fgstripEEmap.end()) {
00194             edm::LogWarning("EcalTPGCondAnalyzer") <<" could not find strip Id "<<(*it).first<<", given in sliding window, inside the EcalTPGFineGranStripEEMap!!!";
00195           } else {
00196             EcalTPGFineGrainStripEE::Item item=(*it2).second;
00197             std::cout<<std::hex<<"0x"<<item.threshold<<" 0x"<<item.lut<<std::endl ;  
00198           }
00199         }
00200       }
00201     }
00202   }
00203 }
00204 
00205 void EcalTPCondAnalyzer::printWEIGHT(const EcalTPGWeightIdMap * ecaltpgWeightIdMap) const {
00206     
00207   std::cout<<std::endl;
00208     EcalTPGWeightIdMap::EcalTPGWeightMapItr it;
00209     uint32_t w0,w1,w2,w3,w4;
00210     const EcalTPGWeightIdMap::EcalTPGWeightMap map=ecaltpgWeightIdMap->getMap();
00211     for (it=map.begin();it!=map.end();++it) {
00212       std::cout <<"WEIGHT "<<(*it).first<<std::endl;
00213       (*it).second.getValues(w0,w1,w2,w3,w4);
00214       std::cout <<std::hex<<"0x"<<w0<<" 0x"<<w1<<" 0x"<<w2<<" 0x"<<w3<<" 0x"<<w4<<" "<<std::endl;
00215     }
00216 }
00217 
00218 void  EcalTPCondAnalyzer::printEcalTPGFineGrainEBIdMap(const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB) const {
00219     EcalTPGFineGrainEBIdMap::EcalTPGFineGrainEBMapItr it;
00220     const EcalTPGFineGrainEBIdMap::EcalTPGFineGrainEBMap map=ecaltpgFineGrainEB->getMap();
00221     uint32_t ThresholdETLow, ThresholdETHigh, RatioLow, RatioHigh, LUT;
00222 
00223     std::cout<<std::endl;
00224     for (it=map.begin();it!=map.end();++it) {
00225       std::cout <<"FG "<<(*it).first<<std::endl;
00226       (*it).second.getValues(ThresholdETLow, ThresholdETHigh, RatioLow, RatioHigh, LUT);
00227       std::cout <<std::hex<<"0x"<<ThresholdETLow<<" 0x"<<ThresholdETHigh<<" 0x"<<RatioLow<<" 0x"<<RatioHigh<<" 0x"<<LUT<<std::endl;
00228     }
00229 }
00230 
00231 
00232 void EcalTPCondAnalyzer::printEcalTPGLutIdMap(const EcalTPGLutIdMap *ecaltpgLut) const {
00233     EcalTPGLutIdMap::EcalTPGLutMapItr it;
00234     const EcalTPGLutIdMap::EcalTPGLutMap map=ecaltpgLut->getMap();
00235 
00236     std::cout<<std::endl;
00237     for (it=map.begin();it!=map.end();++it) {
00238       std::cout <<"LUT "<<(*it).first<<std::endl;
00239       const unsigned int * lut=(*it).second.getLut();
00240       for (unsigned int i=0;i<1024;++i)  std::cout <<std::hex<<"0x"<<*lut++<<std::endl;
00241     }
00242 }
00243 
00244 void EcalTPCondAnalyzer::printCRYSTAL(const EcalTPGPedestals * ecaltpPed, const EcalTPGLinearizationConst * ecaltpLin ) {
00245 
00246   std::cout<<std::endl;
00247   const EcalTPGPedestalsMap pedMap=ecaltpPed->getMap();
00248   const EcalTPGLinearizationConstMap linMap=ecaltpLin->getMap();
00249 
00250   const std::vector<DetId> & ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
00251 
00252   std::cout<<"COMMENT ====== barrel crystals ====== "<<std::endl; 
00253   for (std::vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
00254     EBDetId id(*it) ;
00255     std::cout <<"CRYSTAL "<<std::dec<<id.rawId()<<std::endl;
00256     const EcalTPGPedestal &ped=pedMap[id.rawId()];
00257     const EcalTPGLinearizationConstant &lin=linMap[id.rawId()];
00258     std::cout<<std::hex<<" 0x"<<ped.mean_x12<<" 0x"<<lin.mult_x12<<" 0x"<<lin.shift_x12<<std::endl;
00259     std::cout<<std::hex<<" 0x"<<ped.mean_x6 <<" 0x"<<lin.mult_x6 <<" 0x"<<lin.shift_x6<<std::endl;
00260     std::cout<<std::hex<<" 0x"<<ped.mean_x1 <<" 0x"<<lin.mult_x1 <<" 0x"<<lin.shift_x1<<std::endl;
00261   }
00262 
00263   const std::vector<DetId> & eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
00264   std::cout<<"COMMENT ====== endcap crystals ====== "<<std::endl; 
00265   for (std::vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
00266     EEDetId id(*it) ;
00267     std::cout <<"CRYSTAL "<<std::dec<<id.rawId()<<std::endl;
00268     const EcalTPGPedestal &ped=pedMap[id.rawId()];
00269     const EcalTPGLinearizationConstant &lin=linMap[id.rawId()];
00270     std::cout<<std::hex<<" 0x"<<ped.mean_x12<<" 0x"<<lin.mult_x12<<" 0x"<<lin.shift_x12<<std::endl;
00271     std::cout<<std::hex<<" 0x"<<ped.mean_x6 <<" 0x"<<lin.mult_x6 <<" 0x"<<lin.shift_x6<<std::endl;
00272     std::cout<<std::hex<<" 0x"<<ped.mean_x1 <<" 0x"<<lin.mult_x1 <<" 0x"<<lin.shift_x1<<std::endl;
00273   }
00274 }
00275 void EcalTPCondAnalyzer::printComment() const {
00276   std::cout<<"COMMENT put your comments here\n"<<
00277   "COMMENT =================================\n"<<
00278   "COMMENT           physics EB structure\n"<<
00279   "COMMENT\n"<<
00280   "COMMENT  EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)\n"<<
00281   "COMMENT  FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio\n"<<
00282   "COMMENT =================================\n"<<
00283   "COMMENT\n"<<
00284   "COMMENT =================================\n"<<
00285   "COMMENT           physics EE structure\n"<<
00286   "COMMENT\n"<<
00287   "COMMENT  EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)\n"<<
00288   "COMMENT  FG_Threshold (GeV), dummy, dummy, dummy\n"<<
00289   "COMMENT =================================\n"<<
00290   "COMMENT\n"<<
00291   "COMMENT =================================\n"<<
00292   "COMMENT           crystal structure (same for EB and EE)\n"<<
00293   "COMMENT\n"<<
00294   "COMMENT  ped, mult, shift [gain12]\n"<<
00295   "COMMENT  ped, mult, shift [gain6]\n"<<
00296   "COMMENT  ped, mult, shift [gain1]\n"<<
00297   "COMMENT =================================\n"<<
00298   "COMMENT\n"<<
00299   "COMMENT =================================\n"<<
00300   "COMMENT           strip EB structure\n"<<
00301   "COMMENT\n"<<
00302   "COMMENT  sliding_window\n"<<
00303   "COMMENT  weightGroupId\n"<<
00304   "COMMENT =================================\n"<<
00305   "COMMENT\n"<<
00306   "COMMENT =================================\n"<<
00307   "COMMENT           strip EE structure\n"<<
00308   "COMMENT\n"<<
00309   "COMMENT  sliding_window\n"<<
00310   "COMMENT  weightGroupId\n"<<
00311   "COMMENT  threshold_fg strip_lut_fg\n"<<
00312   "COMMENT =================================\n"<<
00313   "COMMENT\n"<<
00314   "COMMENT =================================\n"<<
00315   "COMMENT           tower EB structure\n"<<
00316   "COMMENT\n"<<
00317   "COMMENT  LUTGroupId\n"<<
00318   "COMMENT  FgGroupId\n"<<
00319   "COMMENT =================================\n"<<
00320   "COMMENT\n"<<
00321   "COMMENT =================================\n"<<
00322   "COMMENT           tower EE structure\n"<<
00323   "COMMENT\n"<<
00324   "COMMENT  LUTGroupId\n"<<
00325   "COMMENT  tower_lut_fg\n"<<
00326   "COMMENT =================================\n"<<
00327   "COMMENT\n"<<
00328   "COMMENT =================================\n"<<
00329   "COMMENT           Weight structure\n"<<
00330   "COMMENT\n"<<
00331   "COMMENT  weightGroupId\n"<<
00332   "COMMENT  w0, w1, w2, w3, w4\n"<<
00333   "COMMENT =================================\n"<<
00334   "COMMENT\n"<<
00335   "COMMENT =================================\n"<<
00336   "COMMENT           lut structure\n"<<
00337   "COMMENT\n"<<
00338   "COMMENT  LUTGroupId\n"<<
00339   "COMMENT  LUT[1-1024]\n"<<
00340   "COMMENT =================================\n"<<
00341   "COMMENT\n"<<
00342   "COMMENT =================================\n"<<
00343   "COMMENT           fg EB structure\n"<<
00344   "COMMENT\n"<<
00345   "COMMENT  FgGroupId\n"<<
00346   "COMMENT  el, eh, tl, th, lut_fg\n"<<
00347   "COMMENT =================================\n"<<
00348   "COMMENT"<<std::endl;
00349 }
00350 
00351 void EcalTPCondAnalyzer::printTOWEREB(const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup,const EcalTPGLutGroup *ecaltpgLutGroup) const {
00352 
00353     const EcalTPGGroups::EcalTPGGroupsMap &lutMap=ecaltpgLutGroup->getMap();
00354     EcalTPGGroups::EcalTPGGroupsMapItr lutGroupId;
00355     const EcalTPGGroups::EcalTPGGroupsMap &fgMap=ecaltpgFgEBGroup->getMap();
00356     EcalTPGGroups::EcalTPGGroupsMapItr it;
00357 
00358     std::cout<<std::endl;
00359     for (it=fgMap.begin();it!=fgMap.end();++it) {
00360       std::cout <<"TOWER_EB "<<std::dec<<(*it).first<<std::endl;
00361       lutGroupId=lutMap.find((*it).first);
00362       std::cout <<" "<<(*it).second<<std::endl;
00363       std::cout <<" "<<(*lutGroupId).second<<std::endl;
00364     }
00365 }
00366 
00367 void EcalTPCondAnalyzer::printTOWEREE(const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE,const EcalTPGLutGroup *ecaltpgLutGroup) const {
00368 
00369     EcalTPGFineGrainTowerEEMapIterator it;
00370     const EcalTPGFineGrainTowerEEMap map=ecaltpgFineGrainTowerEE->getMap();
00371     const EcalTPGGroups::EcalTPGGroupsMap &lutMap=ecaltpgLutGroup->getMap();
00372     EcalTPGGroups::EcalTPGGroupsMapItr lutGroupId;
00373 
00374     std::cout<<std::endl;
00375     for (it=map.begin();it!=map.end();++it) {
00376       std::cout <<"TOWER_EE "<<std::dec<<(*it).first<<std::endl;
00377       lutGroupId=lutMap.find((*it).first);
00378       std::cout <<" "<<(*lutGroupId).second<<std::endl;
00379       std::cout <<std::hex<<"0x"<<(*it).second<<std::endl;
00380     }
00381 }

Generated on Tue Jun 9 17:46:18 2009 for CMSSW by  doxygen 1.5.4