CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQMOffline/Ecal/src/EEClusterTaskExtras.cc

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