Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-05 22:25:50

0001 // -*- C++ -*-
0002 //
0003 // Package:   EcalCosmicsHists
0004 // Class:     EcalCosmicsHists
0005 //
0006 /**\class EcalCosmicsHists EcalCosmicsHists.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 
0014 #include "CaloOnlineTools/EcalTools/plugins/EcalCosmicsHists.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0017 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0018 
0019 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0020 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0021 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0022 
0023 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0024 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0025 
0026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0028 
0029 using namespace cms;
0030 using namespace edm;
0031 using namespace std;
0032 
0033 //
0034 // constants, enums and typedefs
0035 //
0036 
0037 //
0038 // static data member definitions
0039 //
0040 
0041 //
0042 // constructors and destructor
0043 //
0044 EcalCosmicsHists::EcalCosmicsHists(const edm::ParameterSet& iConfig)
0045     : ecalRawDataColl_(iConfig.getParameter<edm::InputTag>("ecalRawDataColl")),
0046       ecalRecHitCollectionEB_(iConfig.getParameter<edm::InputTag>("ecalRecHitCollectionEB")),
0047       ecalRecHitCollectionEE_(iConfig.getParameter<edm::InputTag>("ecalRecHitCollectionEE")),
0048       barrelClusterCollection_(iConfig.getParameter<edm::InputTag>("barrelClusterCollection")),
0049       endcapClusterCollection_(iConfig.getParameter<edm::InputTag>("endcapClusterCollection")),
0050       l1GTReadoutRecTag_(iConfig.getUntrackedParameter<std::string>("L1GlobalReadoutRecord", "gtDigis")),
0051       l1GMTReadoutRecTag_(iConfig.getUntrackedParameter<std::string>("L1GlobalMuonReadoutRecord", "gtDigis")),
0052       barrelClusterToken_(consumes<reco::SuperClusterCollection>(barrelClusterCollection_)),
0053       endcapClusterToken_(consumes<reco::SuperClusterCollection>(endcapClusterCollection_)),
0054       ebRecHitToken_(consumes<EcalRecHitCollection>(ecalRecHitCollectionEB_)),
0055       eeRecHitToken_(consumes<EcalRecHitCollection>(ecalRecHitCollectionEE_)),
0056       ecalRawDataToken_(consumes<EcalRawDataCollection>(ecalRawDataColl_)),
0057       tracksToken_(consumes<reco::TrackCollection>(edm::InputTag("cosmicMuons"))),
0058       tracksBarrelToken_(consumes<reco::TrackCollection>(edm::InputTag("cosmicMuonsBarrelOnly"))),
0059       hbheRecHitToken_(consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"))),
0060       hfRecHitToken_(consumes<HFRecHitCollection>(edm::InputTag("hfreco"))),
0061       hoRecHitToken_(consumes<HORecHitCollection>(edm::InputTag("horeco"))),
0062       l1MuGMTToken_(consumes<L1MuGMTReadoutCollection>(l1GMTReadoutRecTag_)),
0063       l1GTReadoutToken_(consumes<L1GlobalTriggerReadoutRecord>(l1GTReadoutRecTag_)),
0064       gtRecordToken_(consumes<L1GlobalTriggerReadoutRecord>(edm::InputTag("gtDigis"))),
0065       ecalADCToGeVConstantToken_(esConsumes()),
0066       l1MenuToken_(esConsumes()),
0067       ecalMappingToken_(esConsumes<edm::Transition::BeginRun>()),
0068       runNum_(-1),
0069       histRangeMax_(iConfig.getUntrackedParameter<double>("histogramMaxRange", 1.8)),
0070       histRangeMin_(iConfig.getUntrackedParameter<double>("histogramMinRange", 0.0)),
0071       minTimingAmpEB_(iConfig.getUntrackedParameter<double>("MinTimingAmpEB", 0.100)),
0072       minTimingAmpEE_(iConfig.getUntrackedParameter<double>("MinTimingAmpEE", 0.100)),
0073       minRecHitAmpEB_(iConfig.getUntrackedParameter<double>("MinRecHitAmpEB", 0.027)),
0074       minRecHitAmpEE_(iConfig.getUntrackedParameter<double>("MinRecHitAmpEE", 0.18)),
0075       minHighEnergy_(iConfig.getUntrackedParameter<double>("MinHighEnergy", 2.0)),
0076       fileName_(iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalCosmicHists"))),
0077       runInFileName_(iConfig.getUntrackedParameter<bool>("runInFileName", true)),
0078       startTime_(iConfig.getUntrackedParameter<double>("TimeStampStart", 1215107133.)),
0079       runTimeLength_(iConfig.getUntrackedParameter<double>("TimeStampLength", 3.)),
0080       numTimingBins_(iConfig.getUntrackedParameter<int>("TimeStampBins", 1800)) {
0081   naiveEvtNum_ = 0;
0082   cosmicCounter_ = 0;
0083   cosmicCounterEB_ = 0;
0084   cosmicCounterEEM_ = 0;
0085   cosmicCounterEEP_ = 0;
0086   cosmicCounterTopBottom_ = 0;
0087 
0088   // TrackAssociator parameters
0089   edm::ParameterSet trkParameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
0090   edm::ConsumesCollector iC = consumesCollector();
0091   trackParameters_.loadParameters(trkParameters, iC);
0092   trackAssociator_.useDefaultPropagator();
0093 
0094   string title1 = "Seed Energy for All Feds; Seed Energy (GeV)";
0095   string name1 = "SeedEnergyAllFEDs";
0096   int numBins = 200;  //(int)round(histRangeMax_-histRangeMin_)+1;
0097   allFedsHist_ = new TH1F(name1.c_str(), title1.c_str(), numBins, histRangeMin_, histRangeMax_);
0098 
0099   fedMap_ = new EcalFedMap();
0100 }
0101 
0102 EcalCosmicsHists::~EcalCosmicsHists() {}
0103 
0104 //
0105 // member functions
0106 //
0107 
0108 // ------------ method called to for each event  ------------
0109 void EcalCosmicsHists::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
0110   bool hasEndcapClusters = true;
0111   int ievt = iEvent.id().event();
0112 
0113   edm::Handle<reco::SuperClusterCollection> bscHandle;
0114   edm::Handle<reco::SuperClusterCollection> escHandle;
0115 
0116   naiveEvtNum_++;
0117 
0118   //LogDebug("EcalCosmicsHists")<< "  My Event: " << naiveEvtNum_ << " " << iEvent.id().run() << " " << iEvent.id().event() << " " << iEvent.time().value();
0119   //LogDebug("EcalCosmicsHists")<< "Timestamp: " << iEvent.id().run() << " " << iEvent.id().event() << " " << iEvent.time().value();
0120 
0121   // check DB payload
0122   const auto& agc = iSetup.getData(ecalADCToGeVConstantToken_);
0123   if (naiveEvtNum_ <= 1) {
0124     LogWarning("EcalCosmicsHists") << "Global EB ADC->GeV scale: " << agc.getEBValue() << " GeV/ADC count";
0125     LogWarning("EcalCosmicsHists") << "Global EE ADC->GeV scale: " << agc.getEEValue() << " GeV/ADC count";
0126   }
0127 
0128   //===================TIMESTAMP INFORMTION=================================
0129   // Code added to get the time in seconds
0130   unsigned int timeStampLow = (0xFFFFFFFF & iEvent.time().value());
0131   unsigned int timeStampHigh = (iEvent.time().value() >> 32);
0132   double rawEventTime = (double)(timeStampHigh) + ((double)(timeStampLow) / 1000000.);
0133   double eventTime = rawEventTime - startTime_;  //Notice the subtraction of the "starttime"
0134   //std::cout << "Event Time " << eventTime << " High " <<timeStampHigh<< " low"<<timeStampLow <<" value " <<iEvent.time().value() << std::endl;
0135   //========================================================================
0136 
0137   iEvent.getByToken(barrelClusterToken_, bscHandle);
0138   if (!(bscHandle.isValid())) {
0139     LogWarning("EcalCosmicsHists") << barrelClusterCollection_ << " not available";
0140     return;
0141   }
0142   LogDebug("EcalCosmicsHists") << "event " << ievt;
0143 
0144   iEvent.getByToken(endcapClusterToken_, escHandle);
0145   if (!(escHandle.isValid())) {
0146     LogWarning("EcalCosmicsHists") << endcapClusterCollection_ << " not available";
0147     hasEndcapClusters = false;
0148     //return;
0149   }
0150 
0151   Handle<EcalRecHitCollection> hits;
0152   iEvent.getByToken(ebRecHitToken_, hits);
0153   if (!(hits.isValid())) {
0154     LogWarning("EcalCosmicsHists") << ecalRecHitCollectionEB_ << " not available";
0155     return;
0156   }
0157   Handle<EcalRecHitCollection> hitsEE;
0158   iEvent.getByToken(eeRecHitToken_, hitsEE);
0159   if (!(hitsEE.isValid())) {
0160     LogWarning("EcalCosmicsHists") << ecalRecHitCollectionEE_ << " not available";
0161     return;
0162   }
0163 
0164   Handle<EcalRawDataCollection> DCCHeaders;
0165   iEvent.getByToken(ecalRawDataToken_, DCCHeaders);
0166   if (!DCCHeaders.isValid())
0167     LogWarning("EcalCosmicsHists") << "DCC headers not available";
0168 
0169   //make the bx histos right here
0170   //TODO: Right now we are filling histos for errors...
0171   int orbit = -100;
0172   int bx = -100;
0173   int runType = -100;
0174 
0175   for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
0176        ++headerItr) {
0177     headerItr->getEventSettings();
0178     int myorbit = headerItr->getOrbit();
0179     int mybx = headerItr->getBX();
0180     int myRunType = headerItr->getRunType();
0181     int FEDid = headerItr->fedId();
0182     TH2F* dccRuntypeHist = FEDsAndDCCRuntypeVsBxHists_[FEDid];
0183     if (dccRuntypeHist == nullptr) {
0184       initHists(FEDid);
0185       dccRuntypeHist = FEDsAndDCCRuntypeVsBxHists_[FEDid];
0186     }
0187     dccRuntypeHist->Fill(mybx, myRunType);
0188 
0189     if (bx == -100) {
0190       bx = mybx;
0191     } else if (bx != mybx) {
0192       LogWarning("EcalCosmicsHists") << "This header has a conflicting bx OTHERS were " << bx << " here " << mybx;
0193       dccBXErrorByFEDHist_->Fill(headerItr->fedId());
0194       if (bx != -100) {
0195         dccErrorVsBxHist_->Fill(bx, 0);
0196       }
0197     }
0198 
0199     if (runType == -100) {
0200       runType = myRunType;
0201     } else if (runType != myRunType) {
0202       LogWarning("EcalCosmicsHists") << "This header has a conflicting runType OTHERS were " << bx << " here " << mybx;
0203       dccRuntypeErrorByFEDHist_->Fill(headerItr->fedId());
0204       if (bx != -100)
0205         dccErrorVsBxHist_->Fill(bx, 2);
0206     }
0207 
0208     if (orbit == -100) {
0209       orbit = myorbit;
0210     } else if (orbit != myorbit) {
0211       LogWarning("EcalCosmicsHists") << "This header has a conflicting orbit; OTHERS were " << orbit << " here "
0212                                      << myorbit;
0213       dccOrbitErrorByFEDHist_->Fill(headerItr->fedId());
0214       if (bx != -100)
0215         dccErrorVsBxHist_->Fill(bx, 1);
0216     }
0217   }
0218   dccEventVsBxHist_->Fill(bx, runType);
0219   dccRuntypeHist_->Fill(runType);
0220 
0221   std::vector<bool> l1Triggers = determineTriggers(iEvent, iSetup);
0222   bool isEcalL1 = l1Triggers[4];
0223   bool isHCALL1 = l1Triggers[3];
0224   bool isRPCL1 = l1Triggers[2];
0225   bool isCSCL1 = l1Triggers[1];
0226   bool isDTL1 = l1Triggers[0];
0227 
0228   if (runNum_ == -1) {
0229     runNum_ = iEvent.id().run();
0230   }
0231 
0232   int numberOfCosmics = 0;
0233   int numberOfCosmicsEB = 0;
0234   int numberOfCosmicsEEP = 0;
0235   int numberOfCosmicsEEM = 0;
0236   int numberOfCosmicsTop = 0;
0237   int numberOfCosmicsBottom = 0;
0238   int numberOfHighEClusters = 0;
0239   //int eventnum = iEvent.id().event();
0240   std::vector<EBDetId> seeds;
0241 
0242   //++++++++++++++++++BEGIN LOOP OVER EB SUPERCLUSTERS+++++++++++++++++++++++++//
0243 
0244   const reco::SuperClusterCollection* clusterCollection_p = bscHandle.product();
0245   for (reco::SuperClusterCollection::const_iterator clus = clusterCollection_p->begin();
0246        clus != clusterCollection_p->end();
0247        ++clus) {
0248     double energy = clus->energy();
0249     double phi = clus->phi();
0250     double eta = clus->eta();
0251     double time = -1000.0;
0252     double ampli = 0.;
0253     double secondMin = 0.;
0254     double secondTime = -1000.;
0255     int numXtalsinCluster = 0;
0256 
0257     EBDetId maxDet;
0258     EBDetId secDet;
0259 
0260     numberofBCinSC_->Fill(clus->clustersSize());
0261     numberofBCinSCphi_->Fill(phi, clus->clustersSize());
0262 
0263     for (reco::CaloCluster_iterator bclus = (clus->clustersBegin()); bclus != (clus->clustersEnd()); ++bclus) {
0264       double cphi = (*bclus)->phi();
0265       double ceta = (*bclus)->eta();
0266       TrueBCOccupancy_->Fill(cphi, ceta);
0267       TrueBCOccupancyCoarse_->Fill(cphi, ceta);
0268     }
0269 
0270     std::vector<std::pair<DetId, float> > clusterDetIds = clus->hitsAndFractions();  //get these from the cluster
0271     for (std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterDetIds.begin();
0272          detitr != clusterDetIds.end();
0273          ++detitr) {
0274       //Here I use the "find" on a digi collection... I have been warned...
0275       if ((*detitr).first.det() != DetId::Ecal) {
0276         std::cout << " det is " << (*detitr).first.det() << std::endl;
0277         continue;
0278       }
0279       if ((*detitr).first.subdetId() != EcalBarrel) {
0280         std::cout << " subdet is " << (*detitr).first.subdetId() << std::endl;
0281         continue;
0282       }
0283       EcalRecHitCollection::const_iterator thishit = hits->find((*detitr).first);
0284       if (thishit == hits->end())
0285         continue;
0286       //The checking above should no longer be needed...... as only those in the cluster would already have rechits..
0287 
0288       EcalRecHit myhit = (*thishit);
0289 
0290       double thisamp = myhit.energy();
0291       if (thisamp > minRecHitAmpEB_) {
0292         numXtalsinCluster++;
0293       }
0294       if (thisamp > secondMin) {
0295         secondMin = thisamp;
0296         secondTime = myhit.time();
0297         secDet = (EBDetId)(*detitr).first;
0298       }
0299       if (secondMin > ampli) {
0300         std::swap(ampli, secondMin);
0301         std::swap(time, secondTime);
0302         std::swap(maxDet, secDet);
0303       }
0304     }
0305 
0306     double fullnumXtalsinCluster = clusterDetIds.size();
0307 
0308     float E2 = ampli + secondMin;
0309     EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId((EBDetId)maxDet);
0310     int FEDid = 600 + elecId.dccId();
0311 
0312     numberOfCosmics++;
0313     numberOfCosmicsEB++;
0314 
0315     //Set some more values
0316     seeds.push_back(maxDet);
0317     int ieta = maxDet.ieta();
0318     int iphi = maxDet.iphi();
0319     int ietaSM = maxDet.ietaSM();
0320     int iphiSM = maxDet.iphiSM();
0321 
0322     int LM = ecalElectronicsMap_->getLMNumber(maxDet);  //FIX ME
0323 
0324     // top and bottom clusters
0325     if (iphi > 0 && iphi < 180) {
0326       numberOfCosmicsTop++;
0327     } else {
0328       numberOfCosmicsBottom++;
0329     }
0330 
0331     // fill the proper hist
0332     TH1F* uRecHist = FEDsAndHists_[FEDid];
0333     TH1F* E2uRecHist = FEDsAndE2Hists_[FEDid];
0334     TH1F* energyuRecHist = FEDsAndenergyHists_[FEDid];
0335     TH1F* timingHist = FEDsAndTimingHists_[FEDid];
0336     TH1F* freqHist = FEDsAndFrequencyHists_[FEDid];
0337     TH1F* iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
0338     TH1F* ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
0339     TH2F* timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
0340     TH2F* timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
0341     TH2F* E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
0342     TH2F* energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
0343     TH2F* occupHist = FEDsAndOccupancyHists_[FEDid];
0344     TH2F* timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
0345     TH2F* timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
0346 
0347     if (uRecHist == nullptr) {
0348       initHists(FEDid);
0349       uRecHist = FEDsAndHists_[FEDid];
0350       E2uRecHist = FEDsAndE2Hists_[FEDid];
0351       energyuRecHist = FEDsAndenergyHists_[FEDid];
0352       timingHist = FEDsAndTimingHists_[FEDid];
0353       freqHist = FEDsAndFrequencyHists_[FEDid];
0354       timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
0355       timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
0356       iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
0357       ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
0358       E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
0359       energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
0360       occupHist = FEDsAndOccupancyHists_[FEDid];
0361       timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
0362       timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
0363     }
0364 
0365     uRecHist->Fill(ampli);
0366     E2uRecHist->Fill(E2);
0367     E2vsE1uRecHist->Fill(ampli, E2);
0368     energyuRecHist->Fill(energy);
0369     energyvsE1uRecHist->Fill(ampli, energy);
0370     allFedsHist_->Fill(ampli);
0371     allFedsE2Hist_->Fill(E2);
0372     allFedsenergyHist_->Fill(energy);
0373     allFedsenergyHighHist_->Fill(energy);
0374     allFedsE2vsE1Hist_->Fill(ampli, E2);
0375     allFedsenergyvsE1Hist_->Fill(ampli, energy);
0376     freqHist->Fill(naiveEvtNum_);
0377     iphiProfileHist->Fill(iphi);
0378     ietaProfileHist->Fill(ieta);
0379 
0380     allFedsFrequencyHist_->Fill(naiveEvtNum_);
0381     allFedsiPhiProfileHist_->Fill(iphi);
0382     allFedsiEtaProfileHist_->Fill(ieta);
0383     allOccupancy_->Fill(iphi, ieta);
0384     TrueOccupancy_->Fill(phi, eta);
0385     allOccupancyCoarse_->Fill(iphi, ieta);
0386     TrueOccupancyCoarse_->Fill(phi, eta);
0387     allFedsNumXtalsInClusterHist_->Fill(numXtalsinCluster);
0388     NumXtalsInClusterHist_->Fill(fullnumXtalsinCluster);
0389     numxtalsVsEnergy_->Fill(energy, numXtalsinCluster);
0390     numxtalsVsHighEnergy_->Fill(energy, numXtalsinCluster);
0391 
0392     //Fill the hists for the time stamp information
0393     allFedsFreqTimeVsPhiHist_->Fill(iphi, eventTime);
0394     allFedsFreqTimeVsPhiTTHist_->Fill(iphi, eventTime);
0395     allFedsFreqTimeVsEtaHist_->Fill(eventTime, ieta);
0396     allFedsFreqTimeVsEtaTTHist_->Fill(eventTime, ieta);
0397     //end time stamp hists
0398 
0399     occupHist->Fill(ietaSM, iphiSM);
0400     if (fullnumXtalsinCluster == 1) {
0401       allOccupancySingleXtal_->Fill(iphi, ieta);
0402       energySingleXtalHist_->Fill(energy);
0403     }
0404 
0405     // Exclusive trigger plots
0406 
0407     if (isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1) {
0408       allOccupancyExclusiveECAL_->Fill(iphi, ieta);
0409       allOccupancyCoarseExclusiveECAL_->Fill(iphi, ieta);
0410       if (ampli > minTimingAmpEB_) {
0411         allFedsTimingHistECAL_->Fill(time);
0412         allFedsTimingPhiEtaHistECAL_->Fill(iphi, ieta, time);
0413         allFedsTimingTTHistECAL_->Fill(iphi, ieta, time);
0414         allFedsTimingLMHistECAL_->Fill(LM, time);
0415       }
0416       triggerExclusiveHist_->Fill(0);
0417     }
0418 
0419     if (!isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && isHCALL1) {
0420       allOccupancyExclusiveHCAL_->Fill(iphi, ieta);
0421       allOccupancyCoarseExclusiveHCAL_->Fill(iphi, ieta);
0422       if (ampli > minTimingAmpEB_) {
0423         allFedsTimingHistHCAL_->Fill(time);
0424         allFedsTimingPhiEtaHistHCAL_->Fill(iphi, ieta, time);
0425         allFedsTimingTTHistHCAL_->Fill(iphi, ieta, time);
0426         allFedsTimingLMHistHCAL_->Fill(LM, time);
0427       }
0428       triggerExclusiveHist_->Fill(1);
0429     }
0430 
0431     if (!isEcalL1 && isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1) {
0432       allOccupancyExclusiveDT_->Fill(iphi, ieta);
0433       allOccupancyCoarseExclusiveDT_->Fill(iphi, ieta);
0434       if (ampli > minTimingAmpEB_) {
0435         allFedsTimingHistDT_->Fill(time);
0436         allFedsTimingPhiEtaHistDT_->Fill(iphi, ieta, time);
0437         allFedsTimingTTHistDT_->Fill(iphi, ieta, time);
0438         allFedsTimingLMHistDT_->Fill(LM, time);
0439       }
0440       triggerExclusiveHist_->Fill(2);
0441     }
0442 
0443     if (!isEcalL1 && !isDTL1 && isRPCL1 && !isCSCL1 && !isHCALL1) {
0444       allOccupancyExclusiveRPC_->Fill(iphi, ieta);
0445       allOccupancyCoarseExclusiveRPC_->Fill(iphi, ieta);
0446       if (ampli > minTimingAmpEB_) {
0447         allFedsTimingHistRPC_->Fill(time);
0448         allFedsTimingPhiEtaHistRPC_->Fill(iphi, ieta, time);
0449         allFedsTimingTTHistRPC_->Fill(iphi, ieta, time);
0450         allFedsTimingLMHistRPC_->Fill(LM, time);
0451       }
0452       triggerExclusiveHist_->Fill(3);
0453     }
0454 
0455     if (!isEcalL1 && !isDTL1 && !isRPCL1 && isCSCL1 && !isHCALL1) {
0456       allOccupancyExclusiveCSC_->Fill(iphi, ieta);
0457       allOccupancyCoarseExclusiveCSC_->Fill(iphi, ieta);
0458       if (ampli > minTimingAmpEB_) {
0459         allFedsTimingHistCSC_->Fill(time);
0460         allFedsTimingPhiEtaHistCSC_->Fill(iphi, ieta, time);
0461         allFedsTimingTTHistCSC_->Fill(iphi, ieta, time);
0462         allFedsTimingLMHistCSC_->Fill(LM, time);
0463       }
0464       triggerExclusiveHist_->Fill(4);
0465     }
0466 
0467     // Inclusive trigger plots
0468 
0469     if (isEcalL1) {
0470       triggerHist_->Fill(0);
0471       allOccupancyECAL_->Fill(iphi, ieta);
0472       allOccupancyCoarseECAL_->Fill(iphi, ieta);
0473     }
0474     if (isHCALL1) {
0475       triggerHist_->Fill(1);
0476       allOccupancyHCAL_->Fill(iphi, ieta);
0477       allOccupancyCoarseHCAL_->Fill(iphi, ieta);
0478     }
0479     if (isDTL1) {
0480       triggerHist_->Fill(2);
0481       allOccupancyDT_->Fill(iphi, ieta);
0482       allOccupancyCoarseDT_->Fill(iphi, ieta);
0483     }
0484     if (isRPCL1) {
0485       triggerHist_->Fill(3);
0486       allOccupancyRPC_->Fill(iphi, ieta);
0487       allOccupancyCoarseRPC_->Fill(iphi, ieta);
0488     }
0489     if (isCSCL1) {
0490       triggerHist_->Fill(4);
0491       allOccupancyCSC_->Fill(iphi, ieta);
0492       allOccupancyCoarseCSC_->Fill(iphi, ieta);
0493     }
0494 
0495     // Fill histo for Ecal+muon coincidence
0496     if (isEcalL1 && (isCSCL1 || isRPCL1 || isDTL1) && !isHCALL1)
0497       allFedsTimingHistEcalMuon_->Fill(time);
0498 
0499     if (ampli > minTimingAmpEB_) {
0500       timingHist->Fill(time);
0501       timingHistVsFreq->Fill(time, naiveEvtNum_);
0502       timingHistVsAmp->Fill(time, ampli);
0503       allFedsTimingHist_->Fill(time);
0504       allFedsTimingVsAmpHist_->Fill(time, ampli);
0505       allFedsTimingVsFreqHist_->Fill(time, naiveEvtNum_);
0506       timingHistVsPhi->Fill(time, iphiSM);
0507       timingHistVsModule->Fill(time, ietaSM);
0508       allFedsTimingPhiHist_->Fill(iphi, time);
0509       allFedsTimingPhiEtaHist_->Fill(iphi, ieta, time);
0510       allFedsTimingTTHist_->Fill(iphi, ieta, time);
0511       allFedsTimingLMHist_->Fill(LM, time);
0512       if (FEDid >= 610 && FEDid <= 627)
0513         allFedsTimingPhiEbmHist_->Fill(iphi, time);
0514       if (FEDid >= 628 && FEDid <= 645)
0515         allFedsTimingPhiEbpHist_->Fill(iphi, time);
0516 
0517       if (FEDid >= 610 && FEDid <= 627)
0518         allFedsTimingEbmHist_->Fill(time);
0519       if (FEDid >= 628 && FEDid <= 645)
0520         allFedsTimingEbpHist_->Fill(time);
0521       if (FEDid >= 613 && FEDid <= 616)
0522         allFedsTimingEbmTopHist_->Fill(time);
0523       if (FEDid >= 631 && FEDid <= 634)
0524         allFedsTimingEbpTopHist_->Fill(time);
0525       if (FEDid >= 622 && FEDid <= 625)
0526         allFedsTimingEbmBottomHist_->Fill(time);
0527       if (FEDid >= 640 && FEDid <= 643)
0528         allFedsTimingEbpBottomHist_->Fill(time);
0529     }
0530 
0531     // *** High Energy Clusters Analysis ** //
0532 
0533     if (energy > minHighEnergy_) {
0534       LogInfo("EcalCosmicsHists") << "High energy event " << iEvent.id().run() << " : " << iEvent.id().event() << " "
0535                                   << naiveEvtNum_ << " : " << energy << " " << numXtalsinCluster << " : " << iphi << " "
0536                                   << ieta << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1 << isCSCL1;
0537 
0538       numberOfHighEClusters++;
0539       allOccupancyHighEnergy_->Fill(iphi, ieta);
0540       allOccupancyHighEnergyCoarse_->Fill(iphi, ieta);
0541       allFedsOccupancyHighEnergyHist_->Fill(iphi, ieta, energy);
0542       allFedsenergyOnlyHighHist_->Fill(energy);
0543 
0544       HighEnergy_2GeV_occuCoarse->Fill(iphi, ieta);
0545       HighEnergy_2GeV_occu3D->Fill(iphi, ieta, energy);
0546 
0547       HighEnergy_NumXtal->Fill(fullnumXtalsinCluster);
0548       HighEnergy_NumXtalFedId->Fill(FEDid, fullnumXtalsinCluster);
0549       HighEnergy_NumXtaliphi->Fill(iphi, fullnumXtalsinCluster);
0550       HighEnergy_energy3D->Fill(iphi, ieta, energy);
0551       HighEnergy_energyNumXtal->Fill(fullnumXtalsinCluster, energy);
0552 
0553       if (energy > 100.0) {
0554         LogInfo("EcalCosmicsHists") << "Very high energy event " << iEvent.id().run() << " : " << iEvent.id().event()
0555                                     << " " << naiveEvtNum_ << " : " << energy << " " << numXtalsinCluster << " : "
0556                                     << iphi << " " << ieta << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1
0557                                     << isCSCL1;
0558 
0559         HighEnergy_100GeV_occuCoarse->Fill(iphi, ieta);
0560         HighEnergy_100GeV_occu3D->Fill(iphi, ieta, energy);
0561       }
0562     }
0563 
0564     // *** end of High Energy Clusters analysis *** //
0565 
0566   }  //++++++++++++++++++END LOOP OVER EB SUPERCLUSTERS+++++++++++++++++++++++//
0567 
0568   //+++++++++++++++++++LOOP OVER ENDCAP EE CLUSTERS++++++++++++++++++++//
0569 
0570   if (hasEndcapClusters) {
0571     clusterCollection_p = escHandle.product();
0572     for (reco::SuperClusterCollection::const_iterator clus = clusterCollection_p->begin();
0573          clus != clusterCollection_p->end();
0574          ++clus) {
0575       double energy = clus->energy();
0576       //double phi    = clus->phi();
0577       //double eta    = clus->eta();
0578       double time = -1000.0;
0579       double ampli = 0.;
0580       double secondMin = 0.;
0581       double secondTime = -1000.;
0582       int clusSize = clus->clustersSize();
0583       int numXtalsinCluster = 0;
0584 
0585       EEDetId maxDet;
0586       EEDetId secDet;
0587       //LogInfo("EcalCosmicsHists") << "Here is what we initialized the maxDet to: " << maxDet;
0588 
0589       //      for (reco::basicCluster_iterator bclus = (clus->clustersBegin()); bclus != (clus->clustersEnd()); ++bclus) {
0590       //    //double cphi = (*bclus)->phi();
0591       //    //double ceta = (*bclus)->eta();
0592       //         //TODO: extend histos to EE
0593       //         //TrueBCOccupancy_->Fill(cphi,ceta);
0594       //         //TrueBCOccupancyCoarse_->Fill(cphi,ceta);
0595       //       }
0596 
0597       std::vector<std::pair<DetId, float> > clusterDetIds = clus->hitsAndFractions();  //get these from the cluster
0598       for (std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterDetIds.begin();
0599            detitr != clusterDetIds.end();
0600            ++detitr) {
0601         //LogInfo("EcalCosmicsHists") << " Here is the DetId inside the cluster: " << (EEDetId)(*detitr);
0602         //Here I use the "find" on a digi collection... I have been warned...
0603 
0604         if ((*detitr).first.det() != DetId::Ecal) {
0605           LogError("EcalCosmicsHists") << " det is " << (*detitr).first.det();
0606           continue;
0607         }
0608         if ((*detitr).first.subdetId() != EcalEndcap) {
0609           LogError("EcalCosmicsHists") << " subdet is " << (*detitr).first.subdetId();
0610           continue;
0611         }
0612 
0613         EcalRecHitCollection::const_iterator thishit = hitsEE->find((*detitr).first);
0614 
0615         if (thishit == hitsEE->end()) {
0616           LogInfo("EcalCosmicsHists") << " WARNING: EEDetId not found in the RecHit collection!";
0617           continue;
0618         }
0619         // The checking above should no longer be needed......
0620         // as only those in the cluster would already have rechits..
0621 
0622         EcalRecHit myhit = (*thishit);
0623 
0624         //LogInfo("EcalCosmicsHists") << " Found hit for DetId: " << (EEDetId)(*detitr);
0625         double thisamp = myhit.energy();
0626         if (thisamp > minRecHitAmpEE_) {
0627           numXtalsinCluster++;
0628         }
0629         if (thisamp > secondMin) {
0630           secondMin = thisamp;
0631           secondTime = myhit.time();
0632           secDet = (EEDetId)(*detitr).first;
0633         }
0634         if (secondMin > ampli) {
0635           std::swap(ampli, secondMin);
0636           std::swap(time, secondTime);
0637           std::swap(maxDet, secDet);
0638         }
0639 
0640         //LogInfo("EcalCosmicsHists") << "maxDetId is now: " << (EEDetId)(maxDet);
0641       }
0642 
0643       double fullnumXtalsinCluster = clusterDetIds.size();
0644 
0645       float E2 = ampli + secondMin;
0646 
0647       ecalElectronicsMap_->getElectronicsId((EEDetId)maxDet);
0648       //int FEDid = 600+elecId.dccId();
0649 
0650       //Set some more values
0651       //TODO: need to fix the seeds vector to be DetId or have another one for EE
0652       //seeds.push_back(maxDet);
0653 
0654       int ix = maxDet.ix();
0655       int iy = maxDet.iy();
0656       int iz = maxDet.zside();
0657 
0658       //      LogWarning("EcalCosmicsHists") << "EE cluster (x,y,z) : ( "
0659       //                     << ix << " , " << iy << " , " << iz
0660       //                     << " ) " << std::endl;
0661 
0662       if (!EEDetId::validDetId(ix, iy, iz)) {
0663         LogWarning("EcalCosmicsHists") << "INVALID EE DetId !!!";
0664         return;
0665       }
0666 
0667       numberOfCosmics++;
0668       if (iz < 0) {
0669         numberOfCosmicsEEM++;
0670       } else {
0671         numberOfCosmicsEEP++;
0672       }
0673 
0674       //int LM = ecalElectronicsMap_->getLMNumber(maxDet) ;//FIX ME
0675 
0676       //TODO: extend histos to EE
0677       //TH1F* uRecHist = FEDsAndHists_[FEDid];
0678       //TH1F* E2uRecHist = FEDsAndE2Hists_[FEDid];
0679       //TH1F* energyuRecHist = FEDsAndenergyHists_[FEDid];
0680       //TH1F* timingHist = FEDsAndTimingHists_[FEDid];
0681       //TH1F* freqHist = FEDsAndFrequencyHists_[FEDid];
0682       //TH1F* iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
0683       //TH1F* ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
0684       //TH2F* timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
0685       //TH2F* timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
0686       //TH2F* E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
0687       //TH2F* energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
0688       //TH1F* numXtalInClusterHist = FEDsAndNumXtalsInClusterHists_[FEDid];
0689       //TH2F* occupHist = FEDsAndOccupancyHists_[FEDid];
0690       //TH2F* timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
0691       //TH2F* timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
0692       //if(uRecHist==0)
0693       //{
0694       //  initHists(FEDid);
0695       //  uRecHist = FEDsAndHists_[FEDid];
0696       //  E2uRecHist = FEDsAndE2Hists_[FEDid];
0697       //  energyuRecHist = FEDsAndenergyHists_[FEDid];
0698       //  timingHist = FEDsAndTimingHists_[FEDid];
0699       //  freqHist = FEDsAndFrequencyHists_[FEDid];
0700       //  timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
0701       //  timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
0702       //  iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
0703       //  ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
0704       //  E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
0705       //  energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
0706       //  numXtalInClusterHist = FEDsAndNumXtalsInClusterHists_[FEDid];
0707       //  occupHist = FEDsAndOccupancyHists_[FEDid];
0708       //  timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
0709       //  timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
0710       //}
0711       //uRecHist->Fill(ampli);
0712       //E2uRecHist->Fill(E2);
0713       //E2vsE1uRecHist->Fill(ampli,E2);
0714       //energyuRecHist->Fill(energy);
0715       //energyvsE1uRecHist->Fill(ampli,energy);
0716       //allFedsHist_->Fill(ampli);
0717 
0718       if (iz < 0) {
0719         EEM_FedsSeedEnergyHist_->Fill(ampli);
0720         EEM_FedsenergyHist_->Fill(energy);
0721         EEM_FedsenergyHighHist_->Fill(energy);
0722         EEM_FedsE2Hist_->Fill(E2);
0723         EEM_FedsE2vsE1Hist_->Fill(ampli, E2);
0724         EEM_FedsenergyvsE1Hist_->Fill(ampli, energy);
0725         EEM_AllOccupancyCoarse_->Fill(ix - 0.5, iy - 0.5);
0726         EEM_AllOccupancy_->Fill(ix - 0.5, iy - 0.5);
0727 
0728         EEM_FedsNumXtalsInClusterHist_->Fill(numXtalsinCluster);
0729         EEM_NumXtalsInClusterHist_->Fill(fullnumXtalsinCluster);
0730         EEM_numxtalsVsEnergy_->Fill(energy, numXtalsinCluster);
0731         EEM_numxtalsVsHighEnergy_->Fill(energy, numXtalsinCluster);
0732         EEM_numberofBCinSC_->Fill(clusSize);
0733 
0734         if (fullnumXtalsinCluster == 1) {
0735           EEM_OccupancySingleXtal_->Fill(ix - 0.5, iy - 0.5);
0736           EEM_energySingleXtalHist_->Fill(energy);
0737         }
0738 
0739         if (ampli > minTimingAmpEE_) {
0740           EEM_FedsTimingHist_->Fill(time);
0741           EEM_FedsTimingVsAmpHist_->Fill(time, ampli);
0742           EEM_FedsTimingTTHist_->Fill(ix - 0.5, iy - 0.5, time);
0743         }
0744 
0745         // Exclusive trigger plots
0746 
0747         if (isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1) {
0748           EEM_OccupancyExclusiveECAL_->Fill(ix - 0.5, iy - 0.5);
0749           EEM_OccupancyCoarseExclusiveECAL_->Fill(ix - 0.5, iy - 0.5);
0750           if (ampli > minTimingAmpEE_) {
0751             EEM_FedsTimingHistECAL_->Fill(time);
0752             EEM_FedsTimingTTHistECAL_->Fill(ix - 0.5, iy - 0.5, time);
0753           }
0754           EEM_triggerExclusiveHist_->Fill(0);
0755         }
0756 
0757         if (!isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && isHCALL1) {
0758           EEM_OccupancyExclusiveHCAL_->Fill(ix - 0.5, iy - 0.5);
0759           EEM_OccupancyCoarseExclusiveHCAL_->Fill(ix - 0.5, iy - 0.5);
0760           if (ampli > minTimingAmpEE_) {
0761             EEM_FedsTimingHistHCAL_->Fill(time);
0762             EEM_FedsTimingTTHistHCAL_->Fill(ix - 0.5, iy - 0.5, time);
0763           }
0764           EEM_triggerExclusiveHist_->Fill(1);
0765         }
0766 
0767         if (!isEcalL1 && isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1) {
0768           EEM_OccupancyExclusiveDT_->Fill(ix - 0.5, iy - 0.5);
0769           EEM_OccupancyCoarseExclusiveDT_->Fill(ix - 0.5, iy - 0.5);
0770           if (ampli > minTimingAmpEE_) {
0771             EEM_FedsTimingHistDT_->Fill(time);
0772             EEM_FedsTimingTTHistDT_->Fill(ix - 0.5, iy - 0.5, time);
0773           }
0774           EEM_triggerExclusiveHist_->Fill(2);
0775         }
0776 
0777         if (!isEcalL1 && !isDTL1 && isRPCL1 && !isCSCL1 && !isHCALL1) {
0778           EEM_OccupancyExclusiveRPC_->Fill(ix - 0.5, iy - 0.5);
0779           EEM_OccupancyCoarseExclusiveRPC_->Fill(ix - 0.5, iy - 0.5);
0780           if (ampli > minTimingAmpEE_) {
0781             EEM_FedsTimingHistRPC_->Fill(time);
0782             EEM_FedsTimingTTHistRPC_->Fill(ix - 0.5, iy - 0.5, time);
0783           }
0784           EEM_triggerExclusiveHist_->Fill(3);
0785         }
0786 
0787         if (!isEcalL1 && !isDTL1 && !isRPCL1 && isCSCL1 && !isHCALL1) {
0788           EEM_OccupancyExclusiveCSC_->Fill(ix - 0.5, iy - 0.5);
0789           EEM_OccupancyCoarseExclusiveCSC_->Fill(ix - 0.5, iy - 0.5);
0790           if (ampli > minTimingAmpEE_) {
0791             EEM_FedsTimingHistCSC_->Fill(time);
0792             EEM_FedsTimingTTHistCSC_->Fill(ix - 0.5, iy - 0.5, time);
0793           }
0794           EEM_triggerExclusiveHist_->Fill(4);
0795         }
0796 
0797         // Inclusive trigger plots
0798 
0799         if (isEcalL1) {
0800           EEM_triggerHist_->Fill(0);
0801           EEM_OccupancyECAL_->Fill(ix - 0.5, iy - 0.5);
0802           EEM_OccupancyCoarseECAL_->Fill(ix - 0.5, iy - 0.5);
0803         }
0804         if (isHCALL1) {
0805           EEM_triggerHist_->Fill(1);
0806           EEM_OccupancyHCAL_->Fill(ix - 0.5, iy - 0.5);
0807           EEM_OccupancyCoarseHCAL_->Fill(ix - 0.5, iy - 0.5);
0808         }
0809         if (isDTL1) {
0810           EEM_triggerHist_->Fill(2);
0811           EEM_OccupancyDT_->Fill(ix - 0.5, iy - 0.5);
0812           EEM_OccupancyCoarseDT_->Fill(ix - 0.5, iy - 0.5);
0813         }
0814         if (isRPCL1) {
0815           EEM_triggerHist_->Fill(3);
0816           EEM_OccupancyRPC_->Fill(ix - 0.5, iy - 0.5);
0817           EEM_OccupancyCoarseRPC_->Fill(ix - 0.5, iy - 0.5);
0818         }
0819         if (isCSCL1) {
0820           EEM_triggerHist_->Fill(4);
0821           EEM_OccupancyCSC_->Fill(ix - 0.5, iy - 0.5);
0822           EEM_OccupancyCoarseCSC_->Fill(ix - 0.5, iy - 0.5);
0823         }
0824 
0825       } else {
0826         EEP_FedsSeedEnergyHist_->Fill(ampli);
0827         EEP_FedsenergyHist_->Fill(energy);
0828         EEP_FedsenergyHighHist_->Fill(energy);
0829         EEP_FedsE2Hist_->Fill(E2);
0830         EEP_FedsE2vsE1Hist_->Fill(ampli, E2);
0831         EEP_FedsenergyvsE1Hist_->Fill(ampli, energy);
0832         EEP_AllOccupancyCoarse_->Fill(ix - 0.5, iy - 0.5);
0833         EEP_AllOccupancy_->Fill(ix - 0.5, iy - 0.5);
0834 
0835         EEP_FedsNumXtalsInClusterHist_->Fill(numXtalsinCluster);
0836         EEP_NumXtalsInClusterHist_->Fill(fullnumXtalsinCluster);
0837         EEP_numxtalsVsEnergy_->Fill(energy, numXtalsinCluster);
0838         EEP_numxtalsVsHighEnergy_->Fill(energy, numXtalsinCluster);
0839         EEP_numberofBCinSC_->Fill(clusSize);
0840 
0841         if (fullnumXtalsinCluster == 1) {
0842           EEP_OccupancySingleXtal_->Fill(ix - 0.5, iy - 0.5);
0843           EEP_energySingleXtalHist_->Fill(energy);
0844         }
0845 
0846         if (ampli > minTimingAmpEE_) {
0847           EEP_FedsTimingHist_->Fill(time);
0848           EEP_FedsTimingVsAmpHist_->Fill(time, ampli);
0849           EEP_FedsTimingTTHist_->Fill(ix - 0.5, iy - 0.5, time);
0850         }
0851 
0852         // Exclusive trigger plots
0853 
0854         if (isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1) {
0855           EEP_OccupancyExclusiveECAL_->Fill(ix - 0.5, iy - 0.5);
0856           EEP_OccupancyCoarseExclusiveECAL_->Fill(ix - 0.5, iy - 0.5);
0857           if (ampli > minTimingAmpEE_) {
0858             EEP_FedsTimingHistECAL_->Fill(time);
0859             EEP_FedsTimingTTHistECAL_->Fill(ix - 0.5, iy - 0.5, time);
0860           }
0861           EEP_triggerExclusiveHist_->Fill(0);
0862         }
0863 
0864         if (!isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && isHCALL1) {
0865           EEP_OccupancyExclusiveHCAL_->Fill(ix - 0.5, iy - 0.5);
0866           EEP_OccupancyCoarseExclusiveHCAL_->Fill(ix - 0.5, iy - 0.5);
0867           if (ampli > minTimingAmpEE_) {
0868             EEP_FedsTimingHistHCAL_->Fill(time);
0869             EEP_FedsTimingTTHistHCAL_->Fill(ix - 0.5, iy - 0.5, time);
0870           }
0871           EEP_triggerExclusiveHist_->Fill(1);
0872         }
0873 
0874         if (!isEcalL1 && isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1) {
0875           EEP_OccupancyExclusiveDT_->Fill(ix - 0.5, iy - 0.5);
0876           EEP_OccupancyCoarseExclusiveDT_->Fill(ix - 0.5, iy - 0.5);
0877           if (ampli > minTimingAmpEE_) {
0878             EEP_FedsTimingHistDT_->Fill(time);
0879             EEP_FedsTimingTTHistDT_->Fill(ix - 0.5, iy - 0.5, time);
0880           }
0881           EEP_triggerExclusiveHist_->Fill(2);
0882         }
0883 
0884         if (!isEcalL1 && !isDTL1 && isRPCL1 && !isCSCL1 && !isHCALL1) {
0885           EEP_OccupancyExclusiveRPC_->Fill(ix - 0.5, iy - 0.5);
0886           EEP_OccupancyCoarseExclusiveRPC_->Fill(ix - 0.5, iy - 0.5);
0887           if (ampli > minTimingAmpEE_) {
0888             EEP_FedsTimingHistRPC_->Fill(time);
0889             EEP_FedsTimingTTHistRPC_->Fill(ix - 0.5, iy - 0.5, time);
0890           }
0891           EEP_triggerExclusiveHist_->Fill(3);
0892         }
0893 
0894         if (!isEcalL1 && !isDTL1 && !isRPCL1 && isCSCL1 && !isHCALL1) {
0895           EEP_OccupancyExclusiveCSC_->Fill(ix - 0.5, iy - 0.5);
0896           EEP_OccupancyCoarseExclusiveCSC_->Fill(ix - 0.5, iy - 0.5);
0897           if (ampli > minTimingAmpEE_) {
0898             EEP_FedsTimingHistCSC_->Fill(time);
0899             EEP_FedsTimingTTHistCSC_->Fill(ix - 0.5, iy - 0.5, time);
0900           }
0901           EEP_triggerExclusiveHist_->Fill(4);
0902         }
0903 
0904         // Inclusive trigger plots
0905 
0906         if (isEcalL1) {
0907           EEP_triggerHist_->Fill(0);
0908           EEP_OccupancyECAL_->Fill(ix - 0.5, iy - 0.5);
0909           EEP_OccupancyCoarseECAL_->Fill(ix - 0.5, iy - 0.5);
0910         }
0911         if (isHCALL1) {
0912           EEP_triggerHist_->Fill(1);
0913           EEP_OccupancyHCAL_->Fill(ix - 0.5, iy - 0.5);
0914           EEP_OccupancyCoarseHCAL_->Fill(ix - 0.5, iy - 0.5);
0915         }
0916         if (isDTL1) {
0917           EEP_triggerHist_->Fill(2);
0918           EEP_OccupancyDT_->Fill(ix - 0.5, iy - 0.5);
0919           EEP_OccupancyCoarseDT_->Fill(ix - 0.5, iy - 0.5);
0920         }
0921         if (isRPCL1) {
0922           EEP_triggerHist_->Fill(3);
0923           EEP_OccupancyRPC_->Fill(ix - 0.5, iy - 0.5);
0924           EEP_OccupancyCoarseRPC_->Fill(ix - 0.5, iy - 0.5);
0925         }
0926         if (isCSCL1) {
0927           EEP_triggerHist_->Fill(4);
0928           EEP_OccupancyCSC_->Fill(ix - 0.5, iy - 0.5);
0929           EEP_OccupancyCoarseCSC_->Fill(ix - 0.5, iy - 0.5);
0930         }
0931       }
0932 
0933       // *** High Energy Clusters Analysis ** //
0934 
0935       if (energy > minHighEnergy_) {
0936         LogInfo("EcalCosmicsHists") << "High energy event in EE " << iEvent.id().run() << " : " << iEvent.id().event()
0937                                     << " " << naiveEvtNum_ << " : " << energy << " " << numXtalsinCluster << " : " << ix
0938                                     << " " << iy << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1 << isCSCL1;
0939 
0940         //  numberOfHighEClusters++;
0941         //  allOccupancyHighEnergy_->Fill(iphi, ieta);
0942         //  allOccupancyHighEnergyCoarse_->Fill(iphi, ieta);
0943         //  allFedsOccupancyHighEnergyHist_->Fill(iphi,ieta,energy);
0944         if (iz < 0) {
0945           EEM_FedsenergyOnlyHighHist_->Fill(energy);
0946           EEM_OccupancyHighEnergy_->Fill(ix - 0.5, iy - 0.5);
0947           EEM_OccupancyHighEnergyCoarse_->Fill(ix - 0.5, iy - 0.5);
0948         } else {
0949           EEP_FedsenergyOnlyHighHist_->Fill(energy);
0950         }
0951         //  HighEnergy_2GeV_occuCoarse->Fill(iphi,ieta);
0952         //  HighEnergy_2GeV_occu3D->Fill(iphi,ieta,energy);
0953 
0954         //  HighEnergy_NumXtal->Fill(fullnumXtalsinCluster);
0955         //  HighEnergy_NumXtalFedId->Fill(FEDid,fullnumXtalsinCluster);
0956         //  HighEnergy_NumXtaliphi->Fill(iphi,fullnumXtalsinCluster);
0957         //  HighEnergy_energy3D->Fill(iphi,ieta,energy);
0958         //  HighEnergy_energyNumXtal->Fill(fullnumXtalsinCluster,energy);
0959 
0960         if (energy > 100.0) {
0961           LogInfo("EcalCosmicsHists") << "Very high energy event in EE " << iEvent.id().run() << " : "
0962                                       << iEvent.id().event() << " " << naiveEvtNum_ << " : " << energy << " "
0963                                       << numXtalsinCluster << " : " << ix << " " << iy << " : " << isEcalL1 << isHCALL1
0964                                       << isDTL1 << isRPCL1 << isCSCL1;
0965           //    HighEnergy_100GeV_occuCoarse->Fill(iphi,ieta);
0966           //    HighEnergy_100GeV_occu3D->Fill(iphi,ieta,energy);
0967         }
0968       }
0969 
0970       // *** end of High Energy Clusters analysis *** //
0971 
0972     }  //++++++++++++++++++END LOOP OVER EE SUPERCLUSTERS+++++++++++++++++++++++++++++++++++
0973   }
0974 
0975   HighEnergy_numClusHighEn->Fill(numberOfHighEClusters);
0976   HighEnergy_ratioClusters->Fill((double(numberOfHighEClusters)) / (double(numberOfCosmics)));
0977 
0978   numberofCosmicsHist_->Fill(numberOfCosmics);
0979   EEP_numberofCosmicsHist_->Fill(numberOfCosmicsEEP);
0980   EEM_numberofCosmicsHist_->Fill(numberOfCosmicsEEM);
0981   numberofCosmicsHistEB_->Fill(numberOfCosmicsEB);
0982 
0983   if (numberOfCosmics > 0) {
0984     cosmicCounter_++;
0985     numberofGoodEvtFreq_->Fill(naiveEvtNum_);
0986     allFedsFreqTimeHist_->Fill(eventTime);
0987     //This line will work in 21X!!
0988     //std::cout << " Orbit " <<   iEvent.orbitNumber() << " BX " << iEvent.bunchCrossing()<< std::endl;
0989     //std::cout << " BX " << iEvent.experimentType() << std::endl;
0990   }
0991 
0992   if (numberOfCosmicsEB > 0)
0993     cosmicCounterEB_++;
0994   if (numberOfCosmicsEEP > 0)
0995     cosmicCounterEEP_++;
0996   if (numberOfCosmicsEEM > 0)
0997     cosmicCounterEEM_++;
0998 
0999   if (numberOfCosmicsTop && numberOfCosmicsBottom) {
1000     cosmicCounterTopBottom_++;
1001     numberofCosmicsTopBottomHist_->Fill(numberOfCosmicsTop + numberOfCosmicsBottom);
1002   }
1003 
1004   // *** TrackAssociator *** //
1005 
1006   // get reco tracks
1007   edm::Handle<reco::TrackCollection> recoTracks;
1008   iEvent.getByToken(tracksToken_, recoTracks);
1009 
1010   if (recoTracks.isValid()) {
1011     std::map<int, std::vector<DetId> > trackDetIdMap;
1012     int tracks = 0;
1013     for (reco::TrackCollection::const_iterator recoTrack = recoTracks->begin(); recoTrack != recoTracks->end();
1014          ++recoTrack) {
1015       if (fabs(recoTrack->d0()) > 70 || fabs(recoTrack->dz()) > 70)
1016         continue;
1017       if (recoTrack->numberOfValidHits() < 20)
1018         continue;
1019 
1020       //if (recoTrack->pt() < 2) continue; // skip low Pt tracks
1021 
1022       TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *recoTrack, trackParameters_);
1023 
1024       //       edm::LogVerbatim("TrackAssociator") << "\n-------------------------------------------------------\n Track (pt,eta,phi): " <<
1025       //    recoTrack->pt() << " , " << recoTrack->eta() << " , " << recoTrack->phi() ;
1026       //       edm::LogVerbatim("TrackAssociator") << "Ecal energy in crossed crystals based on RecHits: " <<
1027       //    info.crossedEnergy(TrackDetMatchInfo::EcalRecHits);
1028       //       edm::LogVerbatim("TrackAssociator") << "Ecal energy in 3x3 crystals based on RecHits: " <<
1029       //    info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1);
1030       //       edm::LogVerbatim("TrackAssociator") << "Hcal energy in crossed towers based on RecHits: " <<
1031       //    info.crossedEnergy(TrackDetMatchInfo::HcalRecHits);
1032       //       edm::LogVerbatim("TrackAssociator") << "Hcal energy in 3x3 towers based on RecHits: " <<
1033       //    info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1);
1034       //       edm::LogVerbatim("TrackAssociator") << "Number of muon segment matches: " << info.numberOfSegments();
1035 
1036       //       std::cout << "\n-------------------------------------------------------\n Track (pt,eta,phi): " <<
1037       //    recoTrack->pt() << " , " << recoTrack->eta() << " , " << recoTrack->phi() << std::endl;
1038       //       std::cout << "Ecal energy in crossed crystals based on RecHits: " <<
1039       //    info.crossedEnergy(TrackDetMatchInfo::EcalRecHits) << std::endl;
1040       //       std::cout << "Ecal energy in 3x3 crystals based on RecHits: " <<
1041       //    info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1) << std::endl;
1042       //       std::cout << "Hcal energy in crossed towers based on RecHits: " <<
1043       //    info.crossedEnergy(TrackDetMatchInfo::HcalRecHits) << std::endl;
1044       //       std::cout << "Hcal energy in 3x3 towers based on RecHits: " <<
1045       //    info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1) << std::endl;
1046 
1047       for (unsigned int i = 0; i < info.crossedEcalIds.size(); i++) {
1048         // only checks for barrel
1049         if (info.crossedEcalIds[i].det() == DetId::Ecal && info.crossedEcalIds[i].subdetId() == 1) {
1050           EBDetId ebDetId(info.crossedEcalIds[i]);
1051           trackAssoc_muonsEcal_->Fill(ebDetId.iphi(), ebDetId.ieta());
1052           //std::cout << "Crossed iphi: " << ebDetId.iphi()
1053           //    << " ieta: " << ebDetId.ieta() << " : nCross " << info.crossedEcalIds.size() << std::endl;
1054 
1055           EcalRecHitCollection::const_iterator thishit = hits->find(ebDetId);
1056           if (thishit == hits->end())
1057             continue;
1058 
1059           //EcalRecHit myhit = (*thishit);
1060           //double thisamp = myhit.energy();
1061           //std::cout << " Crossed energy: " << thisamp << " : nCross " << info.crossedEcalIds.size() << std::endl;
1062         }
1063       }
1064 
1065       //edm::LogVerbatim("TrackAssociator") << " crossedEcalIds size: " << info.crossedEcalIds.size()
1066       //                  << " crossedEcalRecHits size: " << info.crossedEcalRecHits.size();
1067       numberofCrossedEcalIdsHist_->Fill(info.crossedEcalIds.size());
1068       tracks++;
1069       if (!info.crossedEcalIds.empty())
1070         trackDetIdMap.insert(std::pair<int, std::vector<DetId> >(tracks, info.crossedEcalIds));
1071     }
1072 
1073     // Now to match recoTracks with cosmic clusters
1074 
1075     int numAssocTracks = 0;
1076     int numAssocClusters = 0;
1077     edm::LogVerbatim("TrackAssociator") << "Matching cosmic clusters to tracks...";
1078     int numSeeds = seeds.size();
1079     int numTracks = trackDetIdMap.size();
1080     while (!seeds.empty() && !trackDetIdMap.empty()) {
1081       double bestDr = 1000;
1082       double bestDPhi = 1000;
1083       double bestDEta = 1000;
1084       double bestEtaTrack = 1000;
1085       double bestEtaSeed = 1000;
1086       double bestPhiTrack = 1000;
1087       double bestPhiSeed = 1000;
1088       EBDetId bestTrackDet;
1089       EBDetId bestSeed;
1090       int bestTrack = -1;
1091       std::map<EBDetId, EBDetId> trackDetIdToSeedMap;
1092 
1093       //edm::LogVerbatim("TrackAssociator") << "NumTracks:" << trackDetIdMap.size() << " numClusters:" << seeds.size();
1094 
1095       for (std::vector<EBDetId>::const_iterator seedItr = seeds.begin(); seedItr != seeds.end(); ++seedItr) {
1096         for (std::map<int, std::vector<DetId> >::const_iterator mapItr = trackDetIdMap.begin();
1097              mapItr != trackDetIdMap.end();
1098              ++mapItr) {
1099           for (unsigned int i = 0; i < mapItr->second.size(); i++) {
1100             // only checks for barrel
1101             if (mapItr->second[i].det() == DetId::Ecal && mapItr->second[i].subdetId() == 1) {
1102               EBDetId ebDet = (mapItr->second[i]);
1103               double seedEta = seedItr->ieta();
1104               double deta = ebDet.ieta() - seedEta;
1105               if (seedEta * ebDet.ieta() < 0)
1106                 deta > 0 ? (deta = deta - 1.) : (deta = deta + 1.);
1107               double dR;
1108               double dphi = ebDet.iphi() - seedItr->iphi();
1109               if (abs(dphi) > 180)
1110                 dphi > 0 ? (dphi = 360 - dphi) : (dphi = -360 - dphi);
1111               dR = sqrt(deta * deta + dphi * dphi);
1112               if (dR < bestDr) {
1113                 bestDr = dR;
1114                 bestDPhi = dphi;
1115                 bestDEta = deta;
1116                 bestTrackDet = mapItr->second[i];
1117                 bestTrack = mapItr->first;
1118                 bestSeed = (*seedItr);
1119                 bestEtaTrack = ebDet.ieta();
1120                 bestEtaSeed = seedEta;
1121                 bestPhiTrack = ebDet.iphi();
1122                 bestPhiSeed = seedItr->iphi();
1123               }
1124             }
1125           }
1126         }
1127       }
1128       if (bestDr < 1000) {
1129         //edm::LogVerbatim("TrackAssociator") << "Best deltaR from matched DetId's to cluster:" << bestDr;
1130         deltaRHist_->Fill(bestDr);
1131         deltaPhiHist_->Fill(bestDPhi);
1132         deltaEtaHist_->Fill(bestDEta);
1133         deltaEtaDeltaPhiHist_->Fill(bestDEta, bestDPhi);
1134         seedTrackEtaHist_->Fill(bestEtaSeed, bestEtaTrack);
1135         seedTrackPhiHist_->Fill(bestPhiSeed, bestPhiTrack);
1136         seeds.erase(find(seeds.begin(), seeds.end(), bestSeed));
1137         trackDetIdMap.erase(trackDetIdMap.find(bestTrack));
1138         trackDetIdToSeedMap[bestTrackDet] = bestSeed;
1139         numAssocTracks++;
1140         numAssocClusters++;
1141 
1142         // for high energy analysis
1143         if (bestDPhi < 1.5 && bestDEta < 1.8) {
1144           //edm::LogVerbatim("TrackAssociator") << "Best seed ieta and iphi: ("
1145           //                    << bestSeed.ieta() << ", " << bestSeed.iphi() << ") ";
1146           //check if the bestSeed is a High Energy one
1147           EcalRecHitCollection::const_iterator Ecalhit = hits->find(bestSeed);
1148           if (Ecalhit == hits->end()) {
1149             continue;
1150           }
1151           double EcalhitEnergy = Ecalhit->energy();
1152           //edm::LogVerbatim("TrackAssociator") << "Best seed energy: " << EcalhitEnergy ;
1153           HighEnergy_bestSeed->Fill(EcalhitEnergy);
1154           HighEnergy_bestSeedOccupancy->Fill(bestSeed.iphi(), bestSeed.ieta());
1155         }
1156       } else {
1157         edm::LogVerbatim("TrackAssociator") << "could not match cluster seed to track." << bestDr;
1158         break;  // no match found
1159       }
1160     }
1161     if (numSeeds > 0 && numTracks > 0) {
1162       ratioAssocClustersHist_->AddBinContent(1, numAssocClusters);
1163       ratioAssocClustersHist_->AddBinContent(2, numSeeds);
1164     }
1165     if (numTracks > 0) {
1166       ratioAssocTracksHist_->AddBinContent(1, numAssocTracks);
1167       ratioAssocTracksHist_->AddBinContent(2, numTracks);
1168       numberofCosmicsWTrackHist_->Fill(numSeeds);
1169     }
1170   } else {
1171     LogWarning("EcalCosmicsHists") << "!!! No TrackAssociator recoTracks !!!";
1172   }
1173 
1174   // Study on Tracks for High Energy events
1175   edm::Handle<reco::TrackCollection> recoTracksBarrel;
1176   iEvent.getByToken(tracksBarrelToken_, recoTracksBarrel);
1177   if (!recoTracksBarrel.isValid()) {
1178     edm::LogWarning("EcalCosmicsHists") << "RecoTracksBarrel not valid!! ";
1179   } else {
1180     HighEnergy_numRecoTrackBarrel->Fill(recoTracksBarrel->size());
1181     for (reco::TrackCollection::const_iterator recoTrack = recoTracksBarrel->begin();
1182          recoTrack != recoTracksBarrel->end();
1183          ++recoTrack) {
1184       //edm::LogWarning("EcalCosmicsHists") << "Track (pt,eta,phi): " << recoTrack->pt() << " , " << recoTrack->eta() << " , " << recoTrack->phi() ;
1185       //edm::LogWarning("EcalCosmicsHists") << "Track innermost hit: " << recoTrack->innerPosition().phi() ;
1186     }
1187 
1188     for (reco::SuperClusterCollection::const_iterator clus = clusterCollection_p->begin();
1189          clus != clusterCollection_p->end();
1190          ++clus) {
1191       double energy = clus->energy();
1192       double phi = clus->phi();
1193       double eta = clus->eta();
1194 
1195       if (recoTracksBarrel->empty())
1196         HighEnergy_0tracks_occu3D->Fill(phi, eta, energy);
1197       if (recoTracksBarrel->size() == 1)
1198         HighEnergy_1tracks_occu3D->Fill(phi, eta, energy);
1199       if (recoTracksBarrel->size() == 2)
1200         HighEnergy_2tracks_occu3D->Fill(phi, eta, energy);
1201 
1202       std::vector<std::pair<DetId, float> > clusterDetIds = clus->hitsAndFractions();  //get these from the cluster
1203       for (std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterDetIds.begin();
1204            detitr != clusterDetIds.end();
1205            ++detitr) {
1206         if ((*detitr).first.det() != DetId::Ecal) {
1207           continue;
1208         }
1209         if ((*detitr).first.subdetId() != EcalBarrel) {
1210           continue;
1211         }
1212         EcalRecHitCollection::const_iterator thishit = hits->find((*detitr).first);
1213         if (thishit == hits->end()) {
1214           continue;
1215         }
1216 
1217         double rechitenergy = thishit->energy();
1218         int ieta = ((EBDetId)(*detitr).first).ieta();
1219         int iphi = ((EBDetId)(*detitr).first).iphi();
1220         if (rechitenergy > minRecHitAmpEB_) {
1221           if (recoTracksBarrel->empty())
1222             HighEnergy_0tracks_occu3DXtal->Fill(iphi, ieta, rechitenergy);
1223           if (recoTracksBarrel->size() == 1)
1224             HighEnergy_1tracks_occu3DXtal->Fill(iphi, ieta, rechitenergy);
1225           if (recoTracksBarrel->size() == 2)
1226             HighEnergy_2tracks_occu3DXtal->Fill(iphi, ieta, rechitenergy);
1227 
1228           if (rechitenergy > 10)
1229             edm::LogWarning("EcalCosmicsHists") << "!!!!! Crystal with energy " << rechitenergy << " at (ieta,iphi) ("
1230                                                 << ieta << " ," << iphi << "); Id: " << (*detitr).first.det();
1231         }
1232       }
1233     }
1234 
1235     // look at angle between 2 recoTracks
1236     if (recoTracksBarrel->size() == 2) {
1237       reco::TrackCollection::const_iterator Track1 = recoTracksBarrel->begin();
1238       reco::TrackCollection::const_iterator Track2 = (recoTracksBarrel->begin()) + 1;
1239       float angle = (acos(sin(Track1->theta()) * cos(Track1->phi()) * sin(Track2->theta()) * cos(Track2->phi()) +
1240                           sin(Track1->theta()) * sin(Track1->phi()) * sin(Track2->theta()) * sin(Track2->phi()) +
1241                           cos(Track1->theta()) * cos(Track2->theta()))) /
1242                     0.017453292519943;
1243       //edm::LogWarning("EcalCosmicsHists") << "Tracks angle: " << angle;
1244       HighEnergy_TracksAngle->Fill(angle);
1245       if ((Track1->innerPosition().phi()) > 0 && (Track2->innerPosition().phi()) < 0) {
1246         //edm::LogWarning("EcalCosmicsHists") << "Top-bottom tracks";
1247         HighEnergy_TracksAngleTopBottom->Fill(angle);
1248       }
1249     }
1250   }
1251 
1252   // *** end of TrackAssociator code *** //
1253 
1254   // *** HCAL RecHits code *** //
1255 
1256   //hcal rechits
1257   edm::Handle<HBHERecHitCollection> hbhe;
1258   iEvent.getByToken(hbheRecHitToken_, hbhe);
1259 
1260   edm::Handle<HFRecHitCollection> hfrh;
1261   iEvent.getByToken(hfRecHitToken_, hfrh);
1262 
1263   edm::Handle<HORecHitCollection> horh;
1264   iEvent.getByToken(hoRecHitToken_, horh);
1265 
1266   if (hbhe.isValid()) {
1267     const HBHERecHitCollection hbheHit = *(hbhe.product());
1268     for (HBHERecHitCollection::const_iterator hhit = hbheHit.begin(); hhit != hbheHit.end(); hhit++) {
1269       //      if (hhit->energy() > 0.6){
1270       hcalEnergy_HBHE_->Fill(hhit->energy());
1271       //      }
1272     }
1273   } else {
1274     LogWarning("EcalCosmicHists") << " HBHE RecHits **NOT** VALID!! ";
1275   }
1276 
1277   if (hfrh.isValid()) {
1278     const HFRecHitCollection hfHit = *(hfrh.product());
1279     for (HFRecHitCollection::const_iterator hhit = hfHit.begin(); hhit != hfHit.end(); hhit++) {
1280       hcalEnergy_HF_->Fill(hhit->energy());
1281     }
1282   } else {
1283     LogWarning("EcalCosmicHists") << " HF RecHits **NOT** VALID!! ";
1284   }
1285 
1286   if (horh.isValid()) {
1287     const HORecHitCollection hoHit = *(horh.product());
1288     for (HORecHitCollection::const_iterator hhit = hoHit.begin(); hhit != hoHit.end(); hhit++) {
1289       //     if (hhit->energy() > 0.6){
1290       hcalEnergy_HO_->Fill(hhit->energy());
1291       //     }
1292     }
1293   } else {
1294     LogWarning("EcalCosmicHists") << " HO RecHits **NOT** VALID!! ";
1295   }
1296 
1297   // *** end of HCAL code *** //
1298 }
1299 
1300 std::vector<bool> EcalCosmicsHists::determineTriggers(const edm::Event& iEvent, const edm::EventSetup& eventSetup) {
1301   std::vector<bool> l1Triggers;  //DT,CSC,RPC,HCAL,ECAL
1302                                  //0 , 1 , 2 , 3  , 4
1303   l1Triggers.reserve(5);
1304   for (int i = 0; i < 5; i++)
1305     l1Triggers.push_back(false);
1306 
1307   // get the GMTReadoutCollection
1308   Handle<L1MuGMTReadoutCollection> gmtrc_handle;
1309   iEvent.getByToken(l1MuGMTToken_, gmtrc_handle);
1310   L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
1311   if (!(gmtrc_handle.isValid())) {
1312     LogWarning("EcalCosmicsHists") << "l1MuGMTReadoutCollection"
1313                                    << " not available";
1314     return l1Triggers;
1315   }
1316   // get hold of L1GlobalReadoutRecord
1317   Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
1318   iEvent.getByToken(l1GTReadoutToken_, L1GTRR);
1319 
1320   //Ecal
1321   const auto& menu = eventSetup.getData(l1MenuToken_);
1322   edm::Handle<L1GlobalTriggerReadoutRecord> gtRecord;
1323   iEvent.getByToken(gtRecordToken_, gtRecord);
1324   // Get dWord after masking disabled bits
1325   const DecisionWord dWord = gtRecord->decisionWord();
1326 
1327   bool l1SingleEG1 = menu.gtAlgorithmResult("L1_SingleEG1", dWord);
1328   bool l1SingleEG5 = menu.gtAlgorithmResult("L1_SingleEG5", dWord);
1329   bool l1SingleEG8 = menu.gtAlgorithmResult("L1_SingleEG8", dWord);
1330   bool l1SingleEG10 = menu.gtAlgorithmResult("L1_SingleEG10", dWord);
1331   bool l1SingleEG12 = menu.gtAlgorithmResult("L1_SingleEG12", dWord);
1332   bool l1SingleEG15 = menu.gtAlgorithmResult("L1_SingleEG15", dWord);
1333   bool l1SingleEG20 = menu.gtAlgorithmResult("L1_SingleEG20", dWord);
1334   bool l1SingleEG25 = menu.gtAlgorithmResult("L1_SingleEG25", dWord);
1335   bool l1DoubleNoIsoEGBTBtight = menu.gtAlgorithmResult("L1_DoubleNoIsoEG_BTB_tight", dWord);
1336   bool l1DoubleNoIsoEGBTBloose = menu.gtAlgorithmResult("L1_DoubleNoIsoEG_BTB_loose ", dWord);
1337   bool l1DoubleNoIsoEGTopBottom = menu.gtAlgorithmResult("L1_DoubleNoIsoEGTopBottom", dWord);
1338   bool l1DoubleNoIsoEGTopBottomCen = menu.gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCen", dWord);
1339   bool l1DoubleNoIsoEGTopBottomCen2 = menu.gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCen2", dWord);
1340   bool l1DoubleNoIsoEGTopBottomCenVert = menu.gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCenVert", dWord);
1341 
1342   l1Triggers[4] = l1SingleEG1 || l1SingleEG5 || l1SingleEG8 || l1SingleEG10 || l1SingleEG12 || l1SingleEG15 ||
1343                   l1SingleEG20 || l1SingleEG25 || l1DoubleNoIsoEGBTBtight || l1DoubleNoIsoEGBTBloose ||
1344                   l1DoubleNoIsoEGTopBottom || l1DoubleNoIsoEGTopBottomCen || l1DoubleNoIsoEGTopBottomCen2 ||
1345                   l1DoubleNoIsoEGTopBottomCenVert;
1346 
1347   std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
1348   std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
1349   for (igmtrr = gmt_records.begin(); igmtrr != gmt_records.end(); igmtrr++) {
1350     std::vector<L1MuRegionalCand>::const_iterator iter1;
1351     std::vector<L1MuRegionalCand> rmc;
1352 
1353     //DT triggers
1354     int idt = 0;
1355     rmc = igmtrr->getDTBXCands();
1356     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
1357       if (!(*iter1).empty()) {
1358         idt++;
1359       }
1360     }
1361     //if(idt>0) std::cout << "Found " << idt << " valid DT candidates in bx wrt. L1A = "
1362     //  << igmtrr->getBxInEvent() << std::endl;
1363     if (igmtrr->getBxInEvent() == 0 && idt > 0)
1364       l1Triggers[0] = true;
1365 
1366     //RPC triggers
1367     int irpcb = 0;
1368     rmc = igmtrr->getBrlRPCCands();
1369     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
1370       if (!(*iter1).empty()) {
1371         irpcb++;
1372       }
1373     }
1374     //if(irpcb>0) std::cout << "Found " << irpcb << " valid RPC candidates in bx wrt. L1A = "
1375     //  << igmtrr->getBxInEvent() << std::endl;
1376     if (igmtrr->getBxInEvent() == 0 && irpcb > 0)
1377       l1Triggers[2] = true;
1378 
1379     //CSC Triggers
1380     int icsc = 0;
1381     rmc = igmtrr->getCSCCands();
1382     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
1383       if (!(*iter1).empty()) {
1384         icsc++;
1385       }
1386     }
1387     //if(icsc>0) std::cout << "Found " << icsc << " valid CSC candidates in bx wrt. L1A = "
1388     //  << igmtrr->getBxInEvent() << std::endl;
1389     if (igmtrr->getBxInEvent() == 0 && icsc > 0)
1390       l1Triggers[1] = true;
1391   }
1392 
1393   L1GlobalTriggerReadoutRecord const* gtrr = L1GTRR.product();
1394 
1395   for (int ibx = -1; ibx <= 1; ibx++) {
1396     bool hcal_top = false;
1397     bool hcal_bot = false;
1398     const L1GtPsbWord psb = gtrr->gtPsbWord(0xbb0d, ibx);
1399     std::vector<int> valid_phi;
1400     if ((psb.aData(4) & 0x3f) >= 1) {
1401       valid_phi.push_back((psb.aData(4) >> 10) & 0x1f);
1402     }
1403     if ((psb.bData(4) & 0x3f) >= 1) {
1404       valid_phi.push_back((psb.bData(4) >> 10) & 0x1f);
1405     }
1406     if ((psb.aData(5) & 0x3f) >= 1) {
1407       valid_phi.push_back((psb.aData(5) >> 10) & 0x1f);
1408     }
1409     if ((psb.bData(5) & 0x3f) >= 1) {
1410       valid_phi.push_back((psb.bData(5) >> 10) & 0x1f);
1411     }
1412     std::vector<int>::const_iterator iphi;
1413     for (iphi = valid_phi.begin(); iphi != valid_phi.end(); iphi++) {
1414       //std::cout << "Found HCAL mip with phi=" << *iphi << " in bx wrt. L1A = " << ibx << std::endl;
1415       if (*iphi < 9)
1416         hcal_top = true;
1417       if (*iphi > 8)
1418         hcal_bot = true;
1419     }
1420     if (ibx == 0 && hcal_top && hcal_bot)
1421       l1Triggers[3] = true;
1422   }
1423 
1424   edm::LogInfo("EcalCosmicsHists") << "**** Trigger SourceSource ****";
1425   if (l1Triggers[0])
1426     edm::LogInfo("EcalCosmicsHists") << "DT";
1427   if (l1Triggers[2])
1428     edm::LogInfo("EcalCosmicsHists") << "RPC";
1429   if (l1Triggers[1])
1430     edm::LogInfo("EcalCosmicsHists") << "CSC";
1431   if (l1Triggers[3])
1432     edm::LogInfo("EcalCosmicsHists") << "HCAL";
1433   if (l1Triggers[4])
1434     edm::LogInfo("EcalCosmicsHists") << "ECAL";
1435   edm::LogInfo("EcalCosmicsHists") << "************************";
1436 
1437   return l1Triggers;
1438 }
1439 
1440 // insert the hist map into the map keyed by FED number
1441 void EcalCosmicsHists::initHists(int FED) {
1442   using namespace std;
1443 
1444   string FEDid = intToString(FED);
1445   string title1 = "Energy of Seed Crystal ";
1446   title1.append(fedMap_->getSliceFromFed(FED));
1447   title1.append(";Seed Energy (GeV);Number of Cosmics");
1448   string name1 = "SeedEnergyFED";
1449   name1.append(intToString(FED));
1450   int numBins = 200;  //(int)round(histRangeMax_-histRangeMin_)+1;
1451   TH1F* hist = new TH1F(name1.c_str(), title1.c_str(), numBins, histRangeMin_, histRangeMax_);
1452   FEDsAndHists_[FED] = hist;
1453   FEDsAndHists_[FED]->SetDirectory(nullptr);
1454 
1455   TH1F* E2hist = new TH1F(Form("E2_FED_%d", FED), Form("E2_FED_%d", FED), numBins, histRangeMin_, histRangeMax_);
1456   FEDsAndE2Hists_[FED] = E2hist;
1457   FEDsAndE2Hists_[FED]->SetDirectory(nullptr);
1458 
1459   TH1F* energyhist =
1460       new TH1F(Form("Energy_FED_%d", FED), Form("Energy_FED_%d", FED), numBins, histRangeMin_, histRangeMax_);
1461   FEDsAndenergyHists_[FED] = energyhist;
1462   FEDsAndenergyHists_[FED]->SetDirectory(nullptr);
1463 
1464   TH2F* E2vsE1hist = new TH2F(Form("E2vsE1_FED_%d", FED),
1465                               Form("E2vsE1_FED_%d", FED),
1466                               numBins,
1467                               histRangeMin_,
1468                               histRangeMax_,
1469                               numBins,
1470                               histRangeMin_,
1471                               histRangeMax_);
1472   FEDsAndE2vsE1Hists_[FED] = E2vsE1hist;
1473   FEDsAndE2vsE1Hists_[FED]->SetDirectory(nullptr);
1474 
1475   TH2F* energyvsE1hist = new TH2F(Form("EnergyvsE1_FED_%d", FED),
1476                                   Form("EnergyvsE1_FED_%d", FED),
1477                                   numBins,
1478                                   histRangeMin_,
1479                                   histRangeMax_,
1480                                   numBins,
1481                                   histRangeMin_,
1482                                   histRangeMax_);
1483   FEDsAndenergyvsE1Hists_[FED] = energyvsE1hist;
1484   FEDsAndenergyvsE1Hists_[FED]->SetDirectory(nullptr);
1485 
1486   title1 = "Time for ";
1487   title1.append(fedMap_->getSliceFromFed(FED));
1488   title1.append(";Relative Time (1 clock = 25ns);Events");
1489   name1 = "TimeFED";
1490   name1.append(intToString(FED));
1491   TH1F* timingHist = new TH1F(name1.c_str(), title1.c_str(), 78, -7, 7);
1492   FEDsAndTimingHists_[FED] = timingHist;
1493   FEDsAndTimingHists_[FED]->SetDirectory(nullptr);
1494 
1495   TH1F* freqHist =
1496       new TH1F(Form("Frequency_FED_%d", FED), Form("Frequency for FED %d;Event Number", FED), 100, 0., 100000);
1497   FEDsAndFrequencyHists_[FED] = freqHist;
1498   FEDsAndFrequencyHists_[FED]->SetDirectory(nullptr);
1499 
1500   TH1F* iphiProfileHist =
1501       new TH1F(Form("iPhi_Profile_FED_%d", FED), Form("iPhi Profile for FED %d", FED), 360, 1., 361);
1502   FEDsAndiPhiProfileHists_[FED] = iphiProfileHist;
1503   FEDsAndiPhiProfileHists_[FED]->SetDirectory(nullptr);
1504 
1505   TH1F* ietaProfileHist =
1506       new TH1F(Form("iEta_Profile_FED_%d", FED), Form("iEta Profile for FED %d", FED), 172, -86, 86);
1507   FEDsAndiEtaProfileHists_[FED] = ietaProfileHist;
1508   FEDsAndiEtaProfileHists_[FED]->SetDirectory(nullptr);
1509 
1510   TH2F* timingHistVsFreq =
1511       new TH2F(Form("timeVsFreqFED_%d", FED), Form("time Vs Freq FED %d", FED), 78, -7, 7, 100, 0., 100000);
1512   FEDsAndTimingVsFreqHists_[FED] = timingHistVsFreq;
1513   FEDsAndTimingVsFreqHists_[FED]->SetDirectory(nullptr);
1514 
1515   TH2F* timingHistVsAmp = new TH2F(
1516       Form("timeVsAmpFED_%d", FED), Form("time Vs Amp FED %d", FED), 78, -7, 7, numBins, histRangeMin_, histRangeMax_);
1517   FEDsAndTimingVsAmpHists_[FED] = timingHistVsAmp;
1518   FEDsAndTimingVsAmpHists_[FED]->SetDirectory(nullptr);
1519 
1520   TH1F* numXtalInClusterHist = new TH1F(Form("NumXtalsInCluster_FED_%d", FED),
1521                                         Form("Num active Xtals In Cluster for FED %d;Num Active Xtals", FED),
1522                                         25,
1523                                         0,
1524                                         25);
1525   FEDsAndNumXtalsInClusterHists_[FED] = numXtalInClusterHist;
1526   FEDsAndNumXtalsInClusterHists_[FED]->SetDirectory(nullptr);
1527 
1528   TH2F* OccupHist = new TH2F(Form("occupFED_%d", FED), Form("Occupancy FED %d;i#eta;i#phi", FED), 85, 1, 86, 20, 1, 21);
1529   FEDsAndOccupancyHists_[FED] = OccupHist;
1530   FEDsAndOccupancyHists_[FED]->SetDirectory(nullptr);
1531 
1532   TH2F* timingHistVsPhi = new TH2F(Form("timeVsPhiFED_%d", FED),
1533                                    Form("time Vs Phi FED %d;Relative Time (1 clock = 25ns);i#phi", FED),
1534                                    78,
1535                                    -7,
1536                                    7,
1537                                    20,
1538                                    1,
1539                                    21);
1540   FEDsAndTimingVsPhiHists_[FED] = timingHistVsPhi;
1541   FEDsAndTimingVsPhiHists_[FED]->SetDirectory(nullptr);
1542 
1543   TH2F* timingHistVsModule = new TH2F(Form("timeVsModuleFED_%d", FED),
1544                                       Form("time Vs Module FED %d;Relative Time (1 clock = 25ns);i#eta", FED),
1545                                       78,
1546                                       -7,
1547                                       7,
1548                                       4,
1549                                       1,
1550                                       86);
1551   FEDsAndTimingVsModuleHists_[FED] = timingHistVsModule;
1552   FEDsAndTimingVsModuleHists_[FED]->SetDirectory(nullptr);
1553 
1554   TH2F* dccRuntypeVsBxFED =
1555       new TH2F(Form("DCCRuntypeVsBxFED_%d", FED), Form("DCC Runtype vs. BX FED %d", FED), 3600, 0, 3600, 24, 0, 24);
1556   FEDsAndDCCRuntypeVsBxHists_[FED] = dccRuntypeVsBxFED;
1557   FEDsAndDCCRuntypeVsBxHists_[FED]->SetDirectory(nullptr);
1558 }
1559 
1560 // ------------ method called once each job just before starting event loop  ------------
1561 void EcalCosmicsHists::beginRun(edm::Run const&, edm::EventSetup const& eventSetup) {
1562   ecalElectronicsMap_ = &eventSetup.getData(ecalMappingToken_);
1563 
1564   //Here I will init some of the specific histograms
1565   int numBins = 200;  //(int)round(histRangeMax_-histRangeMin_)+1;
1566 
1567   //=============Special Bins for TT and Modules borders=============================
1568   double ttEtaBins[36] = {-85, -80, -75, -70, -65, -60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0,
1569                           1,   6,   11,  16,  21,  26,  31,  36,  41,  46,  51,  56,  61,  66,  71,  76,  81, 86};
1570   double modEtaBins[10] = {-85, -65, -45, -25, 0, 1, 26, 46, 66, 86};
1571   double ttPhiBins[73];
1572   double modPhiBins[19];
1573   double timingBins[79];
1574   double highEBins[11];
1575   for (int i = 0; i < 79; ++i) {
1576     timingBins[i] = -7. + double(i) * 14. / 78.;
1577     if (i < 73) {
1578       ttPhiBins[i] = 1 + 5 * i;
1579       if (i < 19) {
1580         modPhiBins[i] = 1 + 20 * i;
1581         if (i < 11) {
1582           highEBins[i] = 10. + double(i) * 20.;
1583         }
1584       }
1585     }
1586   }
1587   //=============END Special Bins for TT and Modules borders===========================
1588 
1589   //====================Frequency for Event timing information=========================
1590   double timingEndInSeconds = runTimeLength_ * 3600.;
1591   double timingBinWidth = timingEndInSeconds / double(numTimingBins_);
1592   //====================END Frequency for Event timing information=====================
1593 
1594   allFedsenergyHist_ =
1595       new TH1F("energy_AllClusters", "energy_AllClusters;Cluster Energy (GeV)", numBins, histRangeMin_, histRangeMax_);
1596   allFedsenergyHighHist_ =
1597       new TH1F("energyHigh_AllClusters", "energyHigh_AllClusters;Cluster Energy (GeV)", numBins, histRangeMin_, 200.0);
1598   allFedsenergyOnlyHighHist_ = new TH1F("energyHigh_HighEnergyClusters",
1599                                         "energy of High Energy Clusters;Cluster Energy (GeV)",
1600                                         numBins,
1601                                         histRangeMin_,
1602                                         200.0);
1603   allFedsE2Hist_ = new TH1F(
1604       "E2_AllClusters", "E2_AllClusters;Seed+highest neighbor energy (GeV)", numBins, histRangeMin_, histRangeMax_);
1605   allFedsE2vsE1Hist_ = new TH2F("E2vsE1_AllClusters",
1606                                 "E2vsE1_AllClusters;Seed Energy (GeV);Seed+highest neighbor energy (GeV)",
1607                                 numBins,
1608                                 histRangeMin_,
1609                                 histRangeMax_,
1610                                 numBins,
1611                                 histRangeMin_,
1612                                 histRangeMax_);
1613   allFedsenergyvsE1Hist_ = new TH2F("energyvsE1_AllClusters",
1614                                     "energyvsE1_AllClusters;Seed Energy (GeV);Energy(GeV)",
1615                                     numBins,
1616                                     histRangeMin_,
1617                                     histRangeMax_,
1618                                     numBins,
1619                                     histRangeMin_,
1620                                     histRangeMax_);
1621   allFedsTimingHist_ = new TH1F("timeForAllFeds", "timeForAllFeds;Relative Time (1 clock = 25ns)", 78, -7, 7);
1622   allFedsTimingVsFreqHist_ = new TH2F("timeVsFreqAllEvent",
1623                                       "time Vs Freq All events;Relative Time (1 clock = 25ns);Event Number",
1624                                       78,
1625                                       -7,
1626                                       7,
1627                                       2000,
1628                                       0.,
1629                                       200000);
1630   allFedsTimingVsAmpHist_ = new TH2F("timeVsAmpAllEvents",
1631                                      "time Vs Amp All Events;Relative Time (1 clock = 25ns);Amplitude (GeV)",
1632                                      78,
1633                                      -7,
1634                                      7,
1635                                      numBins,
1636                                      histRangeMin_,
1637                                      histRangeMax_);
1638   allFedsFrequencyHist_ = new TH1F("FrequencyAllEvent", "Frequency for All events;Event Number", 2000, 0., 200000);
1639 
1640   //--------Special Hists for times stamp info----------------------------------------------
1641   allFedsFreqTimeHist_ = new TH1F("FrequencyAllEventsInTime",
1642                                   Form("Time of Cosmic Events; Time (s);Passing Event rate/%5g s", timingBinWidth),
1643                                   numTimingBins_,
1644                                   0.,
1645                                   timingEndInSeconds);
1646   allFedsFreqTimeVsPhiHist_ =
1647       new TH2F("FrequencyAllEventsInTimeVsPhi",
1648                Form("Time of Cosmic Events vs iPhi; iPhi;Time (s)/%5g s", timingBinWidth * 360.),
1649                360,
1650                1.,
1651                361.,
1652                numTimingBins_ / 360,
1653                0.,
1654                timingEndInSeconds);
1655   allFedsFreqTimeVsPhiTTHist_ =
1656       new TH2F("FrequencyAllEventsInTimeVsTTPhi",
1657                Form("Time of Cosmic Events vs iPhi (TT bins); iPhi;Time (s)/%5g s", timingBinWidth * 72.),
1658                72,
1659                1.,
1660                361.,
1661                numTimingBins_ / 72,
1662                0.,
1663                timingEndInSeconds);
1664   allFedsFreqTimeVsEtaHist_ =
1665       new TH2F("FrequencyAllEventsInTimeVsEta",
1666                Form("Time of Cosmic Events vs iEta; Time (s)/%5g s; iEta", timingBinWidth * 172.),
1667                numTimingBins_ / 172,
1668                0.,
1669                timingEndInSeconds,
1670                172,
1671                -86.,
1672                86.);
1673   allFedsFreqTimeVsEtaTTHist_ =
1674       new TH2F("FrequencyAllEventsInTimeVsTTEta",
1675                Form("Time of Cosmic Events vs Eta (TT bins);Time (s)/%5g s; iEta", timingBinWidth * 35.),
1676                numTimingBins_ / 35,
1677                0.,
1678                timingEndInSeconds,
1679                35,
1680                ttEtaBins);
1681   //--------END Special Hists for times stamp info------------------------------------------
1682 
1683   allFedsiPhiProfileHist_ = new TH1F("iPhiProfileAllEvents", "iPhi Profile all events;i#phi", 360, 1., 361.);
1684   allFedsiEtaProfileHist_ = new TH1F("iEtaProfileAllEvents", "iEta Profile all events;i#eta", 172, -86, 86);
1685 
1686   allOccupancy_ = new TH2F("OccupancyAllEvents", "Occupancy all events;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1687   TrueOccupancy_ =
1688       new TH2F("TrueOccupancyAllEvents", "True Occupancy all events;#phi;#eta", 360, -3.14159, 3.14159, 172, -1.5, 1.5);
1689   allOccupancyCoarse_ =
1690       new TH2F("OccupancyAllEventsCoarse", "Occupancy all events Coarse;i#phi;i#eta", 360 / 5, 1, 361., 35, ttEtaBins);
1691   TrueOccupancyCoarse_ = new TH2F("TrueOccupancyAllEventsCoarse",
1692                                   "True Occupancy all events Coarse;#phi;#eta",
1693                                   360 / 5,
1694                                   -3.14159,
1695                                   3.14159,
1696                                   34,
1697                                   -1.5,
1698                                   1.5);
1699 
1700   // single xtal cluster occupancy
1701   allOccupancySingleXtal_ =
1702       new TH2F("OccupancySingleXtal", "Occupancy single xtal clusters;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1703   energySingleXtalHist_ = new TH1F(
1704       "energy_SingleXtalClusters", "Energy single xtal clusters;Cluster Energy (GeV)", numBins, histRangeMin_, 200.0);
1705 
1706   allFedsTimingPhiHist_ = new TH2F("timePhiAllFEDs",
1707                                    "time vs Phi for all FEDs (TT binning);i#phi;Relative Time (1 clock = 25ns)",
1708                                    72,
1709                                    1,
1710                                    361,
1711                                    78,
1712                                    -7,
1713                                    7);
1714   allFedsTimingPhiEbpHist_ = new TH2F("timePhiEBP",
1715                                       "time vs Phi for FEDs in EB+ (TT binning) ;i#phi;Relative Time (1 clock = 25ns)",
1716                                       72,
1717                                       1,
1718                                       361,
1719                                       78,
1720                                       -7,
1721                                       7);
1722   allFedsTimingPhiEbmHist_ = new TH2F("timePhiEBM",
1723                                       "time vs Phi for FEDs in EB- (TT binning);i#phi;Relative Time (1 clock = 25ns)",
1724                                       72,
1725                                       1,
1726                                       361,
1727                                       78,
1728                                       -7,
1729                                       7);
1730   allFedsTimingPhiEtaHist_ =
1731       new TH3F("timePhiEtaAllFEDs",
1732                "(Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1733                18,
1734                modPhiBins,
1735                9,
1736                modEtaBins,
1737                78,
1738                timingBins);
1739   allFedsTimingTTHist_ =
1740       new TH3F("timeTTAllFEDs",
1741                "(Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1742                72,
1743                ttPhiBins,
1744                35,
1745                ttEtaBins,
1746                78,
1747                timingBins);
1748   allFedsTimingLMHist_ = new TH2F(
1749       "timeLMAllFEDs", "(LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)", 92, 1, 92, 78, -7, 7);
1750 
1751   allFedsTimingEbpHist_ = new TH1F("timeEBP", "time for FEDs in EB+;Relative Time (1 clock = 25ns)", 78, -7, 7);
1752   allFedsTimingEbmHist_ = new TH1F("timeEBM", "time for FEDs in EB-;Relative Time (1 clock = 25ns)", 78, -7, 7);
1753   allFedsTimingEbpTopHist_ =
1754       new TH1F("timeEBPTop", "time for FEDs in EB+ Top;Relative Time (1 clock = 25ns)", 78, -7, 7);
1755   allFedsTimingEbmTopHist_ =
1756       new TH1F("timeEBMTop", "time for FEDs in EB- Top;Relative Time (1 clock = 25ns)", 78, -7, 7);
1757   allFedsTimingEbpBottomHist_ =
1758       new TH1F("timeEBPBottom", "time for FEDs in EB+ Bottom;Relative Time (1 clock = 25ns)", 78, -7, 7);
1759   allFedsTimingEbmBottomHist_ =
1760       new TH1F("timeEBMBottom", "time for FEDs in EB- Bottom;Relative Time (1 clock = 25ns)", 78, -7, 7);
1761 
1762   numberofCosmicsHist_ =
1763       new TH1F("numberofCosmicsPerEvent", "Number of cosmics per event;Number of Cosmics", 30, 0, 30);
1764   numberofCosmicsHistEB_ =
1765       new TH1F("numberofCosmicsPerEvent_EB", "Number of cosmics per event EB;Number of Cosmics", 30, 0, 30);
1766 
1767   numberofCosmicsWTrackHist_ =
1768       new TH1F("numberofCosmicsWTrackPerEvent", "Number of cosmics with track per event", 30, 0, 30);
1769   numberofCosmicsTopBottomHist_ = new TH1F(
1770       "numberofCosmicsTopBottomPerEvent", "Number of top bottom cosmics per event;Number of Cosmics", 30, 0, 30);
1771   numberofGoodEvtFreq_ = new TH1F("frequencyOfGoodEvents",
1772                                   "Number of events with cosmic vs Event;Event Number;Number of Good Events/100 Events",
1773                                   2000,
1774                                   0,
1775                                   200000);
1776 
1777   numberofCrossedEcalIdsHist_ = new TH1F("numberofCrossedEcalCosmicsPerEvent",
1778                                          "Number of crossed ECAL cosmics per event;Number of Crossed Cosmics",
1779                                          10,
1780                                          0,
1781                                          10);
1782 
1783   allOccupancyExclusiveECAL_ = new TH2F("OccupancyAllEvents_ExclusiveECAL",
1784                                         "Occupancy all events Exclusive ECAL ;i#phi;i#eta",
1785                                         360,
1786                                         1.,
1787                                         361.,
1788                                         172,
1789                                         -86,
1790                                         86);
1791   allOccupancyCoarseExclusiveECAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveECAL",
1792                                               "Occupancy all events Coarse Exclusive ECAL;i#phi;i#eta",
1793                                               360 / 5,
1794                                               ttPhiBins,
1795                                               35,
1796                                               ttEtaBins);
1797   allOccupancyECAL_ =
1798       new TH2F("OccupancyAllEvents_ECAL", "Occupancy all events ECAL;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1799   allOccupancyCoarseECAL_ = new TH2F("OccupancyAllEventsCoarse_ECAL",
1800                                      "Occupancy all events Coarse ECAL;i#phi;i#eta",
1801                                      360 / 5,
1802                                      ttPhiBins,
1803                                      35,
1804                                      ttEtaBins);
1805   allFedsTimingHistECAL_ =
1806       new TH1F("timeForAllFeds_ECAL", "timeForAllFeds ECAL;Relative Time (1 clock = 25ns)", 78, -7, 7);
1807   allFedsTimingPhiEtaHistECAL_ =
1808       new TH3F("timePhiEtaAllFEDs_ECAL",
1809                "ECAL (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1810                18,
1811                modPhiBins,
1812                9,
1813                modEtaBins,
1814                78,
1815                timingBins);
1816   allFedsTimingTTHistECAL_ =
1817       new TH3F("timeTTAllFEDs_ECAL",
1818                "ECAL (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1819                72,
1820                ttPhiBins,
1821                35,
1822                ttEtaBins,
1823                78,
1824                timingBins);
1825   allFedsTimingLMHistECAL_ = new TH2F("timeLMAllFEDs_ECAL",
1826                                       "ECAL (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",
1827                                       92,
1828                                       1,
1829                                       92,
1830                                       78,
1831                                       -7,
1832                                       7);
1833 
1834   allOccupancyExclusiveDT_ = new TH2F(
1835       "OccupancyAllEvents_ExclusiveDT", "Occupancy all events Exclusive DT;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1836   allOccupancyCoarseExclusiveDT_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveDT",
1837                                             "Occupancy all events Coarse Exclusive DT;i#phi;i#eta",
1838                                             360 / 5,
1839                                             1,
1840                                             361.,
1841                                             35,
1842                                             ttEtaBins);
1843   allOccupancyDT_ =
1844       new TH2F("OccupancyAllEvents_DT", "Occupancy all events DT;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1845   allOccupancyCoarseDT_ = new TH2F(
1846       "OccupancyAllEventsCoarse_DT", "Occupancy all events Coarse DT;i#phi;i#eta", 360 / 5, 1, 361., 35, ttEtaBins);
1847   allFedsTimingHistDT_ = new TH1F("timeForAllFeds_DT", "timeForAllFeds DT;Relative Time (1 clock = 25ns)", 78, -7, 7);
1848   allFedsTimingPhiEtaHistDT_ =
1849       new TH3F("timePhiEtaAllFEDs_DT",
1850                "DT (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1851                18,
1852                modPhiBins,
1853                9,
1854                modEtaBins,
1855                78,
1856                timingBins);
1857   allFedsTimingTTHistDT_ =
1858       new TH3F("timeTTAllFEDs_DT",
1859                "DT (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1860                72,
1861                ttPhiBins,
1862                35,
1863                ttEtaBins,
1864                78,
1865                timingBins);
1866   allFedsTimingLMHistDT_ = new TH2F("timeLMAllFEDs_DT",
1867                                     "DT (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",
1868                                     92,
1869                                     1,
1870                                     92,
1871                                     78,
1872                                     -7,
1873                                     7);
1874 
1875   allOccupancyExclusiveRPC_ = new TH2F(
1876       "OccupancyAllEvents_ExclusiveRPC", "Occupancy all events Exclusive RPC;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1877   allOccupancyCoarseExclusiveRPC_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveRPC",
1878                                              "Occupancy all events Coarse Exclusive RPC;i#phi;i#eta",
1879                                              360 / 5,
1880                                              1,
1881                                              361.,
1882                                              35,
1883                                              ttEtaBins);
1884   allOccupancyRPC_ =
1885       new TH2F("OccupancyAllEvents_RPC", "Occupancy all events RPC;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1886   allOccupancyCoarseRPC_ = new TH2F(
1887       "OccupancyAllEventsCoarse_RPC", "Occupancy all events Coarse RPC;i#phi;i#eta", 360 / 5, 1, 361., 35, ttEtaBins);
1888   allFedsTimingHistRPC_ =
1889       new TH1F("timeForAllFeds_RPC", "timeForAllFeds RPC;Relative Time (1 clock = 25ns)", 78, -7, 7);
1890   allFedsTimingPhiEtaHistRPC_ =
1891       new TH3F("timePhiEtaAllFEDs_RPC",
1892                "RPC (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1893                18,
1894                modPhiBins,
1895                9,
1896                modEtaBins,
1897                78,
1898                timingBins);
1899   allFedsTimingTTHistRPC_ =
1900       new TH3F("timeTTAllFEDs_RPC",
1901                "RPC (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1902                72,
1903                ttPhiBins,
1904                35,
1905                ttEtaBins,
1906                78,
1907                timingBins);
1908   allFedsTimingLMHistRPC_ = new TH2F("timeLMAllFEDs_RPC",
1909                                      "RPC (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",
1910                                      92,
1911                                      1,
1912                                      92,
1913                                      78,
1914                                      -7,
1915                                      7);
1916 
1917   allOccupancyExclusiveCSC_ = new TH2F(
1918       "OccupancyAllEvents_ExclusiveCSC", "Occupancy all events Exclusive CSC;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1919   allOccupancyCoarseExclusiveCSC_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveCSC",
1920                                              "Occupancy all events Coarse Exclusive CSC;i#phi;i#eta",
1921                                              360 / 5,
1922                                              1,
1923                                              361.,
1924                                              35,
1925                                              ttEtaBins);
1926   allOccupancyCSC_ =
1927       new TH2F("OccupancyAllEvents_CSC", "Occupancy all events CSC;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1928   allOccupancyCoarseCSC_ = new TH2F(
1929       "OccupancyAllEventsCoarse_CSC", "Occupancy all events Coarse CSC;i#phi;i#eta", 360 / 5, 1, 361., 35, ttEtaBins);
1930   allFedsTimingHistCSC_ =
1931       new TH1F("timeForAllFeds_CSC", "timeForAllFeds CSC;Relative Time (1 clock = 25ns)", 78, -7, 7);
1932   allFedsTimingPhiEtaHistCSC_ =
1933       new TH3F("timePhiEtaAllFEDs_CSC",
1934                "CSC (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1935                18,
1936                modPhiBins,
1937                9,
1938                modEtaBins,
1939                78,
1940                timingBins);
1941   allFedsTimingTTHistCSC_ =
1942       new TH3F("timeTTAllFEDs_CSC",
1943                "CSC (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1944                72,
1945                ttPhiBins,
1946                35,
1947                ttEtaBins,
1948                78,
1949                timingBins);
1950   allFedsTimingLMHistCSC_ = new TH2F("timeLMAllFEDs_CSC",
1951                                      "CSC (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",
1952                                      92,
1953                                      1,
1954                                      62,
1955                                      78,
1956                                      -7,
1957                                      7);
1958 
1959   allOccupancyExclusiveHCAL_ = new TH2F("OccupancyAllEvents_ExclusiveHCAL",
1960                                         "Occupancy all events Exclusive HCAL;i#phi;i#eta",
1961                                         360,
1962                                         1.,
1963                                         361.,
1964                                         172,
1965                                         -86,
1966                                         86);
1967   allOccupancyCoarseExclusiveHCAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveHCAL",
1968                                               "Occupancy all events Coarse Exclusive HCAL;i#phi;i#eta",
1969                                               360 / 5,
1970                                               1,
1971                                               361.,
1972                                               35,
1973                                               ttEtaBins);
1974   allOccupancyHCAL_ =
1975       new TH2F("OccupancyAllEvents_HCAL", "Occupancy all events HCAL;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
1976   allOccupancyCoarseHCAL_ = new TH2F(
1977       "OccupancyAllEventsCoarse_HCAL", "Occupancy all events Coarse HCAL;i#phi;i#eta", 360 / 5, 1, 361., 35, ttEtaBins);
1978   allFedsTimingHistHCAL_ =
1979       new TH1F("timeForAllFeds_HCAL", "timeForAllFeds HCAL;Relative Time (1 clock = 25ns)", 78, -7, 7);
1980   allFedsTimingPhiEtaHistHCAL_ =
1981       new TH3F("timePhiEtaAllFEDs_HCAL",
1982                "HCAL (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1983                18,
1984                modPhiBins,
1985                9,
1986                modEtaBins,
1987                78,
1988                timingBins);
1989   allFedsTimingTTHistHCAL_ =
1990       new TH3F("timeTTAllFEDs_HCAL",
1991                "HCAL (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",
1992                72,
1993                ttPhiBins,
1994                35,
1995                ttEtaBins,
1996                78,
1997                timingBins);
1998   allFedsTimingLMHistHCAL_ = new TH2F("timeLMAllFEDs_HCAL",
1999                                       "HCAL (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",
2000                                       92,
2001                                       1,
2002                                       92,
2003                                       78,
2004                                       -7,
2005                                       7);
2006 
2007   TrueBCOccupancy_ = new TH2F(
2008       "BCTrueOccupancyAllEvents", "True SB Occupancy all events;#phi;#eta", 360, -3.14159, 3.14159, 172, -1.5, 1.5);
2009   TrueBCOccupancyCoarse_ = new TH2F("BCTrueOccupancyAllEventsCoarse",
2010                                     "True BC Occupancy all events Coarse;#phi;#eta",
2011                                     360 / 5,
2012                                     -3.14159,
2013                                     3.14159,
2014                                     34,
2015                                     -1.5,
2016                                     1.5);
2017 
2018   numberofBCinSC_ =
2019       new TH1F("numberofBCinSC", "Number of Basic Clusters in Super Cluster;Num Basic Clusters", 20, 0, 20);  //SC
2020   numberofBCinSCphi_ = new TH2F("numberofBCinSCphi",
2021                                 "Number of Basic Clusters in Super Cluster;phi;Num Basic Clusters",
2022                                 360 / 5,
2023                                 -3.14159,
2024                                 3.14159,
2025                                 20,
2026                                 0,
2027                                 20);  //SC
2028 
2029   allFedsTimingHistEcalMuon_ =
2030       new TH1F("timeForAllFeds_EcalMuon", "timeForAllFeds Ecal+Muon;Relative Time (1 clock = 25ns)", 78, -7, 7);
2031 
2032   triggerHist_ = new TH1F("triggerHist", "Trigger Number", 5, 0, 5);
2033   triggerHist_->GetXaxis()->SetBinLabel(1, "ECAL");
2034   triggerHist_->GetXaxis()->SetBinLabel(2, "HCAL");
2035   triggerHist_->GetXaxis()->SetBinLabel(3, "DT");
2036   triggerHist_->GetXaxis()->SetBinLabel(4, "RPC");
2037   triggerHist_->GetXaxis()->SetBinLabel(5, "CSC");
2038 
2039   triggerExclusiveHist_ = new TH1F("triggerExclusiveHist", "Trigger Number (Mutually Exclusive)", 5, 0, 5);
2040   triggerExclusiveHist_->GetXaxis()->SetBinLabel(1, "ECAL");
2041   triggerExclusiveHist_->GetXaxis()->SetBinLabel(2, "HCAL");
2042   triggerExclusiveHist_->GetXaxis()->SetBinLabel(3, "DT");
2043   triggerExclusiveHist_->GetXaxis()->SetBinLabel(4, "RPC");
2044   triggerExclusiveHist_->GetXaxis()->SetBinLabel(5, "CSC");
2045 
2046   runNumberHist_ = new TH1F("runNumberHist", "Run Number", 1, 0, 1);
2047 
2048   deltaRHist_ = new TH1F("deltaRHist", "deltaR", 500, -0.5, 499.5);
2049   deltaEtaHist_ = new TH1F("deltaIEtaHist", "deltaIEta", 170, -85.5, 84.5);
2050   deltaPhiHist_ = new TH1F("deltaIPhiHist", "deltaIPhi", 720, -360.5, 359.5);
2051   ratioAssocTracksHist_ = new TH1F("ratioAssocTracks", "num assoc. tracks/tracks through Ecal", 11, 0, 1.1);
2052   ratioAssocClustersHist_ = new TH1F("ratioAssocClusters", "num assoc. clusters/total clusters", 11, 0, 1.1);
2053   trackAssoc_muonsEcal_ = new TH2F(
2054       "trackAssoc_muonsEcal", "Map of muon hits in Ecal", 360, 1., 361., 172, -86, 86);  //360, 0 , 360, 170,-85 ,85);
2055   deltaEtaDeltaPhiHist_ =
2056       new TH2F("deltaEtaDeltaPhi", "Delta ieta vs. delta iphi", 170, -85.5, 84.5, 720, -360.5, 359.5);
2057   seedTrackEtaHist_ = new TH2F("seedTrackEta", "track ieta vs. seed ieta", 170, -85.5, 84.5, 170, -85.5, 84.5);
2058   seedTrackPhiHist_ = new TH2F("seedTrackPhi", "track iphi vs. seed iphi", 720, -360.5, 359.5, 720, -360.5, 359.5);
2059 
2060   dccEventVsBxHist_ = new TH2F("dccEventVsBx", "DCC Runtype vs. bunch crossing", 3600, 0, 3600, 24, 0, 24);
2061   dccBXErrorByFEDHist_ = new TH1F("dccBXErrorByFED", "Incorrect BX number by FED", 54, 601, 655);
2062   dccOrbitErrorByFEDHist_ = new TH1F("dccOrbitErrorByFED", "Incorrect orbit number by FED", 54, 601, 655);
2063   dccRuntypeErrorByFEDHist_ = new TH1F("dccRuntypeErrorByFED", "Incorrect DCC Runtype by FED", 54, 601, 655);
2064   dccRuntypeHist_ = new TH1F("dccRuntype", "DCC Runtype frequency", 24, 0, 24);
2065   dccErrorVsBxHist_ = new TH2F("dccErrorVsBX", "DCC Errors vs. BX", 3600, 0, 3600, 3, 0, 3);
2066 
2067   hcalEnergy_HBHE_ = new TH1F("hcalEnergy_HBHE", "RecHit Energy HBHE", 440, -10, 100);
2068   hcalEnergy_HF_ = new TH1F("hcalEnergy_HF", "RecHit Energy HF", 440, -10, 100);
2069   hcalEnergy_HO_ = new TH1F("hcalEnergy_HO", "RecHit Energy HO", 440, -10, 100);
2070   hcalHEHBecalEB_ =
2071       new TH2F("hcalHEHBecalEB", "HCAL HBHE RecHit energy vs ECAL EB energy", numBins, histRangeMin_, 300.0, 40, -5, 5);
2072 
2073   NumXtalsInClusterHist_ = new TH1F("NumXtalsInClusterAllHist", "Number of Xtals in Cluster;NumXtals", 150, 0, 150);
2074   numxtalsVsEnergy_ = new TH2F("NumXtalsVsEnergy",
2075                                "Number of Xtals in Cluster vs Energy;Energy (GeV);Number of Xtals in Cluster",
2076                                numBins,
2077                                histRangeMin_,
2078                                histRangeMax_,
2079                                150,
2080                                0,
2081                                150);
2082   numxtalsVsHighEnergy_ = new TH2F("NumXtalsVsHighEnergy",
2083                                    "Number of Xtals in Cluster vs Energy;Energy (GeV);Number of Xtals in Cluster",
2084                                    numBins,
2085                                    histRangeMin_,
2086                                    200.,
2087                                    150,
2088                                    0,
2089                                    150);
2090 
2091   // high energy analysis
2092   allOccupancyHighEnergy_ =
2093       new TH2F("OccupancyHighEnergyEvents", "Occupancy high energy events;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
2094   allOccupancyHighEnergyCoarse_ = new TH2F("OccupancyHighEnergyEventsCoarse",
2095                                            "Occupancy high energy events Coarse;i#phi;i#eta",
2096                                            72,
2097                                            ttPhiBins,
2098                                            35,
2099                                            ttEtaBins);
2100   allFedsOccupancyHighEnergyHist_ = new TH3F("OccupancyHighEnergyEvents3D",
2101                                              "(Phi,Eta,energy) for all high energy events;i#phi;i#eta;energy (GeV)",
2102                                              18,
2103                                              modPhiBins,
2104                                              9,
2105                                              modEtaBins,
2106                                              10,
2107                                              highEBins);
2108   allFedsNumXtalsInClusterHist_ =
2109       new TH1F("NumActiveXtalsInClusterAllHist", "Number of active Xtals in Cluster;NumXtals", 100, 0, 100);
2110 
2111   HighEnergy_NumXtal = new TH1F("HighEnergy_NumXtal", "Num crystals in high E clusters;num crystals", 150, 0, 150);
2112   HighEnergy_NumXtalFedId = new TH2F(
2113       "HighEnergy_NumXtalFedId", "Num crystals in cluster vs FedId;FedId;num crystals", 36, 610., 645., 150, 0, 150);
2114   HighEnergy_NumXtaliphi = new TH2F(
2115       "HighEnergy_NumXtaliphi", "Num crystals in cluster vs iphi;i#phi;num crystals", 360, 1., 361., 150, 0, 150);
2116   HighEnergy_energy3D = new TH3F("HighEnergy_energy3D",
2117                                  "(Phi,Eta,energy) for all high energy events;i#phi;i#eta;energy (GeV)",
2118                                  72,
2119                                  ttPhiBins,
2120                                  35,
2121                                  ttEtaBins,
2122                                  10,
2123                                  highEBins);
2124 
2125   HighEnergy_energyNumXtal = new TH2F("HighEnergy_energyNumXtal",
2126                                       "Energy in cluster vs Num crystals in cluster;num crystals;energy",
2127                                       150,
2128                                       0,
2129                                       150,
2130                                       200,
2131                                       0.,
2132                                       200.);
2133 
2134   HighEnergy_bestSeed = new TH1F("HighEnergy_bestSeedEnergy", "BestSeed Energy from TrackAss", 200, 0., 200.);
2135   HighEnergy_bestSeedOccupancy = new TH2F(
2136       "HighEnergy_bestSeedOccupancy", "Occupancy HighEn events from TrackAss;i#phi;i#eta", 360, 1., 361., 172, -86, 86);
2137 
2138   HighEnergy_numClusHighEn = new TH1F("HighEnergy_numClusHighEn", "Num High Energy Clusters", 7, 0, 7);
2139   HighEnergy_ratioClusters =
2140       new TH1F("HighEnergy_ratioClusters", "Num High Energy Clusters/Num tot Clusters", 100, 0., 1.1);
2141 
2142   HighEnergy_numRecoTrackBarrel = new TH1F("HighEnergy_numRecoTracksBarrel", "Num BarrelRecoTracks", 10, 0, 10);
2143   HighEnergy_TracksAngle = new TH1F("HighEnergy_TracksAngle", "Angle between tracks", 720, 0., 180.);
2144   HighEnergy_TracksAngleTopBottom =
2145       new TH1F("HighEnergy_TopBottomTracksAngle", "Angle between top-bottom tracks", 720, 0., 180.);
2146 
2147   HighEnergy_2GeV_occuCoarse = new TH2F("HighEnergy_occu2GeV_Coarse",
2148                                         "Occupancy high energy events with more than 2 GeV;i#phi;i#eta",
2149                                         72,
2150                                         ttPhiBins,
2151                                         35,
2152                                         ttEtaBins);
2153   HighEnergy_2GeV_occu3D = new TH3F("HighEnergy_2GeV_energy3D",
2154                                     "(iphi,ieta,energy) for all high energy events w > 10 GeV;i#phi;i#eta;energy (GeV)",
2155                                     72,
2156                                     ttPhiBins,
2157                                     35,
2158                                     ttEtaBins,
2159                                     10,
2160                                     highEBins);
2161   HighEnergy_100GeV_occuCoarse = new TH2F("HighEnergy_occu100GeV_Coarse",
2162                                           "Occupancy high energy events with more than 100 GeV;i#phi;i#eta",
2163                                           72,
2164                                           ttPhiBins,
2165                                           35,
2166                                           ttEtaBins);
2167   HighEnergy_100GeV_occu3D =
2168       new TH3F("HighEnergy_100GeV_energy3D",
2169                "(iphi,ieta,energy) for all high energy events more than 100 GeV;i#phi;i#eta;energy (GeV)",
2170                72,
2171                ttPhiBins,
2172                35,
2173                ttEtaBins,
2174                10,
2175                highEBins);
2176   HighEnergy_0tracks_occu3D = new TH3F("HighEnergy_0Tracks_energy3D",
2177                                        "(iphi,ieta,energy) for all events with 0 tracks;i#phi;i#eta;energy (GeV)",
2178                                        72,
2179                                        ttPhiBins,
2180                                        35,
2181                                        ttEtaBins,
2182                                        10,
2183                                        highEBins);
2184   HighEnergy_1tracks_occu3D = new TH3F("HighEnergy_1Tracks_energy3D",
2185                                        "(iphi,ieta,energy) for all events with 1 tracks;i#phi;i#eta;energy (GeV)",
2186                                        72,
2187                                        ttPhiBins,
2188                                        35,
2189                                        ttEtaBins,
2190                                        10,
2191                                        highEBins);
2192   HighEnergy_2tracks_occu3D = new TH3F("HighEnergy_2Tracks_energy3D",
2193                                        "(iphi,ieta,energy) for all events with 2 tracks;i#phi;i#eta;energy (GeV)",
2194                                        72,
2195                                        ttPhiBins,
2196                                        35,
2197                                        ttEtaBins,
2198                                        10,
2199                                        highEBins);
2200   HighEnergy_0tracks_occu3DXtal = new TH3F("HighEnergy_0Tracks_energy3DXtal",
2201                                            "(iphi,ieta,energy) for all events with 0 tracks;i#phi;i#eta;energy (GeV)",
2202                                            360,
2203                                            1.,
2204                                            361.,
2205                                            172,
2206                                            -86,
2207                                            86,
2208                                            200,
2209                                            0.,
2210                                            200.);
2211   HighEnergy_1tracks_occu3DXtal = new TH3F("HighEnergy_1Tracks_energy3DXtal",
2212                                            "(iphi,ieta,energy) for all events with 1 tracks;i#phi;i#eta;energy (GeV)",
2213                                            360,
2214                                            1.,
2215                                            361.,
2216                                            172,
2217                                            -86,
2218                                            86,
2219                                            200,
2220                                            0.,
2221                                            200.);
2222   HighEnergy_2tracks_occu3DXtal = new TH3F("HighEnergy_2Tracks_energy3DXtal",
2223                                            "(iphi,ieta,energy) for all events with 2 tracks;i#phi;i#eta;energy (GeV)",
2224                                            360,
2225                                            1.,
2226                                            361.,
2227                                            172,
2228                                            -86,
2229                                            86,
2230                                            200,
2231                                            0.,
2232                                            200.);
2233 
2234   //EE histograms
2235 
2236   // EE-
2237   EEM_FedsSeedEnergyHist_ =
2238       new TH1F("SeedEnergyAllFEDs", "Seed Energy for EEM Feds; Seed Energy (GeV)", 200, histRangeMin_, 10.0);
2239 
2240   EEM_AllOccupancyCoarse_ =
2241       new TH2F("OccupancyAllEventsCoarse", "Occupancy all events Coarse EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2242   EEM_AllOccupancy_ = new TH2F("OccupancyAllEvents", "Occupancy all events EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2243   EEM_FedsenergyHist_ =
2244       new TH1F("energy_AllClusters", "energy_AllClusters_EEM;Cluster Energy (GeV)", numBins, histRangeMin_, 10.0);
2245   EEM_FedsenergyHighHist_ = new TH1F(
2246       "energyHigh_AllClusters", "energyHigh_AllClusters in EEM;Cluster Energy (GeV)", numBins, histRangeMin_, 200.0);
2247   EEM_FedsenergyOnlyHighHist_ = new TH1F("energyHigh_HighEnergyClusters",
2248                                          "energy of High Energy Clusters in EEM;Cluster Energy (GeV)",
2249                                          numBins,
2250                                          histRangeMin_,
2251                                          200.0);
2252   EEM_FedsE2Hist_ =
2253       new TH1F("E2_AllClusters", "E2_AllClusters_EEM;Seed+highest neighbor energy (GeV)", numBins, histRangeMin_, 10.0);
2254   EEM_FedsE2vsE1Hist_ = new TH2F("E2vsE1_AllClusters",
2255                                  "E2vsE1_AllClusters_EEM;Seed Energy (GeV);Seed+highest neighbor energy (GeV)",
2256                                  numBins,
2257                                  histRangeMin_,
2258                                  10.0,
2259                                  numBins,
2260                                  histRangeMin_,
2261                                  10.0);
2262   EEM_FedsenergyvsE1Hist_ = new TH2F("energyvsE1_AllClusters",
2263                                      "energyvsE1_AllClusters_EEM;Seed Energy (GeV);Energy(GeV)",
2264                                      numBins,
2265                                      histRangeMin_,
2266                                      10.0,
2267                                      numBins,
2268                                      histRangeMin_,
2269                                      10.0);
2270   EEM_FedsTimingHist_ = new TH1F("timeForAllFeds", "timeForAllFeds_EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
2271   EEM_numberofCosmicsHist_ =
2272       new TH1F("numberofCosmicsPerEvent", "Number of cosmics per event EEM;Number of Cosmics", 30, 0, 30);
2273 
2274   EEM_FedsTimingVsAmpHist_ = new TH2F("timeVsAmpAllEvents",
2275                                       "time Vs Amp All Events EEM;Relative Time (1 clock = 25ns);Amplitude (GeV)",
2276                                       78,
2277                                       -7,
2278                                       7,
2279                                       numBins,
2280                                       histRangeMin_,
2281                                       10.0);
2282   EEM_FedsTimingTTHist_ = new TH3F("timeTTAllFEDs",
2283                                    "(ix,iy,time) for all FEDs (SM,TT binning) EEM;ix;iy;Relative Time (1 clock = 25ns)",
2284                                    20,
2285                                    0,
2286                                    100,
2287                                    20,
2288                                    0,
2289                                    100,
2290                                    78,
2291                                    -7,
2292                                    7);
2293 
2294   EEM_OccupancySingleXtal_ =
2295       new TH2F("OccupancySingleXtal", "Occupancy single xtal clusters EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2296   EEM_energySingleXtalHist_ = new TH1F("energy_SingleXtalClusters",
2297                                        "Energy single xtal clusters EEM;Cluster Energy (GeV)",
2298                                        numBins,
2299                                        histRangeMin_,
2300                                        200.0);
2301 
2302   EEM_OccupancyExclusiveECAL_ = new TH2F(
2303       "OccupancyAllEvents_ExclusiveECAL", "Occupancy all events Exclusive ECAL  EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2304   EEM_OccupancyCoarseExclusiveECAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveECAL",
2305                                                "Occupancy all events Coarse Exclusive ECAL EEM;ix;iy",
2306                                                20,
2307                                                0,
2308                                                100,
2309                                                20,
2310                                                0,
2311                                                100);
2312   EEM_OccupancyECAL_ =
2313       new TH2F("OccupancyAllEvents_ECAL", "Occupancy all events ECAL EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2314   EEM_OccupancyCoarseECAL_ =
2315       new TH2F("OccupancyAllEventsCoarse_ECAL", "Occupancy all events Coarse ECAL EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2316   EEM_FedsTimingHistECAL_ =
2317       new TH1F("timeForAllFeds_ECAL", "timeForAllFeds ECAL EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
2318   EEM_FedsTimingTTHistECAL_ =
2319       new TH3F("timeTTAllFEDs_ECAL",
2320                "(ix,iy,time) for all FEDs (SM,TT binning) ECAL EEM;ix;iy;Relative Time (1 clock = 25ns)",
2321                20,
2322                0,
2323                100,
2324                20,
2325                0,
2326                100,
2327                78,
2328                -7,
2329                7);
2330 
2331   EEM_OccupancyExclusiveDT_ = new TH2F(
2332       "OccupancyAllEvents_ExclusiveDT", "Occupancy all events Exclusive DT EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2333   EEM_OccupancyCoarseExclusiveDT_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveDT",
2334                                              "Occupancy all events Coarse Exclusive DT EEM;ix;iy",
2335                                              20,
2336                                              0,
2337                                              100,
2338                                              20,
2339                                              0,
2340                                              100);
2341   EEM_OccupancyDT_ = new TH2F("OccupancyAllEvents_DT", "Occupancy all events DT EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2342   EEM_OccupancyCoarseDT_ =
2343       new TH2F("OccupancyAllEventsCoarse_DT", "Occupancy all events Coarse DT EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2344   EEM_FedsTimingHistDT_ =
2345       new TH1F("timeForAllFeds_DT", "timeForAllFeds DT EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
2346   EEM_FedsTimingTTHistDT_ =
2347       new TH3F("timeTTAllFEDs_DT",
2348                "(ix,iy,time) for all FEDs (SM,TT binning) DT EEM;ix;iy;Relative Time (1 clock = 25ns)",
2349                20,
2350                0,
2351                100,
2352                20,
2353                0,
2354                100,
2355                78,
2356                -7,
2357                7);
2358 
2359   EEM_OccupancyExclusiveRPC_ = new TH2F(
2360       "OccupancyAllEvents_ExclusiveRPC", "Occupancy all events Exclusive RPC EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2361   EEM_OccupancyCoarseExclusiveRPC_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveRPC",
2362                                               "Occupancy all events Coarse Exclusive RPC EEM;ix;iy",
2363                                               20,
2364                                               0,
2365                                               100,
2366                                               20,
2367                                               0,
2368                                               100);
2369   EEM_OccupancyRPC_ =
2370       new TH2F("OccupancyAllEvents_RPC", "Occupancy all events RPC EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2371   EEM_OccupancyCoarseRPC_ =
2372       new TH2F("OccupancyAllEventsCoarse_RPC", "Occupancy all events Coarse RPC EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2373   EEM_FedsTimingHistRPC_ =
2374       new TH1F("timeForAllFeds_RPC", "timeForAllFeds RPC EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
2375   EEM_FedsTimingTTHistRPC_ =
2376       new TH3F("timeTTAllFEDs_RPC",
2377                "(ix,iy,time) for all FEDs (SM,TT binning) RPC EEM;ix;iy;Relative Time (1 clock = 25ns)",
2378                20,
2379                0,
2380                100,
2381                20,
2382                0,
2383                100,
2384                78,
2385                -7,
2386                7);
2387 
2388   EEM_OccupancyExclusiveCSC_ = new TH2F(
2389       "OccupancyAllEvents_ExclusiveCSC", "Occupancy all events Exclusive CSC EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2390   EEM_OccupancyCoarseExclusiveCSC_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveCSC",
2391                                               "Occupancy all events Coarse Exclusive CSC EEM;ix;iy",
2392                                               20,
2393                                               0,
2394                                               100,
2395                                               20,
2396                                               0,
2397                                               100);
2398   EEM_OccupancyCSC_ =
2399       new TH2F("OccupancyAllEvents_CSC", "Occupancy all events CSC EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2400   EEM_OccupancyCoarseCSC_ =
2401       new TH2F("OccupancyAllEventsCoarse_CSC", "Occupancy all events Coarse CSC EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2402   EEM_FedsTimingHistCSC_ =
2403       new TH1F("timeForAllFeds_CSC", "timeForAllFeds CSC EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
2404   EEM_FedsTimingTTHistCSC_ =
2405       new TH3F("timeTTAllFEDs_CSC",
2406                "(ix,iy,time) for all FEDs (SM,TT binning) CSC EEM;ix;iy;Relative Time (1 clock = 25ns)",
2407                20,
2408                0,
2409                100,
2410                20,
2411                0,
2412                100,
2413                78,
2414                -7,
2415                7);
2416 
2417   EEM_OccupancyExclusiveHCAL_ = new TH2F(
2418       "OccupancyAllEvents_ExclusiveHCAL", "Occupancy all events Exclusive HCAL EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2419   EEM_OccupancyCoarseExclusiveHCAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveHCAL",
2420                                                "Occupancy all events Coarse Exclusive HCAL EEM;ix;iy",
2421                                                20,
2422                                                0,
2423                                                100,
2424                                                20,
2425                                                0,
2426                                                100);
2427   EEM_OccupancyHCAL_ =
2428       new TH2F("OccupancyAllEvents_HCAL", "Occupancy all events HCAL EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2429   EEM_OccupancyCoarseHCAL_ =
2430       new TH2F("OccupancyAllEventsCoarse_HCAL", "Occupancy all events Coarse HCAL EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2431   EEM_FedsTimingHistHCAL_ =
2432       new TH1F("timeForAllFeds_HCAL", "timeForAllFeds HCAL EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
2433   EEM_FedsTimingTTHistHCAL_ =
2434       new TH3F("timeTTAllFEDs_HCAL",
2435                "(ix,iy,time) for all FEDs (SM,TT binning) HCAL EEM;ix;iy;Relative Time (1 clock = 25ns)",
2436                20,
2437                0,
2438                100,
2439                20,
2440                0,
2441                100,
2442                78,
2443                -7,
2444                7);
2445 
2446   EEM_numberofBCinSC_ =
2447       new TH1F("numberofBCinSC", "Number of Basic Clusters in Super Cluster EEM;Num Basic Clusters", 20, 0, 20);
2448 
2449   EEM_triggerHist_ = new TH1F("triggerHist", "Trigger Number EEM", 5, 0, 5);
2450   EEM_triggerHist_->GetXaxis()->SetBinLabel(1, "ECAL");
2451   EEM_triggerHist_->GetXaxis()->SetBinLabel(2, "HCAL");
2452   EEM_triggerHist_->GetXaxis()->SetBinLabel(3, "DT");
2453   EEM_triggerHist_->GetXaxis()->SetBinLabel(4, "RPC");
2454   EEM_triggerHist_->GetXaxis()->SetBinLabel(5, "CSC");
2455 
2456   EEM_triggerExclusiveHist_ = new TH1F("triggerExclusiveHist", "Trigger Number (Mutually Exclusive) EEM", 5, 0, 5);
2457   triggerExclusiveHist_->GetXaxis()->SetBinLabel(1, "ECAL");
2458   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(2, "HCAL");
2459   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(3, "DT");
2460   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(4, "RPC");
2461   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(5, "CSC");
2462 
2463   EEM_NumXtalsInClusterHist_ =
2464       new TH1F("NumXtalsInClusterAllHist", "Number of Xtals in Cluster EEM;NumXtals", 150, 0, 150);
2465   EEM_numxtalsVsEnergy_ = new TH2F("NumXtalsVsEnergy",
2466                                    "Number of Xtals in Cluster vs Energy EEM;Energy (GeV);Number of Xtals in Cluster",
2467                                    numBins,
2468                                    histRangeMin_,
2469                                    10.0,
2470                                    150,
2471                                    0,
2472                                    150);
2473   EEM_numxtalsVsHighEnergy_ =
2474       new TH2F("NumXtalsVsHighEnergy",
2475                "Number of Xtals in Cluster vs Energy EEM;Energy (GeV);Number of Xtals in Cluster",
2476                numBins,
2477                histRangeMin_,
2478                200.,
2479                150,
2480                0,
2481                150);
2482 
2483   EEM_OccupancyHighEnergy_ =
2484       new TH2F("OccupancyHighEnergyEvents", "Occupancy high energy events EEM;ix;iy", 100, 0, 100, 100, 0, 100);
2485   EEM_OccupancyHighEnergyCoarse_ = new TH2F(
2486       "OccupancyHighEnergyEventsCoarse", "Occupancy high energy events Coarse EEM;ix;iy", 20, 0, 100, 20, 0, 100);
2487 
2488   EEM_FedsNumXtalsInClusterHist_ =
2489       new TH1F("NumActiveXtalsInClusterAllHist", "Number of active Xtals in Cluster EEM;NumXtals", 100, 0, 100);
2490 
2491   // EE+
2492   EEP_FedsSeedEnergyHist_ =
2493       new TH1F("SeedEnergyAllFEDs", "Seed Energy for EEP Feds; Seed Energy (GeV)", 200, histRangeMin_, 10.0);
2494 
2495   EEP_AllOccupancyCoarse_ =
2496       new TH2F("OccupancyAllEventsCoarse", "Occupancy all events Coarse EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2497   EEP_AllOccupancy_ = new TH2F("OccupancyAllEvents", "Occupancy all events EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2498   EEP_FedsenergyHist_ =
2499       new TH1F("energy_AllClusters", "energy_AllClusters_EEP;Cluster Energy (GeV)", numBins, histRangeMin_, 10.0);
2500   EEP_FedsenergyHighHist_ = new TH1F(
2501       "energyHigh_AllClusters", "energyHigh_AllClusters in EEP;Cluster Energy (GeV)", numBins, histRangeMin_, 200.0);
2502   EEP_FedsenergyOnlyHighHist_ = new TH1F("energyHigh_HighEnergyClusters",
2503                                          "energy of High Energy Clusters in EEP;Cluster Energy (GeV)",
2504                                          numBins,
2505                                          histRangeMin_,
2506                                          200.0);
2507   EEP_FedsE2Hist_ =
2508       new TH1F("E2_AllClusters", "E2_AllClusters_EEP;Seed+highest neighbor energy (GeV)", numBins, histRangeMin_, 10.0);
2509   EEP_FedsE2vsE1Hist_ = new TH2F("E2vsE1_AllClusters",
2510                                  "E2vsE1_AllClusters_EEP;Seed Energy (GeV);Seed+highest neighbor energy (GeV)",
2511                                  numBins,
2512                                  histRangeMin_,
2513                                  10.0,
2514                                  numBins,
2515                                  histRangeMin_,
2516                                  10.0);
2517   EEP_FedsenergyvsE1Hist_ = new TH2F("energyvsE1_AllClusters",
2518                                      "energyvsE1_AllClusters_EEP;Seed Energy (GeV);Energy(GeV)",
2519                                      numBins,
2520                                      histRangeMin_,
2521                                      10.0,
2522                                      numBins,
2523                                      histRangeMin_,
2524                                      10.0);
2525   EEP_FedsTimingHist_ = new TH1F("timeForAllFeds", "timeForAllFeds_EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
2526   EEP_numberofCosmicsHist_ =
2527       new TH1F("numberofCosmicsPerEvent", "Number of cosmics per event EEP;Number of Cosmics", 30, 0, 30);
2528 
2529   EEP_FedsTimingVsAmpHist_ = new TH2F("timeVsAmpAllEvents",
2530                                       "time Vs Amp All Events EEP;Relative Time (1 clock = 25ns);Amplitude (GeV)",
2531                                       78,
2532                                       -7,
2533                                       7,
2534                                       numBins,
2535                                       histRangeMin_,
2536                                       10.0);
2537   EEP_FedsTimingTTHist_ = new TH3F("timeTTAllFEDs",
2538                                    "(ix,iy,time) for all FEDs (SM,TT binning) EEP;ix;iy;Relative Time (1 clock = 25ns)",
2539                                    20,
2540                                    0,
2541                                    100,
2542                                    20,
2543                                    0,
2544                                    100,
2545                                    78,
2546                                    -7,
2547                                    7);
2548 
2549   EEP_OccupancySingleXtal_ =
2550       new TH2F("OccupancySingleXtal", "Occupancy single xtal clusters EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2551   EEP_energySingleXtalHist_ = new TH1F("energy_SingleXtalClusters",
2552                                        "Energy single xtal clusters EEP;Cluster Energy (GeV)",
2553                                        numBins,
2554                                        histRangeMin_,
2555                                        200.0);
2556 
2557   EEP_OccupancyExclusiveECAL_ = new TH2F(
2558       "OccupancyAllEvents_ExclusiveECAL", "Occupancy all events Exclusive ECAL  EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2559   EEP_OccupancyCoarseExclusiveECAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveECAL",
2560                                                "Occupancy all events Coarse Exclusive ECAL EEP;ix;iy",
2561                                                20,
2562                                                0,
2563                                                100,
2564                                                20,
2565                                                0,
2566                                                100);
2567   EEP_OccupancyECAL_ =
2568       new TH2F("OccupancyAllEvents_ECAL", "Occupancy all events ECAL EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2569   EEP_OccupancyCoarseECAL_ =
2570       new TH2F("OccupancyAllEventsCoarse_ECAL", "Occupancy all events Coarse ECAL EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2571   EEP_FedsTimingHistECAL_ =
2572       new TH1F("timeForAllFeds_ECAL", "timeForAllFeds ECAL EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
2573   EEP_FedsTimingTTHistECAL_ =
2574       new TH3F("timeTTAllFEDs_ECAL",
2575                "(ix,iy,time) for all FEDs (SM,TT binning) ECAL EEP;ix;iy;Relative Time (1 clock = 25ns)",
2576                20,
2577                0,
2578                100,
2579                20,
2580                0,
2581                100,
2582                78,
2583                -7,
2584                7);
2585 
2586   EEP_OccupancyExclusiveDT_ = new TH2F(
2587       "OccupancyAllEvents_ExclusiveDT", "Occupancy all events Exclusive DT EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2588   EEP_OccupancyCoarseExclusiveDT_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveDT",
2589                                              "Occupancy all events Coarse Exclusive DT EEP;ix;iy",
2590                                              20,
2591                                              0,
2592                                              100,
2593                                              20,
2594                                              0,
2595                                              100);
2596   EEP_OccupancyDT_ = new TH2F("OccupancyAllEvents_DT", "Occupancy all events DT EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2597   EEP_OccupancyCoarseDT_ =
2598       new TH2F("OccupancyAllEventsCoarse_DT", "Occupancy all events Coarse DT EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2599   EEP_FedsTimingHistDT_ =
2600       new TH1F("timeForAllFeds_DT", "timeForAllFeds DT EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
2601   EEP_FedsTimingTTHistDT_ =
2602       new TH3F("timeTTAllFEDs_DT",
2603                "(ix,iy,time) for all FEDs (SM,TT binning) DT EEP;ix;iy;Relative Time (1 clock = 25ns)",
2604                20,
2605                0,
2606                100,
2607                20,
2608                0,
2609                100,
2610                78,
2611                -7,
2612                7);
2613 
2614   EEP_OccupancyExclusiveRPC_ = new TH2F(
2615       "OccupancyAllEvents_ExclusiveRPC", "Occupancy all events Exclusive RPC EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2616   EEP_OccupancyCoarseExclusiveRPC_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveRPC",
2617                                               "Occupancy all events Coarse Exclusive RPC EEP;ix;iy",
2618                                               20,
2619                                               0,
2620                                               100,
2621                                               20,
2622                                               0,
2623                                               100);
2624   EEP_OccupancyRPC_ =
2625       new TH2F("OccupancyAllEvents_RPC", "Occupancy all events RPC EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2626   EEP_OccupancyCoarseRPC_ =
2627       new TH2F("OccupancyAllEventsCoarse_RPC", "Occupancy all events Coarse RPC EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2628   EEP_FedsTimingHistRPC_ =
2629       new TH1F("timeForAllFeds_RPC", "timeForAllFeds RPC EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
2630   EEP_FedsTimingTTHistRPC_ =
2631       new TH3F("timeTTAllFEDs_RPC",
2632                "(ix,iy,time) for all FEDs (SM,TT binning) RPC EEP;ix;iy;Relative Time (1 clock = 25ns)",
2633                20,
2634                0,
2635                100,
2636                20,
2637                0,
2638                100,
2639                78,
2640                -7,
2641                7);
2642 
2643   EEP_OccupancyExclusiveCSC_ = new TH2F(
2644       "OccupancyAllEvents_ExclusiveCSC", "Occupancy all events Exclusive CSC EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2645   EEP_OccupancyCoarseExclusiveCSC_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveCSC",
2646                                               "Occupancy all events Coarse Exclusive CSC EEP;ix;iy",
2647                                               20,
2648                                               0,
2649                                               100,
2650                                               20,
2651                                               0,
2652                                               100);
2653   EEP_OccupancyCSC_ =
2654       new TH2F("OccupancyAllEvents_CSC", "Occupancy all events CSC EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2655   EEP_OccupancyCoarseCSC_ =
2656       new TH2F("OccupancyAllEventsCoarse_CSC", "Occupancy all events Coarse CSC EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2657   EEP_FedsTimingHistCSC_ =
2658       new TH1F("timeForAllFeds_CSC", "timeForAllFeds CSC EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
2659   EEP_FedsTimingTTHistCSC_ =
2660       new TH3F("timeTTAllFEDs_CSC",
2661                "(ix,iy,time) for all FEDs (SM,TT binning) CSC EEP;ix;iy;Relative Time (1 clock = 25ns)",
2662                20,
2663                0,
2664                100,
2665                20,
2666                0,
2667                100,
2668                78,
2669                -7,
2670                7);
2671 
2672   EEP_OccupancyExclusiveHCAL_ = new TH2F(
2673       "OccupancyAllEvents_ExclusiveHCAL", "Occupancy all events Exclusive HCAL EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2674   EEP_OccupancyCoarseExclusiveHCAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveHCAL",
2675                                                "Occupancy all events Coarse Exclusive HCAL EEP;ix;iy",
2676                                                20,
2677                                                0,
2678                                                100,
2679                                                20,
2680                                                0,
2681                                                100);
2682   EEP_OccupancyHCAL_ =
2683       new TH2F("OccupancyAllEvents_HCAL", "Occupancy all events HCAL EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2684   EEP_OccupancyCoarseHCAL_ =
2685       new TH2F("OccupancyAllEventsCoarse_HCAL", "Occupancy all events Coarse HCAL EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2686   EEP_FedsTimingHistHCAL_ =
2687       new TH1F("timeForAllFeds_HCAL", "timeForAllFeds HCAL EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
2688   EEP_FedsTimingTTHistHCAL_ =
2689       new TH3F("timeTTAllFEDs_HCAL",
2690                "(ix,iy,time) for all FEDs (SM,TT binning) HCAL EEP;ix;iy;Relative Time (1 clock = 25ns)",
2691                20,
2692                0,
2693                100,
2694                20,
2695                0,
2696                100,
2697                78,
2698                -7,
2699                7);
2700 
2701   EEP_numberofBCinSC_ =
2702       new TH1F("numberofBCinSC", "Number of Basic Clusters in Super Cluster EEP;Num Basic Clusters", 20, 0, 20);
2703 
2704   EEP_triggerHist_ = new TH1F("triggerHist", "Trigger Number EEP", 5, 0, 5);
2705   EEP_triggerHist_->GetXaxis()->SetBinLabel(1, "ECAL");
2706   EEP_triggerHist_->GetXaxis()->SetBinLabel(2, "HCAL");
2707   EEP_triggerHist_->GetXaxis()->SetBinLabel(3, "DT");
2708   EEP_triggerHist_->GetXaxis()->SetBinLabel(4, "RPC");
2709   EEP_triggerHist_->GetXaxis()->SetBinLabel(5, "CSC");
2710 
2711   EEP_triggerExclusiveHist_ = new TH1F("triggerExclusiveHist", "Trigger Number (Mutually Exclusive) EEP", 5, 0, 5);
2712   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(1, "ECAL");
2713   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(2, "HCAL");
2714   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(3, "DT");
2715   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(4, "RPC");
2716   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(5, "CSC");
2717 
2718   EEP_NumXtalsInClusterHist_ =
2719       new TH1F("NumXtalsInClusterAllHist", "Number of Xtals in Cluster EEP;NumXtals", 150, 0, 150);
2720   EEP_numxtalsVsEnergy_ = new TH2F("NumXtalsVsEnergy",
2721                                    "Number of Xtals in Cluster vs Energy EEP;Energy (GeV);Number of Xtals in Cluster",
2722                                    numBins,
2723                                    histRangeMin_,
2724                                    10.0,
2725                                    150,
2726                                    0,
2727                                    150);
2728   EEP_numxtalsVsHighEnergy_ =
2729       new TH2F("NumXtalsVsHighEnergy",
2730                "Number of Xtals in Cluster vs Energy EEP;Energy (GeV);Number of Xtals in Cluster",
2731                numBins,
2732                histRangeMin_,
2733                200.,
2734                150,
2735                0,
2736                150);
2737 
2738   EEP_OccupancyHighEnergy_ =
2739       new TH2F("OccupancyHighEnergyEvents", "Occupancy high energy events EEP;ix;iy", 100, 0, 100, 100, 0, 100);
2740   EEP_OccupancyHighEnergyCoarse_ = new TH2F(
2741       "OccupancyHighEnergyEventsCoarse", "Occupancy high energy events Coarse EEP;ix;iy", 20, 0, 100, 20, 0, 100);
2742 
2743   EEP_FedsNumXtalsInClusterHist_ =
2744       new TH1F("NumActiveXtalsInClusterAllHist", "Number of active Xtals in Cluster EEP;NumXtals", 100, 0, 100);
2745 }
2746 
2747 void EcalCosmicsHists::endRun(edm::Run const&, edm::EventSetup const& eventSetup) {}
2748 
2749 // ------------ method called once each job just after ending the event loop  ------------
2750 void EcalCosmicsHists::endJob() {
2751   using namespace std;
2752   if (runInFileName_) {
2753     fileName_ += "-" + intToString(runNum_) + ".graph.root";
2754   } else {
2755     fileName_ += ".root";
2756   }
2757 
2758   TFile root_file_(fileName_.c_str(), "RECREATE");
2759 
2760   for (map<int, TH1F*>::const_iterator itr = FEDsAndHists_.begin(); itr != FEDsAndHists_.end(); ++itr) {
2761     string dir = fedMap_->getSliceFromFed(itr->first);
2762     TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
2763     FEDdir->cd();
2764 
2765     TH1F* hist = itr->second;
2766     if (hist != nullptr)
2767       hist->Write();
2768     else {
2769       cerr << "EcalCosmicsHists: Error: This shouldn't happen!" << endl;
2770     }
2771     // Write out timing hist
2772     hist = FEDsAndTimingHists_[itr->first];
2773     if (hist != nullptr)
2774       hist->Write();
2775     else {
2776       cerr << "EcalCosmicsHists: Error: This shouldn't happen!" << endl;
2777     }
2778 
2779     hist = FEDsAndFrequencyHists_[itr->first];
2780     hist->Write();
2781 
2782     hist = FEDsAndiPhiProfileHists_[itr->first];
2783     hist->Write();
2784 
2785     hist = FEDsAndiEtaProfileHists_[itr->first];
2786     hist->Write();
2787 
2788     hist = FEDsAndE2Hists_[itr->first];
2789     hist->Write();
2790 
2791     hist = FEDsAndenergyHists_[itr->first];
2792     hist->Write();
2793 
2794     hist = FEDsAndNumXtalsInClusterHists_[itr->first];
2795     hist->Write();
2796 
2797     TH2F* hist2 = FEDsAndTimingVsAmpHists_[itr->first];
2798     hist2->Write();
2799 
2800     hist2 = FEDsAndTimingVsFreqHists_[itr->first];
2801     hist2->Write();
2802 
2803     hist2 = FEDsAndE2vsE1Hists_[itr->first];
2804     hist2->Write();
2805 
2806     hist2 = FEDsAndenergyvsE1Hists_[itr->first];
2807     hist2->Write();
2808 
2809     hist2 = FEDsAndOccupancyHists_[itr->first];
2810     hist2->Write();
2811 
2812     hist2 = FEDsAndTimingVsPhiHists_[itr->first];
2813     hist2->Write();
2814 
2815     hist2 = FEDsAndTimingVsModuleHists_[itr->first];
2816     hist2->Write();
2817 
2818     //2d hist
2819     map<int, TH2F*>::const_iterator itr2d;
2820     itr2d = FEDsAndDCCRuntypeVsBxHists_.find(itr->first);
2821     if (itr2d != FEDsAndDCCRuntypeVsBxHists_.end()) {
2822       TH2F* hist2 = itr2d->second;
2823       hist2->GetYaxis()->SetBinLabel(1, "COSMIC");
2824       hist2->GetYaxis()->SetBinLabel(2, "BEAMH4");
2825       hist2->GetYaxis()->SetBinLabel(3, "BEAMH2");
2826       hist2->GetYaxis()->SetBinLabel(4, "MTCC");
2827       hist2->GetYaxis()->SetBinLabel(5, "LASER_STD");
2828       hist2->GetYaxis()->SetBinLabel(6, "LASER_POWER_SCAN");
2829       hist2->GetYaxis()->SetBinLabel(7, "LASER_DELAY_SCAN");
2830       hist2->GetYaxis()->SetBinLabel(8, "TESTPULSE_SCAN_MEM");
2831       hist2->GetYaxis()->SetBinLabel(9, "TESTPULSE_MGPA");
2832       hist2->GetYaxis()->SetBinLabel(10, "PEDESTAL_STD");
2833       hist2->GetYaxis()->SetBinLabel(11, "PEDESTAL_OFFSET_SCAN");
2834       hist2->GetYaxis()->SetBinLabel(12, "PEDESTAL_25NS_SCAN");
2835       hist2->GetYaxis()->SetBinLabel(13, "LED_STD");
2836       hist2->GetYaxis()->SetBinLabel(14, "PHYSICS_GLOBAL");
2837       hist2->GetYaxis()->SetBinLabel(15, "COSMICS_GLOBAL");
2838       hist2->GetYaxis()->SetBinLabel(16, "HALO_GLOBAL");
2839       hist2->GetYaxis()->SetBinLabel(17, "LASER_GAP");
2840       hist2->GetYaxis()->SetBinLabel(18, "TESTPULSE_GAP");
2841       hist2->GetYaxis()->SetBinLabel(19, "PEDESTAL_GAP");
2842       hist2->GetYaxis()->SetBinLabel(20, "LED_GAP");
2843       hist2->GetYaxis()->SetBinLabel(21, "PHYSICS_LOCAL");
2844       hist2->GetYaxis()->SetBinLabel(22, "COSMICS_LOCAL");
2845       hist2->GetYaxis()->SetBinLabel(23, "HALO_LOCAL");
2846       hist2->GetYaxis()->SetBinLabel(24, "CALIB_LOCAL");
2847       hist2->Write();
2848     }
2849 
2850     root_file_.cd();
2851   }
2852   allFedsHist_->Write();
2853   allFedsE2Hist_->Write();
2854   allFedsenergyHist_->Write();
2855   allFedsenergyHighHist_->Write();
2856   allFedsenergyOnlyHighHist_->Write();
2857   allFedsE2vsE1Hist_->Write();
2858   allFedsenergyvsE1Hist_->Write();
2859   allFedsTimingHist_->Write();
2860   allFedsTimingVsAmpHist_->Write();
2861   allFedsFrequencyHist_->Write();
2862   allFedsTimingVsFreqHist_->Write();
2863   allFedsiEtaProfileHist_->Write();
2864   allFedsiPhiProfileHist_->Write();
2865   allOccupancy_->Write();
2866   TrueOccupancy_->Write();
2867   allOccupancyCoarse_->Write();
2868   TrueOccupancyCoarse_->Write();
2869   allOccupancyHighEnergy_->Write();
2870   allOccupancyHighEnergyCoarse_->Write();
2871   allOccupancySingleXtal_->Write();
2872   energySingleXtalHist_->Write();
2873   allFedsNumXtalsInClusterHist_->Write();
2874   allFedsTimingPhiHist_->Write();
2875   allFedsTimingPhiEbpHist_->Write();
2876   allFedsTimingPhiEbmHist_->Write();
2877   allFedsTimingEbpHist_->Write();
2878   allFedsTimingEbmHist_->Write();
2879   allFedsTimingEbpTopHist_->Write();
2880   allFedsTimingEbmTopHist_->Write();
2881   allFedsTimingEbpBottomHist_->Write();
2882   allFedsTimingEbmBottomHist_->Write();
2883   allFedsTimingPhiEtaHist_->Write();
2884   allFedsTimingTTHist_->Write();
2885   allFedsTimingLMHist_->Write();
2886   allFedsOccupancyHighEnergyHist_->Write();
2887 
2888   numberofBCinSC_->Write();         //SC
2889   numberofBCinSCphi_->Write();      //SC
2890   TrueBCOccupancyCoarse_->Write();  //BC
2891   TrueBCOccupancy_->Write();        //BC
2892 
2893   numxtalsVsEnergy_->Write();
2894   numxtalsVsHighEnergy_->Write();
2895 
2896   allOccupancyExclusiveECAL_->Write();
2897   allOccupancyCoarseExclusiveECAL_->Write();
2898   allOccupancyECAL_->Write();
2899   allOccupancyCoarseECAL_->Write();
2900   allFedsTimingPhiEtaHistECAL_->Write();
2901   allFedsTimingHistECAL_->Write();
2902   allFedsTimingTTHistECAL_->Write();
2903   allFedsTimingLMHistECAL_->Write();
2904 
2905   allOccupancyExclusiveHCAL_->Write();
2906   allOccupancyCoarseExclusiveHCAL_->Write();
2907   allOccupancyHCAL_->Write();
2908   allOccupancyCoarseHCAL_->Write();
2909   allFedsTimingPhiEtaHistHCAL_->Write();
2910   allFedsTimingHistHCAL_->Write();
2911   allFedsTimingTTHistHCAL_->Write();
2912   allFedsTimingLMHistHCAL_->Write();
2913 
2914   allOccupancyExclusiveDT_->Write();
2915   allOccupancyCoarseExclusiveDT_->Write();
2916   allOccupancyDT_->Write();
2917   allOccupancyCoarseDT_->Write();
2918   allFedsTimingPhiEtaHistDT_->Write();
2919   allFedsTimingHistDT_->Write();
2920   allFedsTimingTTHistDT_->Write();
2921   allFedsTimingLMHistDT_->Write();
2922 
2923   allOccupancyExclusiveRPC_->Write();
2924   allOccupancyCoarseExclusiveRPC_->Write();
2925   allOccupancyRPC_->Write();
2926   allOccupancyCoarseRPC_->Write();
2927   allFedsTimingPhiEtaHistRPC_->Write();
2928   allFedsTimingHistRPC_->Write();
2929   allFedsTimingTTHistRPC_->Write();
2930   allFedsTimingLMHistRPC_->Write();
2931 
2932   allOccupancyExclusiveCSC_->Write();
2933   allOccupancyCoarseExclusiveCSC_->Write();
2934   allOccupancyCSC_->Write();
2935   allOccupancyCoarseCSC_->Write();
2936   allFedsTimingPhiEtaHistCSC_->Write();
2937   allFedsTimingHistCSC_->Write();
2938   allFedsTimingTTHistCSC_->Write();
2939   allFedsTimingLMHistCSC_->Write();
2940 
2941   allFedsTimingHistEcalMuon_->Write();
2942 
2943   //EE
2944   TDirectory* EEMinusDir = gDirectory->mkdir("EEMinus");
2945   EEMinusDir->cd();
2946   EEM_FedsSeedEnergyHist_->Write();
2947   EEM_AllOccupancyCoarse_->Write();
2948   EEM_AllOccupancy_->Write();
2949   EEM_FedsenergyHist_->Write();
2950   EEM_FedsenergyHighHist_->Write();
2951   EEM_FedsenergyOnlyHighHist_->Write();
2952   EEM_FedsE2Hist_->Write();
2953   EEM_FedsE2vsE1Hist_->Write();
2954   EEM_FedsenergyvsE1Hist_->Write();
2955   EEM_FedsTimingHist_->Write();
2956   EEM_numberofCosmicsHist_->Write();
2957   EEM_FedsTimingVsAmpHist_->Write();
2958   EEM_FedsTimingTTHist_->Write();
2959   EEM_OccupancySingleXtal_->Write();
2960   EEM_energySingleXtalHist_->Write();
2961   EEM_OccupancyExclusiveECAL_->Write();
2962   EEM_OccupancyCoarseExclusiveECAL_->Write();
2963   EEM_OccupancyECAL_->Write();
2964   EEM_OccupancyCoarseECAL_->Write();
2965   EEM_FedsTimingHistECAL_->Write();
2966   EEM_FedsTimingTTHistECAL_->Write();
2967   EEM_OccupancyExclusiveDT_->Write();
2968   EEM_OccupancyCoarseExclusiveDT_->Write();
2969   EEM_OccupancyDT_->Write();
2970   EEM_OccupancyCoarseDT_->Write();
2971   EEM_FedsTimingHistDT_->Write();
2972   EEM_FedsTimingTTHistDT_->Write();
2973   EEM_OccupancyExclusiveRPC_->Write();
2974   EEM_OccupancyCoarseExclusiveRPC_->Write();
2975   EEM_OccupancyRPC_->Write();
2976   EEM_OccupancyCoarseRPC_->Write();
2977   EEM_FedsTimingHistRPC_->Write();
2978   EEM_FedsTimingTTHistRPC_->Write();
2979   EEM_OccupancyExclusiveCSC_->Write();
2980   EEM_OccupancyCoarseExclusiveCSC_->Write();
2981   EEM_OccupancyCSC_->Write();
2982   EEM_OccupancyCoarseCSC_->Write();
2983   EEM_FedsTimingHistCSC_->Write();
2984   EEM_FedsTimingTTHistCSC_->Write();
2985   EEM_OccupancyExclusiveHCAL_->Write();
2986   EEM_OccupancyCoarseExclusiveHCAL_->Write();
2987   EEM_OccupancyHCAL_->Write();
2988   EEM_OccupancyCoarseHCAL_->Write();
2989   EEM_FedsTimingHistHCAL_->Write();
2990   EEM_FedsTimingTTHistHCAL_->Write();
2991   EEM_numberofBCinSC_->Write();
2992   EEM_triggerHist_->Write();
2993   EEM_triggerExclusiveHist_->Write();
2994   EEM_NumXtalsInClusterHist_->Write();
2995   EEM_numxtalsVsEnergy_->Write();
2996   EEM_numxtalsVsHighEnergy_->Write();
2997   EEM_OccupancyHighEnergy_->Write();
2998   EEM_OccupancyHighEnergyCoarse_->Write();
2999   EEM_FedsNumXtalsInClusterHist_->Write();
3000   root_file_.cd();
3001 
3002   TDirectory* EEPlusDir = gDirectory->mkdir("EEPlus");
3003   EEPlusDir->cd();
3004   EEP_FedsSeedEnergyHist_->Write();
3005   EEP_AllOccupancyCoarse_->Write();
3006   EEP_AllOccupancy_->Write();
3007   EEP_FedsenergyHist_->Write();
3008   EEP_FedsenergyHighHist_->Write();
3009   EEP_FedsenergyOnlyHighHist_->Write();
3010   EEP_FedsE2Hist_->Write();
3011   EEP_FedsE2vsE1Hist_->Write();
3012   EEP_FedsenergyvsE1Hist_->Write();
3013   EEP_FedsTimingHist_->Write();
3014   EEP_numberofCosmicsHist_->Write();
3015   EEP_FedsTimingVsAmpHist_->Write();
3016   EEP_FedsTimingTTHist_->Write();
3017   EEP_OccupancySingleXtal_->Write();
3018   EEP_energySingleXtalHist_->Write();
3019   EEP_OccupancyExclusiveECAL_->Write();
3020   EEP_OccupancyCoarseExclusiveECAL_->Write();
3021   EEP_OccupancyECAL_->Write();
3022   EEP_OccupancyCoarseECAL_->Write();
3023   EEP_FedsTimingHistECAL_->Write();
3024   EEP_FedsTimingTTHistECAL_->Write();
3025   EEP_OccupancyExclusiveDT_->Write();
3026   EEP_OccupancyCoarseExclusiveDT_->Write();
3027   EEP_OccupancyDT_->Write();
3028   EEP_OccupancyCoarseDT_->Write();
3029   EEP_FedsTimingHistDT_->Write();
3030   EEP_FedsTimingTTHistDT_->Write();
3031   EEP_OccupancyExclusiveRPC_->Write();
3032   EEP_OccupancyCoarseExclusiveRPC_->Write();
3033   EEP_OccupancyRPC_->Write();
3034   EEP_OccupancyCoarseRPC_->Write();
3035   EEP_FedsTimingHistRPC_->Write();
3036   EEP_FedsTimingTTHistRPC_->Write();
3037   EEP_OccupancyExclusiveCSC_->Write();
3038   EEP_OccupancyCoarseExclusiveCSC_->Write();
3039   EEP_OccupancyCSC_->Write();
3040   EEP_OccupancyCoarseCSC_->Write();
3041   EEP_FedsTimingHistCSC_->Write();
3042   EEP_FedsTimingTTHistCSC_->Write();
3043   EEP_OccupancyExclusiveHCAL_->Write();
3044   EEP_OccupancyCoarseExclusiveHCAL_->Write();
3045   EEP_OccupancyHCAL_->Write();
3046   EEP_OccupancyCoarseHCAL_->Write();
3047   EEP_FedsTimingHistHCAL_->Write();
3048   EEP_FedsTimingTTHistHCAL_->Write();
3049   EEP_numberofBCinSC_->Write();
3050   EEP_triggerHist_->Write();
3051   EEP_triggerExclusiveHist_->Write();
3052   EEP_NumXtalsInClusterHist_->Write();
3053   EEP_numxtalsVsEnergy_->Write();
3054   EEP_numxtalsVsHighEnergy_->Write();
3055   EEP_OccupancyHighEnergy_->Write();
3056   EEP_OccupancyHighEnergyCoarse_->Write();
3057   EEP_FedsNumXtalsInClusterHist_->Write();
3058   root_file_.cd();
3059 
3060   triggerHist_->Write();
3061   triggerExclusiveHist_->Write();
3062 
3063   NumXtalsInClusterHist_->Write();
3064 
3065   numberofCosmicsHist_->Write();
3066   numberofCosmicsHistEB_->Write();
3067 
3068   numberofCosmicsWTrackHist_->Write();
3069   numberofCosmicsTopBottomHist_->Write();
3070   numberofGoodEvtFreq_->Write();
3071   numberofCrossedEcalIdsHist_->Write();
3072 
3073   runNumberHist_->SetBinContent(1, runNum_);
3074   runNumberHist_->Write();
3075 
3076   deltaRHist_->Write();
3077   deltaEtaHist_->Write();
3078   deltaPhiHist_->Write();
3079   ratioAssocClustersHist_->Write();
3080   ratioAssocTracksHist_->Write();
3081   deltaEtaDeltaPhiHist_->Write();
3082   seedTrackPhiHist_->Write();
3083   seedTrackEtaHist_->Write();
3084   dccEventVsBxHist_->Write();
3085   dccOrbitErrorByFEDHist_->Write();
3086   dccBXErrorByFEDHist_->Write();
3087   dccRuntypeErrorByFEDHist_->Write();
3088   dccErrorVsBxHist_->Write();
3089   dccRuntypeHist_->Write();
3090 
3091   trackAssoc_muonsEcal_->Write();
3092 
3093   hcalEnergy_HBHE_->Write();
3094   hcalEnergy_HF_->Write();
3095   hcalEnergy_HO_->Write();
3096   hcalHEHBecalEB_->Write();
3097 
3098   TDirectory* highEnergyDir = gDirectory->mkdir("HighEnergy");
3099   highEnergyDir->cd();
3100   HighEnergy_NumXtal->Write();
3101   HighEnergy_NumXtalFedId->Write();
3102   HighEnergy_NumXtaliphi->Write();
3103   HighEnergy_energy3D->Write();
3104   HighEnergy_energyNumXtal->Write();
3105   HighEnergy_bestSeed->Write();
3106   HighEnergy_bestSeedOccupancy->Write();
3107   HighEnergy_numClusHighEn->Write();
3108   HighEnergy_ratioClusters->Write();
3109   HighEnergy_numRecoTrackBarrel->Write();
3110   HighEnergy_TracksAngle->Write();
3111   HighEnergy_TracksAngleTopBottom->Write();
3112   HighEnergy_2GeV_occuCoarse->Write();
3113   HighEnergy_2GeV_occu3D->Write();
3114   HighEnergy_100GeV_occuCoarse->Write();
3115   HighEnergy_100GeV_occu3D->Write();
3116   HighEnergy_0tracks_occu3D->Write();
3117   HighEnergy_1tracks_occu3D->Write();
3118   HighEnergy_2tracks_occu3D->Write();
3119   HighEnergy_0tracks_occu3DXtal->Write();
3120   HighEnergy_1tracks_occu3DXtal->Write();
3121   HighEnergy_2tracks_occu3DXtal->Write();
3122 
3123   root_file_.cd();
3124 
3125   TDirectory* TimeStampdir = gDirectory->mkdir("EventTiming");
3126   TimeStampdir->cd();
3127   allFedsFreqTimeHist_->Write();
3128   allFedsFreqTimeVsPhiHist_->Write();
3129   allFedsFreqTimeVsPhiTTHist_->Write();
3130   allFedsFreqTimeVsEtaHist_->Write();
3131   allFedsFreqTimeVsEtaTTHist_->Write();
3132 
3133   root_file_.cd();
3134 
3135   root_file_.Close();
3136 
3137   LogWarning("EcalCosmicsHists") << "---> Number of cosmic events: " << cosmicCounter_ << " in " << naiveEvtNum_
3138                                  << " events.";
3139   LogWarning("EcalCosmicsHists") << "---> Number of EB cosmic events: " << cosmicCounterEB_ << " in " << naiveEvtNum_
3140                                  << " events.";
3141   LogWarning("EcalCosmicsHists") << "---> Number of EE- cosmic events: " << cosmicCounterEEM_ << " in " << naiveEvtNum_
3142                                  << " events.";
3143   LogWarning("EcalCosmicsHists") << "---> Number of EE+ cosmic events: " << cosmicCounterEEP_ << " in " << naiveEvtNum_
3144                                  << " events.";
3145 
3146   //  LogWarning("EcalCosmicsHists") << "---> Number of top+bottom cosmic events: " << cosmicCounterTopBottom_ << " in " << cosmicCounter_ << " cosmics in " << naiveEvtNum_ << " events.";
3147 }
3148 
3149 std::string EcalCosmicsHists::intToString(int num) {
3150   using namespace std;
3151   ostringstream myStream;
3152   myStream << num << flush;
3153   return (myStream.str());  //returns the string form of the stringstream object
3154 }