CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/L1TMonitor/src/L1TRCT.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TRCT.cc
00003  *
00004  * $Date: 2009/11/19 14:54:33 $
00005  * $Revision: 1.18 $
00006  * \author P. Wittich
00007  *
00008  */
00009 
00010 #include "DQM/L1TMonitor/interface/L1TRCT.h"
00011 
00012 // GCT and RCT data formats
00013 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
00014 #include "DQMServices/Core/interface/DQMStore.h"
00015 
00016 
00017 
00018 
00019 using namespace edm;
00020 
00021 const unsigned int PHIBINS = 18;
00022 const float PHIMIN = -0.5;
00023 const float PHIMAX = 17.5;
00024 
00025 // Ranks 6, 10 and 12 bits
00026 const unsigned int R6BINS = 64;
00027 const float R6MIN = -0.5;
00028 const float R6MAX = 63.5;
00029 const unsigned int R10BINS = 1024;
00030 const float R10MIN = -0.5;
00031 const float R10MAX = 1023.5;
00032 const unsigned int R12BINS = 4096;
00033 const float R12MIN = -0.5;
00034 const float R12MAX = 4095.5;
00035 
00036 const unsigned int ETABINS = 22;
00037 const float ETAMIN = -0.5;
00038 const float ETAMAX = 21.5;
00039 
00040 
00041 
00042 L1TRCT::L1TRCT(const ParameterSet & ps) :
00043    rctSource_( ps.getParameter< InputTag >("rctSource") )
00044 
00045 {
00046 
00047   // verbosity switch
00048   verbose_ = ps.getUntrackedParameter < bool > ("verbose", false);
00049 
00050   if (verbose_)
00051     std::cout << "L1TRCT: constructor...." << std::endl;
00052 
00053 
00054   dbe = NULL;
00055   if (ps.getUntrackedParameter < bool > ("DQMStore", false)) {
00056     dbe = Service < DQMStore > ().operator->();
00057     dbe->setVerbose(0);
00058   }
00059 
00060   outputFile_ =
00061       ps.getUntrackedParameter < std::string > ("outputFile", "");
00062   if (outputFile_.size() != 0) {
00063     std::
00064 	cout << "L1T Monitoring histograms will be saved to " <<
00065         outputFile_.c_str() << std::endl;
00066   }
00067 
00068   bool disable =
00069       ps.getUntrackedParameter < bool > ("disableROOToutput", false);
00070   if (disable) {
00071     outputFile_ = "";
00072   }
00073 
00074 
00075   if (dbe != NULL) {
00076     dbe->setCurrentFolder("L1T/L1TRCT");
00077   }
00078 
00079 
00080 }
00081 
00082 L1TRCT::~L1TRCT()
00083 {
00084 }
00085 
00086 void L1TRCT::beginJob(void)
00087 {
00088 
00089 
00090   nev_ = 0;
00091 
00092   // get hold of back-end interface
00093   DQMStore *dbe = 0;
00094   dbe = Service < DQMStore > ().operator->();
00095 
00096   if (dbe) {
00097     dbe->setCurrentFolder("L1T/L1TRCT");
00098     dbe->rmdir("L1T/L1TRCT");
00099   }
00100 
00101 
00102   if (dbe) {
00103     dbe->setCurrentFolder("L1T/L1TRCT");
00104 
00105     rctIsoEmEtEtaPhi_ =
00106         dbe->book2D("RctEmIsoEmEtEtaPhi", "ISO EM E_{T}", ETABINS, ETAMIN,
00107                     ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00108     rctIsoEmOccEtaPhi_ =
00109         dbe->book2D("RctEmIsoEmOccEtaPhi", "ISO EM OCCUPANCY", ETABINS,
00110                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00111     rctNonIsoEmEtEtaPhi_ =
00112         dbe->book2D("RctEmNonIsoEmEtEtaPhi", "NON-ISO EM E_{T}", ETABINS,
00113                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00114     rctNonIsoEmOccEtaPhi_ =
00115         dbe->book2D("RctEmNonIsoEmOccEtaPhi", "NON-ISO EM OCCUPANCY",
00116                     ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00117 
00118     // global regions
00119     rctRegionsEtEtaPhi_ =
00120         dbe->book2D("RctRegionsEtEtaPhi", "REGION E_{T}", ETABINS, ETAMIN,
00121                     ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00122     rctRegionsOccEtaPhi_ =
00123         dbe->book2D("RctRegionsOccEtaPhi", "REGION OCCUPANCY", ETABINS,
00124                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00125 
00126     rctOverFlowEtaPhi_ =
00127         dbe->book2D("RctBitOverFlowEtaPhi", "OVER FLOW OCCUPANCY", ETABINS,
00128                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00129 
00130     rctTauVetoEtaPhi_ =
00131         dbe->book2D("RctBitTauVetoEtaPhi", "TAU VETO OCCUPANCY", ETABINS,
00132                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00133 
00134     rctMipEtaPhi_ =
00135         dbe->book2D("RctBitMipEtaPhi", "MIP OCCUPANCY", ETABINS,
00136                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00137 
00138     rctQuietEtaPhi_ =
00139         dbe->book2D("RctBitQuietEtaPhi", "QUIET OCCUPANCY", ETABINS,
00140                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00141 
00142     rctHfPlusTauEtaPhi_ =
00143         dbe->book2D("RctBitHfPlusTauEtaPhi", "HF plus Tau OCCUPANCY", ETABINS,
00144                     ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
00145 
00146     // local regions
00147 /*
00148     const int nlocphibins = 2; 
00149     const float locphimin = -0.5;
00150     const float locphimax = 1.5;
00151     const int nlocetabins = 11;
00152     const float locetamin = -0.5;
00153     const float locetamax = 10.5;
00154     rctRegionsLocalEtEtaPhi_ =
00155         dbe->book2D("RctRegionsLocalEtEtaPhi", "REGION E_{T} (Local)", 
00156                     nlocetabins, locetamin, locetamax,
00157                     nlocphibins, locphimin, locphimax);
00158     rctRegionsLocalOccEtaPhi_ =
00159         dbe->book2D("RctRegionsLocalOccEtaPhi", "REGION OCCUPANCY (Local)", 
00160                     nlocetabins, locetamin, locetamax,
00161                     nlocphibins, locphimin, locphimax);
00162     rctTauVetoLocalEtaPhi_ =
00163         dbe->book2D("RctTauLocalVetoEtaPhi", "TAU VETO OCCUPANCY (Local)",
00164                     nlocetabins, locetamin, locetamax,
00165                     nlocphibins, locphimin, locphimax);
00166 */
00167     // rank histos
00168     rctRegionRank_ =
00169         dbe->book1D("RctRegionRank", "REGION RANK", R10BINS, R10MIN,
00170                     R10MAX);
00171     rctIsoEmRank_ =
00172         dbe->book1D("RctEmIsoEmRank", "ISO EM RANK", R6BINS, R6MIN, R6MAX);
00173     rctNonIsoEmRank_ =
00174         dbe->book1D("RctEmNonIsoEmRank", "NON-ISO EM RANK", R6BINS, R6MIN,
00175                     R6MAX);
00176     // hw coordinates
00177 //    rctEmCardRegion_ = dbe->book1D("rctEmCardRegion", "Em Card * Region",
00178 //                                 256, -127.5, 127.5);
00179 
00180     // bx histos
00181     rctRegionBx_ = dbe->book1D("RctRegionBx", "Region BX", 256, -0.5, 4095.5);
00182     rctEmBx_ = dbe->book1D("RctEmBx", "EM BX", 256, -0.5, 4095.5);
00183 
00184     
00185 
00186   }
00187 }
00188 
00189 
00190 void L1TRCT::endJob(void)
00191 {
00192   if (verbose_)
00193     std::cout << "L1TRCT: end job...." << std::endl;
00194   LogInfo("EndJob") << "analyzed " << nev_ << " events";
00195 
00196   if (outputFile_.size() != 0 && dbe)
00197     dbe->save(outputFile_);
00198 
00199   return;
00200 }
00201 
00202 void L1TRCT::analyze(const Event & e, const EventSetup & c)
00203 {
00204   nev_++;
00205   if (verbose_) {
00206     std::cout << "L1TRCT: analyze...." << std::endl;
00207   }
00208 
00209   // Get the RCT digis
00210   edm::Handle < L1CaloEmCollection > em;
00211   edm::Handle < L1CaloRegionCollection > rgn;
00212 
00213   // need to change to getByLabel
00214   bool doEm = true; 
00215   bool doHd = true;
00216 
00217   
00218   e.getByLabel(rctSource_,rgn);
00219  
00220   if (!rgn.isValid()) {
00221     edm::LogInfo("DataNotFound") << "can't find L1CaloRegionCollection with label "
00222                                << rctSource_.label() ;
00223     doHd = false;
00224   }
00225 
00226   if ( doHd ) {
00227     // Fill the RCT histograms
00228 
00229     // Regions
00230     for (L1CaloRegionCollection::const_iterator ireg = rgn->begin();
00231          ireg != rgn->end(); ireg++) {
00232       if(ireg->et()>0)
00233       {
00234       rctRegionRank_->Fill(ireg->et());
00235       rctRegionsOccEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
00236       rctRegionsEtEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi(), ireg->et());
00237 //      rctTauVetoEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi(),
00238 //                            ireg->tauVeto());
00239 
00240       // now do local coordinate eta and phi
00241 //      rctRegionsLocalOccEtaPhi_->Fill(ireg->rctEta(), ireg->rctPhi());
00242 //      rctRegionsLocalEtEtaPhi_->Fill(ireg->rctEta(), ireg->rctPhi(), 
00243 //                                   ireg->et());
00244 //      rctTauVetoLocalEtaPhi_->Fill(ireg->rctEta(), ireg->rctPhi(),
00245 //                                 ireg->tauVeto());
00246       rctRegionBx_->Fill(ireg->bx());
00247       }
00248 
00249     if(ireg->overFlow())  rctOverFlowEtaPhi_ ->Fill(ireg->gctEta(), ireg->gctPhi());
00250     if(ireg->tauVeto())   rctTauVetoEtaPhi_  ->Fill(ireg->gctEta(), ireg->gctPhi());
00251     if(ireg->mip())       rctMipEtaPhi_      ->Fill(ireg->gctEta(), ireg->gctPhi());
00252     if(ireg->quiet())     rctQuietEtaPhi_    ->Fill(ireg->gctEta(), ireg->gctPhi());
00253     if(ireg->fineGrain()) rctHfPlusTauEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi()); 
00254     
00255     }
00256   }
00257 
00258   
00259   e.getByLabel(rctSource_,em);
00260   
00261   if (!em.isValid()) {
00262     edm::LogInfo("DataNotFound") << "can't find L1CaloEmCollection with label "
00263                                << rctSource_.label() ;
00264     doEm = false;
00265   }
00266   if ( ! doEm ) return;
00267   // Isolated and non-isolated EM
00268   for (L1CaloEmCollection::const_iterator iem = em->begin();
00269        iem != em->end(); iem++) {
00270     
00271  //   rctEmCardRegion_->Fill((iem->rctRegion()==0?1:-1)*(iem->rctCard()));
00272 
00273     if (iem->isolated()) {
00274       if(iem->rank()>0)
00275       {
00276       rctIsoEmRank_->Fill(iem->rank());
00277       rctIsoEmEtEtaPhi_->Fill(iem->regionId().ieta(),
00278                               iem->regionId().iphi(), iem->rank());
00279       rctIsoEmOccEtaPhi_->Fill(iem->regionId().ieta(),
00280                                iem->regionId().iphi());
00281       rctEmBx_->Fill(iem->bx());
00282       }
00283     }
00284     else {
00285       if(iem->rank()>0)
00286       { 
00287       rctNonIsoEmRank_->Fill(iem->rank());
00288       rctNonIsoEmEtEtaPhi_->Fill(iem->regionId().ieta(),
00289                                  iem->regionId().iphi(), iem->rank());
00290       rctNonIsoEmOccEtaPhi_->Fill(iem->regionId().ieta(),
00291                                   iem->regionId().iphi());
00292       rctEmBx_->Fill(iem->bx());
00293       }
00294     }
00295 
00296   }
00297 
00298 }