Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:   EcalDisplaysByEvent
0004 // Class:     EcalDisplaysByEvent
0005 //
0006 /**\class EcalDisplaysByEvent EcalDisplaysByEvent.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Seth COOPER
0015 //         Created:  Th Aug 28 5:46:22 CEST 2007
0016 //
0017 //
0018 
0019 #include "CaloOnlineTools/EcalTools/plugins/EcalDisplaysByEvent.h"
0020 #include "RecoCaloTools/Navigation/interface/CaloNavigator.h"
0021 #include "TLatex.h"
0022 #include "TLine.h"
0023 #include "TProfile2D.h"
0024 #include <utility>
0025 using namespace edm;
0026 using namespace std;
0027 
0028 //
0029 // constants, enums and typedefs
0030 //
0031 
0032 //
0033 // static data member definitions
0034 //
0035 float EcalDisplaysByEvent::gainRatio[3] = {1., 2., 12.};
0036 edm::Service<TFileService> EcalDisplaysByEvent::fileService;
0037 
0038 //
0039 // constructors and destructor
0040 //
0041 EcalDisplaysByEvent::EcalDisplaysByEvent(const edm::ParameterSet& iConfig)
0042     : EBRecHitCollection_(iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEB")),
0043       EERecHitCollection_(iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEE")),
0044       EBDigis_(iConfig.getParameter<edm::InputTag>("EBDigiCollection")),
0045       EEDigis_(iConfig.getParameter<edm::InputTag>("EEDigiCollection")),
0046       headerProducer_(iConfig.getParameter<edm::InputTag>("headerProducer")),
0047       rawDataToken_(consumes<EcalRawDataCollection>(headerProducer_)),
0048       ebRecHitToken_(consumes<EcalRecHitCollection>(EBRecHitCollection_)),
0049       eeRecHitToken_(consumes<EcalRecHitCollection>(EERecHitCollection_)),
0050       ebDigiToken_(consumes<EBDigiCollection>(EBDigis_)),
0051       eeDigiToken_(consumes<EEDigiCollection>(EEDigis_)),
0052       ecalMappingToken_(esConsumes<edm::Transition::BeginRun>()),
0053       topologyToken_(esConsumes()),
0054       runNum_(-1),
0055       side_(iConfig.getUntrackedParameter<int>("side", 3)),
0056       threshold_(iConfig.getUntrackedParameter<double>("amplitudeThreshold", 0.5)),
0057       minTimingAmp_(iConfig.getUntrackedParameter<double>("minimumTimingAmplitude", 0.100)),
0058       makeDigiGraphs_(iConfig.getUntrackedParameter<bool>("makeDigiGraphs", false)),
0059       makeTimingHistos_(iConfig.getUntrackedParameter<bool>("makeTimingHistos", true)),
0060       makeEnergyHistos_(iConfig.getUntrackedParameter<bool>("makeEnergyHistos", true)),
0061       makeOccupancyHistos_(iConfig.getUntrackedParameter<bool>("makeOccupancyHistos", true)),
0062       histRangeMin_(iConfig.getUntrackedParameter<double>("histogramMinRange", 0.0)),
0063       histRangeMax_(iConfig.getUntrackedParameter<double>("histogramMaxRange", 1.8)),
0064       minTimingEnergyEB_(iConfig.getUntrackedParameter<double>("minTimingEnergyEB", 0.0)),
0065       minTimingEnergyEE_(iConfig.getUntrackedParameter<double>("minTimingEnergyEE", 0.0)) {
0066   vector<int> listDefaults;
0067   listDefaults.push_back(-1);
0068 
0069   maskedChannels_ = iConfig.getUntrackedParameter<vector<int> >("maskedChannels", listDefaults);
0070   maskedFEDs_ = iConfig.getUntrackedParameter<vector<int> >("maskedFEDs", listDefaults);
0071   seedCrys_ = iConfig.getUntrackedParameter<vector<int> >("seedCrys", listDefaults);
0072 
0073   vector<string> defaultMaskedEBs;
0074   defaultMaskedEBs.push_back("none");
0075   maskedEBs_ = iConfig.getUntrackedParameter<vector<string> >("maskedEBs", defaultMaskedEBs);
0076 
0077   fedMap_ = new EcalFedMap();
0078 
0079   string title1 = "Jitter for all FEDs all events";
0080   string name1 = "JitterAllFEDsAllEvents";
0081   allFedsTimingHist_ = fileService->make<TH1F>(name1.c_str(), title1.c_str(), 150, -7, 7);
0082 
0083   // load up the maskedFED list with the proper FEDids
0084   if (maskedFEDs_[0] == -1) {
0085     //if "actual" EB id given, then convert to FEDid and put in listFEDs_
0086     if (maskedEBs_[0] != "none") {
0087       maskedFEDs_.clear();
0088       for (vector<string>::const_iterator ebItr = maskedEBs_.begin(); ebItr != maskedEBs_.end(); ++ebItr) {
0089         maskedFEDs_.push_back(fedMap_->getFedFromSlice(*ebItr));
0090       }
0091     }
0092   }
0093 
0094   for (int i = 0; i < 10; i++)
0095     abscissa[i] = i;
0096 
0097   naiveEvtNum_ = 0;
0098 
0099   initAllEventHistos();
0100 }
0101 
0102 EcalDisplaysByEvent::~EcalDisplaysByEvent() {}
0103 
0104 //
0105 // member functions
0106 //
0107 
0108 // ------------ method called once each job just before starting event loop  ------------
0109 void EcalDisplaysByEvent::beginRun(edm::Run const&, edm::EventSetup const& c) {
0110   ecalElectronicsMap_ = &c.getData(ecalMappingToken_);
0111 }
0112 
0113 void EcalDisplaysByEvent::endRun(edm::Run const&, edm::EventSetup const& c) {}
0114 
0115 // ------------ method called to for each event  ------------
0116 void EcalDisplaysByEvent::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
0117   // get the headers
0118   // (one header for each supermodule)
0119   edm::Handle<EcalRawDataCollection> DCCHeaders;
0120   iEvent.getByToken(rawDataToken_, DCCHeaders);
0121 
0122   for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
0123        ++headerItr) {
0124     FEDsAndDCCHeaders_[headerItr->id() + 600] = *headerItr;
0125   }
0126 
0127   int ievt = iEvent.id().event();
0128   naiveEvtNum_++;
0129 
0130   if (runNum_ == -1) {
0131     runNum_ = iEvent.id().run();
0132     canvasNames_ = fileService->make<TTree>("canvasNames", "Names of written canvases");
0133     names = new std::vector<string>();
0134     canvasNames_->Branch("names", "vector<string>", &names);
0135 
0136     histoCanvasNames_ = fileService->make<TTree>("histoCanvasNames", "Names of written canvases with histos");
0137     histoCanvasNamesVector = new std::vector<string>();
0138     histoCanvasNames_->Branch("histoCanvasNamesVector", "vector<string>", &histoCanvasNamesVector);
0139   }
0140 
0141   //We only want the 3x3's for this event...
0142   listEBChannels.clear();
0143   listEEChannels.clear();
0144 
0145   //Get hits, digis, caloTopology from event/eventSetup
0146   caloTopo_ = &iSetup.getData(topologyToken_);
0147 
0148   Handle<EcalRecHitCollection> EBhits;
0149   Handle<EcalRecHitCollection> EEhits;
0150   iEvent.getByToken(ebRecHitToken_, EBhits);
0151   iEvent.getByToken(eeRecHitToken_, EEhits);
0152   iEvent.getByToken(ebDigiToken_, EBdigisHandle);
0153   iEvent.getByToken(eeDigiToken_, EEdigisHandle);
0154 
0155   // Initialize histos for this event
0156   initEvtByEvtHists(naiveEvtNum_, ievt);
0157 
0158   bool hasEBdigis = false;
0159   bool hasEEdigis = false;
0160   if (!EBdigisHandle->empty())
0161     hasEBdigis = true;
0162   if (!EEdigisHandle->empty())
0163     hasEEdigis = true;
0164 
0165   // Produce the digi graphs
0166   if (makeDigiGraphs_) {
0167     if (hasEBdigis)  //if event has digis, it should have hits
0168       selectHits(EBhits, ievt);
0169     if (hasEEdigis)
0170       selectHits(EEhits, ievt);
0171   }
0172 
0173   // Produce the histos
0174   if (hasEBdigis) {
0175     makeHistos(EBdigisHandle);
0176     makeHistos(EBhits);
0177   }
0178   if (hasEEdigis) {
0179     makeHistos(EEdigisHandle);
0180     makeHistos(EEhits);
0181   }
0182 
0183   if (hasEBdigis || hasEEdigis)
0184     drawHistos();
0185 
0186   deleteEvtByEvtHists();
0187 }
0188 
0189 void EcalDisplaysByEvent::selectHits(Handle<EcalRecHitCollection> hits, int ievt) {
0190   for (EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr) {
0191     EcalRecHit hit = (*hitItr);
0192     DetId det = hit.id();
0193     EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(det);
0194     int FEDid = 600 + elecId.dccId();
0195     bool isBarrel = true;
0196     if (FEDid < 610 || FEDid > 645)
0197       isBarrel = false;
0198     int cryIndex = isBarrel ? ((EBDetId)det).hashedIndex() : getEEIndex(elecId);
0199     int ic = isBarrel ? ((EBDetId)det).ic() : getEEIndex(elecId);
0200 
0201     float ampli = hit.energy();
0202 
0203     vector<int>::iterator result;
0204     result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
0205     if (result != maskedFEDs_.end()) {
0206       //LogWarning("EcalDisplaysByEvent") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
0207       continue;
0208     }
0209     result = find(maskedChannels_.begin(), maskedChannels_.end(), cryIndex);
0210     if (result != maskedChannels_.end()) {
0211       //LogWarning("EcalDisplaysByEvent") << "skipping uncalRecHit for channel: " << cryIndex << " in fed: " << FEDid << " with amplitude " << ampli ;
0212       continue;
0213     }
0214     bool cryIsInList = false;
0215     result = find(seedCrys_.begin(), seedCrys_.end(), cryIndex);
0216     if (result != seedCrys_.end())
0217       cryIsInList = true;
0218 
0219     // Either we must have a user-requested cry (in which case there is no amplitude selection)
0220     // Or we pick all crys that pass the amplitude cut (in which case there is no fixed crystal selection)
0221     if (cryIsInList || (seedCrys_.empty() && ampli > threshold_)) {
0222       // We have a winner!
0223       crysAndAmplitudesMap_[cryIndex] = ampli;
0224       string name = "Digis_Event" + intToString(naiveEvtNum_) + "_ic" + intToString(ic) + "_FED" + intToString(FEDid);
0225       string title = "Digis";
0226       string seed = "ic" + intToString(ic) + "_FED" + intToString(FEDid);
0227       int freq = 1;
0228       pair<map<string, int>::iterator, bool> pair = seedFrequencyMap_.insert(make_pair(seed, freq));
0229       if (!pair.second) {
0230         ++(pair.first->second);
0231       }
0232 
0233       //TODO: move this also to TFileService
0234       TCanvas can(name.c_str(), title.c_str(), 200, 50, 900, 900);
0235       can.Divide(side_, side_);
0236       TGraph* myGraph;
0237 
0238       CaloNavigator<DetId> cursor = CaloNavigator<DetId>(det, caloTopo_->getSubdetectorTopology(det));
0239       //Now put each graph in one by one
0240       for (int j = side_ / 2; j >= -side_ / 2; --j) {
0241         for (int i = -side_ / 2; i <= side_ / 2; ++i) {
0242           cursor.home();
0243           cursor.offsetBy(i, j);
0244           can.cd(i + 1 + side_ / 2 + side_ * (1 - j));
0245           myGraph = selectDigi(*cursor, ievt);
0246           myGraph->Draw("A*");
0247         }
0248       }
0249       can.Write();
0250       names->push_back(name);
0251     }
0252   }
0253 }
0254 
0255 TGraph* EcalDisplaysByEvent::selectDigi(DetId thisDet, int ievt) {
0256   int emptyY[10];
0257   for (int i = 0; i < 10; i++)
0258     emptyY[i] = 0;
0259   TGraph* emptyGraph = fileService->make<TGraph>(10, abscissa, emptyY);
0260   emptyGraph->SetTitle("NOT ECAL");
0261 
0262   //If the DetId is not from Ecal, return
0263   if (thisDet.det() != DetId::Ecal)
0264     return emptyGraph;
0265 
0266   emptyGraph->SetTitle("NO DIGIS");
0267   //find digi we need  -- can't get find() to work; need DataFrame(DetId det) to work?
0268   EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(thisDet);
0269   int FEDid = 600 + elecId.dccId();
0270   bool isBarrel = true;
0271   if (FEDid < 610 || FEDid > 645)
0272     isBarrel = false;
0273   int cryIndex = isBarrel ? ((EBDetId)thisDet).hashedIndex() : getEEIndex(elecId);
0274   int ic = isBarrel ? ((EBDetId)thisDet).ic() : cryIndex;
0275 
0276   string sliceName = fedMap_->getSliceFromFed(FEDid);
0277   EcalDataFrame df;
0278   if (isBarrel) {
0279     EBDigiCollection::const_iterator digiItr = EBdigisHandle->begin();
0280     while (digiItr != EBdigisHandle->end() && ((*digiItr).id() != (EBDetId)thisDet)) {
0281       ++digiItr;
0282     }
0283     if (digiItr == EBdigisHandle->end()) {
0284       //LogWarning("EcalDisplaysByEvent") << "Cannot find digi for ic:" << ic
0285       //  << " FED:" << FEDid << " evt:" << naiveEvtNum_;
0286       return emptyGraph;
0287     } else
0288       df = *digiItr;
0289   } else {
0290     EEDigiCollection::const_iterator digiItr = EEdigisHandle->begin();
0291     while (digiItr != EEdigisHandle->end() && ((*digiItr).id() != (EEDetId)thisDet)) {
0292       ++digiItr;
0293     }
0294     if (digiItr == EEdigisHandle->end()) {
0295       //LogWarning("EcalDisplaysByEvent") << "Cannot find digi for ic:" << ic
0296       //  << " FED:" << FEDid << " evt:" << naiveEvtNum_;
0297       return emptyGraph;
0298     } else
0299       df = *digiItr;
0300   }
0301 
0302   int gainId = FEDsAndDCCHeaders_[FEDid].getMgpaGain();
0303   int gainHuman;
0304   if (gainId == 1)
0305     gainHuman = 12;
0306   else if (gainId == 2)
0307     gainHuman = 6;
0308   else if (gainId == 3)
0309     gainHuman = 1;
0310   else
0311     gainHuman = -1;
0312 
0313   double pedestal = 200;
0314 
0315   emptyGraph->SetTitle("FIRST TWO SAMPLES NOT GAIN12");
0316   if (df.sample(0).gainId() != 1 || df.sample(1).gainId() != 1)
0317     return emptyGraph;  //goes to the next digi
0318   else {
0319     ordinate[0] = df.sample(0).adc();
0320     ordinate[1] = df.sample(1).adc();
0321     pedestal = (double)(ordinate[0] + ordinate[1]) / (double)2;
0322   }
0323 
0324   for (int i = 0; i < df.size(); ++i) {
0325     if (df.sample(i).gainId() != 0)
0326       ordinate[i] = (int)(pedestal + (df.sample(i).adc() - pedestal) * gainRatio[df.sample(i).gainId() - 1]);
0327     else
0328       ordinate[i] = 49152;  //Saturation of gain1
0329   }
0330 
0331   TGraph* oneGraph = fileService->make<TGraph>(10, abscissa, ordinate);
0332   string name = "Graph_ev" + intToString(naiveEvtNum_) + "_ic" + intToString(ic) + "_FED" + intToString(FEDid);
0333   string gainString = (gainId == 1) ? "Free" : intToString(gainHuman);
0334   string title = "Event" + intToString(naiveEvtNum_) + "_lv1a" + intToString(ievt) + "_ic" + intToString(ic) + "_" +
0335                  sliceName + "_gain" + gainString;
0336 
0337   float energy = 0;
0338   map<int, float>::const_iterator itr;
0339   itr = crysAndAmplitudesMap_.find(cryIndex);
0340   if (itr != crysAndAmplitudesMap_.end()) {
0341     //edm::LogWarning("EcalDisplaysByEvent")<< "itr->second(ampli)="<< itr->second;
0342     energy = (float)itr->second;
0343   }
0344   //else
0345   //edm::LogWarning("EcalDisplaysByEvent") << "cry " << ic << "not found in ampMap";
0346 
0347   title += "_Energy" + floatToString(round(energy * 1000));
0348 
0349   oneGraph->SetTitle(title.c_str());
0350   oneGraph->SetName(name.c_str());
0351   oneGraph->GetXaxis()->SetTitle("sample");
0352   oneGraph->GetYaxis()->SetTitle("ADC");
0353   return oneGraph;
0354 }
0355 
0356 int EcalDisplaysByEvent::getEEIndex(EcalElectronicsId elecId) {
0357   int FEDid = 600 + elecId.dccId();
0358   return 10000 * FEDid + 100 * elecId.towerId() + 5 * (elecId.stripId() - 1) + elecId.xtalId();
0359 }
0360 
0361 void EcalDisplaysByEvent::makeHistos(Handle<EBDigiCollection> ebDigiHandle) {
0362   const EBDigiCollection* ebDigis = ebDigiHandle.product();
0363   for (EBDigiCollection::const_iterator digiItr = ebDigis->begin(); digiItr != ebDigis->end(); ++digiItr) {
0364     EBDetId digiId = digiItr->id();
0365     int ieta = digiId.ieta();
0366     int iphi = digiId.iphi();
0367     digiOccupancyEBAll_->Fill(iphi, ieta);
0368     digiOccupancyEBcoarseAll_->Fill(iphi, ieta);
0369     if (makeOccupancyHistos_) {
0370       digiOccupancyEB_->Fill(iphi, ieta);
0371       digiOccupancyEBcoarse_->Fill(iphi, ieta);
0372     }
0373   }
0374 }
0375 
0376 void EcalDisplaysByEvent::makeHistos(Handle<EEDigiCollection> eeDigiHandle) {
0377   const EEDigiCollection* eeDigis = eeDigiHandle.product();
0378   for (EEDigiCollection::const_iterator digiItr = eeDigis->begin(); digiItr != eeDigis->end(); ++digiItr) {
0379     DetId det = digiItr->id();
0380     EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(det);
0381     size_t FEDid = 600 + elecId.dccId();
0382     bool isEEM = false;
0383     if (FEDid < 610)
0384       isEEM = true;
0385     EEDetId digiId = digiItr->id();
0386     int ieta = digiId.iy();
0387     int iphi = digiId.ix();
0388     if (isEEM) {
0389       digiOccupancyEEMAll_->Fill(iphi, ieta);
0390       digiOccupancyEEMcoarseAll_->Fill(iphi, ieta);
0391       if (makeOccupancyHistos_) {
0392         digiOccupancyEEMcoarse_->Fill(iphi, ieta);
0393         digiOccupancyEEM_->Fill(iphi, ieta);
0394       }
0395     } else {
0396       digiOccupancyEEPAll_->Fill(iphi, ieta);
0397       digiOccupancyEEPcoarseAll_->Fill(iphi, ieta);
0398       if (makeOccupancyHistos_) {
0399         digiOccupancyEEP_->Fill(iphi, ieta);
0400         digiOccupancyEEPcoarse_->Fill(iphi, ieta);
0401       }
0402     }
0403   }
0404 }
0405 
0406 void EcalDisplaysByEvent::makeHistos(Handle<EcalRecHitCollection> hits) {
0407   for (EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr) {
0408     EcalRecHit hit = (*hitItr);
0409     DetId det = hit.id();
0410     EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(det);
0411     int FEDid = 600 + elecId.dccId();
0412     bool isBarrel = true;
0413     bool isEEM = false;
0414     if (FEDid < 610 || FEDid > 645) {
0415       isBarrel = false;
0416       if (FEDid < 610)
0417         isEEM = true;
0418     }
0419     int iphi = isBarrel ? ((EBDetId)det).iphi() : ((EEDetId)det).ix();
0420     int ieta = isBarrel ? ((EBDetId)det).ieta() : ((EEDetId)det).iy();
0421     float energy = hit.energy();
0422     float time = hit.time();
0423 
0424     // Fill energy histos
0425     if (makeEnergyHistos_) {
0426       if (isBarrel) {
0427         energyEB_->Fill(energy);
0428         energyMapEB_->Fill(iphi, ieta, energy);
0429         energyMapEBcoarse_->Fill(iphi, ieta, energy);
0430       } else if (isEEM) {
0431         energyEEM_->Fill(energy);
0432         energyMapEEM_->Fill(iphi, ieta, energy);
0433         energyMapEEMcoarse_->Fill(iphi, ieta, energy);
0434       } else {
0435         energyEEP_->Fill(energy);
0436         energyMapEEP_->Fill(iphi, ieta, energy);
0437         energyMapEEPcoarse_->Fill(iphi, ieta, energy);
0438       }
0439     }
0440     // Fill occupancy histos
0441     if (makeOccupancyHistos_) {
0442       if (isBarrel) {
0443         recHitOccupancyEB_->Fill(iphi, ieta);
0444         recHitOccupancyEBcoarse_->Fill(iphi, ieta);
0445       } else if (isEEM) {
0446         recHitOccupancyEEM_->Fill(iphi, ieta);
0447         recHitOccupancyEEMcoarse_->Fill(iphi, ieta);
0448       } else {
0449         recHitOccupancyEEP_->Fill(iphi, ieta);
0450         recHitOccupancyEEPcoarse_->Fill(iphi, ieta);
0451       }
0452     }
0453 
0454     // Fill timing histos
0455     if (makeTimingHistos_) {
0456       if (isBarrel) {
0457         timingEB_->Fill(time);
0458         if (energy > minTimingEnergyEB_) {
0459           timingMapEB_->Fill(iphi, ieta, time);
0460           //timingMapEBCoarse_->Fill(iphi,ieta,time);
0461         }
0462       } else if (isEEM) {
0463         timingEEM_->Fill(time);
0464         if (energy > minTimingEnergyEE_) {
0465           timingMapEEM_->Fill(iphi, ieta, time);
0466           //timingMapEEMCoarse_->Fill(iphi,ieta,time);
0467         }
0468       } else {
0469         timingEEP_->Fill(time);
0470         if (energy > minTimingEnergyEE_) {
0471           timingMapEEP_->Fill(iphi, ieta, time);
0472           //timingMapEEPCoarse_->Fill(iphi,ieta,time);
0473         }
0474       }
0475     }
0476 
0477     //All events
0478     if (isBarrel) {
0479       energyEBAll_->Fill(energy);
0480       energyMapEBAll_->Fill(iphi, ieta, energy);
0481       energyMapEBcoarseAll_->Fill(iphi, ieta, energy);
0482       recHitOccupancyEBAll_->Fill(iphi, ieta);
0483       recHitOccupancyEBcoarseAll_->Fill(iphi, ieta);
0484       timingEBAll_->Fill(time);
0485       if (energy > minTimingEnergyEB_) {
0486         timingMapEBAll_->Fill(iphi, ieta, time);
0487         timingMapEBCoarseAll_->Fill(iphi, ieta, time);
0488       }
0489     } else if (isEEM) {
0490       energyEEMAll_->Fill(energy);
0491       energyMapEEMAll_->Fill(iphi, ieta, energy);
0492       energyMapEEMcoarseAll_->Fill(iphi, ieta, energy);
0493       recHitOccupancyEEMAll_->Fill(iphi, ieta);
0494       recHitOccupancyEEMcoarseAll_->Fill(iphi, ieta);
0495       timingEEMAll_->Fill(time);
0496       if (energy > minTimingEnergyEE_) {
0497         timingMapEEMAll_->Fill(iphi, ieta, time);
0498         timingMapEEMCoarseAll_->Fill(iphi, ieta, time);
0499       }
0500     } else {
0501       energyEEPAll_->Fill(energy);
0502       energyMapEEPAll_->Fill(iphi, ieta, energy);
0503       energyMapEEPcoarseAll_->Fill(iphi, ieta, energy);
0504       recHitOccupancyEEPAll_->Fill(iphi, ieta);
0505       recHitOccupancyEEPcoarseAll_->Fill(iphi, ieta);
0506       timingEEPAll_->Fill(time);
0507       if (energy > minTimingEnergyEE_) {
0508         timingMapEEPAll_->Fill(iphi, ieta, time);
0509         timingMapEEPCoarseAll_->Fill(iphi, ieta, time);
0510       }
0511     }
0512     // Fill FED-by-FED timing histos (all events)
0513     TH1F* timingHist = FEDsAndTimingHists_[FEDid];
0514     if (timingHist == nullptr) {
0515       initHists(FEDid);
0516       timingHist = FEDsAndTimingHists_[FEDid];
0517     }
0518     if (energy > minTimingAmp_) {
0519       timingHist->Fill(hit.time());
0520       allFedsTimingHist_->Fill(hit.time());
0521     }
0522   }
0523 }
0524 
0525 // ------------ method called once each job just after ending the event loop  ------------
0526 void EcalDisplaysByEvent::endJob() {
0527   //All-event canvases
0528   drawCanvas(timingCanvasAll_, timingEEMAll_, timingEBAll_, timingEEPAll_);
0529   drawCanvas(timingMapCanvasAll_, timingMapEEMAll_, timingMapEBAll_, timingMapEEPAll_);
0530   drawCanvas(energyCanvasAll_, energyEEMAll_, energyEBAll_, energyEEPAll_);
0531   drawCanvas(energyMapCanvasAll_, energyMapEEMAll_, energyMapEBAll_, energyMapEEPAll_);
0532   drawCanvas(energyMapCoarseCanvasAll_, energyMapEEMcoarseAll_, energyMapEBcoarseAll_, energyMapEEPcoarseAll_);
0533   drawCanvas(recHitOccupancyCanvasAll_, recHitOccupancyEEMAll_, recHitOccupancyEBAll_, recHitOccupancyEEPAll_);
0534   drawCanvas(recHitOccupancyCoarseCanvasAll_,
0535              recHitOccupancyEEMcoarseAll_,
0536              recHitOccupancyEBcoarseAll_,
0537              recHitOccupancyEEPcoarseAll_);
0538   drawCanvas(digiOccupancyCanvasAll_, digiOccupancyEEMAll_, digiOccupancyEBAll_, digiOccupancyEEPAll_);
0539   drawCanvas(
0540       digiOccupancyCoarseCanvasAll_, digiOccupancyEEMcoarseAll_, digiOccupancyEBcoarseAll_, digiOccupancyEEPcoarseAll_);
0541 
0542   if (runNum_ != -1) {
0543     canvasNames_->Fill();
0544     histoCanvasNames_->Fill();
0545   }
0546 
0547   string frequencies = "";
0548   for (std::map<std::string, int>::const_iterator itr = seedFrequencyMap_.begin(); itr != seedFrequencyMap_.end();
0549        ++itr) {
0550     if (itr->second > 1) {
0551       frequencies += itr->first;
0552       frequencies += " Frequency: ";
0553       frequencies += intToString(itr->second);
0554       frequencies += "\n";
0555     }
0556   }
0557   LogWarning("EcalDisplaysByEvent") << "Found seeds with frequency > 1: "
0558                                     << "\n\n"
0559                                     << frequencies;
0560 
0561   std::string channels;
0562   for (std::vector<int>::const_iterator itr = maskedChannels_.begin(); itr != maskedChannels_.end(); ++itr) {
0563     channels += intToString(*itr);
0564     channels += ",";
0565   }
0566 
0567   std::string feds;
0568   for (std::vector<int>::const_iterator itr = maskedFEDs_.begin(); itr != maskedFEDs_.end(); ++itr) {
0569     feds += intToString(*itr);
0570     feds += ",";
0571   }
0572 
0573   LogWarning("EcalDisplaysByEvent") << "Masked channels are: " << channels;
0574   LogWarning("EcalDisplaysByEvent") << "Masked FEDs are: " << feds << " and that is all!";
0575 }
0576 
0577 std::string EcalDisplaysByEvent::intToString(int num) {
0578   using namespace std;
0579   ostringstream myStream;
0580   myStream << num << flush;
0581   return (myStream.str());  //returns the string form of the stringstream object
0582 }
0583 
0584 std::string EcalDisplaysByEvent::floatToString(float num) {
0585   using namespace std;
0586   ostringstream myStream;
0587   myStream << num << flush;
0588   return (myStream.str());  //returns the string form of the stringstream object
0589 }
0590 
0591 // insert the hist map into the map keyed by FED number
0592 void EcalDisplaysByEvent::initHists(int FED) {
0593   using namespace std;
0594 
0595   string title1 = "Jitter for ";
0596   title1.append(fedMap_->getSliceFromFed(FED));
0597   string name1 = "JitterFED";
0598   name1.append(intToString(FED));
0599   TH1F* timingHist = fileService->make<TH1F>(name1.c_str(), title1.c_str(), 150, -7, 7);
0600   FEDsAndTimingHists_[FED] = timingHist;
0601 }
0602 
0603 void EcalDisplaysByEvent::initEvtByEvtHists(int naiveEvtNum_, int ievt) {
0604   string lastPart = intToString(naiveEvtNum_) + "_LV1a" + intToString(ievt);
0605   if (makeTimingHistos_) {
0606     string canvasTitle = "Timing_Event" + lastPart;
0607     timingEB_ = new TH1F("timeForAllFedsEB", "timeForAllFeds;Relative Time (1 clock = 25ns)", 78, -7, 7);
0608     timingEEM_ = new TH1F("timeForAllFedsEEM", "timeForAllFeds_EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
0609     timingEEP_ = new TH1F("timeForAllFedsEEP", "timeForAllFeds_EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
0610     timingCanvas_ = new TCanvas(canvasTitle.c_str(), canvasTitle.c_str(), 300, 60, 500, 200);
0611     timingMapEB_ = init3DEcalHist("TimingMap", EB_FINE);
0612     timingMapEEM_ = init3DEcalHist("TimingMap", EEM_FINE);
0613     timingMapEEP_ = init3DEcalHist("TimingMap", EEP_FINE);
0614     timingMapCanvas_ = init2DEcalCanvas("TimingMap_Event" + lastPart);
0615     //timingMapEBCoarse_ = init3DEcalHist("TimingMap", EB_COARSE);
0616     timingMapEEMCoarse_ = init3DEcalHist("TimingMap", EEM_COARSE);
0617     timingMapEEPCoarse_ = init3DEcalHist("TimingMap", EEP_COARSE);
0618     //timingMapCoarseCanvas_ = init2DEcalCanvas("TimingMapCoarse_Event"+lastPart);
0619   }
0620   if (makeEnergyHistos_) {
0621     energyEB_ = new TH1F("energyEB", "Energy for EB Feds (GeV)", 200, histRangeMin_, histRangeMax_);
0622     energyEEM_ = new TH1F("energyEEM", "Energy for EEM Feds (GeV)", 200, histRangeMin_, 10.0);
0623     energyEEP_ = new TH1F("energyEEP", "Energy for EEP Feds (GeV)", 200, histRangeMin_, 10.0);
0624     string canvasTitle = "Energy_Event" + lastPart;
0625     energyCanvas_ = new TCanvas(canvasTitle.c_str(), canvasTitle.c_str(), 300, 60, 500, 200);
0626 
0627     // Energy map hists
0628     energyMapEB_ = init2DEcalHist("EnergyMap", EB_FINE);
0629     energyMapEBcoarse_ = init2DEcalHist("EnergyMap", EB_COARSE);
0630     energyMapEEMcoarse_ = init2DEcalHist("EnergyMap", EEM_COARSE);
0631     energyMapEEM_ = init2DEcalHist("EnergyMap", EEM_FINE);
0632     energyMapEEPcoarse_ = init2DEcalHist("EnergyMap", EEP_COARSE);
0633     energyMapEEP_ = init2DEcalHist("EnergyMap", EEP_FINE);
0634     energyMapCanvas_ = init2DEcalCanvas("EnergyMap_Event" + lastPart);
0635     energyMapCoarseCanvas_ = init2DEcalCanvas("EnergyMapCoarse_Event" + lastPart);
0636   }
0637   if (makeOccupancyHistos_) {
0638     // RecHit Occupancy
0639     recHitOccupancyEB_ = init2DEcalHist("RecHitOccupancy", EB_FINE);
0640     recHitOccupancyEBcoarse_ = init2DEcalHist("RecHitOccupancy", EB_COARSE);
0641     recHitOccupancyEEMcoarse_ = init2DEcalHist("RecHitOccupancy", EEM_COARSE);
0642     recHitOccupancyEEM_ = init2DEcalHist("RecHitOccupancy", EEM_FINE);
0643     recHitOccupancyEEPcoarse_ = init2DEcalHist("RecHitOccupancy", EEP_COARSE);
0644     recHitOccupancyEEP_ = init2DEcalHist("RecHitOccupancy", EEP_FINE);
0645     recHitOccupancyCanvas_ = init2DEcalCanvas("RecHitOccupancy_Event" + lastPart);
0646     recHitOccupancyCoarseCanvas_ = init2DEcalCanvas("RecHitOccupancyCoarse_Event" + lastPart);
0647 
0648     //DigiOccupancy
0649     digiOccupancyEB_ = init2DEcalHist("DigiOccupancy", EB_FINE);
0650     digiOccupancyEBcoarse_ = init2DEcalHist("DigiOccupancy", EB_COARSE);
0651     digiOccupancyEEMcoarse_ = init2DEcalHist("DigiOccupancy", EEM_COARSE);
0652     digiOccupancyEEM_ = init2DEcalHist("DigiOccupancy", EEM_FINE);
0653     digiOccupancyEEPcoarse_ = init2DEcalHist("DigiOccupancy", EEP_COARSE);
0654     digiOccupancyEEP_ = init2DEcalHist("DigiOccupancy", EEP_FINE);
0655     digiOccupancyCanvas_ = init2DEcalCanvas("DigiOccupancy_Event" + lastPart);
0656     digiOccupancyCoarseCanvas_ = init2DEcalCanvas("DigiOccupancyCoarse_Event" + lastPart);
0657   }
0658 }
0659 
0660 void EcalDisplaysByEvent::deleteEvtByEvtHists() {
0661   delete timingEB_;
0662   delete timingEEM_;
0663   delete timingEEP_;
0664   delete timingMapEB_;
0665   delete timingMapEEM_;
0666   delete timingMapEEP_;
0667   delete timingCanvas_;
0668   delete timingMapCanvas_;
0669   delete energyEB_;
0670   delete energyEEM_;
0671   delete energyEEP_;
0672   delete energyMapEB_;
0673   delete energyMapEEM_;
0674   delete energyMapEEP_;
0675   delete energyMapEBcoarse_;
0676   delete energyMapEEMcoarse_;
0677   delete energyMapEEPcoarse_;
0678   delete energyCanvas_;
0679   delete energyMapCanvas_;
0680   delete energyMapCoarseCanvas_;
0681   delete recHitOccupancyEB_;
0682   delete recHitOccupancyEEP_;
0683   delete recHitOccupancyEEM_;
0684   delete recHitOccupancyEBcoarse_;
0685   delete recHitOccupancyEEMcoarse_;
0686   delete recHitOccupancyEEPcoarse_;
0687   delete digiOccupancyEB_;
0688   delete digiOccupancyEEM_;
0689   delete digiOccupancyEEP_;
0690   delete digiOccupancyEBcoarse_;
0691   delete digiOccupancyEEMcoarse_;
0692   delete digiOccupancyEEPcoarse_;
0693   delete recHitOccupancyCanvas_;
0694   delete recHitOccupancyCoarseCanvas_;
0695   delete digiOccupancyCanvas_;
0696   delete digiOccupancyCoarseCanvas_;
0697 }
0698 
0699 void EcalDisplaysByEvent::initAllEventHistos() {
0700   string canvasTitle = "Timing_AllEvents";
0701   timingEBAll_ = new TH1F("timeForAllFedsEBAll", "timeForAllFeds;Relative Time (1 clock = 25ns)", 78, -7, 7);
0702   timingEEMAll_ = new TH1F("timeForAllFedsEEMAll", "timeForAllFeds_EEM;Relative Time (1 clock = 25ns)", 78, -7, 7);
0703   timingEEPAll_ = new TH1F("timeForAllFedsEEPAll", "timeForAllFeds_EEP;Relative Time (1 clock = 25ns)", 78, -7, 7);
0704   timingCanvasAll_ = new TCanvas(canvasTitle.c_str(), canvasTitle.c_str(), 300, 60, 500, 200);
0705   timingMapEBAll_ = init3DEcalHist("TimingMapA", EB_FINE);
0706   timingMapEEMAll_ = init3DEcalHist("TimingMapA", EEM_FINE);
0707   timingMapEEPAll_ = init3DEcalHist("TimingMapA", EEP_FINE);
0708   timingMapCanvasAll_ = init2DEcalCanvas("TimingMap_AllEvents");
0709   timingMapEBCoarseAll_ = init3DEcalHist("TimingMapA", EB_COARSE);
0710   timingMapEEMCoarseAll_ = init3DEcalHist("TimingMapA", EEM_COARSE);
0711   timingMapEEPCoarseAll_ = init3DEcalHist("TimingMapA", EEP_COARSE);
0712   //timingMapCoarseCanvasAll_ = init2DEcalCanvas("TimingMapCoarse_AllEvents");
0713   energyEBAll_ = new TH1F("energyEBAllEvents", "Energy for EB Feds (GeV)", 200, histRangeMin_, histRangeMax_);
0714   energyEEMAll_ = new TH1F("energyEEMAllEvents", "Energy for EEM Feds (GeV)", 200, histRangeMin_, 10.0);
0715   energyEEPAll_ = new TH1F("energyEEPAllEvents", "Energy for EEP Feds (GeV)", 200, histRangeMin_, 10.0);
0716   canvasTitle = "Energy_AllEvents";
0717   energyCanvasAll_ = new TCanvas(canvasTitle.c_str(), canvasTitle.c_str(), 300, 60, 500, 200);
0718 
0719   // Energy map hists
0720   energyMapEBAll_ = init2DEcalHist("EnergyMapA", EB_FINE);
0721   energyMapEBcoarseAll_ = init2DEcalHist("EnergyMapA", EB_COARSE);
0722   energyMapEEMcoarseAll_ = init2DEcalHist("EnergyMapA", EEM_COARSE);
0723   energyMapEEMAll_ = init2DEcalHist("EnergyMapA", EEM_FINE);
0724   energyMapEEPcoarseAll_ = init2DEcalHist("EnergyMapA", EEP_COARSE);
0725   energyMapEEPAll_ = init2DEcalHist("EnergyMapA", EEP_FINE);
0726   energyMapCanvasAll_ = init2DEcalCanvas("EnergyMap_AllEvents");
0727   energyMapCoarseCanvasAll_ = init2DEcalCanvas("EnergyMapCoarse_AllEvents");
0728   // RecHit Occupancy
0729   recHitOccupancyEBAll_ = init2DEcalHist("RecHitOccupancyA", EB_FINE);
0730   recHitOccupancyEBcoarseAll_ = init2DEcalHist("RecHitOccupancyA", EB_COARSE);
0731   recHitOccupancyEEMcoarseAll_ = init2DEcalHist("RecHitOccupancyA", EEM_COARSE);
0732   recHitOccupancyEEMAll_ = init2DEcalHist("RecHitOccupancyA", EEM_FINE);
0733   recHitOccupancyEEPcoarseAll_ = init2DEcalHist("RecHitOccupancyA", EEP_COARSE);
0734   recHitOccupancyEEPAll_ = init2DEcalHist("RecHitOccupancyA", EEP_FINE);
0735   recHitOccupancyCanvasAll_ = init2DEcalCanvas("RecHitOccupancy_AllEvents");
0736   recHitOccupancyCoarseCanvasAll_ = init2DEcalCanvas("RecHitOccupancyCoarse_AllEvents");
0737 
0738   //DigiOccupancy
0739   digiOccupancyEBAll_ = init2DEcalHist("DigiOccupancyA", EB_FINE);
0740   digiOccupancyEBcoarseAll_ = init2DEcalHist("DigiOccupancyA", EB_COARSE);
0741   digiOccupancyEEMcoarseAll_ = init2DEcalHist("DigiOccupancyA", EEM_COARSE);
0742   digiOccupancyEEMAll_ = init2DEcalHist("DigiOccupancyA", EEM_FINE);
0743   digiOccupancyEEPcoarseAll_ = init2DEcalHist("DigiOccupancyA", EEP_COARSE);
0744   digiOccupancyEEPAll_ = init2DEcalHist("DigiOccupancyA", EEP_FINE);
0745   digiOccupancyCanvasAll_ = init2DEcalCanvas("DigiOccupancy_AllEvents");
0746   digiOccupancyCoarseCanvasAll_ = init2DEcalCanvas("DigiOccupancyCoarse_AllEvents");
0747 }
0748 
0749 TH3F* EcalDisplaysByEvent::init3DEcalHist(std::string histTypeName, int subDet) {
0750   TH3F* hist;
0751   bool isBarrel = (subDet == EB_FINE || subDet == EB_COARSE) ? true : false;
0752   bool isCoarse = (subDet == EB_COARSE || subDet == EEM_COARSE || subDet == EEP_COARSE) ? true : false;
0753   bool isEEM = (subDet == EEM_FINE || subDet == EEM_COARSE) ? true : false;
0754   std::string histName = histTypeName;
0755   std::string histTitle = histTypeName;
0756   double ttEtaBins[36] = {-85, -80, -75, -70, -65, -60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0,
0757                           1,   6,   11,  16,  21,  26,  31,  36,  41,  46,  51,  56,  61,  66,  71,  76,  81, 86};
0758   double modEtaBins[10] = {-85, -65, -45, -25, 0, 1, 26, 46, 66, 86};
0759   double ttPhiBins[73];
0760   double modPhiBins[19];
0761   double timingBins[79];
0762   for (int i = 0; i < 79; ++i) {
0763     timingBins[i] = 6 - 7. + double(i) * 14. / 78.;
0764     if (i < 73) {
0765       ttPhiBins[i] = 1 + 5 * i;
0766       if (i < 19) {
0767         modPhiBins[i] = 1 + 20 * i;
0768       }
0769     }
0770   }
0771 
0772   if (isBarrel) {
0773     histName = histName + "EB";
0774     histTitle = histTitle + " EB";
0775     if (isCoarse) {
0776       histName = histName + "Coarse";
0777       histTitle = histTitle + " by Module Nominal value = 6;iphi;ieta ";
0778       hist = new TH3F(histName.c_str(), histTitle.c_str(), 18, modPhiBins, 9, modEtaBins, 78, timingBins);
0779     } else {
0780       histTitle = histTitle + " by TT Nominal value = 6;iphi;ieta";
0781       hist = new TH3F(histName.c_str(), histTitle.c_str(), 360 / 5, ttPhiBins, 35, ttEtaBins, 78, timingBins);
0782     }
0783   } else {
0784     double ttXBins[21];
0785     double ttYBins[21];
0786     for (int i = 0; i != 21; ++i) {
0787       ttXBins[i] = 1 + 5 * i;
0788       ttYBins[i] = 1 + 5 * i;
0789     }
0790     if (isEEM) {
0791       histName = histName + "EEM";
0792       histTitle = histTitle + " EEM";
0793     } else {
0794       histName = histName + "EEP";
0795       histTitle = histTitle + " EEP";
0796     }
0797     if (isCoarse) {
0798       histName = histName + "Coarse";
0799       histTitle = histTitle + " by Module Nominal value = 6;ix;iy";
0800       hist = new TH3F(histName.c_str(), histTitle.c_str(), 20, ttXBins, 20, ttYBins, 78, timingBins);
0801     } else {
0802       histTitle = histTitle + " by TT Nominal value = 6;ix;iy";
0803       hist = new TH3F(histName.c_str(), histTitle.c_str(), 20, ttXBins, 20, ttYBins, 78, timingBins);
0804     }
0805   }
0806   return hist;
0807 }
0808 
0809 TH2F* EcalDisplaysByEvent::init2DEcalHist(std::string histTypeName, int subDet) {
0810   TH2F* hist;
0811   bool isBarrel = (subDet == EB_FINE || subDet == EB_COARSE) ? true : false;
0812   bool isCoarse = (subDet == EB_COARSE || subDet == EEM_COARSE || subDet == EEP_COARSE) ? true : false;
0813   bool isEEM = (subDet == EEM_FINE || subDet == EEM_COARSE) ? true : false;
0814   std::string histName = histTypeName;
0815   std::string histTitle = histTypeName;
0816   if (isBarrel) {
0817     histName = histName + "EB";
0818     histTitle = histTitle + " EB";
0819     if (isCoarse) {
0820       histName = histName + "Coarse";
0821       histTitle = histTitle + " Coarse;iphi;ieta";
0822       double ttEtaBins[36] = {-85, -80, -75, -70, -65, -60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0,
0823                               1,   6,   11,  16,  21,  26,  31,  36,  41,  46,  51,  56,  61,  66,  71,  76,  81, 86};
0824       hist = new TH2F(histName.c_str(), histTitle.c_str(), 360 / 5, 1, 361., 35, ttEtaBins);
0825     } else {
0826       histTitle = histTitle + ";iphi;ieta";
0827       hist = new TH2F(histName.c_str(), histTitle.c_str(), 360, 1, 361., 172, -86, 86);
0828     }
0829   } else {
0830     if (isEEM) {
0831       histName = histName + "EEM";
0832       histTitle = histTitle + " EEM";
0833     } else {
0834       histName = histName + "EEP";
0835       histTitle = histTitle + " EEP";
0836     }
0837     if (isCoarse) {
0838       histName = histName + "Coarse";
0839       histTitle = histTitle + " Coarse;ix;iy";
0840       hist = new TH2F(histName.c_str(), histTitle.c_str(), 20, 1, 101, 20, 1, 101);
0841     } else {
0842       histTitle = histTitle + ";ix;iy";
0843       hist = new TH2F(histName.c_str(), histTitle.c_str(), 100, 1, 101, 100, 1, 101);
0844     }
0845   }
0846   return hist;
0847 }
0848 
0849 TCanvas* EcalDisplaysByEvent::init2DEcalCanvas(std::string canvasTitle) {
0850   TCanvas* canvas = new TCanvas(canvasTitle.c_str(), canvasTitle.c_str(), 300, 60, 500, 200);
0851   return canvas;
0852 }
0853 
0854 void EcalDisplaysByEvent::drawHistos() {
0855   if (makeTimingHistos_) {
0856     // Put the timing canvas together
0857     drawCanvas(timingCanvas_, timingEEM_, timingEB_, timingEEP_);
0858     //   drawCanvas(timingMapCoarseCanvas_,timingMapEEMCoarse_,timingMapEBCoarse_,timingMapEEPCoarse_);
0859     drawCanvas(timingMapCanvas_, timingMapEEM_, timingMapEB_, timingMapEEP_);
0860   }
0861   if (makeEnergyHistos_) {
0862     // Put the energy canvas together
0863     drawCanvas(energyCanvas_, energyEEM_, energyEB_, energyEEP_);
0864     // Put the energy map canvas together
0865     drawCanvas(energyMapCanvas_, energyMapEEM_, energyMapEB_, energyMapEEP_);
0866     drawCanvas(energyMapCoarseCanvas_, energyMapEEMcoarse_, energyMapEBcoarse_, energyMapEEPcoarse_);
0867   }
0868   if (makeOccupancyHistos_) {
0869     // Put the occupancy canvas together
0870     drawCanvas(recHitOccupancyCanvas_, recHitOccupancyEEM_, recHitOccupancyEB_, recHitOccupancyEEP_);
0871     drawCanvas(
0872         recHitOccupancyCoarseCanvas_, recHitOccupancyEEMcoarse_, recHitOccupancyEBcoarse_, recHitOccupancyEEPcoarse_);
0873     // And the same for the digis
0874     drawCanvas(digiOccupancyCanvas_, digiOccupancyEEM_, digiOccupancyEB_, digiOccupancyEEP_);
0875     drawCanvas(digiOccupancyCoarseCanvas_, digiOccupancyEEMcoarse_, digiOccupancyEBcoarse_, digiOccupancyEEPcoarse_);
0876   }
0877 }
0878 
0879 void EcalDisplaysByEvent::drawCanvas(TCanvas* canvas, TH1F* hist1, TH1F* hist2, TH1F* hist3) {
0880   canvas->Divide(1, 2);
0881   canvas->cd(1)->Divide(2, 1);
0882   canvas->cd(1)->cd(1);
0883   hist1->Draw();
0884   canvas->cd(2);
0885   hist2->Draw();
0886   canvas->cd(1)->cd(2);
0887   hist3->Draw();
0888   histoCanvasNamesVector->push_back(canvas->GetName());
0889   canvas->SetCanvasSize(500, 500);
0890   canvas->SetFixedAspectRatio(true);
0891   canvas->Write();
0892 }
0893 
0894 void EcalDisplaysByEvent::drawCanvas(TCanvas* canvas, TH2F* hist1, TH2F* hist2, TH2F* hist3) {
0895   canvas->Divide(1, 2);
0896   canvas->cd(1)->Divide(2, 1);
0897   // EEM
0898   canvas->cd(1)->cd(1);
0899   hist1->Draw("colz");
0900   drawEELines();
0901   // EB
0902   canvas->cd(2);
0903   hist2->Draw("colz");
0904   hist2->GetXaxis()->SetNdivisions(-18);
0905   hist2->GetYaxis()->SetNdivisions(2);
0906   canvas->GetPad(2)->SetGridx(1);
0907   canvas->GetPad(2)->SetGridy(1);
0908   // EEP
0909   canvas->cd(1)->cd(2);
0910   hist3->Draw("colz");
0911   drawEELines();
0912   histoCanvasNamesVector->push_back(canvas->GetName());
0913   canvas->SetCanvasSize(500, 500);
0914   canvas->SetFixedAspectRatio(true);
0915   canvas->Write();
0916 }
0917 
0918 void EcalDisplaysByEvent::drawCanvas(TCanvas* canvas, TH3F* hist1, TH3F* hist2, TH3F* hist3) {
0919   if (canvas == timingMapCoarseCanvas_) {
0920     canvas->cd();
0921     TProfile2D* profile2 = (TProfile2D*)hist2->Project3DProfile("yx");
0922     profile2->Draw("colz");
0923     drawTimingErrors(profile2);
0924   } else {
0925     canvas->Divide(1, 2);
0926     canvas->cd(1)->Divide(2, 1);
0927     // EEM
0928     canvas->cd(1)->cd(1);
0929     TProfile2D* profile1 = (TProfile2D*)hist1->Project3DProfile("yx");
0930     profile1->Draw("colz");
0931     drawEELines();
0932     // EB
0933     canvas->cd(2);
0934     TProfile2D* profile2 = (TProfile2D*)hist2->Project3DProfile("yx");
0935     profile2->Draw("colz");
0936     profile2->GetXaxis()->SetNdivisions(-18);
0937     profile2->GetYaxis()->SetNdivisions(2);
0938     canvas->GetPad(2)->SetGridx(1);
0939     canvas->GetPad(2)->SetGridy(1);
0940     // EEP
0941     canvas->cd(1)->cd(2);
0942     TProfile2D* profile3 = (TProfile2D*)hist3->Project3DProfile("yx");
0943     profile3->Draw("colz");
0944     drawEELines();
0945   }
0946   histoCanvasNamesVector->push_back(canvas->GetName());
0947   canvas->SetCanvasSize(500, 500);
0948   canvas->SetFixedAspectRatio(true);
0949   canvas->Write();
0950 }
0951 
0952 void EcalDisplaysByEvent::drawTimingErrors(TProfile2D* profile) {
0953   int nxb = profile->GetNbinsX();
0954   int nyb = profile->GetNbinsY();
0955   char tempErr[200];
0956   for (int i = 0; i != nxb; ++i) {
0957     for (int j = 0; j != nyb; ++j) {
0958       int xb = i + 1;
0959       int yb = j + 1;
0960       //   std::cout << "xb: " << xb << "\tyb: " << yb << std::endl;
0961       double xcorr = profile->GetBinCenter(xb);
0962       double ycorr = profile->GetBinCenter(yb);
0963       sprintf(tempErr, "%0.2f", profile->GetBinError(xb, yb));
0964       int nBin = profile->GetBin(xb, yb, 0);
0965       int nBinEntries = (int)profile->GetBinEntries(nBin);
0966       if (nBinEntries != 0) {
0967         TLatex* tex = new TLatex(xcorr, ycorr, tempErr);
0968         tex->SetTextAlign(23);
0969         tex->SetTextSize(42);
0970         tex->SetTextSize(0.025);
0971         tex->SetLineWidth(2);
0972         tex->Draw();
0973         delete tex;
0974       }
0975       sprintf(tempErr, "%i", nBinEntries);
0976       if (nBinEntries != 0) {
0977         TLatex* tex = new TLatex(xcorr, ycorr, tempErr);
0978         tex->SetTextAlign(21);
0979         tex->SetTextFont(42);
0980         tex->SetTextSize(0.025);
0981         tex->SetLineWidth(2);
0982         tex->Draw();
0983         delete tex;
0984       }
0985     }
0986   }
0987 }
0988 
0989 void EcalDisplaysByEvent::drawEELines() {
0990   int ixSectorsEE[202] = {
0991       61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41,  40,  40,  39,  39, 40, 40,
0992       41, 41, 42, 42, 43, 43, 45, 45, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61,  0,   100, 100, 97, 97, 95,
0993       95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25,  25,  20,  20,  15, 15, 13,
0994       13, 8,  8,  5,  5,  3,  3,  0,  0,  3,  3,  5,  5,  8,  8,  13, 13, 15, 15, 20,  20,  25,  25,  35, 35, 40,
0995       40, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97, 100, 100, 0,   61,  65, 65, 70,
0996       70, 80, 80, 90, 90, 92, 0,  61, 65, 65, 90, 90, 97, 0,  57, 60, 60, 65, 65, 70,  70,  75,  75,  80, 80, 0,
0997       50, 50, 0,  43, 40, 40, 35, 35, 30, 30, 25, 25, 20, 20, 0,  39, 35, 35, 10, 10,  3,   0,   39,  35, 35, 30,
0998       30, 20, 20, 10, 10, 8,  0,  45, 45, 40, 40, 35, 35, 0,  55, 55, 60, 60, 65, 65};
0999 
1000   int iySectorsEE[202] = {50, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 60, 60, 59, 59, 58, 58, 57,  57,  55,  55,
1001                           45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43,  45,  45,  50,
1002                           0,  50, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,  100, 100, 97,
1003                           97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35,  35,  25,  25,
1004                           20, 20, 15, 15, 13, 13, 8,  8,  5,  5,  3,  3,  0,  0,  3,  3,  5,  5,  8,  8,   13,  13,  15,
1005                           15, 20, 20, 25, 25, 35, 35, 40, 40, 50, 0,  45, 45, 40, 40, 35, 35, 30, 30, 25,  25,  0,   50,
1006                           50, 55, 55, 60, 60, 0,  60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0,  61, 100, 0,   60,  60,
1007                           65, 65, 70, 70, 75, 75, 85, 85, 87, 0,  50, 50, 55, 55, 60, 60, 0,  45, 45, 40,  40,  35,  35,
1008                           30, 30, 25, 25, 0,  39, 30, 30, 15, 15, 5,  0,  39, 30, 30, 15, 15, 5};
1009 
1010   for (int i = 0; i < 202; i++) {
1011     ixSectorsEE[i] += 1;
1012     iySectorsEE[i] += 1;
1013     //   std::cout << i << " " << ixSectorsEE[i] << " " << iySectorsEE[i] << std::endl;
1014   }
1015 
1016   TLine l;
1017   l.SetLineWidth(1);
1018   for (int i = 0; i < 201; i = i + 1) {
1019     if ((ixSectorsEE[i] != 1 || iySectorsEE[i] != 1) && (ixSectorsEE[i + 1] != 1 || iySectorsEE[i + 1] != 1)) {
1020       l.DrawLine(ixSectorsEE[i], iySectorsEE[i], ixSectorsEE[i + 1], iySectorsEE[i + 1]);
1021     }
1022   }
1023 }