Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:00:04

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 // system include files
0020 #include <memory>
0021 #include <vector>
0022 #include <map>
0023 #include <set>
0024 #include <string>
0025 
0026 // user include files
0027 #include "FWCore/Framework/interface/Frameworkfwd.h"
0028 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/ServiceRegistry/interface/Service.h"
0034 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0035 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0036 
0037 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0038 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0039 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0040 #include "DataFormats/DetId/interface/DetId.h"
0041 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
0042 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
0043 
0044 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0045 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0046 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0047 
0048 #include "CaloOnlineTools/EcalTools/interface/EcalFedMap.h"
0049 
0050 #include "TFile.h"
0051 #include "TH1F.h"
0052 #include "TH2F.h"
0053 #include "TH3F.h"
0054 #include "TGraph.h"
0055 #include "TTree.h"
0056 #include "TCanvas.h"
0057 
0058 //
0059 // class declaration
0060 //
0061 
0062 class EcalDisplaysByEvent : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0063 public:
0064   explicit EcalDisplaysByEvent(const edm::ParameterSet&);
0065   ~EcalDisplaysByEvent() override;
0066 
0067 private:
0068   void beginRun(edm::Run const&, edm::EventSetup const&) override;
0069   void endRun(edm::Run const&, edm::EventSetup const&) override;
0070   void analyze(edm::Event const&, edm::EventSetup const&) override;
0071   void endJob() override;
0072   std::string intToString(int num);
0073   std::string floatToString(float num);
0074   void initHists(int);
0075   void initEvtByEvtHists(int naiveEvtNum_, int ievt);
0076   void deleteEvtByEvtHists();
0077   void initAllEventHistos();
0078   enum Ecal2DHistSubDetType { EB_FINE = 0, EB_COARSE = 1, EEM_FINE = 2, EEM_COARSE = 3, EEP_FINE = 4, EEP_COARSE = 5 };
0079   TH2F* init2DEcalHist(std::string histTypeName, int subDet);
0080   TH3F* init3DEcalHist(std::string histTypeName, int dubDet);
0081   TCanvas* init2DEcalCanvas(std::string canvasName);
0082   void selectHits(edm::Handle<EcalRecHitCollection> hits, int ievt);
0083   TGraph* selectDigi(DetId det, int ievt);
0084   int getEEIndex(EcalElectronicsId elecId);
0085   void makeHistos(edm::Handle<EBDigiCollection> ebDigis);
0086   void makeHistos(edm::Handle<EEDigiCollection> eeDigis);
0087   void makeHistos(edm::Handle<EcalRecHitCollection> hits);
0088   void drawHistos();
0089   void drawCanvas(TCanvas* canvas, TH1F* hist1, TH1F* hist2, TH1F* hist3);
0090   void drawCanvas(TCanvas* canvas, TH2F* hist1, TH2F* hist2, TH2F* hist3);
0091   void drawCanvas(TCanvas* canvas, TH3F* hist1, TH3F* hist2, TH3F* hist3);
0092   void drawTimingErrors(TProfile2D* profile);
0093   void drawEELines();
0094 
0095   // ----------member data ---------------------------
0096 
0097   const edm::InputTag EBRecHitCollection_;
0098   const edm::InputTag EERecHitCollection_;
0099   const edm::InputTag EBDigis_;
0100   const edm::InputTag EEDigis_;
0101   const edm::InputTag headerProducer_;
0102 
0103   edm::Handle<EBDigiCollection> EBdigisHandle;
0104   edm::Handle<EEDigiCollection> EEdigisHandle;
0105 
0106   const edm::EDGetTokenT<EcalRawDataCollection> rawDataToken_;
0107   const edm::EDGetTokenT<EcalRecHitCollection> ebRecHitToken_;
0108   const edm::EDGetTokenT<EcalRecHitCollection> eeRecHitToken_;
0109   const edm::EDGetTokenT<EBDigiCollection> ebDigiToken_;
0110   const edm::EDGetTokenT<EEDigiCollection> eeDigiToken_;
0111 
0112   const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalMappingToken_;
0113   const edm::ESGetToken<CaloTopology, CaloTopologyRecord> topologyToken_;
0114 
0115   int runNum_;
0116   const int side_;
0117   const double threshold_;
0118   const double minTimingAmp_;
0119   const bool makeDigiGraphs_;
0120   const bool makeTimingHistos_;
0121   const bool makeEnergyHistos_;
0122   const bool makeOccupancyHistos_;
0123   const double histRangeMin_;
0124   const double histRangeMax_;
0125   const double minTimingEnergyEB_;
0126   const double minTimingEnergyEE_;
0127 
0128   std::set<EBDetId> listEBChannels;
0129   std::set<EEDetId> listEEChannels;
0130 
0131   int abscissa[10];
0132   int ordinate[10];
0133 
0134   static float gainRatio[3];
0135   static edm::Service<TFileService> fileService;
0136 
0137   std::vector<std::string>* names;
0138   std::vector<std::string>* histoCanvasNamesVector;
0139   std::vector<int> maskedChannels_;
0140   std::vector<int> maskedFEDs_;
0141   std::vector<int> seedCrys_;
0142   std::vector<std::string> maskedEBs_;
0143   std::map<int, TH1F*> FEDsAndTimingHists_;
0144   std::map<int, float> crysAndAmplitudesMap_;
0145   std::map<int, EcalDCCHeaderBlock> FEDsAndDCCHeaders_;
0146   std::map<std::string, int> seedFrequencyMap_;
0147 
0148   TH1F* allFedsTimingHist_;
0149   // For event-by-evet histos
0150   TH1F* timingEB_;
0151   TH1F* timingEEM_;
0152   TH1F* timingEEP_;
0153   TH1F* energyEB_;
0154   TH1F* energyEEM_;
0155   TH1F* energyEEP_;
0156   TH2F* energyMapEB_;
0157   TH2F* energyMapEBcoarse_;
0158   TH2F* energyMapEEM_;
0159   TH2F* energyMapEEMcoarse_;
0160   TH2F* energyMapEEP_;
0161   TH2F* energyMapEEPcoarse_;
0162   TH2F* recHitOccupancyEB_;
0163   TH2F* recHitOccupancyEBcoarse_;
0164   TH2F* recHitOccupancyEEM_;
0165   TH2F* recHitOccupancyEEMcoarse_;
0166   TH2F* recHitOccupancyEEP_;
0167   TH2F* recHitOccupancyEEPcoarse_;
0168   TH2F* digiOccupancyEB_;
0169   TH2F* digiOccupancyEBcoarse_;
0170   TH2F* digiOccupancyEEM_;
0171   TH2F* digiOccupancyEEMcoarse_;
0172   TH2F* digiOccupancyEEP_;
0173   TH2F* digiOccupancyEEPcoarse_;
0174   TH3F* timingMapEBCoarse_;
0175   TH3F* timingMapEEMCoarse_;
0176   TH3F* timingMapEEPCoarse_;
0177   TH3F* timingMapEB_;
0178   TH3F* timingMapEEM_;
0179   TH3F* timingMapEEP_;
0180   TCanvas* timingCanvas_;
0181   TCanvas* energyCanvas_;
0182   TCanvas* energyMapCanvas_;
0183   TCanvas* energyMapCoarseCanvas_;
0184   TCanvas* recHitOccupancyCanvas_;
0185   TCanvas* recHitOccupancyCoarseCanvas_;
0186   TCanvas* digiOccupancyCanvas_;
0187   TCanvas* digiOccupancyCoarseCanvas_;
0188   TCanvas* timingMapCoarseCanvas_;
0189   TCanvas* timingMapCanvas_;
0190 
0191   // For all-event hitos
0192   TH1F* timingEBAll_;
0193   TH1F* timingEEMAll_;
0194   TH1F* timingEEPAll_;
0195   TH1F* energyEBAll_;
0196   TH1F* energyEEMAll_;
0197   TH1F* energyEEPAll_;
0198   TH2F* energyMapEBAll_;
0199   TH2F* energyMapEBcoarseAll_;
0200   TH2F* energyMapEEMAll_;
0201   TH2F* energyMapEEMcoarseAll_;
0202   TH2F* energyMapEEPAll_;
0203   TH2F* energyMapEEPcoarseAll_;
0204   TH2F* recHitOccupancyEBAll_;
0205   TH2F* recHitOccupancyEBcoarseAll_;
0206   TH2F* recHitOccupancyEEMAll_;
0207   TH2F* recHitOccupancyEEMcoarseAll_;
0208   TH2F* recHitOccupancyEEPAll_;
0209   TH2F* recHitOccupancyEEPcoarseAll_;
0210   TH2F* digiOccupancyEBAll_;
0211   TH2F* digiOccupancyEBcoarseAll_;
0212   TH2F* digiOccupancyEEMAll_;
0213   TH2F* digiOccupancyEEMcoarseAll_;
0214   TH2F* digiOccupancyEEPAll_;
0215   TH2F* digiOccupancyEEPcoarseAll_;
0216   TH3F* timingMapEBCoarseAll_;
0217   TH3F* timingMapEEMCoarseAll_;
0218   TH3F* timingMapEEPCoarseAll_;
0219   TH3F* timingMapEBAll_;
0220   TH3F* timingMapEEMAll_;
0221   TH3F* timingMapEEPAll_;
0222   TCanvas* timingCanvasAll_;
0223   TCanvas* energyCanvasAll_;
0224   TCanvas* energyMapCanvasAll_;
0225   TCanvas* energyMapCoarseCanvasAll_;
0226   TCanvas* recHitOccupancyCanvasAll_;
0227   TCanvas* recHitOccupancyCoarseCanvasAll_;
0228   TCanvas* digiOccupancyCanvasAll_;
0229   TCanvas* digiOccupancyCoarseCanvasAll_;
0230   TCanvas* timingMapCoarseCanvasAll_;
0231   TCanvas* timingMapCanvasAll_;
0232 
0233   TTree* canvasNames_;
0234   TTree* histoCanvasNames_;
0235   EcalFedMap* fedMap_;
0236   const EcalElectronicsMapping* ecalElectronicsMap_;
0237   const CaloTopology* caloTopo_;
0238 
0239   int naiveEvtNum_;
0240 };