CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DQM/L1TMonitor/src/L1TRCT.cc

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