CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/DQMOffline/Ecal/src/EBClusterTaskExtras.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBClusterTaskExtras.cc
00003  *
00004  * $Date: 2012/06/28 12:15:15 $
00005  * $Revision: 1.11 $
00006  * \author G. Della Ricca
00007  * \author E. Di Marco
00008  *
00009  */
00010 
00011 #include <iostream>
00012 #include <fstream>
00013 #include <vector>
00014 #include <math.h>
00015 
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 
00019 #include "DQMServices/Core/interface/MonitorElement.h"
00020 
00021 #include "DQMServices/Core/interface/DQMStore.h"
00022 
00023 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00024 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00025 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00026 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00027 #include "FWCore/Framework/interface/ESHandle.h"
00028 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00029 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00030 #include "DataFormats/Math/interface/Point3D.h"
00031 
00032 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
00033 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00034 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00035 #include "DataFormats/L1GlobalTrigger/interface/L1GtPsbWord.h"
00036 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00037 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00038 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00039 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00040 
00041 #include <DQM/EcalCommon/interface/Numbers.h>
00042 
00043 #include <DQMOffline/Ecal/interface/EBClusterTaskExtras.h>
00044 
00045 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00046 
00047 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
00048 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00049 
00050 using namespace cms;
00051 using namespace edm;
00052 using namespace std;
00053 using namespace reco;
00054 
00055 
00056 EBClusterTaskExtras::EBClusterTaskExtras(const ParameterSet& ps){
00057 
00058    init_ = false;
00059 
00060    dqmStore_ = Service<DQMStore>().operator->();
00061 
00062    prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00063 
00064    enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00065 
00066    mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00067 
00068    // parameters...
00069    SuperClusterCollection_ = ps.getParameter<edm::InputTag>("SuperClusterCollection");
00070    EcalRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalRecHitCollection");
00071    l1GTReadoutRecTag_ = ps.getParameter<edm::InputTag>("l1GlobalReadoutRecord");
00072    l1GMTReadoutRecTag_ = ps.getParameter<edm::InputTag>("l1GlobalMuonReadoutRecord");
00073 
00074    // histograms...
00075 #ifndef EBCLUSTERTASKEXTRAS_DQMOFFLINE
00076    meSCSizCrystal_ = 0;
00077    meSCSizBC_ = 0;
00078    meSCSizPhi_ = 0;
00079 
00080    meSCSeedEne_ = 0;
00081    meSCEne2_ = 0;
00082    meSCEneLow_ = 0;
00083    meSCEneHigh_ = 0;
00084    meSCEneSingleCrystal_ = 0;
00085 
00086    meSCSeedMapOccSingleCrystal_ = 0;
00087    meSCSeedMapOccTT_ = 0;
00088    meSCSeedMapOccHighEne_ = 0;
00089 
00090    meSCSeedTime_ = 0;
00091    meSCSeedMapTimeTT_ = 0;
00092    meSCSeedMapTimeMod_ = 0;
00093    meSCSeedTimeVsPhi_ = 0;
00094    meSCSeedTimeVsAmp_ = 0;
00095    meSCSeedTimeEBM_ = 0;
00096    meSCSeedTimeEBP_ = 0;
00097    meSCSeedTimeEBMTop_ = 0;
00098    meSCSeedTimeEBPTop_ = 0;
00099    meSCSeedTimeEBMBot_ = 0;
00100    meSCSeedTimeEBPBot_ = 0;
00101    for(int i=0;i!=36;++i)
00102       meSCSeedTimePerFed_[i] = 0;
00103    for(int i=0;i!=5;++i) {
00104       meSCSeedMapOccTrg_[i] = 0;
00105       meSCSeedMapOccTrgExcl_[i] = 0;
00106       meSCSeedMapTimeTrgMod_[i] = 0;
00107    }
00108 #endif
00109 
00110    meSCSizCrystalVsEne_ = 0;
00111 
00112    meSCSeedMapOcc_ = 0;
00113    meSCSeedMapOccHighEneTT_ = 0;
00114    for(int i=0;i!=5;++i) {
00115       meSCSeedMapOccTrgTT_[i] = 0;
00116       meSCSeedMapOccTrgExclTT_[i] = 0;
00117 
00118       meSCSeedMapTimeTrgTT_[i] = 0;
00119       meSCSeedTimeTrg_[i] = 0;
00120    }
00121 
00122    meTrg_ = 0;
00123    meTrgExcl_ = 0;
00124 
00125 }
00126 
00127 EBClusterTaskExtras::~EBClusterTaskExtras(){
00128 
00129 }
00130 
00131 void EBClusterTaskExtras::beginJob(){
00132 
00133    ievt_ = 0;
00134 
00135    if ( dqmStore_ ) {
00136       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras");
00137       dqmStore_->rmdir(prefixME_ + "/EBClusterTaskExtras");
00138    }
00139 
00140 }
00141 
00142 void EBClusterTaskExtras::beginRun(const Run& r, const EventSetup& c) {
00143 
00144    Numbers::initGeometry(c, false);
00145 
00146    if ( ! mergeRuns_ ) this->reset();
00147 
00148 }
00149 
00150 void EBClusterTaskExtras::endRun(const Run& r, const EventSetup& c) {
00151 
00152 }
00153 
00154 void EBClusterTaskExtras::reset(void) {
00155 #ifndef EBCLUSTERTASKEXTRAS_DQMOFFLINE
00156    if ( meSCSizCrystal_ ) meSCSizCrystal_->Reset();
00157    if ( meSCSizBC_ ) meSCSizBC_->Reset(); 
00158    if ( meSCSizPhi_ ) meSCSizPhi_->Reset();
00159 
00160    if ( meSCSeedEne_ ) meSCSeedEne_->Reset();
00161    if ( meSCEne2_ ) meSCEne2_->Reset();
00162    if ( meSCEneLow_ ) meSCEneLow_->Reset();
00163    if ( meSCEneHigh_ ) meSCEneHigh_->Reset();
00164    if ( meSCEneSingleCrystal_ ) meSCEneSingleCrystal_->Reset();
00165 
00166    if ( meSCSeedMapOccSingleCrystal_ ) meSCSeedMapOccSingleCrystal_->Reset();
00167    if ( meSCSeedMapOccTT_ ) meSCSeedMapOccTT_->Reset();
00168    if ( meSCSeedMapOccHighEne_ ) meSCSeedMapOccHighEne_->Reset();
00169 
00170    if ( meSCSeedTime_ ) meSCSeedTime_->Reset();
00171    if ( meSCSeedMapTimeTT_ ) meSCSeedMapTimeTT_->Reset();
00172    if ( meSCSeedTimeVsPhi_ ) meSCSeedTimeVsPhi_->Reset();
00173    if ( meSCSeedTimeVsAmp_ ) meSCSeedTimeVsAmp_->Reset();
00174    if ( meSCSeedTimeEBM_ ) meSCSeedTimeEBM_->Reset();
00175    if ( meSCSeedTimeEBP_ ) meSCSeedTimeEBP_->Reset();
00176    if ( meSCSeedTimeEBMTop_ ) meSCSeedTimeEBMTop_->Reset();
00177    if ( meSCSeedTimeEBPTop_ ) meSCSeedTimeEBPTop_->Reset();
00178    if ( meSCSeedTimeEBMBot_ ) meSCSeedTimeEBMBot_->Reset();
00179    if ( meSCSeedTimeEBPBot_ ) meSCSeedTimeEBPBot_->Reset();
00180 
00181    for(int i=0;i!=36; ++i) 
00182       if ( meSCSeedTimePerFed_[i] ) meSCSeedTimePerFed_[i]->Reset();
00183 
00184    for(int i=0;i!=5;++i) {
00185       if ( meSCSeedMapOccTrg_[i] ) meSCSeedMapOccTrg_[i]->Reset();
00186       if ( meSCSeedMapOccTrgExcl_[i] ) meSCSeedMapOccTrgExcl_[i]->Reset();
00187       if ( meSCSeedMapTimeTrgMod_[i] ) meSCSeedMapTimeTrgMod_[i]->Reset();
00188    }
00189 
00190    if ( meSCSeedMapTimeMod_ ) meSCSeedMapTimeMod_->Reset();
00191 #endif
00192 
00193    if ( meSCSizCrystalVsEne_ ) meSCSizCrystalVsEne_->Reset();
00194 
00195    if ( meSCSeedMapOcc_ ) meSCSeedMapOcc_->Reset();
00196    if ( meSCSeedMapOccHighEneTT_ ) meSCSeedMapOccHighEneTT_->Reset();
00197 
00198 
00199    for(int i=0; i!=5; ++i) {
00200       if ( meSCSeedMapOccTrgTT_[i] ) meSCSeedMapOccTrgTT_[i]->Reset();
00201       if ( meSCSeedMapOccTrgExclTT_[i] ) meSCSeedMapOccTrgExclTT_[i]->Reset();
00202 
00203       if ( meSCSeedMapTimeTrgTT_[i] ) meSCSeedMapTimeTrgTT_[i]->Reset();
00204       if ( meSCSeedTimeTrg_[i] ) meSCSeedTimeTrg_[i]->Reset();
00205    }
00206    if ( meTrg_ ) meTrg_->Reset();
00207    if ( meTrgExcl_ ) meTrgExcl_->Reset();
00208 }
00209 
00210 void EBClusterTaskExtras::setup(void){
00211 
00212    init_ = true;
00213 
00214    std::string histo;
00215 
00216    if ( dqmStore_ ) {
00217       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras");
00218 
00219 #ifndef EBCLUSTERTASKEXTRAS_DQMOFFLINE
00220       // Cluster hists
00221       histo = "EBCLTE SC size (crystal)";
00222       meSCSizCrystal_ = dqmStore_->book1D(histo,histo,150,0,150);
00223       meSCSizCrystal_->setAxisTitle("super cluster size (crystal)", 1);
00224 
00225       histo = "EBCLTE SC size (basic clusters)";
00226       meSCSizBC_ = dqmStore_->book1D(histo,histo,20,0,20);
00227       meSCSizBC_->setAxisTitle("super cluster size (basic clusters)", 1);
00228 
00229       histo = "EBCLTE SC size in basic clusters vs phi";
00230       meSCSizPhi_ = dqmStore_->bookProfile(histo,histo,360/5,-3.14159,3.14159,20,0,20);
00231       meSCSizPhi_->setAxisTitle("phi", 1);
00232       meSCSizPhi_->setAxisTitle("super cluster size (basic clusters)", 2);
00233 
00234       histo = "EBCLTE SC seed crystal energy";
00235       meSCSeedEne_ = dqmStore_->book1D(histo,histo,200,0,1.8);
00236       meSCSeedEne_->setAxisTitle("seed crystal energy (GeV)", 1);
00237 
00238       histo = "EBCLTE SC seed e2";
00239       meSCEne2_ = dqmStore_->book1D(histo,histo,200,0,1.8);
00240       meSCEne2_->setAxisTitle("seed + highest neighbor crystal energy (GeV)", 1);
00241 
00242       histo = "EBCLTE SC energy low scale";
00243       meSCEneLow_ = dqmStore_->book1D(histo,histo,200,0,1.8);
00244       meSCEneLow_->setAxisTitle("energy (GeV)", 1);
00245 
00246       histo = "EBCLTE SC energy high scale";
00247       meSCEneHigh_ = dqmStore_->book1D(histo,histo,200,0,200);
00248       meSCEneHigh_->setAxisTitle("energy (GeV)", 1);
00249 
00250       histo = "EBCLTE SC single crystal energy (GeV)";
00251       meSCEneSingleCrystal_ = dqmStore_->book1D(histo,histo,200,0,200);
00252       meSCEneSingleCrystal_->setAxisTitle("energy (GeV)", 1);
00253 
00254       histo = "EBCLTE SC seed occupancy map trigger tower binned";
00255       meSCSeedMapOccTT_ = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00256       meSCSeedMapOccTT_->setAxisTitle("jphi", 1);
00257       meSCSeedMapOccTT_->setAxisTitle("jeta", 2);
00258 
00259       histo = "EBCLTE SC seed occupancy map (high energy clusters) (crystal binned)";
00260       meSCSeedMapOccHighEne_ = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00261       meSCSeedMapOccHighEne_->setAxisTitle("jphi", 1);
00262       meSCSeedMapOccHighEne_->setAxisTitle("jeta", 2);
00263 
00264       histo = "EBCLTE SC single crystal cluster occupancy map";
00265       meSCSeedMapOccSingleCrystal_ = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00266       meSCSeedMapOccSingleCrystal_->setAxisTitle("jphi", 1);
00267       meSCSeedMapOccSingleCrystal_->setAxisTitle("jeta", 2);
00268 
00269       histo = "EBCLTE SC seed crystal timing";
00270       meSCSeedTime_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00271       meSCSeedTime_->setAxisTitle("seed crystal timing");
00272 
00273       histo = "EBCLTE SC seed crystal timing map trigger tower binned";
00274       meSCSeedMapTimeTT_ = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00275       meSCSeedMapTimeTT_->setAxisTitle("jphi", 1);
00276       meSCSeedMapTimeTT_->setAxisTitle("jeta", 2);
00277 
00278       histo = "EBCLTE SC seed crystal timing map module binned";
00279       meSCSeedMapTimeMod_ = dqmStore_->bookProfile2D(histo,histo,18,0,360,8,-85,85,78,0.,10.,"s");
00280       meSCSeedMapTimeMod_->setAxisTitle("jphi",1);
00281       meSCSeedMapTimeMod_->setAxisTitle("jeta",2);
00282 
00283       histo = "EBCLTE SC seed crystal timing vs phi";
00284       meSCSeedTimeVsPhi_ = dqmStore_->bookProfile(histo, histo, 72, 0, 360, 78, -7, 7);
00285       meSCSeedTimeVsPhi_->setAxisTitle("jphi",1);
00286       meSCSeedTimeVsPhi_->setAxisTitle("seed crystal timing",2);
00287 
00288       histo = "EBCLTE SC seed crystal energy vs relative timing";
00289       meSCSeedTimeVsAmp_ = dqmStore_->bookProfile(histo, histo, 78, -7, 7, 200, 0, 1.8);
00290       meSCSeedTimeVsAmp_->setAxisTitle("seed crystal timing", 1);
00291       meSCSeedTimeVsAmp_->setAxisTitle("seed crystal energy (GeV)", 2);
00292 
00293       histo = "EBCLTE SC seed crystal timing EB -";
00294       meSCSeedTimeEBM_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00295       meSCSeedTimeEBM_->setAxisTitle("seed crystal timing");
00296 
00297       histo = "EBCLTE SC seed crystal timing EB +";
00298       meSCSeedTimeEBP_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00299       meSCSeedTimeEBP_->setAxisTitle("seed crystal timing");
00300 
00301       histo = "EBCLTE SC seed crystal timing EB - top";
00302       meSCSeedTimeEBMTop_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00303       meSCSeedTimeEBMTop_->setAxisTitle("seed crystal timing", 1);
00304 
00305       histo = "EBCLTE SC seed crystal timing EB + top";
00306       meSCSeedTimeEBPTop_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00307       meSCSeedTimeEBPTop_->setAxisTitle("seed crystal timing", 1);
00308 
00309       histo = "EBCLTE SC seed crystal timing EB - bottom";
00310       meSCSeedTimeEBMBot_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00311       meSCSeedTimeEBMBot_->setAxisTitle("seed crystal timing", 1);
00312 
00313       histo = "EBCLTE SC seed crystal timing EB + bottom";
00314       meSCSeedTimeEBPBot_ = dqmStore_->book1D(histo,histo,78,0.,10.);
00315       meSCSeedTimeEBPBot_->setAxisTitle("seed crystal timing", 1);
00316 
00317       std::stringstream ss;
00318 
00319       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras/EBCLTE seed crystal timing per super module");
00320       for(int i=0;i!=36;++i) {
00321         ss.str("");
00322         if((i+1) <= 18){
00323           ss << "EBCLTE SC seed crystal timing EB - " << i+1;
00324           histo = ss.str();
00325         }
00326         else{
00327           ss << "EBCLTE SC seed crystal timing EB + " << i+1-18;
00328           histo = ss.str();
00329         }
00330          meSCSeedTimePerFed_[i] = dqmStore_->book1D(histo,histo,78,0.,10.);
00331          meSCSeedTimePerFed_[i]->setAxisTitle("seed crystal timing", 1);
00332       }
00333 
00334       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras");
00335 
00336       histo = "EBCLTE SC seed occupancy map (CSC exclusive triggered)";
00337       meSCSeedMapOccTrgExcl_[0] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00338       meSCSeedMapOccTrgExcl_[0]->setAxisTitle("jphi", 1);
00339       meSCSeedMapOccTrgExcl_[0]->setAxisTitle("jeta", 2);
00340 
00341       histo = "EBCLTE SC seed occupancy map (DT exclusive triggered)";
00342       meSCSeedMapOccTrgExcl_[1] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00343       meSCSeedMapOccTrgExcl_[1]->setAxisTitle("jphi", 1);
00344       meSCSeedMapOccTrgExcl_[1]->setAxisTitle("jeta", 2);
00345 
00346       histo = "EBCLTE SC seed occupancy map (ECAL exclusive triggered)";
00347       meSCSeedMapOccTrgExcl_[2] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00348       meSCSeedMapOccTrgExcl_[2]->setAxisTitle("jphi", 1);
00349       meSCSeedMapOccTrgExcl_[2]->setAxisTitle("jeta", 2);
00350 
00351       histo = "EBCLTE SC seed occupancy map (HCAL exclusive triggered)";
00352       meSCSeedMapOccTrgExcl_[3] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00353       meSCSeedMapOccTrgExcl_[3]->setAxisTitle("jphi", 1);
00354       meSCSeedMapOccTrgExcl_[3]->setAxisTitle("jeta", 2);
00355 
00356       histo = "EBCLTE SC seed occupancy map (RPC exclusive triggered)";
00357       meSCSeedMapOccTrgExcl_[4] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00358       meSCSeedMapOccTrgExcl_[4]->setAxisTitle("jphi", 1);
00359       meSCSeedMapOccTrgExcl_[4]->setAxisTitle("jeta", 2);
00360 
00361       histo = "EBCLTE SC seed occupancy map (CSC triggered)";
00362       meSCSeedMapOccTrg_[0] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00363       meSCSeedMapOccTrg_[0]->setAxisTitle("jphi", 1);
00364       meSCSeedMapOccTrg_[0]->setAxisTitle("jeta", 2);
00365 
00366       histo = "EBCLTE SC seed occupancy map (DT triggered)";
00367       meSCSeedMapOccTrg_[1] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00368       meSCSeedMapOccTrg_[1]->setAxisTitle("jphi", 1);
00369       meSCSeedMapOccTrg_[1]->setAxisTitle("jeta", 2);
00370 
00371       histo = "EBCLTE SC seed occupancy map (ECAL triggered)";
00372       meSCSeedMapOccTrg_[2] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00373       meSCSeedMapOccTrg_[2]->setAxisTitle("jphi", 1);
00374       meSCSeedMapOccTrg_[2]->setAxisTitle("jeta", 2);
00375 
00376       histo = "EBCLTE SC seed occupancy map (HCAL triggered)";
00377       meSCSeedMapOccTrg_[3] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00378       meSCSeedMapOccTrg_[3]->setAxisTitle("jphi", 1);
00379       meSCSeedMapOccTrg_[3]->setAxisTitle("jeta", 2);
00380 
00381       histo = "EBCLTE SC seed occupancy map (RPC triggered)";
00382       meSCSeedMapOccTrg_[4] = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00383       meSCSeedMapOccTrg_[4]->setAxisTitle("jphi", 1);
00384       meSCSeedMapOccTrg_[4]->setAxisTitle("jeta", 2);
00385 
00386       histo = "EBCLTE SC seed crystal timing map (CSC triggered) module binned";
00387       meSCSeedMapTimeTrgMod_[0] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00388       meSCSeedMapTimeTrgMod_[0]->setAxisTitle("jphi", 1);
00389       meSCSeedMapTimeTrgMod_[0]->setAxisTitle("jeta", 2);
00390 
00391       histo = "EBCLTE SC seed crystal timing map (DT triggered) module binned";
00392       meSCSeedMapTimeTrgMod_[1] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00393       meSCSeedMapTimeTrgMod_[1]->setAxisTitle("jphi", 1);
00394       meSCSeedMapTimeTrgMod_[1]->setAxisTitle("jeta", 2);
00395 
00396       histo = "EBCLTE SC seed crystal timing map (ECAL triggered) module binned";
00397       meSCSeedMapTimeTrgMod_[2] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00398       meSCSeedMapTimeTrgMod_[2]->setAxisTitle("jphi", 1);
00399       meSCSeedMapTimeTrgMod_[2]->setAxisTitle("jeta", 2);
00400 
00401       histo = "EBCLTE SC seed crystal timing map (HCAL triggered) module binned";
00402       meSCSeedMapTimeTrgMod_[3] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00403       meSCSeedMapTimeTrgMod_[3]->setAxisTitle("jphi", 1);
00404       meSCSeedMapTimeTrgMod_[3]->setAxisTitle("jeta", 2);
00405 
00406       histo = "EBCLTE SC seed crystal timing map (RPC triggered) module binned";
00407       meSCSeedMapTimeTrgMod_[4] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00408       meSCSeedMapTimeTrgMod_[4]->setAxisTitle("jphi", 1);
00409       meSCSeedMapTimeTrgMod_[4]->setAxisTitle("jeta", 2);
00410 
00411 #endif
00412 
00413       histo = "EBCLTE SC size (crystal) vs energy (GeV)";
00414       meSCSizCrystalVsEne_ = dqmStore_->bookProfile(histo,histo,200,0.,10.,150,0,150);
00415       meSCSizCrystalVsEne_->setAxisTitle("energy (GeV)", 1);
00416       meSCSizCrystalVsEne_->setAxisTitle("super cluster size (crystal)", 2);
00417 
00418       histo = "EBCLTE SC seed occupancy map";
00419       meSCSeedMapOcc_ = dqmStore_->book2D(histo,histo,360,0,360,170,-85,85);
00420       meSCSeedMapOcc_->setAxisTitle("jphi", 1);
00421       meSCSeedMapOcc_->setAxisTitle("jeta", 2);
00422 
00423       histo = "EBCLTE SC seed occupancy map (high energy clusters) trigger tower binned";
00424       meSCSeedMapOccHighEneTT_ = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00425       meSCSeedMapOccHighEneTT_->setAxisTitle("jphi", 1);
00426       meSCSeedMapOccHighEneTT_->setAxisTitle("jeta", 2);
00427 
00428       histo = "EBCLTE SC seed occupancy map (CSC triggered) trigger tower binned";
00429       meSCSeedMapOccTrgTT_[0] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00430       meSCSeedMapOccTrgTT_[0]->setAxisTitle("jphi", 1);
00431       meSCSeedMapOccTrgTT_[0]->setAxisTitle("jeta", 2);
00432 
00433       histo = "EBCLTE SC seed occupancy map (DT triggered) trigger tower binned";
00434       meSCSeedMapOccTrgTT_[1] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00435       meSCSeedMapOccTrgTT_[1]->setAxisTitle("jphi", 1);
00436       meSCSeedMapOccTrgTT_[1]->setAxisTitle("jeta", 2);
00437 
00438       histo = "EBCLTE SC seed occupancy map (ECAL triggered) trigger tower binned";
00439       meSCSeedMapOccTrgTT_[2] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00440       meSCSeedMapOccTrgTT_[2]->setAxisTitle("jphi", 1);
00441       meSCSeedMapOccTrgTT_[2]->setAxisTitle("jeta", 2);
00442 
00443       histo = "EBCLTE SC seed occupancy map (HCAL triggered) trigger tower binned";
00444       meSCSeedMapOccTrgTT_[3] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00445       meSCSeedMapOccTrgTT_[3]->setAxisTitle("jphi", 1);
00446       meSCSeedMapOccTrgTT_[3]->setAxisTitle("jeta", 2);
00447 
00448       histo = "EBCLTE SC seed occupancy map (RPC triggered) trigger tower binned";
00449       meSCSeedMapOccTrgTT_[4] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00450       meSCSeedMapOccTrgTT_[4]->setAxisTitle("jphi", 1);
00451       meSCSeedMapOccTrgTT_[4]->setAxisTitle("jeta", 2);
00452 
00453       histo = "EBCLTE SC seed occupancy map (CSC exclusive triggered) trigger tower binned";
00454       meSCSeedMapOccTrgExclTT_[0] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00455       meSCSeedMapOccTrgExclTT_[0]->setAxisTitle("jphi", 1);
00456       meSCSeedMapOccTrgExclTT_[0]->setAxisTitle("jeta", 2);
00457 
00458       histo = "EBCLTE SC seed occupancy map (DT exclusive triggered) trigger tower binned";
00459       meSCSeedMapOccTrgExclTT_[1] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00460       meSCSeedMapOccTrgExclTT_[1]->setAxisTitle("jphi", 1);
00461       meSCSeedMapOccTrgExclTT_[1]->setAxisTitle("jeta", 2);
00462 
00463       histo = "EBCLTE SC seed occupancy map (ECAL exclusive triggered) trigger tower binned";
00464       meSCSeedMapOccTrgExclTT_[2] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00465       meSCSeedMapOccTrgExclTT_[2]->setAxisTitle("jphi", 1);
00466       meSCSeedMapOccTrgExclTT_[2]->setAxisTitle("jeta", 2);
00467 
00468       histo = "EBCLTE SC seed occupancy map (HCAL exclusive triggered) trigger tower binned";
00469       meSCSeedMapOccTrgExclTT_[3] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00470       meSCSeedMapOccTrgExclTT_[3]->setAxisTitle("jphi", 1);
00471       meSCSeedMapOccTrgExclTT_[3]->setAxisTitle("jeta", 2);
00472 
00473       histo = "EBCLTE SC seed occupancy map (RPC exclusive triggered) trigger tower binned";
00474       meSCSeedMapOccTrgExclTT_[4] = dqmStore_->book2D(histo,histo,72,0,360,34,-85,85);
00475       meSCSeedMapOccTrgExclTT_[4]->setAxisTitle("jphi", 1);
00476       meSCSeedMapOccTrgExclTT_[4]->setAxisTitle("jeta", 2);
00477 
00478       histo = "EBCLTE SC seed crystal timing map (CSC exclusive triggered) trigger tower binned";
00479       meSCSeedMapTimeTrgTT_[0] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00480       meSCSeedMapTimeTrgTT_[0]->setAxisTitle("jphi", 1);
00481       meSCSeedMapTimeTrgTT_[0]->setAxisTitle("jeta", 2);
00482 
00483       histo = "EBCLTE SC seed crystal timing map (DT exclusive triggered) trigger tower binned";
00484       meSCSeedMapTimeTrgTT_[1] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00485       meSCSeedMapTimeTrgTT_[1]->setAxisTitle("jphi", 1);
00486       meSCSeedMapTimeTrgTT_[1]->setAxisTitle("jeta", 2);
00487 
00488       histo = "EBCLTE SC seed crystal timing map (ECAL exclusive triggered) trigger tower binned";
00489       meSCSeedMapTimeTrgTT_[2] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00490       meSCSeedMapTimeTrgTT_[2]->setAxisTitle("jphi", 1);
00491       meSCSeedMapTimeTrgTT_[2]->setAxisTitle("jeta", 2);
00492 
00493       histo = "EBCLTE SC seed crystal timing map (HCAL exclusive triggered) trigger tower binned";
00494       meSCSeedMapTimeTrgTT_[3] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00495       meSCSeedMapTimeTrgTT_[3]->setAxisTitle("jphi", 1);
00496       meSCSeedMapTimeTrgTT_[3]->setAxisTitle("jeta", 2);
00497 
00498       histo = "EBCLTE SC seed crystal timing map (RPC exclusive triggered) trigger tower binned";
00499       meSCSeedMapTimeTrgTT_[4] = dqmStore_->bookProfile2D(histo,histo,72,0,360,34,-85,85,78,0.,10.,"s");
00500       meSCSeedMapTimeTrgTT_[4]->setAxisTitle("jphi", 1);
00501       meSCSeedMapTimeTrgTT_[4]->setAxisTitle("jeta", 2);
00502 
00503       histo = "EBCLTE SC seed crystal timing (CSC triggered)";
00504       meSCSeedTimeTrg_[0] = dqmStore_->book1D(histo,histo,78,0.,10.);
00505       meSCSeedTimeTrg_[0]->setAxisTitle("seed crystal timing",1);
00506 
00507       histo = "EBCLTE SC seed crystal timing (DT triggered)";
00508       meSCSeedTimeTrg_[1] = dqmStore_->book1D(histo,histo,78,0.,10.);
00509       meSCSeedTimeTrg_[1]->setAxisTitle("seed crystal timing",1);
00510 
00511       histo = "EBCLTE SC seed crystal timing (ECAL triggered)";
00512       meSCSeedTimeTrg_[2] = dqmStore_->book1D(histo,histo,78,0.,10.);
00513       meSCSeedTimeTrg_[2]->setAxisTitle("seed crystal timing",1);
00514 
00515       histo = "EBCLTE SC seed crystal timing (HCAL triggered)";
00516       meSCSeedTimeTrg_[3] = dqmStore_->book1D(histo,histo,78,0.,10.);
00517       meSCSeedTimeTrg_[3]->setAxisTitle("seed crystal timing",1);
00518 
00519       histo = "EBCLTE SC seed crystal timing (RPC triggered)";
00520       meSCSeedTimeTrg_[4] = dqmStore_->book1D(histo,histo,78,0.,10.);
00521       meSCSeedTimeTrg_[4]->setAxisTitle("seed crystal timing",1);
00522 
00523       histo = "EBCLTE triggers";
00524       meTrg_ = dqmStore_->book1D(histo, histo, 5, 0, 5);
00525       meTrg_->setAxisTitle("triggers");
00526 
00527       histo = "EBCLTE exclusive triggers";
00528       meTrgExcl_ = dqmStore_->book1D(histo, histo, 5, 0, 5);
00529       meTrgExcl_->setAxisTitle("triggers");
00530 
00531    }
00532 
00533 }
00534 
00535 void EBClusterTaskExtras::cleanup(void){
00536 
00537    if ( ! init_ ) return;
00538 
00539    if ( dqmStore_ ) {
00540       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras");
00541 
00542 #ifndef EBCLUSTERTASKEXTRAS_DQMOFFLINE
00543       if ( meSCSizCrystal_ ) dqmStore_->removeElement( meSCSizCrystal_->getName() );
00544       meSCSizCrystal_ = 0;
00545 
00546       if ( meSCSizBC_ ) dqmStore_->removeElement( meSCSizBC_->getName() );
00547       meSCSizBC_ = 0;
00548 
00549       if ( meSCSizPhi_ ) dqmStore_->removeElement( meSCSizPhi_->getName() );
00550       meSCSizPhi_ = 0;
00551 
00552       if ( meSCSeedEne_ ) dqmStore_->removeElement( meSCSeedEne_->getName() );
00553       meSCSeedEne_ = 0;
00554 
00555       if ( meSCEne2_ ) dqmStore_->removeElement( meSCEne2_->getName() );
00556       meSCEne2_ = 0;
00557 
00558       if ( meSCEneLow_ ) dqmStore_->removeElement( meSCEneLow_->getName() );
00559       meSCEneLow_ = 0;
00560 
00561       if ( meSCEneHigh_ ) dqmStore_->removeElement( meSCEneHigh_->getName() );
00562       meSCEneHigh_ = 0;
00563 
00564       if ( meSCEneSingleCrystal_ ) dqmStore_->removeElement( meSCEneSingleCrystal_->getName() );
00565       meSCEneSingleCrystal_ = 0;
00566 
00567       if ( meSCSeedMapOccTT_ ) dqmStore_->removeElement( meSCSeedMapOccTT_->getName() );
00568       meSCSeedMapOccTT_ = 0;
00569 
00570       if ( meSCSeedMapOccHighEne_ ) dqmStore_->removeElement( meSCSeedMapOccHighEne_->getName() );
00571       meSCSeedMapOccHighEne_ = 0;
00572 
00573       if ( meSCSeedMapOccSingleCrystal_ ) dqmStore_->removeElement( meSCSeedMapOccSingleCrystal_->getName() );
00574       meSCSeedMapOccSingleCrystal_ = 0;
00575 
00576       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras/EBCLTE seed crystal timing per super module");
00577       for(int i=0; i!=36; ++i) {
00578          if( meSCSeedTimePerFed_[i] ) dqmStore_->removeElement( meSCSeedTimePerFed_[i]->getName() );
00579          meSCSeedTimePerFed_[i] = 0;
00580       }
00581       dqmStore_->setCurrentFolder(prefixME_ + "/EBClusterTaskExtras");
00582 
00583       if ( meSCSeedTime_ ) dqmStore_->removeElement( meSCSeedTime_->getName() );
00584       meSCSeedTime_ = 0;
00585       if ( meSCSeedMapTimeTT_ ) dqmStore_->removeElement( meSCSeedMapTimeTT_->getName() );
00586       meSCSeedMapTimeTT_ = 0;
00587       if ( meSCSeedMapTimeMod_ ) dqmStore_->removeElement( meSCSeedMapTimeMod_->getName() );
00588       meSCSeedMapTimeMod_ = 0;
00589       if ( meSCSeedTimeVsPhi_ ) dqmStore_->removeElement( meSCSeedTimeVsPhi_->getName() );
00590       meSCSeedTimeVsPhi_ = 0;
00591       if ( meSCSeedTimeVsAmp_ ) dqmStore_->removeElement( meSCSeedTimeVsAmp_->getName() );
00592       meSCSeedTimeVsAmp_ = 0;
00593       if ( meSCSeedTimeEBM_ ) dqmStore_->removeElement( meSCSeedTimeEBM_->getName() );
00594       meSCSeedTimeEBM_ = 0;
00595       if ( meSCSeedTimeEBP_ ) dqmStore_->removeElement( meSCSeedTimeEBP_->getName() );
00596       meSCSeedTimeEBP_ = 0;
00597       if ( meSCSeedTimeEBMTop_ ) dqmStore_->removeElement( meSCSeedTimeEBMTop_->getName() );
00598       meSCSeedTimeEBMTop_ = 0;
00599       if ( meSCSeedTimeEBPTop_ ) dqmStore_->removeElement( meSCSeedTimeEBPTop_->getName() );
00600       meSCSeedTimeEBPTop_ = 0;
00601       if ( meSCSeedTimeEBMBot_ ) dqmStore_->removeElement( meSCSeedTimeEBMBot_->getName() );
00602       meSCSeedTimeEBMBot_ = 0;
00603       if ( meSCSeedTimeEBPBot_ ) dqmStore_->removeElement( meSCSeedTimeEBPBot_->getName() );
00604       meSCSeedTimeEBPBot_ = 0;
00605 
00606       for(int i=0;i!=5+ii) {
00607          if ( meSCSeedMapOccTrg_[i] ) dqmStore_->removeElement( meSCSeedMapOccTrg_[i]->getName() );
00608          meSCSeedMapOccTrg_[i] = 0;
00609          if ( meSCSeedMapOccTrgExcl_[i] ) dqmStore_->removeElement( meSCSeedMapOccTrgExcl_[i]->getName() );
00610          meSCSeedMapOccTrgExcl_[i] = 0;
00611          if ( meSCSeedMapTimeTrgMod_[i] ) dqmStore_->removeElement( meSCSeedMapTimeTrgMod_[i]->getName() );
00612          meSCSeedMapTimeTrgMod_[i] = 0;
00613       }
00614 #endif
00615 
00616       if ( meSCSizCrystalVsEne_ ) dqmStore_->removeElement( meSCSizCrystalVsEne_->getName() );
00617       meSCSizCrystalVsEne_ = 0;
00618 
00619 
00620       if ( meSCSeedMapOcc_ ) dqmStore_->removeElement( meSCSeedMapOcc_->getName() );
00621       meSCSeedMapOcc_ = 0;
00622 
00623       if ( meSCSeedMapOccHighEneTT_ ) dqmStore_->removeElement( meSCSeedMapOccHighEneTT_->getName() );
00624       meSCSeedMapOccHighEneTT_ = 0;
00625 
00626       for(int i=0; i!=5; ++i) {
00627          if ( meSCSeedMapOccTrgTT_[i] ) dqmStore_->removeElement( meSCSeedMapOccTrgTT_[i]->getName() );
00628          meSCSeedMapOccTrgTT_[i] = 0;
00629          if ( meSCSeedMapOccTrgExclTT_[i] ) dqmStore_->removeElement( meSCSeedMapOccTrgExclTT_[i]->getName() );
00630          meSCSeedMapOccTrgExclTT_[i] = 0;
00631 
00632          if ( meSCSeedMapTimeTrgTT_[i] ) dqmStore_->removeElement( meSCSeedMapTimeTrgTT_[i]->getName() );
00633          meSCSeedMapTimeTrgTT_[i] = 0;
00634 
00635          if ( meSCSeedTimeTrg_[i] ) dqmStore_->removeElement( meSCSeedTimeTrg_[i]->getName() );
00636          meSCSeedTimeTrg_[i] = 0;
00637       }
00638 
00639       if ( meTrg_ ) dqmStore_->removeElement( meTrg_->getName() );
00640       meTrg_ = 0;
00641 
00642       if ( meTrgExcl_ ) dqmStore_->removeElement( meTrgExcl_->getName() );
00643       meTrgExcl_ = 0;
00644 
00645 
00646    }
00647 
00648    init_ = false;
00649 
00650 }
00651 
00652 void EBClusterTaskExtras::endJob(void){
00653 
00654    LogInfo("EBClusterTaskExtras") << "analyzed " << ievt_ << " events";
00655 
00656    if ( enableCleanup_ ) this->cleanup();
00657 
00658 }
00659 
00660 void EBClusterTaskExtras::analyze(const Event& e, const EventSetup& c) {
00661 
00662    using namespace std;
00663 
00664    if ( ! init_ ) this->setup();
00665 
00666    ievt_++;
00667 
00668    // --- Barrel Super Clusters ---
00669 
00670    Handle<SuperClusterCollection> pSuperClusters;
00671 
00672    if ( e.getByLabel(SuperClusterCollection_, pSuperClusters) ) {
00673 
00674       //int nscc = pSuperClusters->size();
00675 
00676       //TLorentzVector sc1_p(0,0,0,0);
00677       //TLorentzVector sc2_p(0,0,0,0);
00678 
00679       for ( SuperClusterCollection::const_iterator sCluster = pSuperClusters->begin(); sCluster != pSuperClusters->end(); ++sCluster ) {
00680 
00681          // seed and shapes
00682          edm::Handle< EcalRecHitCollection > pEBRecHits;
00683          e.getByLabel( EcalRecHitCollection_, pEBRecHits );
00684          if ( pEBRecHits.isValid() ) {
00685             const EcalRecHitCollection *ebRecHits = pEBRecHits.product();
00686 
00687             // Find the seed rec hit
00688             // <= CMSSW_3_0_X
00689             //std::vector<DetId> sIds = sCluster->getHitsByDetId();
00690             // >= CMSSW_3_1_X
00691             std::vector< std::pair<DetId,float> > sIds = sCluster->hitsAndFractions();
00692 
00693             EcalRecHitCollection::const_iterator seedItr = ebRecHits->begin();
00694             EcalRecHitCollection::const_iterator secondItr = ebRecHits->begin();
00695 
00696             // <= CMSSW_3_0_X
00697             //for(std::vector<DetId>::const_iterator idItr = sIds.begin(); idItr != sIds.end(); ++idItr) {
00698                //if(idItr->det() != DetId::Ecal) { continue; }
00699                //EcalRecHitCollection::const_iterator hitItr = ebRecHits->find((*idItr));
00700                // <= CMSSW_3_1_X
00701                for(std::vector< std::pair<DetId,float> >::const_iterator idItr = sIds.begin(); idItr != sIds.end(); ++idItr) {
00702                 DetId id = idItr->first;
00703                if(id.det() != DetId::Ecal) { continue; }
00704                EcalRecHitCollection::const_iterator hitItr = ebRecHits->find(id);
00705                if(hitItr == ebRecHits->end()) { continue; }
00706                if(hitItr->energy() > secondItr->energy()) { secondItr = hitItr; }
00707                if(hitItr->energy() > seedItr->energy()) { std::swap(seedItr,secondItr); }
00708             }
00709 
00710             EBDetId seedId = (EBDetId) seedItr->id();
00711 
00712             // Prepare to fill maps
00713             int ebeta = seedId.ieta();
00714             int ebphi = seedId.iphi();
00715             float xebeta = ebeta - 0.5 * seedId.zside();
00716             float xebphi = ebphi - 0.5;
00717 
00718             // get the gain info;
00719             edm::ESHandle<EcalADCToGeVConstant> pAgc;
00720             c.get<EcalADCToGeVConstantRcd>().get(pAgc);
00721 
00722             vector<bool> triggers = determineTriggers(e,c);
00723 
00724 #ifndef EBCLUSTERTASKEXTRAS_DQMOFFLINE
00725             float e2nd = secondItr->energy();
00726             float eMax = seedItr->energy();
00727             int ism = Numbers::iSM(seedId);
00728 
00729             // energy, size
00730             if(meSCEneLow_) meSCEneLow_->Fill( sCluster->energy() );
00731             if(meSCEneHigh_) meSCEneHigh_->Fill( sCluster->energy() );
00732             if(meSCSizBC_) meSCSizBC_->Fill( float(sCluster->clustersSize()) );
00733             if(meSCSizPhi_) meSCSizPhi_->Fill(xebphi,sCluster->clustersSize());
00734 
00735             if(meSCSizCrystal_) meSCSizCrystal_->Fill(sIds.size());
00736             if(meSCSeedEne_) meSCSeedEne_->Fill(eMax);
00737             if(meSCEne2_) meSCEne2_->Fill(eMax+e2nd);
00738             //if(meSCEneVsEMax_) meSCEneVsEMax_->Fill(eMax,sCluster->energy());
00739 
00740             if(meSCSeedMapOccTT_) meSCSeedMapOccTT_->Fill(xebphi, xebeta);
00741             if(sIds.size() == 1) {
00742                if(meSCEneSingleCrystal_) meSCEneSingleCrystal_->Fill(sCluster->energy());
00743                if(meSCSeedMapOccSingleCrystal_) meSCSeedMapOccSingleCrystal_->Fill(xebphi, xebeta);
00744             }
00745 
00746             if(sCluster->energy() > 2) if(meSCSeedMapOccHighEne_) meSCSeedMapOccHighEne_->Fill(xebphi, xebeta);
00747             if(pAgc.isValid()) {
00748                const EcalADCToGeVConstant* agc = pAgc.product();
00749                if(seedItr->energy() / agc->getEBValue() > 12) {
00750                   if(meSCSeedTimeVsAmp_) meSCSeedTimeVsAmp_->Fill(seedItr->time() + 5,sCluster->energy());
00751                   if(meSCSeedTime_) meSCSeedTime_->Fill(seedItr->time() + 5);
00752                   if (ism >=  1 && ism <= 18 && meSCSeedTimeEBM_)  meSCSeedTimeEBM_->Fill(seedItr->time() + 5);
00753                   if (ism >= 19 && ism <= 36 && meSCSeedTimeEBP_)  meSCSeedTimeEBP_->Fill(seedItr->time() + 5);
00754                   if (ism >=  4 && ism <=  7 && meSCSeedTimeEBMTop_)  meSCSeedTimeEBMTop_->Fill(seedItr->time() + 5);
00755                   if (ism >= 22 && ism <= 25 && meSCSeedTimeEBPTop_)  meSCSeedTimeEBPTop_->Fill(seedItr->time() + 5);
00756                   if (ism >= 13 && ism <= 16 && meSCSeedTimeEBMBot_)  meSCSeedTimeEBMBot_->Fill(seedItr->time() + 5);
00757                   if (ism >= 31 && ism <= 34 && meSCSeedTimeEBPBot_)  meSCSeedTimeEBPBot_->Fill(seedItr->time() + 5);
00758                   if(meSCSeedTimePerFed_[ism-1]) meSCSeedTimePerFed_[ism-1]->Fill(seedItr->time() + 5);
00759                   if(meSCSeedMapTimeTT_) meSCSeedMapTimeTT_->Fill(xebphi,xebeta,seedItr->time() + 5);
00760                   if(meSCSeedMapTimeMod_) meSCSeedMapTimeMod_->Fill(xebphi,xebeta,seedItr->time() + 5);
00761                   if(meSCSeedTimeVsPhi_) meSCSeedTimeVsPhi_->Fill(xebphi,seedItr->time() + 5);
00762                }
00763             }
00764             else {
00765                LogWarning("EBClusterTaskExtras") << "EcalADCToGeVConstant not valid";
00766             }
00767 
00768             for(int i=0;i!=5;++i) {
00769                if(triggers[i]) {
00770                   if(meSCSeedMapOccTrg_[i]) meSCSeedMapOccTrg_[i]->Fill(xebphi, xebeta);
00771                   bool isExclusive = true;
00772                   for(int j=0;j!=5;++j) {
00773                      if(pAgc.isValid()) 
00774                         if(meSCSeedMapTimeTrgMod_[i]) meSCSeedMapTimeTrgMod_[i]->Fill(xebphi, xebeta, seedItr->time() + 5);
00775                      if(j != i && triggers[j])
00776                         isExclusive = false;
00777                   }
00778                   if(isExclusive) if(meSCSeedMapOccTrgExcl_[i]) meSCSeedMapOccTrgExcl_[i]->Fill(xebphi, xebeta);
00779                }
00780             }
00781 #endif
00782             if(meSCSizCrystalVsEne_) meSCSizCrystalVsEne_->Fill(sCluster->energy(),sIds.size());
00783 
00784             if(meSCSeedMapOcc_) meSCSeedMapOcc_->Fill(xebphi, xebeta);
00785 
00786             if(sCluster->energy() > 2) if(meSCSeedMapOccHighEneTT_) meSCSeedMapOccHighEneTT_->Fill(xebphi, xebeta);
00787             
00788 
00789             for(int i=0;i!=5;++i) {
00790                if(triggers[i]) {
00791                   if(meSCSeedMapOccTrgTT_[i]) meSCSeedMapOccTrgTT_[i]->Fill(xebphi, xebeta);
00792                   if(meTrg_) meTrg_->Fill(i);
00793 
00794                   if(pAgc.isValid()) {
00795                      if(meSCSeedMapTimeTrgTT_[i]) meSCSeedMapTimeTrgTT_[i]->Fill(xebphi, xebeta, seedItr->time() + 5);
00796                      if(meSCSeedTimeTrg_[i]) meSCSeedTimeTrg_[i]->Fill(seedItr->time() + 5);
00797                   }
00798                   else {
00799                      LogWarning("EBClusterTaskExtras") << "EcalADCToGeVConstant not valid";
00800                   }
00801 
00802                   bool isExclusive = true;
00803                   for(int j=0;j!=5;++j) {
00804                      if(j != i && triggers[j])
00805                         isExclusive = false;
00806                   }
00807 
00808                   if(isExclusive) if(meTrgExcl_) meTrgExcl_->Fill(i);
00809                }
00810             }
00811          }
00812          else {
00813             LogWarning("EBClusterTaskExtras") << EcalRecHitCollection_ << " not available";
00814          }
00815 
00816       }
00817    } else {
00818 
00819       LogWarning("EBClusterTaskExtras") << SuperClusterCollection_ << " not available";
00820 
00821    }
00822 
00823 }
00824 
00825 std::vector<bool> 
00826 EBClusterTaskExtras::determineTriggers(const edm::Event& iEvent, const edm::EventSetup& eventSetup) {
00827 
00828    using namespace edm;
00829    std::vector<bool> l1Triggers; //CSC,DT,HCAL,ECAL,RPC
00830    //0 , 1 , 2 , 3  , 4
00831    for(int i=0;i<5;i++)
00832       l1Triggers.push_back(false);
00833 
00834    // get the GMTReadoutCollection
00835    edm::Handle<L1MuGMTReadoutCollection> gmtrc_handle;
00836    iEvent.getByLabel(l1GMTReadoutRecTag_,gmtrc_handle);
00837    L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
00838    if (!(gmtrc_handle.isValid()))  
00839    {
00840       LogWarning("EcalCosmicsHists") << "l1MuGMTReadoutCollection" << " not available";
00841       return l1Triggers;
00842    }  
00843    // get hold of L1GlobalReadoutRecord
00844    edm::Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
00845    iEvent.getByLabel(l1GTReadoutRecTag_,L1GTRR);
00846 
00847    //Ecal
00848    edm::ESHandle<L1GtTriggerMenu> menuRcd;
00849    eventSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
00850    const L1GtTriggerMenu* menu = menuRcd.product();
00851    edm::Handle< L1GlobalTriggerReadoutRecord > gtRecord;
00852    iEvent.getByLabel( edm::InputTag("gtDigis"), gtRecord);
00853    // Get dWord after masking disabled bits
00854    const DecisionWord dWord = gtRecord->decisionWord();
00855 
00856    bool l1SingleEG2 = menu->gtAlgorithmResult("L1_SingleEG2", dWord);
00857    bool l1SingleEG5 = menu->gtAlgorithmResult("L1_SingleEG5", dWord);
00858    bool l1SingleEG8 = menu->gtAlgorithmResult("L1_SingleEG8", dWord);
00859    bool l1SingleEG10 = menu->gtAlgorithmResult("L1_SingleEG10", dWord);
00860    bool l1SingleEG12 = menu->gtAlgorithmResult("L1_SingleEG12", dWord);
00861    bool l1SingleEG15 = menu->gtAlgorithmResult("L1_SingleEG15", dWord);
00862    bool l1SingleEG20 = menu->gtAlgorithmResult("L1_SingleEG20", dWord);
00863    bool l1SingleEG25 = menu->gtAlgorithmResult("L1_SingleEG25", dWord);
00864    bool l1DoubleNoIsoEGBTBtight = menu->gtAlgorithmResult("L1_DoubleNoIsoEG_BTB_tight", dWord);
00865    bool l1DoubleNoIsoEGBTBloose = menu->gtAlgorithmResult("L1_DoubleNoIsoEG_BTB_loose ", dWord);
00866    bool l1DoubleNoIsoEGTopBottom = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottom", dWord);
00867    bool l1DoubleNoIsoEGTopBottomCen  = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCen", dWord);
00868    bool l1DoubleNoIsoEGTopBottomCen2  = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCen2", dWord);
00869    bool l1DoubleNoIsoEGTopBottomCenVert  = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCenVert", dWord);
00870 
00871    l1Triggers[ECAL_TRIGGER] = l1SingleEG2 || l1SingleEG5 || l1SingleEG8 || l1SingleEG10 || l1SingleEG12 || l1SingleEG15
00872       || l1SingleEG20 || l1SingleEG25 || l1DoubleNoIsoEGBTBtight || l1DoubleNoIsoEGBTBloose
00873       || l1DoubleNoIsoEGTopBottom || l1DoubleNoIsoEGTopBottomCen || l1DoubleNoIsoEGTopBottomCen2
00874       || l1DoubleNoIsoEGTopBottomCenVert;
00875 
00876    std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
00877    std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
00878    for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
00879       std::vector<L1MuRegionalCand>::const_iterator iter1;
00880       std::vector<L1MuRegionalCand> rmc;
00881 
00882       //DT triggers
00883       int idt = 0;
00884       rmc = igmtrr->getDTBXCands();
00885       for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00886          if ( !(*iter1).empty() ) {
00887             idt++;
00888          }
00889       }
00890       //if(idt>0) std::cout << "Found " << idt << " valid DT candidates in bx wrt. L1A = " 
00891       //  << igmtrr->getBxInEvent() << std::endl;
00892       if(igmtrr->getBxInEvent()==0 && idt>0) l1Triggers[DT_TRIGGER] = true;
00893 
00894       //RPC triggers
00895       int irpcb = 0;
00896       rmc = igmtrr->getBrlRPCCands();
00897       for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00898          if ( !(*iter1).empty() ) {
00899             irpcb++;
00900          }
00901       }
00902       //if(irpcb>0) std::cout << "Found " << irpcb << " valid RPC candidates in bx wrt. L1A = " 
00903       //  << igmtrr->getBxInEvent() << std::endl;
00904       if(igmtrr->getBxInEvent()==0 && irpcb>0) l1Triggers[RPC_TRIGGER] = true;
00905 
00906       //CSC Triggers
00907       int icsc = 0;
00908       rmc = igmtrr->getCSCCands();
00909       for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00910          if ( !(*iter1).empty() ) {
00911             icsc++;
00912          }
00913       }
00914       //if(icsc>0) std::cout << "Found " << icsc << " valid CSC candidates in bx wrt. L1A = " 
00915       //  << igmtrr->getBxInEvent() << std::endl;
00916       if(igmtrr->getBxInEvent()==0 && icsc>0) l1Triggers[CSC_TRIGGER] = true;
00917    }
00918 
00919    L1GlobalTriggerReadoutRecord const* gtrr = L1GTRR.product();
00920 
00921    for(int ibx=-1; ibx<=1; ibx++) {
00922       bool hcal_top = false;
00923       bool hcal_bot = false;
00924       const L1GtPsbWord psb = gtrr->gtPsbWord(0xbb0d,ibx);
00925       std::vector<int> valid_phi; 
00926       if((psb.aData(4)&0x3f) >= 1) {valid_phi.push_back( (psb.aData(4)>>10)&0x1f ); }
00927       if((psb.bData(4)&0x3f) >= 1) {valid_phi.push_back( (psb.bData(4)>>10)&0x1f ); }
00928       if((psb.aData(5)&0x3f) >= 1) {valid_phi.push_back( (psb.aData(5)>>10)&0x1f ); }
00929       if((psb.bData(5)&0x3f) >= 1) {valid_phi.push_back( (psb.bData(5)>>10)&0x1f ); }
00930       std::vector<int>::const_iterator iphi;
00931       for(iphi=valid_phi.begin(); iphi!=valid_phi.end(); iphi++) {
00932          //std::cout << "Found HCAL mip with phi=" << *iphi << " in bx wrt. L1A = " << ibx << std::endl;
00933          if(*iphi<9) hcal_top=true;
00934          if(*iphi>8) hcal_bot=true;
00935       }
00936       if(ibx==0 && hcal_top && hcal_bot) l1Triggers[HCAL_TRIGGER]=true;
00937    }     
00938    return l1Triggers;
00939 }