Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-11 04:33:24

0001 // -*- C++ -*-
0002 //
0003 // Package:    HGCalValidation/HGCalCellHitSum
0004 // Class:      HGCalCellHitSum
0005 //
0006 /**\class HGCalCellHitSum HGCalCellHitSum.cc Validation/HGCalValidation/test/HGCalCellHitSum.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Indranil Das
0015 //         Created:  Wed, 25 Aug 2021 06:18:11 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <vector>
0022 #include <fstream>
0023 #include <string>
0024 #include <cstdarg>
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/ModuleFactory.h"
0032 #include "FWCore/Framework/interface/MakerMacros.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 #include "FWCore/ParameterSet/interface/FileInPath.h"
0035 #include "FWCore/ServiceRegistry/interface/Service.h"
0036 #include "FWCore/Utilities/interface/InputTag.h"
0037 
0038 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0039 
0040 #include "SimDataFormats/Track/interface/SimTrack.h"
0041 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0042 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0043 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0044 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0045 
0046 #include "DataFormats/DetId/interface/DetId.h"
0047 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0048 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0049 #include "DataFormats/Math/interface/angle_units.h"
0050 
0051 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0052 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0053 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0054 
0055 #include <CLHEP/Units/SystemOfUnits.h>
0056 #include <CLHEP/Units/GlobalPhysicalConstants.h>
0057 
0058 #include <TH1.h>
0059 #include <TH2.h>
0060 #include <TGraph.h>
0061 #include <TMath.h>
0062 
0063 using namespace angle_units::operators;
0064 
0065 //
0066 // class declaration
0067 //
0068 
0069 class HGCalCellHitSum : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0070 public:
0071   //Implemented following Validation/HGCalValidation/plugins/HGCalSimHitValidation.cc
0072   struct energysum {
0073     energysum() {
0074       etotal = 0;
0075       for (int i = 0; i < 6; ++i)
0076         eTime[i] = 0.;
0077     }
0078     double eTime[6], etotal;
0079   };
0080 
0081   struct waferinfo {
0082     waferinfo() { layer = u = v = type = -999; }
0083     //v15 format : layer, u, v, type ; where type = 0 (partial wafer) and 1 (full wafer)
0084     //v16 format : index, layer, u, v, prop, thickness, cuttype, orientation ; where cuttype = "full" for full wafers and all others are partial wafers
0085     //v17 format : index, layer, u, v, prop, thickness, cuttype, orientation, cassette ; where cuttype = "full" for full wafers and all others are partial wafers
0086     int layer, u, v, type;
0087   };
0088 
0089   struct hitsinfo {
0090     hitsinfo() {
0091       x = y = z = phi = eta = trkpt = trketa = trkphi = 0.0;
0092       cell = cell2 = sector = sector2 = type = layer = pdg = charge = 0;
0093       hitid = nhits = 0;
0094       isMu = false;
0095     }
0096     double x, y, z, phi, eta, trkpt, trketa, trkphi;
0097     int cell, cell2, sector, sector2, type, layer, pdg, charge;
0098     unsigned int hitid, nhits;
0099     bool isMu;
0100   };
0101 
0102   explicit HGCalCellHitSum(const edm::ParameterSet &);
0103   ~HGCalCellHitSum() override = default;
0104 
0105   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0106 
0107 private:
0108   void beginJob() override {}
0109   void analyze(const edm::Event &, const edm::EventSetup &) override;
0110   void endJob() override {}
0111 
0112   // ----------member data ---------------------------
0113   const edm::EDGetTokenT<edm::SimTrackContainer> tSimTrackContainer;
0114   const edm::EDGetTokenT<edm::PCaloHitContainer> tSimCaloHitContainer;
0115   const std::string name_;
0116   const edm::FileInPath geometryFileName_;
0117   const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
0118   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0119   const std::string layers_;
0120 
0121   TH1D *hCharge;
0122   TH1D *hChargeLowELoss;
0123 
0124   TH1D *hPt;
0125   TH1D *hPtNoGen;
0126   TH1D *hPtLowELoss;
0127 
0128   TH1D *hEta;
0129   TH1D *hEtaCell;
0130   TH1D *hEtaLowELoss;
0131 
0132   TH1D *hPhi;
0133   TH1D *hPhiCell;
0134   TH1D *hPhiLowELoss;
0135 
0136   TH1D *hPDG;
0137   TH1D *hPDGLowELoss;
0138 
0139   TH1D *hELossEE;
0140   TH1D *hELossEEF;
0141   TH1D *hELossEECN;
0142   TH1D *hELossEECK;
0143   TH1D *hELossHEF;
0144   TH1D *hELossHEFF;
0145   TH1D *hELossHEFCN;
0146   TH1D *hELossHEFCK;
0147   TH1D *hELossHEB;
0148 
0149   TH1D *hELossCSinBunchEE;
0150   TH1D *hELossCSinBunchEEF;
0151   TH1D *hELossCSinBunchEECN;
0152   TH1D *hELossCSinBunchEECK;
0153   TH1D *hELossCSinBunchHEF;
0154   TH1D *hELossCSinBunchHEFF;
0155   TH1D *hELossCSinBunchHEFCN;
0156   TH1D *hELossCSinBunchHEFCK;
0157   TH1D *hELossCSinBunchHEFCNFiltered;
0158   TH1D *hELossCSinBunchHEFCNNoise;
0159 
0160   TH1D *hELossCSmissedEE;
0161   TH1D *hELossCSmissedEEF;
0162   TH1D *hELossCSmissedEECN;
0163   TH1D *hELossCSmissedEECK;
0164   TH1D *hELossCSmissedHEF;
0165   TH1D *hELossCSmissedHEFF;
0166   TH1D *hELossCSmissedHEFCN;
0167   TH1D *hELossCSmissedHEFCK;
0168 
0169   TH1D *hELossCSMaxEE;
0170   TH1D *hELossCSMaxEEF;
0171   TH1D *hELossCSMaxEECN;
0172   TH1D *hELossCSMaxEECK;
0173   TH1D *hELossCSMaxHEF;
0174   TH1D *hELossCSMaxHEFF;
0175   TH1D *hELossCSMaxHEFCN;
0176   TH1D *hELossCSMaxHEFCK;
0177 
0178   TH1D *hHxELossCSMaxF;
0179   TH1D *hHxELossCSMaxCN;
0180   TH1D *hHxELossCSMaxCK;
0181   TH1D *hNHxELossCSMaxF;
0182   TH1D *hNHxELossCSMaxCN;
0183   TH1D *hNHxELossCSMaxCK;
0184 
0185   std::vector<TH1D *> hELossDQMEqV;
0186   std::vector<TH1D *> hELossLayer;
0187 
0188   // TH2D *hYZhits;
0189   std::vector<TH2D *> hXYhits;
0190 
0191   std::vector<TH2D *> hXYhitsF0;
0192   std::vector<TH2D *> hXYhitsCN0;
0193   std::vector<TH2D *> hXYhitsCK0;
0194   std::vector<TH2D *> hXYhitsB0;
0195 
0196   std::vector<TH2D *> hXYhitsF1;
0197   std::vector<TH2D *> hXYhitsCN1;
0198   std::vector<TH2D *> hXYhitsCK1;
0199   std::vector<TH2D *> hXYhitsB1;
0200 
0201   std::vector<TH2D *> hEPhitsF0;
0202   std::vector<TH2D *> hEPhitsCN0;
0203   std::vector<TH2D *> hEPhitsCK0;
0204   std::vector<TH2D *> hEPhitsB0;
0205 
0206   std::vector<TH2D *> hEPhitsF1;
0207   std::vector<TH2D *> hEPhitsCN1;
0208   std::vector<TH2D *> hEPhitsCK1;
0209   std::vector<TH2D *> hEPhitsB1;
0210 
0211   std::vector<TH2D *> hXYFailhitsF0;
0212   std::vector<TH2D *> hXYFailhitsCN0;
0213   std::vector<TH2D *> hXYFailhitsCK0;
0214   std::vector<TH2D *> hXYFailhitsB0;
0215 
0216   std::vector<TH2D *> hXYFailhitsF1;
0217   std::vector<TH2D *> hXYFailhitsCN1;
0218   std::vector<TH2D *> hXYFailhitsCK1;
0219   std::vector<TH2D *> hXYFailhitsB1;
0220 
0221   std::vector<TH2D *> hEPFailhitsF0;
0222   std::vector<TH2D *> hEPFailhitsCN0;
0223   std::vector<TH2D *> hEPFailhitsCK0;
0224   std::vector<TH2D *> hEPFailhitsB0;
0225 
0226   std::vector<TH2D *> hEPFailhitsF1;
0227   std::vector<TH2D *> hEPFailhitsCN1;
0228   std::vector<TH2D *> hEPFailhitsCK1;
0229   std::vector<TH2D *> hEPFailhitsB1;
0230 
0231   std::vector<TH1D *> hELossLayerF0;
0232   std::vector<TH1D *> hELossLayerCN0;
0233   std::vector<TH1D *> hELossLayerCK0;
0234   std::vector<TH1D *> hELossLayerB0;
0235 
0236   std::vector<TH1D *> hELossLayerF1;
0237   std::vector<TH1D *> hELossLayerCN1;
0238   std::vector<TH1D *> hELossLayerCK1;
0239   std::vector<TH1D *> hELossLayerB1;
0240 
0241   std::vector<TH2D *> hXYhitsLELCN;
0242   std::vector<TH2D *> hXYhitsHELCN;
0243   std::vector<TH2D *> hXYhitsLELCK;
0244   std::vector<TH2D *> hXYhitsHELCK;
0245   std::vector<TH2D *> hNHxXYhitsF;
0246   std::vector<TH2D *> hNHxXYhitsCN;
0247   std::vector<TH2D *> hNHxXYhitsCK;
0248 
0249   // For rechittool z positions. The 0 and 1 are for -ve and +ve, respectively.
0250   std::vector<TGraph *> grXYhitsF0;
0251   std::vector<TGraph *> grXYhitsCN0;
0252   std::vector<TGraph *> grXYhitsCK0;
0253   std::vector<TGraph *> grXYhitsAR0;
0254   std::vector<TGraph *> grXYhitsB0;
0255   int ixyF0[50], ixyCN0[50], ixyCK0[50], ixyAR0[50], ixyB0[50];
0256 
0257   std::vector<TGraph *> grXYhitsF1;
0258   std::vector<TGraph *> grXYhitsCN1;
0259   std::vector<TGraph *> grXYhitsCK1;
0260   std::vector<TGraph *> grXYhitsAR1;
0261   std::vector<TGraph *> grXYhitsB1;
0262   int ixyF1[50], ixyCN1[50], ixyCK1[50], ixyAR1[50], ixyB1[50];
0263   /////////////////////////////////
0264 
0265   // For rechittool z positions. The 0 and 1 are for -ve and +ve, respectively.
0266   std::vector<TGraph *> grEtaPhihitsF0;
0267   std::vector<TGraph *> grEtaPhihitsCN0;
0268   std::vector<TGraph *> grEtaPhihitsCK0;
0269   std::vector<TGraph *> grEtaPhihitsB0;
0270   int iepF0[50], iepCN0[50], iepCK0[50], iepB0[50];
0271 
0272   std::vector<TGraph *> grEtaPhihitsF1;
0273   std::vector<TGraph *> grEtaPhihitsCN1;
0274   std::vector<TGraph *> grEtaPhihitsCK1;
0275   std::vector<TGraph *> grEtaPhihitsB1;
0276   int iepF1[50], iepCN1[50], iepCK1[50], iepB1[50];
0277   //////////////////////////////////////////
0278 
0279   std::vector<TH1D *> hELCSMaxF;
0280   std::vector<TH1D *> hELCSMaxCN;
0281   std::vector<TH1D *> hELCSMaxCK;
0282 
0283   std::vector<TH1D *> hHxELCSMaxF;
0284   std::vector<TH1D *> hHxELCSMaxCN;
0285   std::vector<TH1D *> hHxELCSMaxCK;
0286   std::vector<TH1D *> hNHxELCSMaxF;
0287   std::vector<TH1D *> hNHxELCSMaxCN;
0288   std::vector<TH1D *> hNHxELCSMaxCK;
0289 
0290   TH2D *hXYLowELosshitsF;
0291   TH2D *hXYLowELosshitsCN;
0292   TH2D *hXYLowELosshitsCK;
0293   TH2D *hXYmissedhits;
0294   TH2D *hYZLowELosshitsF;
0295   TH2D *hYZLowELosshitsCN;
0296   TH2D *hYZLowELosshitsCK;
0297   TH2D *hYZLLowELosshitsHEFCN;
0298   TH2D *hYZmissedhits;
0299 
0300   TH1D *hXLowELosshitsHEFCN;
0301   TH1D *hYLowELosshitsHEFCN;
0302   TH1D *hZLowELosshitsHEFCN;
0303 
0304   TH2D *hYZhitsEE;
0305   TH2D *hYZhitsHEF;
0306   TH2D *hYZhitsHEB;
0307 
0308   TH2D *hYZhitsEEF;
0309   TH2D *hYZhitsEECN;
0310   TH2D *hYZhitsEECK;
0311 
0312   TH2D *hYZhitsHEFF;
0313   TH2D *hYZhitsHEFCN;
0314   TH2D *hYZhitsHEFCK;
0315 
0316   TH2D *hRHTXYhits;
0317   TH2D *hRHTYZhitsEE;
0318   TH2D *hRHTYZhitsHEF;
0319   TH2D *hRHTYZhitsHEB;
0320   TH2D *hRHTYZhitsEEF;
0321   TH2D *hRHTYZhitsEECN;
0322   TH2D *hRHTYZhitsEECK;
0323   TH2D *hRHTYZhitsHEFF;
0324   TH2D *hRHTYZhitsHEFCN;
0325   TH2D *hRHTYZhitsHEFCK;
0326 
0327   TH2D *hRHTRZhitsEE;
0328   TH2D *hRHTRZhitsHEF;
0329   TH2D *hRHTRZhitsHEB;
0330   TH2D *hRHTRZhitsEEF;
0331   TH2D *hRHTRZhitsEECN;
0332   TH2D *hRHTRZhitsEECK;
0333   TH2D *hRHTRZhitsHEFF;
0334   TH2D *hRHTRZhitsHEFCN;
0335   TH2D *hRHTRZhitsHEFCK;
0336 
0337   TH2D *hRHTGlbRZhitsF;
0338   TH2D *hRHTGlbRZhitsCN;
0339   TH2D *hRHTGlbRZhitsCK;
0340   TH2D *hRHTGlbRZhitsSci;
0341 
0342   TH1D *hDiffX;
0343   TH1D *hDiffY;
0344   TH1D *hDiffZ;
0345 
0346   TH1D *hCellThickness;
0347 
0348   std::vector<Int_t> layerList;
0349 
0350   hgcal::RecHitTools rhtools_;
0351   std::vector<waferinfo> winfo;
0352   int evt;
0353 };
0354 
0355 //
0356 // constructors and destructor
0357 //
0358 HGCalCellHitSum::HGCalCellHitSum(const edm::ParameterSet &iConfig)
0359     : tSimTrackContainer(consumes<edm::SimTrackContainer>(iConfig.getParameter<edm::InputTag>("simtrack"))),
0360       tSimCaloHitContainer(consumes<edm::PCaloHitContainer>(iConfig.getParameter<edm::InputTag>("simhits"))),
0361       name_(iConfig.getParameter<std::string>("detector")),
0362       geometryFileName_(iConfig.getParameter<edm::FileInPath>("geometryFileName")),
0363       geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", name_})),
0364       caloGeomToken_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
0365       layers_(iConfig.getParameter<std::string>("layerList")),
0366       evt(0) {
0367   //now do what ever initialization is needed
0368   usesResource(TFileService::kSharedResource);
0369   edm::LogVerbatim("ValidHGCal") << "HGCalCellHitSum::Initialize for " << name_ << " using " << geometryFileName_
0370                                  << " and collections for simTrack:" << iConfig.getParameter<edm::InputTag>("simtrack")
0371                                  << " and for hits " << iConfig.getParameter<edm::InputTag>("simhits")
0372                                  << " and for layers " << layers_;
0373 
0374   layerList.clear();
0375 
0376   if (layers_.find("-") != std::string::npos) {
0377     std::vector<std::string> tokens;
0378     std::stringstream check1(layers_);
0379     std::string intermediate;
0380     while (getline(check1, intermediate, '-'))
0381       tokens.push_back(intermediate);
0382     int minLayer = (stoi(tokens[0]) < 1) ? 1 : stoi(tokens[0]);
0383     int maxLayer = (stoi(tokens[1]) > 47) ? 47 : stoi(tokens[1]);
0384     for (int i = minLayer; i <= maxLayer; i++) {
0385       layerList.push_back(i);
0386       //std::cout << tokens[i] << '\n';
0387     }
0388     tokens.clear();
0389 
0390   } else if (layers_.find(",") != std::string::npos) {
0391     std::vector<std::string> tokens;
0392     std::stringstream check1(layers_);
0393     std::string intermediate;
0394     while (getline(check1, intermediate, ','))
0395       tokens.push_back(intermediate);
0396     for (unsigned int i = 0; i < tokens.size(); i++) {
0397       if (stoi(tokens[i]) >= 1 and stoi(tokens[i]) <= 47)
0398         layerList.push_back(stoi(tokens[i]));
0399       //std::cout << tokens[i] << '\n';
0400     }
0401     tokens.clear();
0402 
0403   } else {
0404     if (stoi(layers_) >= 1 and stoi(layers_) <= 47)
0405       layerList.push_back(stoi(layers_));
0406   }
0407 
0408   // for(unsigned int i = 0; i < layerList.size(); i++){
0409   //   std::cout << layerList[i] << "," ;
0410   // }
0411   // std::cout << std::endl;
0412 
0413   edm::Service<TFileService> fs;
0414 
0415   hCharge = fs->make<TH1D>("charge", "Charges", 200, -20, 20);
0416   hChargeLowELoss = fs->make<TH1D>("charge LowELoss", "Charges LowELoss", 200, -20, 20);
0417 
0418   hPDG = fs->make<TH1D>("hPDG", "hPDG", 10000, -5000, 5000);
0419   hPDGLowELoss = fs->make<TH1D>("hPDGLowELoss", "hPDGLowELoss", 10000, -5000, 5000);
0420 
0421   hPt = fs->make<TH1D>("hPt", "hPt", 1000, 0., 1000.);
0422   hPtNoGen = fs->make<TH1D>("hPtNoGen", "hPtNoGen", 1000, 0., 1000.);
0423   hPtLowELoss = fs->make<TH1D>("hPtLowELoss", "hPtLowELoss", 1000, 0., 1000.);
0424 
0425   hEta = fs->make<TH1D>("hEta", "hEta", 100, -5., 5.);
0426   hEtaCell = fs->make<TH1D>("hEtaCell", "hEtaCell", 100, -5., 5.);
0427   hEtaLowELoss = fs->make<TH1D>("hEtaLowELoss", "hEtaLowELoss", 100, -5., 5.);
0428 
0429   hPhi = fs->make<TH1D>("hPhi", "hPhi", 100, -5., 5.);
0430   hPhiCell = fs->make<TH1D>("hPhiCell", "hPhiCell", 100, -5., 5.);
0431   hPhiLowELoss = fs->make<TH1D>("hPhiLowELoss", "hPhiLowELoss", 100, -5., 5.);
0432 
0433   hELossEE = fs->make<TH1D>("hELossEE", "hELossEE", 1000, 0., 1000.);
0434   hELossEEF = fs->make<TH1D>("hELossEEF", "hELossEEF", 1000, 0., 1000.);
0435   hELossEECN = fs->make<TH1D>("hELossEECN", "hELossEECN", 1000, 0., 1000.);
0436   hELossEECK = fs->make<TH1D>("hELossEECK", "hELossEECK", 1000, 0., 1000.);
0437 
0438   hELossHEF = fs->make<TH1D>("hELossHEF", "hELossHEF", 1000, 0., 1000.);
0439   hELossHEFF = fs->make<TH1D>("hELossHEFF", "hELossHEFF", 1000, 0., 1000.);
0440   hELossHEFCN = fs->make<TH1D>("hELossHEFCN", "hELossHEFCN", 1000, 0., 1000.);
0441   hELossHEFCK = fs->make<TH1D>("hELossHEFCK", "hELossHEFCK", 1000, 0., 1000.);
0442 
0443   hELossHEB = fs->make<TH1D>("hELossHEB", "hELossHEB", 1000, 0., 1000.);
0444 
0445   hELossCSinBunchEE = fs->make<TH1D>("hELossCSinBunchEE", "hELossCSinBunchEE", 1000, 0., 1000.);
0446   hELossCSinBunchEEF = fs->make<TH1D>("hELossCSinBunchEEF", "hELossCSinBunchEEF", 1000, 0., 1000.);
0447   hELossCSinBunchEECN = fs->make<TH1D>("hELossCSinBunchEECN", "hELossCSinBunchEECN", 1000, 0., 1000.);
0448   hELossCSinBunchEECK = fs->make<TH1D>("hELossCSinBunchEECK", "hELossCSinBunchEECK", 1000, 0., 1000.);
0449   hELossCSinBunchHEF = fs->make<TH1D>("hELossCSinBunchHEF", "hELossCSinBunchHEF", 1000, 0., 1000.);
0450   hELossCSinBunchHEFF = fs->make<TH1D>("hELossCSinBunchHEFF", "hELossCSinBunchHEFF", 1000, 0., 1000.);
0451   hELossCSinBunchHEFCN = fs->make<TH1D>("hELossCSinBunchHEFCN", "hELossCSinBunchHEFCN", 1000, 0., 1000.);
0452   hELossCSinBunchHEFCK = fs->make<TH1D>("hELossCSinBunchHEFCK", "hELossCSinBunchHEFCK", 1000, 0., 1000.);
0453   hELossCSinBunchHEFCNFiltered =
0454       fs->make<TH1D>("hELossCSinBunchHEFCNFiltered", "hELossCSinBunchHEFCNFiltered", 1000, 0., 1000.);
0455   hELossCSinBunchHEFCNNoise = fs->make<TH1D>("hELossCSinBunchHEFCNNoise", "hELossCSinBunchHEFCNNoise", 1000, 0., 1000.);
0456 
0457   hELossCSmissedEE = fs->make<TH1D>("hELossCSmissedEE", "hELossCSmissedEE", 1000, 0., 1000.);
0458   hELossCSmissedEEF = fs->make<TH1D>("hELossCSmissedEEF", "hELossCSmissedEEF", 1000, 0., 1000.);
0459   hELossCSmissedEECN = fs->make<TH1D>("hELossCSmissedEECN", "hELossCSmissedEECN", 1000, 0., 1000.);
0460   hELossCSmissedEECK = fs->make<TH1D>("hELossCSmissedEECK", "hELossCSmissedEECK", 1000, 0., 1000.);
0461   hELossCSmissedHEF = fs->make<TH1D>("hELossCSmissedHEF", "hELossCSmissedHEF", 1000, 0., 1000.);
0462   hELossCSmissedHEFF = fs->make<TH1D>("hELossCSmissedHEFF", "hELossCSmissedHEFF", 1000, 0., 1000.);
0463   hELossCSmissedHEFCN = fs->make<TH1D>("hELossCSmissedHEFCN", "hELossCSmissedHEFCN", 1000, 0., 1000.);
0464   hELossCSmissedHEFCK = fs->make<TH1D>("hELossCSmissedHEFCK", "hELossCSmissedHEFCK", 1000, 0., 1000.);
0465 
0466   hELossCSMaxEE = fs->make<TH1D>("hELossCSMaxEE", "hELossCSMaxEE", 1000, 0., 1000.);
0467   hELossCSMaxEEF = fs->make<TH1D>("hELossCSMaxEEF", "hELossCSMaxEEF", 1000, 0., 1000.);
0468   hELossCSMaxEECN = fs->make<TH1D>("hELossCSMaxEECN", "hELossCSMaxEECN", 1000, 0., 1000.);
0469   hELossCSMaxEECK = fs->make<TH1D>("hELossCSMaxEECK", "hELossCSMaxEECK", 1000, 0., 1000.);
0470   hELossCSMaxHEF = fs->make<TH1D>("hELossCSMaxHEF", "hELossCSMaxHEF", 1000, 0., 1000.);
0471   hELossCSMaxHEFF = fs->make<TH1D>("hELossCSMaxHEFF", "hELossCSMaxHEFF", 1000, 0., 1000.);
0472   hELossCSMaxHEFCN = fs->make<TH1D>("hELossCSMaxHEFCN", "hELossCSMaxHEFCN", 1000, 0., 1000.);
0473   hELossCSMaxHEFCK = fs->make<TH1D>("hELossCSMaxHEFCK", "hELossCSMaxHEFCK", 1000, 0., 1000.);
0474 
0475   hHxELossCSMaxF = fs->make<TH1D>("hHxELossCSMaxF", "hHxELossCSMaxF", 1000, 0., 1000.);
0476   hHxELossCSMaxCN = fs->make<TH1D>("hHxELossCSMaxCN", "hHxELossCSMaxCN", 1000, 0., 1000.);
0477   hHxELossCSMaxCK = fs->make<TH1D>("hHxELossCSMaxCK", "hHxELossCSMaxCK", 1000, 0., 1000.);
0478 
0479   hNHxELossCSMaxF = fs->make<TH1D>("hNHxELossCSMaxF", "hNHxELossCSMaxF", 1000, 0., 1000.);
0480   hNHxELossCSMaxCN = fs->make<TH1D>("hNHxELossCSMaxCN", "hNHxELossCSMaxCN", 1000, 0., 1000.);
0481   hNHxELossCSMaxCK = fs->make<TH1D>("hNHxELossCSMaxCK", "hNHxELossCSMaxCK", 1000, 0., 1000.);
0482 
0483   for (unsigned int i = 0; i < layerList.size(); i++) {
0484     hELCSMaxF.emplace_back(fs->make<TH1D>(
0485         Form("hELCSMaxF_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0486     hELCSMaxCN.emplace_back(fs->make<TH1D>(
0487         Form("hELCSMaxCN_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0488     hELCSMaxCK.emplace_back(fs->make<TH1D>(
0489         Form("hELCSMaxCK_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0490   }
0491   for (unsigned int i = 0; i < layerList.size(); i++) {
0492     hHxELCSMaxF.emplace_back(fs->make<TH1D>(
0493         Form("hHxELCSMaxF_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0494     hHxELCSMaxCN.emplace_back(fs->make<TH1D>(
0495         Form("hHxELCSMaxCN_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0496     hHxELCSMaxCK.emplace_back(fs->make<TH1D>(
0497         Form("hHxELCSMaxCK_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0498     hNHxELCSMaxF.emplace_back(fs->make<TH1D>(
0499         Form("hNHxELCSMaxF_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0500     hNHxELCSMaxCN.emplace_back(fs->make<TH1D>(
0501         Form("hNHxELCSMaxCN_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0502     hNHxELCSMaxCK.emplace_back(fs->make<TH1D>(
0503         Form("hNHxELCSMaxCK_layer_%02d", layerList[i]), Form("Energy for layer %d", layerList[i]), 500, 0., 500.));
0504     hELossDQMEqV.emplace_back(fs->make<TH1D>(
0505         Form("hELossDQMEqV_layer_%02d", layerList[i]), Form("hELossDQMEqV_layer_%02d", layerList[i]), 100, 0, 0.1));
0506     hELossLayer.emplace_back(fs->make<TH1D>(
0507         Form("hELossLayer_%02d", layerList[i]), Form("hELossLayer_%02d", layerList[i]), 1000, 0., 1000.));
0508   }
0509   for (unsigned int i = 0; i < layerList.size(); i++) {
0510     hXYhits.emplace_back(fs->make<TH2D>(Form("hXYhits_layer_%02d", layerList[i]),
0511                                         Form("Gen:Hits in XY for layer %d", layerList[i]),
0512                                         600,
0513                                         -300.,
0514                                         300.,
0515                                         600,
0516                                         -300.,
0517                                         300.));
0518 
0519     hXYhitsF0.emplace_back(fs->make<TH2D>(Form("hXYhitsF0_layer_%02d", layerList[i]),
0520                                           Form("Gen:HitsF0 in XY for layer %d", layerList[i]),
0521                                           600,
0522                                           -300.,
0523                                           300.,
0524                                           600,
0525                                           -300.,
0526                                           300.));
0527     hXYhitsCN0.emplace_back(fs->make<TH2D>(Form("hXYhitsCN0_layer_%02d", layerList[i]),
0528                                            Form("Gen:HitsCN0 in XY for layer %d", layerList[i]),
0529                                            600,
0530                                            -300.,
0531                                            300.,
0532                                            600,
0533                                            -300.,
0534                                            300.));
0535     hXYhitsCK0.emplace_back(fs->make<TH2D>(Form("hXYhitsCK0_layer_%02d", layerList[i]),
0536                                            Form("Gen:HitsCK0 in XY for layer %d", layerList[i]),
0537                                            600,
0538                                            -300.,
0539                                            300.,
0540                                            600,
0541                                            -300.,
0542                                            300.));
0543     hXYhitsB0.emplace_back(fs->make<TH2D>(Form("hXYhitsB0_layer_%02d", layerList[i]),
0544                                           Form("Gen:HitsB0 in XY for layer %d", layerList[i]),
0545                                           600,
0546                                           -300.,
0547                                           300.,
0548                                           600,
0549                                           -300.,
0550                                           300.));
0551     hXYhitsF1.emplace_back(fs->make<TH2D>(Form("hXYhitsF1_layer_%02d", layerList[i]),
0552                                           Form("Gen:HitsF1 in XY for layer %d", layerList[i]),
0553                                           600,
0554                                           -300.,
0555                                           300.,
0556                                           600,
0557                                           -300.,
0558                                           300.));
0559     hXYhitsCN1.emplace_back(fs->make<TH2D>(Form("hXYhitsCN1_layer_%02d", layerList[i]),
0560                                            Form("Gen:HitsCN1 in XY for layer %d", layerList[i]),
0561                                            600,
0562                                            -300.,
0563                                            300.,
0564                                            600,
0565                                            -300.,
0566                                            300.));
0567     hXYhitsCK1.emplace_back(fs->make<TH2D>(Form("hXYhitsCK1_layer_%02d", layerList[i]),
0568                                            Form("Gen:HitsCK1 in XY for layer %d", layerList[i]),
0569                                            600,
0570                                            -300.,
0571                                            300.,
0572                                            600,
0573                                            -300.,
0574                                            300.));
0575     hXYhitsB1.emplace_back(fs->make<TH2D>(Form("hXYhitsB1_layer_%02d", layerList[i]),
0576                                           Form("Gen:HitsB1 in XY for layer %d", layerList[i]),
0577                                           600,
0578                                           -300.,
0579                                           300.,
0580                                           600,
0581                                           -300.,
0582                                           300.));
0583 
0584     hEPhitsF0.emplace_back(fs->make<TH2D>(Form("hEPhitsF0_layer_%02d", layerList[i]),
0585                                           Form("Gen:HitsF0 in EP for layer %d", layerList[i]),
0586                                           640,
0587                                           -3.2,
0588                                           3.2,
0589                                           640,
0590                                           -3.2,
0591                                           3.2));
0592     hEPhitsCN0.emplace_back(fs->make<TH2D>(Form("hEPhitsCN0_layer_%02d", layerList[i]),
0593                                            Form("Gen:HitsCN0 in EP for layer %d", layerList[i]),
0594                                            640,
0595                                            -3.2,
0596                                            3.2,
0597                                            640,
0598                                            -3.2,
0599                                            3.2));
0600     hEPhitsCK0.emplace_back(fs->make<TH2D>(Form("hEPhitsCK0_layer_%02d", layerList[i]),
0601                                            Form("Gen:HitsCK0 in EP for layer %d", layerList[i]),
0602                                            640,
0603                                            -3.2,
0604                                            3.2,
0605                                            640,
0606                                            -3.2,
0607                                            3.2));
0608     hEPhitsB0.emplace_back(fs->make<TH2D>(Form("hEPhitsB0_layer_%02d", layerList[i]),
0609                                           Form("Gen:HitsB0 in EP for layer %d", layerList[i]),
0610                                           640,
0611                                           -3.2,
0612                                           3.2,
0613                                           640,
0614                                           -3.2,
0615                                           3.2));
0616     hEPhitsF1.emplace_back(fs->make<TH2D>(Form("hEPhitsF1_layer_%02d", layerList[i]),
0617                                           Form("Gen:HitsF1 in EP for layer %d", layerList[i]),
0618                                           640,
0619                                           -3.2,
0620                                           3.2,
0621                                           640,
0622                                           -3.2,
0623                                           3.2));
0624     hEPhitsCN1.emplace_back(fs->make<TH2D>(Form("hEPhitsCN1_layer_%02d", layerList[i]),
0625                                            Form("Gen:HitsCN1 in EP for layer %d", layerList[i]),
0626                                            640,
0627                                            -3.2,
0628                                            3.2,
0629                                            640,
0630                                            -3.2,
0631                                            3.2));
0632     hEPhitsCK1.emplace_back(fs->make<TH2D>(Form("hEPhitsCK1_layer_%02d", layerList[i]),
0633                                            Form("Gen:HitsCK1 in EP for layer %d", layerList[i]),
0634                                            640,
0635                                            -3.2,
0636                                            3.2,
0637                                            640,
0638                                            -3.2,
0639                                            3.2));
0640     hEPhitsB1.emplace_back(fs->make<TH2D>(Form("hEPhitsB1_layer_%02d", layerList[i]),
0641                                           Form("Gen:HitsB1 in EP for layer %d", layerList[i]),
0642                                           640,
0643                                           -3.2,
0644                                           3.2,
0645                                           640,
0646                                           -3.2,
0647                                           3.2));
0648 
0649     hXYFailhitsF0.emplace_back(fs->make<TH2D>(Form("hXYFailhitsF0_layer_%02d", layerList[i]),
0650                                               Form("Gen:FailhitsF0 in XY for layer %d", layerList[i]),
0651                                               600,
0652                                               -300.,
0653                                               300.,
0654                                               600,
0655                                               -300.,
0656                                               300.));
0657     hXYFailhitsCN0.emplace_back(fs->make<TH2D>(Form("hXYFailhitsCN0_layer_%02d", layerList[i]),
0658                                                Form("Gen:FailhitsCN0 in XY for layer %d", layerList[i]),
0659                                                600,
0660                                                -300.,
0661                                                300.,
0662                                                600,
0663                                                -300.,
0664                                                300.));
0665     hXYFailhitsCK0.emplace_back(fs->make<TH2D>(Form("hXYFailhitsCK0_layer_%02d", layerList[i]),
0666                                                Form("Gen:FailhitsCK0 in XY for layer %d", layerList[i]),
0667                                                600,
0668                                                -300.,
0669                                                300.,
0670                                                600,
0671                                                -300.,
0672                                                300.));
0673     hXYFailhitsB0.emplace_back(fs->make<TH2D>(Form("hXYFailhitsB0_layer_%02d", layerList[i]),
0674                                               Form("Gen:FailhitsB0 in XY for layer %d", layerList[i]),
0675                                               600,
0676                                               -300.,
0677                                               300.,
0678                                               600,
0679                                               -300.,
0680                                               300.));
0681     hXYFailhitsF1.emplace_back(fs->make<TH2D>(Form("hXYFailhitsF1_layer_%02d", layerList[i]),
0682                                               Form("Gen:FailhitsF1 in XY for layer %d", layerList[i]),
0683                                               600,
0684                                               -300.,
0685                                               300.,
0686                                               600,
0687                                               -300.,
0688                                               300.));
0689     hXYFailhitsCN1.emplace_back(fs->make<TH2D>(Form("hXYFailhitsCN1_layer_%02d", layerList[i]),
0690                                                Form("Gen:FailhitsCN1 in XY for layer %d", layerList[i]),
0691                                                600,
0692                                                -300.,
0693                                                300.,
0694                                                600,
0695                                                -300.,
0696                                                300.));
0697     hXYFailhitsCK1.emplace_back(fs->make<TH2D>(Form("hXYFailhitsCK1_layer_%02d", layerList[i]),
0698                                                Form("Gen:FailhitsCK1 in XY for layer %d", layerList[i]),
0699                                                600,
0700                                                -300.,
0701                                                300.,
0702                                                600,
0703                                                -300.,
0704                                                300.));
0705     hXYFailhitsB1.emplace_back(fs->make<TH2D>(Form("hXYFailhitsB1_layer_%02d", layerList[i]),
0706                                               Form("Gen:FailhitsB1 in XY for layer %d", layerList[i]),
0707                                               600,
0708                                               -300.,
0709                                               300.,
0710                                               600,
0711                                               -300.,
0712                                               300.));
0713 
0714     hEPFailhitsF0.emplace_back(fs->make<TH2D>(Form("hEPFailhitsF0_layer_%02d", layerList[i]),
0715                                               Form("Gen:FailhitsF0 in EP for layer %d", layerList[i]),
0716                                               640,
0717                                               -3.2,
0718                                               3.2,
0719                                               640,
0720                                               -3.2,
0721                                               3.2));
0722     hEPFailhitsCN0.emplace_back(fs->make<TH2D>(Form("hEPFailhitsCN0_layer_%02d", layerList[i]),
0723                                                Form("Gen:FailhitsCN0 in EP for layer %d", layerList[i]),
0724                                                640,
0725                                                -3.2,
0726                                                3.2,
0727                                                640,
0728                                                -3.2,
0729                                                3.2));
0730     hEPFailhitsCK0.emplace_back(fs->make<TH2D>(Form("hEPFailhitsCK0_layer_%02d", layerList[i]),
0731                                                Form("Gen:FailhitsCK0 in EP for layer %d", layerList[i]),
0732                                                640,
0733                                                -3.2,
0734                                                3.2,
0735                                                640,
0736                                                -3.2,
0737                                                3.2));
0738     hEPFailhitsB0.emplace_back(fs->make<TH2D>(Form("hEPFailhitsB0_layer_%02d", layerList[i]),
0739                                               Form("Gen:FailhitsB0 in EP for layer %d", layerList[i]),
0740                                               640,
0741                                               -3.2,
0742                                               3.2,
0743                                               640,
0744                                               -3.2,
0745                                               3.2));
0746     hEPFailhitsF1.emplace_back(fs->make<TH2D>(Form("hEPFailhitsF1_layer_%02d", layerList[i]),
0747                                               Form("Gen:FailhitsF1 in EP for layer %d", layerList[i]),
0748                                               640,
0749                                               -3.2,
0750                                               3.2,
0751                                               640,
0752                                               -3.2,
0753                                               3.2));
0754     hEPFailhitsCN1.emplace_back(fs->make<TH2D>(Form("hEPFailhitsCN1_layer_%02d", layerList[i]),
0755                                                Form("Gen:FailhitsCN1 in EP for layer %d", layerList[i]),
0756                                                640,
0757                                                -3.2,
0758                                                3.2,
0759                                                640,
0760                                                -3.2,
0761                                                3.2));
0762     hEPFailhitsCK1.emplace_back(fs->make<TH2D>(Form("hEPFailhitsCK1_layer_%02d", layerList[i]),
0763                                                Form("Gen:FailhitsCK1 in EP for layer %d", layerList[i]),
0764                                                640,
0765                                                -3.2,
0766                                                3.2,
0767                                                640,
0768                                                -3.2,
0769                                                3.2));
0770     hEPFailhitsB1.emplace_back(fs->make<TH2D>(Form("hEPFailhitsB1_layer_%02d", layerList[i]),
0771                                               Form("Gen:FailhitsB1 in EP for layer %d", layerList[i]),
0772                                               640,
0773                                               -3.2,
0774                                               3.2,
0775                                               640,
0776                                               -3.2,
0777                                               3.2));
0778 
0779     hELossLayerF0.emplace_back(fs->make<TH1D>(Form("hELossLayerF0_layer_%02d", layerList[i]),
0780                                               Form("Gen:ELossF0 in XY for layer %d", layerList[i]),
0781                                               1000,
0782                                               0.,
0783                                               1000.));
0784     hELossLayerCN0.emplace_back(fs->make<TH1D>(Form("hELossLayerCN0_layer_%02d", layerList[i]),
0785                                                Form("Gen:ELossCN0 in XY for layer %d", layerList[i]),
0786                                                1000,
0787                                                0.,
0788                                                1000.));
0789     hELossLayerCK0.emplace_back(fs->make<TH1D>(Form("hELossLayerCK0_layer_%02d", layerList[i]),
0790                                                Form("Gen:ELossCK0 in XY for layer %d", layerList[i]),
0791                                                1000,
0792                                                0.,
0793                                                1000.));
0794     hELossLayerB0.emplace_back(fs->make<TH1D>(Form("hELossLayerB0_layer_%02d", layerList[i]),
0795                                               Form("Gen:ELossB0 in XY for layer %d", layerList[i]),
0796                                               1000,
0797                                               0.,
0798                                               1000.));
0799     hELossLayerF1.emplace_back(fs->make<TH1D>(Form("hELossLayerF1_layer_%02d", layerList[i]),
0800                                               Form("Gen:ELossF1 in XY for layer %d", layerList[i]),
0801                                               1000,
0802                                               0.,
0803                                               1000.));
0804     hELossLayerCN1.emplace_back(fs->make<TH1D>(Form("hELossLayerCN1_layer_%02d", layerList[i]),
0805                                                Form("Gen:ELossCN1 in XY for layer %d", layerList[i]),
0806                                                1000,
0807                                                0.,
0808                                                1000.));
0809     hELossLayerCK1.emplace_back(fs->make<TH1D>(Form("hELossLayerCK1_layer_%02d", layerList[i]),
0810                                                Form("Gen:ELossCK1 in XY for layer %d", layerList[i]),
0811                                                1000,
0812                                                0.,
0813                                                1000.));
0814     hELossLayerB1.emplace_back(fs->make<TH1D>(Form("hELossLayerB1_layer_%02d", layerList[i]),
0815                                               Form("Gen:ELossB1 in XY for layer %d", layerList[i]),
0816                                               1000,
0817                                               0.,
0818                                               1000.));
0819 
0820     hXYhitsLELCN.emplace_back(fs->make<TH2D>(Form("hXYhitsLELCN_layer_%02d", layerList[i]),
0821                                              Form("Gen:LELCN in XY for layer %d", layerList[i]),
0822                                              600,
0823                                              -300.,
0824                                              300.,
0825                                              600,
0826                                              -300.,
0827                                              300.));
0828     hXYhitsHELCN.emplace_back(fs->make<TH2D>(Form("hXYhitsHELCN_layer_%02d", layerList[i]),
0829                                              Form("Gen:HELCN in XY for layer %d", layerList[i]),
0830                                              600,
0831                                              -300.,
0832                                              300.,
0833                                              600,
0834                                              -300.,
0835                                              300.));
0836     hXYhitsLELCK.emplace_back(fs->make<TH2D>(Form("hXYhitsLELCK_layer_%02d", layerList[i]),
0837                                              Form("Gen:LELCK in XY for layer %d", layerList[i]),
0838                                              600,
0839                                              -300.,
0840                                              300.,
0841                                              600,
0842                                              -300.,
0843                                              300.));
0844     hXYhitsHELCK.emplace_back(fs->make<TH2D>(Form("hXYhitsHELCK_layer_%02d", layerList[i]),
0845                                              Form("Gen:HELCK in XY for layer %d", layerList[i]),
0846                                              600,
0847                                              -300.,
0848                                              300.,
0849                                              600,
0850                                              -300.,
0851                                              300.));
0852   }
0853 
0854   for (unsigned int i = 0; i < layerList.size(); i++) {
0855     grXYhitsF0.emplace_back(fs->make<TGraph>(0));
0856     grXYhitsF0[i]->SetNameTitle(Form("grXYhitsF0_layer_%02d", layerList[i]),
0857                                 Form("Gen:HitsF0 in XY for layer %d", layerList[i]));
0858     grXYhitsCN0.emplace_back(fs->make<TGraph>(0));
0859     grXYhitsCN0[i]->SetNameTitle(Form("grXYhitsCN0_layer_%02d", layerList[i]),
0860                                  Form("Gen:HitsCN0 in XY for layer %d", layerList[i]));
0861     grXYhitsCK0.emplace_back(fs->make<TGraph>(0));
0862     grXYhitsCK0[i]->SetNameTitle(Form("grXYhitsCK0_layer_%02d", layerList[i]),
0863                                  Form("Gen:HitsCK0 in XY for layer %d", layerList[i]));
0864     grXYhitsB0.emplace_back(fs->make<TGraph>(0));
0865     grXYhitsB0[i]->SetNameTitle(Form("grXYhitsB0_layer_%02d", layerList[i]),
0866                                 Form("Gen:HitsB0 in XY for layer %d", layerList[i]));
0867     grXYhitsAR0.emplace_back(fs->make<TGraph>(0));
0868     grXYhitsAR0[i]->SetNameTitle(Form("grXYhitsAR0_layer_%02d", layerList[i]),
0869                                  Form("Gen:HitsAR0 in XY for layer %d", layerList[i]));
0870     ixyF0[i] = 0;
0871     ixyCN0[i] = 0;
0872     ixyCK0[i] = 0;
0873     ixyB0[i] = 0;
0874     ixyAR0[i] = 0;
0875 
0876     grXYhitsF1.emplace_back(fs->make<TGraph>(0));
0877     grXYhitsF1[i]->SetNameTitle(Form("grXYhitsF1_layer_%02d", layerList[i]),
0878                                 Form("Gen:HitsF1 in XY for layer %d", layerList[i]));
0879     grXYhitsCN1.emplace_back(fs->make<TGraph>(0));
0880     grXYhitsCN1[i]->SetNameTitle(Form("grXYhitsCN1_layer_%02d", layerList[i]),
0881                                  Form("Gen:HitsCN1 in XY for layer %d", layerList[i]));
0882     grXYhitsCK1.emplace_back(fs->make<TGraph>(0));
0883     grXYhitsCK1[i]->SetNameTitle(Form("grXYhitsCK1_layer_%02d", layerList[i]),
0884                                  Form("Gen:HitsCK1 in XY for layer %d", layerList[i]));
0885     grXYhitsB1.emplace_back(fs->make<TGraph>(0));
0886     grXYhitsB1[i]->SetNameTitle(Form("grXYhitsB1_layer_%02d", layerList[i]),
0887                                 Form("Gen:HitsB1 in XY for layer %d", layerList[i]));
0888     grXYhitsAR1.emplace_back(fs->make<TGraph>(0));
0889     grXYhitsAR1[i]->SetNameTitle(Form("grXYhitsAR1_layer_%02d", layerList[i]),
0890                                  Form("Gen:HitsAR1 in XY for layer %d", layerList[i]));
0891     ixyF1[i] = 0;
0892     ixyCN1[i] = 0;
0893     ixyCK1[i] = 0;
0894     ixyB1[i] = 0;
0895     ixyAR1[i] = 0;
0896 
0897     grEtaPhihitsF0.emplace_back(fs->make<TGraph>(0));
0898     grEtaPhihitsF0[i]->SetNameTitle(Form("grEtaPhihitsF0_layer_%02d", layerList[i]),
0899                                     Form("Gen:HitsF0 in XY for layer %d", layerList[i]));
0900     grEtaPhihitsCN0.emplace_back(fs->make<TGraph>(0));
0901     grEtaPhihitsCN0[i]->SetNameTitle(Form("grEtaPhihitsCN0_layer_%02d", layerList[i]),
0902                                      Form("Gen:HitsCN0 in XY for layer %d", layerList[i]));
0903     grEtaPhihitsCK0.emplace_back(fs->make<TGraph>(0));
0904     grEtaPhihitsCK0[i]->SetNameTitle(Form("grEtaPhihitsCK0_layer_%02d", layerList[i]),
0905                                      Form("Gen:HitsCK0 in XY for layer %d", layerList[i]));
0906     grEtaPhihitsB0.emplace_back(fs->make<TGraph>(0));
0907     grEtaPhihitsB0[i]->SetNameTitle(Form("grEtaPhihitsB0_layer_%02d", layerList[i]),
0908                                     Form("Gen:HitsB0 in XY for layer %d", layerList[i]));
0909     iepF0[i] = 0;
0910     iepCN0[i] = 0;
0911     iepCK0[i] = 0;
0912     iepB0[i] = 0;
0913 
0914     grEtaPhihitsF1.emplace_back(fs->make<TGraph>(0));
0915     grEtaPhihitsF1[i]->SetNameTitle(Form("grEtaPhihitsF1_layer_%02d", layerList[i]),
0916                                     Form("Gen:HitsF1 in XY for layer %d", layerList[i]));
0917     grEtaPhihitsCN1.emplace_back(fs->make<TGraph>(0));
0918     grEtaPhihitsCN1[i]->SetNameTitle(Form("grEtaPhihitsCN1_layer_%02d", layerList[i]),
0919                                      Form("Gen:HitsCN1 in XY for layer %d", layerList[i]));
0920     grEtaPhihitsCK1.emplace_back(fs->make<TGraph>(0));
0921     grEtaPhihitsCK1[i]->SetNameTitle(Form("grEtaPhihitsCK1_layer_%02d", layerList[i]),
0922                                      Form("Gen:HitsCK1 in XY for layer %d", layerList[i]));
0923     grEtaPhihitsB1.emplace_back(fs->make<TGraph>(0));
0924     grEtaPhihitsB1[i]->SetNameTitle(Form("grEtaPhihitsB1_layer_%02d", layerList[i]),
0925                                     Form("Gen:HitsB1 in XY for layer %d", layerList[i]));
0926     iepF1[i] = 0;
0927     iepCN1[i] = 0;
0928     iepCK1[i] = 0;
0929     iepB1[i] = 0;
0930   }
0931   for (unsigned int i = 0; i < layerList.size(); i++) {
0932     hNHxXYhitsF.emplace_back(fs->make<TH2D>(Form("hNHxXYhitsF_layer_%02d", layerList[i]),
0933                                             Form("NHx HitsF in XY for layer %d", layerList[i]),
0934                                             600,
0935                                             -300.,
0936                                             300.,
0937                                             600,
0938                                             -300.,
0939                                             300.));
0940     hNHxXYhitsCN.emplace_back(fs->make<TH2D>(Form("hNHxXYhitsCN_layer_%02d", layerList[i]),
0941                                              Form("NHx HitsCN in XY for layer %d", layerList[i]),
0942                                              600,
0943                                              -300.,
0944                                              300.,
0945                                              600,
0946                                              -300.,
0947                                              300.));
0948     hNHxXYhitsCK.emplace_back(fs->make<TH2D>(Form("hNHxXYhitsCK_layer_%02d", layerList[i]),
0949                                              Form("NHx HitsCK in XY for layer %d", layerList[i]),
0950                                              600,
0951                                              -300.,
0952                                              300.,
0953                                              600,
0954                                              -300.,
0955                                              300.));
0956   }
0957   hXYmissedhits = fs->make<TH2D>("hXYmissedhits", "hXYmissedhits", 600, -300., 300., 600, -300., 300.);
0958   hXYLowELosshitsF = fs->make<TH2D>("hXYLowELosshitsF", "hXYLowELosshitsF", 600, -300., 300., 600, -300., 300.);
0959   hXYLowELosshitsCN = fs->make<TH2D>("hXYLowELosshitsCN", "hXYLowELosshitsCN", 600, -300., 300., 600, -300., 300.);
0960   hXYLowELosshitsCK = fs->make<TH2D>("hXYLowELosshitsCK", "hXYLowELosshitsCK", 600, -300., 300., 600, -300., 300.);
0961 
0962   hYZmissedhits = fs->make<TH2D>("hYZmissedhits", "hYZmissedhits", 250, 300., 550., 300, 0., 300.);
0963   hYZLowELosshitsF = fs->make<TH2D>("hYZLowELosshitsF", "hYZLowELosshitsF", 250, 300., 550., 300, 0., 300.);
0964   hYZLowELosshitsCN = fs->make<TH2D>("hYZLowELosshitsCN", "hYZLowELosshitsCN", 250, 300., 550., 300, 0., 300.);
0965   hYZLowELosshitsCK = fs->make<TH2D>("hYZLowELosshitsCK", "hYZLowELosshitsCK", 250, 300., 550., 300, 0., 300.);
0966   hYZLLowELosshitsHEFCN =
0967       fs->make<TH2D>("hYZLLowELosshitsHEFCN", "hYZLLowELosshitsHEFCN", 600, -50., 550., 350, -50., 300.);
0968 
0969   hXLowELosshitsHEFCN = fs->make<TH1D>("hXLowELosshitsHEFCN", "hXLowELosshitsHEFCN", 600, -300., 300.);
0970   hYLowELosshitsHEFCN = fs->make<TH1D>("hYLowELosshitsHEFCN", "hYLowELosshitsHEFCN", 600, -300., 300.);
0971   hZLowELosshitsHEFCN = fs->make<TH1D>("hZLowELosshitsHEFCN", "hZLowELosshitsHEFCN", 2400, -1200., 1200.);
0972 
0973   hYZhitsEE = fs->make<TH2D>("hYZhitsEE", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0974   hYZhitsHEF = fs->make<TH2D>("hYZhitsHEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0975   hYZhitsHEB = fs->make<TH2D>("hYZhitsHEB", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0976 
0977   hYZhitsEEF = fs->make<TH2D>("hYZhitsEEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0978   hYZhitsEECN = fs->make<TH2D>("hYZhitsEECN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0979   hYZhitsEECK = fs->make<TH2D>("hYZhitsEECK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0980 
0981   hYZhitsHEFF = fs->make<TH2D>("hYZhitsHEFF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0982   hYZhitsHEFCN = fs->make<TH2D>("hYZhitsHEFCN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0983   hYZhitsHEFCK = fs->make<TH2D>("hYZhitsHEFCK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0984 
0985   hRHTXYhits = fs->make<TH2D>("hRHTXYhits", "Hits in XY", 600, -300., 300., 600, -300., 300.);
0986   hRHTYZhitsEE = fs->make<TH2D>("hRHTYZhitsEE", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0987   hRHTYZhitsHEF = fs->make<TH2D>("hRHTYZhitsHEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0988   hRHTYZhitsHEB = fs->make<TH2D>("hRHTYZhitsHEB", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0989   hRHTYZhitsEEF = fs->make<TH2D>("hRHTYZhitsEEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0990   hRHTYZhitsEECN = fs->make<TH2D>("hRHTYZhitsEECN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0991   hRHTYZhitsEECK = fs->make<TH2D>("hRHTYZhitsEECK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0992   hRHTYZhitsHEFF = fs->make<TH2D>("hRHTYZhitsHEFF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0993   hRHTYZhitsHEFCN =
0994       fs->make<TH2D>("hRHTYZhitsHEFCN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0995   hRHTYZhitsHEFCK =
0996       fs->make<TH2D>("hRHTYZhitsHEFCK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0997 
0998   hRHTRZhitsEE =
0999       fs->make<TH2D>("hRHTRZhitsEE", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1000   hRHTRZhitsHEF =
1001       fs->make<TH2D>("hRHTRZhitsHEF", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1002   hRHTRZhitsHEB =
1003       fs->make<TH2D>("hRHTRZhitsHEB", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1004   hRHTRZhitsEEF =
1005       fs->make<TH2D>("hRHTRZhitsEEF", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1006   hRHTRZhitsEECN =
1007       fs->make<TH2D>("hRHTRZhitsEECN", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1008   hRHTRZhitsEECK =
1009       fs->make<TH2D>("hRHTRZhitsEECK", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1010   hRHTRZhitsHEFF =
1011       fs->make<TH2D>("hRHTRZhitsHEFF", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1012   hRHTRZhitsHEFCN =
1013       fs->make<TH2D>("hRHTRZhitsHEFCN", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1014   hRHTRZhitsHEFCK =
1015       fs->make<TH2D>("hRHTRZhitsHEFCK", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
1016 
1017   hRHTGlbRZhitsF = fs->make<TH2D>("hRHTGlbRZhitsF", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
1018   hRHTGlbRZhitsCN = fs->make<TH2D>("hRHTGlbRZhitsCN", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
1019   hRHTGlbRZhitsCK = fs->make<TH2D>("hRHTGlbRZhitsCK", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
1020   hRHTGlbRZhitsSci = fs->make<TH2D>("hRHTGlbRZhitsSci", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
1021 
1022   hDiffX = fs->make<TH1D>("hDiffX", "Difference of x-position (testHGCalGeometry - RecHitTools)", 200, -20, 20);
1023   hDiffX->GetXaxis()->SetTitle("x-axis (cm)");
1024   hDiffY = fs->make<TH1D>("hDiffY", "Difference of y-position (testHGCalGeometry - RecHitTools)", 200, -20, 20);
1025   hDiffY->GetXaxis()->SetTitle("y-axis (cm)");
1026   hDiffZ = fs->make<TH1D>("hDiffZ", "Difference of z-position (testHGCalGeometry - RecHitTools)", 200, -20, 20);
1027   hDiffZ->GetXaxis()->SetTitle("z-axis (cm)");
1028 
1029   hCellThickness = fs->make<TH1D>("hCellThickness", "Cell Thickness", 500, 0, 500);
1030   hDiffZ->GetXaxis()->SetTitle("thickness (#mum)");
1031 
1032   evt = 0;
1033   winfo.clear();
1034 }
1035 
1036 //
1037 // member functions
1038 //
1039 
1040 // ------------ method called for each event  ------------
1041 void HGCalCellHitSum::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
1042   //================================================================================================================
1043   //In case of first event read the csv file prepared from sensor/scintillator layout file (aka flatfile)
1044   //================================================================================================================
1045   if (evt == 0) {
1046     std::string fileName = geometryFileName_.fullPath();
1047     std::ifstream fin(fileName);
1048 
1049     //v15 format : layer, u, v, type ; where type = 0 (partial wafer) and 1 (full wafer)
1050     //v16 format : index, layer, u, v, prop, thickness, cuttype, orientation ; where cuttype = "full" for full wafers and all others are partial wafers
1051     //v17 format : index, layer, u, v, prop, thickness, cuttype, orientation, cassette ; where cuttype = "full" for full wafers and all others are partial wafers
1052     int hgcal_geom_version = 17;
1053     if (fileName.find("v15.csv") != std::string::npos)
1054       hgcal_geom_version = 15;
1055     else if (fileName.find("v16.csv") != std::string::npos)
1056       hgcal_geom_version = 16;
1057     else if (fileName.find("v17.csv") != std::string::npos)
1058       hgcal_geom_version = 17;
1059 
1060     std::string s;
1061     waferinfo wafer;
1062     std::string wcuttype;
1063     std::vector<std::string> tokens;
1064     while (std::getline(fin, s)) {
1065       //std::cout << "line " << s.data() << std::endl;
1066       if (hgcal_geom_version == 15) {
1067         sscanf(s.c_str(), "%d,%d,%d,%d", &wafer.layer, &wafer.u, &wafer.v, &wafer.type);
1068       } else if (hgcal_geom_version == 16 or hgcal_geom_version == 17) {
1069         tokens.clear();
1070         std::stringstream check1(s);
1071         std::string intermediate;
1072         while (getline(check1, intermediate, ','))
1073           tokens.push_back(intermediate);
1074 
1075         //Useful variables
1076         wafer.layer = stoi(tokens[1]);
1077         wafer.u = stoi(tokens[2]);
1078         wafer.v = stoi(tokens[3]);
1079         wcuttype = tokens[6];
1080 
1081         //Additional variables
1082         //===============================================
1083         // int windex            = stoi(tokens[0]);
1084         // int wprop             = stoi(tokens[4]);
1085         // std::string wthickness    = tokens[5];
1086         // int worient           = stoi(tokens[7]);
1087         // if(hgcal_geom_version==17)
1088         //   int wcassette   = stoi(tokens[8]);
1089         //===============================================
1090 
1091         //std::cout<<"wcuttype : " << wcuttype << std::endl;
1092         wafer.type = (wcuttype.find("full") != std::string::npos) ? 1 : 0;
1093       }
1094       //printf("%d | %d | %d | %d\n",wafer.layer,wafer.u,wafer.v,wafer.type);
1095       winfo.push_back(wafer);
1096     }
1097     fin.close();
1098   }
1099   evt++;
1100   //================================================================================================================
1101 
1102   //================================================================================================================
1103   // Read the gen track information
1104   //================================================================================================================
1105   const edm::Handle<edm::SimTrackContainer> &simtrack = iEvent.getHandle(tSimTrackContainer);
1106   edm::SimTrackContainer::const_iterator itTrack;
1107   for (itTrack = simtrack->begin(); itTrack != simtrack->end(); ++itTrack) {
1108     int charge = itTrack->charge();
1109     hCharge->Fill(charge);
1110     if (!itTrack->noGenpart()) {  //negation of negation, yes, thats how we access the primary parent particles ;-)
1111       hPt->Fill(itTrack->momentum().pt());
1112       hEta->Fill(itTrack->momentum().eta());
1113       hPhi->Fill(itTrack->momentum().phi());
1114     }
1115     hPDG->Fill(itTrack->type());
1116 
1117     if (itTrack->noGenpart())  //secondary particles
1118       hPtNoGen->Fill(itTrack->momentum().pt());
1119   }
1120   //================================================================================================================
1121 
1122   //================================================================================================================
1123   // Two ways to access the geometry object
1124   //================================================================================================================
1125   // Method 1
1126   const CaloGeometry &geomCalo = iSetup.getData(caloGeomToken_);
1127   rhtools_.setGeometry(geomCalo);
1128 
1129   // Method 2
1130   const HGCalGeometry *geom = &iSetup.getData(geomToken_);
1131   //================================================================================================================
1132 
1133   //================================================================================================================
1134   // This is loop over all calo hits
1135   //================================================================================================================
1136   std::map<uint32_t, std::pair<hitsinfo, energysum> > map_hits;
1137   map_hits.clear();
1138   unsigned int nofSiHits = 0;
1139   const edm::Handle<edm::PCaloHitContainer> &simhit = iEvent.getHandle(tSimCaloHitContainer);
1140   for (edm::PCaloHitContainer::const_iterator itHit = simhit->begin(); itHit != simhit->end(); ++itHit) {
1141     //==============================================================================================================
1142     // Fill the Eloss per hit basis separately for EE and HE silicons and finally for scintillators
1143     //==============================================================================================================
1144     if ((name_ == "HGCalEESensitive") || (name_ == "HGCalHESiliconSensitive")) {
1145       HGCSiliconDetId id(itHit->id());
1146       if (name_ == "HGCalEESensitive") {
1147         hELossEE->Fill(convertGeVToKeV(itHit->energy()));
1148         if (id.type() == HGCSiliconDetId::HGCalHD120)
1149           hELossEEF->Fill(convertGeVToKeV(itHit->energy()));  //in keV
1150         if (id.type() == HGCSiliconDetId::HGCalLD200)
1151           hELossEECN->Fill(convertGeVToKeV(itHit->energy()));  //in keV
1152         if (id.type() == HGCSiliconDetId::HGCalLD300)
1153           hELossEECK->Fill(convertGeVToKeV(itHit->energy()));  //in keV
1154       }
1155 
1156       if (name_ == "HGCalHESiliconSensitive") {
1157         hELossHEF->Fill(convertGeVToKeV(itHit->energy()));
1158         if (id.type() == HGCSiliconDetId::HGCalHD120)
1159           hELossHEFF->Fill(convertGeVToKeV(itHit->energy()));  //in keV
1160         if (id.type() == HGCSiliconDetId::HGCalLD200)
1161           hELossHEFCN->Fill(convertGeVToKeV(itHit->energy()));  //in keV
1162         if (id.type() == HGCSiliconDetId::HGCalLD300)
1163           hELossHEFCK->Fill(convertGeVToKeV(itHit->energy()));  //in keV
1164       }
1165     }
1166 
1167     if (name_ == "HGCalHEScintillatorSensitive")
1168       hELossHEB->Fill(convertGeVToKeV(itHit->energy()));
1169     //==============================================================================================================
1170 
1171     //==============================================================================================================
1172     // Fill the thickness dependent R-Z and eta-phi inclusive histograms using the geometry object accessed via Method 1
1173     //==============================================================================================================
1174     DetId id1 = static_cast<DetId>(itHit->id());
1175     GlobalPoint global1 = rhtools_.getPosition(id1);
1176     double RXY = TMath::Sqrt(global1.x() * global1.x() + global1.y() * global1.y());
1177 
1178     // std::cout << "DetId (" << det << ": position ("<< global1.x() << ", " << global1.y() << ", " << global1.z()
1179     //        << "), Si thickness "<< rhtools_.getSiThickness(id1)
1180     //        << ", IsSi "<< rhtools_.isSilicon(id1)
1181     //        << ", IsSci "<< rhtools_.isScintillator(id1)
1182     //        << ", Layer1 "<< rhtools_.getLayer(id1)
1183     //        << ", Layer2 "<< rhtools_.getLayerWithOffset(id1)
1184     //        << ", lastLayerEE  "<< rhtools_.lastLayerEE()
1185     //        << ", lastLayerFH  "<< rhtools_.lastLayerFH()
1186     //        << ", firstLayerBH  "<< rhtools_.firstLayerBH()
1187     //        << ", lastLayerBH  "<< rhtools_.lastLayerBH()
1188     //        << ", lastLayer  "<< rhtools_.lastLayer()
1189     //        << std::endl;
1190 
1191     if ((rhtools_.isSilicon(id1)) || (rhtools_.isScintillator(id1))) {
1192       if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 120., 1.e-7))
1193         hRHTGlbRZhitsF->Fill(TMath::Abs(global1.z()), RXY);
1194       else if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 200., 1.e-7))
1195         hRHTGlbRZhitsCN->Fill(TMath::Abs(global1.z()), RXY);
1196       else if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 300., 1.e-7))
1197         hRHTGlbRZhitsCK->Fill(TMath::Abs(global1.z()), RXY);
1198       else
1199         hRHTGlbRZhitsSci->Fill(TMath::Abs(global1.z()), RXY);
1200     }
1201     hEtaCell->Fill(rhtools_.getEta(id1));
1202     hPhiCell->Fill(rhtools_.getPhi(id1));
1203     //==============================================================================================================
1204 
1205     //==============================================================================================================
1206     // Core loop of summing hits for a given cell
1207     //==============================================================================================================
1208     ///////////////////////////////////////////////////////////////////////////////////////////////
1209     if ((rhtools_.isSilicon(id1)) || (rhtools_.isScintillator(id1))) {
1210       uint32_t id_ = itHit->id();
1211 
1212       energysum esum;
1213       hitsinfo hinfo;
1214 
1215       if (map_hits.count(id_) != 0) {
1216         hinfo = map_hits[id_].first;
1217         esum = map_hits[id_].second;
1218       } else {
1219         hinfo.hitid = nofSiHits;
1220         hinfo.x = global1.x();
1221         hinfo.y = global1.y();
1222         hinfo.z = global1.z();
1223         hinfo.layer = rhtools_.getLayerWithOffset(id1);
1224         hinfo.phi = rhtools_.getPhi(id1);
1225         hinfo.eta = rhtools_.getEta(id1);
1226         for (itTrack = simtrack->begin(); itTrack != simtrack->end(); ++itTrack) {
1227           if (itTrack->trackId() == UInt_t(itHit->geantTrackId())) {
1228             hinfo.trkpt = itTrack->momentum().pt();
1229             hinfo.trketa = itTrack->momentum().eta();
1230             hinfo.trkphi = itTrack->momentum().phi();
1231             hinfo.charge = itTrack->charge();
1232             hinfo.pdg = itTrack->type();
1233           }
1234         }
1235       }
1236       esum.etotal += itHit->energy();
1237       hinfo.nhits++;
1238 
1239       HepGeom::Point3D<float> gcoord = HepGeom::Point3D<float>(global1.x(), global1.y(), global1.z());
1240       // The timing information of following lines needs to be modified when new timing standard is filled according to https://indico.cern.ch/event/1210093/ (See slides of Andre)
1241       double tof = (gcoord.mag() * CLHEP::cm) / CLHEP::c_light;
1242       double time = itHit->time();
1243       time -= tof;
1244 
1245       for (unsigned int k = 0; k < 2; ++k) {
1246         if (time > 0 && time < 25.)
1247           esum.eTime[k] += itHit->energy();
1248         else {
1249           esum.eTime[k + 2] += itHit->energy();
1250         }
1251       }
1252 
1253       map_hits[id_] = std::pair<hitsinfo, energysum>(hinfo, esum);
1254       nofSiHits++;
1255     }
1256     ///////////////////////////////////////////////////////////////////////////////////////////////
1257     //==============================================================================================================
1258 
1259     //==============================================================================================================
1260     // Fill the histograms using the geometry object accessed via Method 2
1261     //==============================================================================================================
1262 
1263     GlobalPoint global2 = geom->getPosition(id1);
1264     if (geom->topology().valid(id1)) {
1265       //std::cout << "DetId (" << det << ": position ("<< global2.x() << ", " << global2.y() << ", " << global2.z() << ") " << std::endl;
1266       //hYZhits->Fill(global2.z(),global2.y());
1267       if (TMath::Abs(global2.x()) < 20.0) {
1268         if ((name_ == "HGCalEESensitive") || (name_ == "HGCalHESiliconSensitive")) {
1269           HGCSiliconDetId id(itHit->id());
1270 
1271           if (name_ == "HGCalEESensitive") {
1272             hYZhitsEE->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1273             if (id.type() == HGCSiliconDetId::HGCalHD120)
1274               hYZhitsEEF->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1275             if (id.type() == HGCSiliconDetId::HGCalLD200)
1276               hYZhitsEECN->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1277             if (id.type() == HGCSiliconDetId::HGCalLD300)
1278               hYZhitsEECK->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1279           }
1280 
1281           if (name_ == "HGCalHESiliconSensitive") {
1282             hYZhitsHEF->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1283             if (id.type() == HGCSiliconDetId::HGCalHD120)
1284               hYZhitsHEFF->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1285             if (id.type() == HGCSiliconDetId::HGCalLD200)
1286               hYZhitsHEFCN->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1287             if (id.type() == HGCSiliconDetId::HGCalLD300)
1288               hYZhitsHEFCK->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1289           }
1290         }
1291 
1292         if (name_ == "HGCalHEScintillatorSensitive")
1293           hYZhitsHEB->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
1294       }
1295       //==============================================================================================================
1296 
1297       //==============================================================================================================
1298       // Fill the Silicon thickness dependent R-Z histograms for selection region using the geometry object accessed via Method 1
1299       //==============================================================================================================
1300 
1301       if (TMath::Abs(global1.x()) < 20.0) {
1302         if (rhtools_.isSilicon(id1)) {
1303           if (rhtools_.getLayerWithOffset(id1) <= rhtools_.lastLayerEE()) {
1304             hRHTYZhitsEE->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1305             hRHTRZhitsEE->Fill(TMath::Abs(global1.z()), RXY);
1306 
1307             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 120., 1.e-7)) {
1308               hRHTYZhitsEEF->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1309               hRHTRZhitsEEF->Fill(TMath::Abs(global1.z()), RXY);
1310             }
1311             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 200., 1.e-7)) {
1312               hRHTYZhitsEECN->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1313               hRHTRZhitsEECN->Fill(TMath::Abs(global1.z()), RXY);
1314             }
1315             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 300., 1.e-7)) {
1316               hRHTYZhitsEECK->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1317               hRHTRZhitsEECK->Fill(TMath::Abs(global1.z()), RXY);
1318             }
1319 
1320           } else {
1321             hRHTYZhitsHEF->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1322             hRHTRZhitsHEF->Fill(TMath::Abs(global1.z()), RXY);
1323 
1324             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 120., 1.e-7)) {
1325               hRHTYZhitsHEFF->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1326               hRHTRZhitsHEFF->Fill(TMath::Abs(global1.z()), RXY);
1327             }
1328             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 200., 1.e-7)) {
1329               hRHTYZhitsHEFCN->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1330               hRHTRZhitsHEFCN->Fill(TMath::Abs(global1.z()), RXY);
1331             }
1332             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 300., 1.e-7)) {
1333               hRHTYZhitsHEFCK->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1334               hRHTRZhitsHEFCK->Fill(TMath::Abs(global1.z()), RXY);
1335             }
1336           }
1337 
1338         }  //is Si
1339 
1340         if (rhtools_.isScintillator(id1)) {
1341           hRHTYZhitsHEB->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
1342           hRHTRZhitsHEB->Fill(TMath::Abs(global1.z()), RXY);
1343         }
1344       }
1345       hRHTXYhits->Fill(global1.x(), global1.y());
1346       //==============================================================================================================
1347 
1348       //==============================================================================================================
1349       // Fill the Silicon thickness dependent XY histograms using the geometry object accessed via Method 1
1350       //==============================================================================================================
1351       std::vector<int>::iterator ilyr = std::find(layerList.begin(), layerList.end(), rhtools_.getLayerWithOffset(id1));
1352       if (ilyr != layerList.cend()) {
1353         int il = std::distance(layerList.begin(), ilyr);
1354 
1355         hXYhits[il]->Fill(global1.x(), global1.y());
1356         if (rhtools_.isSilicon(id1)) {
1357           HGCSiliconDetId id(itHit->id());
1358           HGCalDetId hid(itHit->id());
1359 
1360           if (id.type() == HGCSiliconDetId::HGCalHD120) {
1361             if (global1.z() < 0.0) {
1362               grXYhitsF0[il]->SetPoint(ixyF0[il]++, global1.x(), global1.y());
1363               grEtaPhihitsF0[il]->SetPoint(iepF0[il]++, global1.eta(), global1.phi());
1364             } else {
1365               grXYhitsF1[il]->SetPoint(ixyF1[il]++, global1.x(), global1.y());
1366               grEtaPhihitsF1[il]->SetPoint(iepF1[il]++, global1.eta(), global1.phi());
1367             }
1368           }
1369           if (id.type() == HGCSiliconDetId::HGCalLD200) {
1370             if (global1.z() < 0.0) {
1371               grXYhitsCN0[il]->SetPoint(ixyCN0[il]++, global1.x(), global1.y());
1372               grEtaPhihitsCN0[il]->SetPoint(iepCN0[il]++, global1.eta(), global1.phi());
1373             } else {
1374               grXYhitsCN1[il]->SetPoint(ixyCN1[il]++, global1.x(), global1.y());
1375               grEtaPhihitsCN1[il]->SetPoint(iepCN1[il]++, global1.eta(), global1.phi());
1376             }
1377           }
1378           if (id.type() == HGCSiliconDetId::HGCalLD300) {  //case 2 :
1379 
1380             if (global1.z() < 0.0) {
1381               grXYhitsCK0[il]->SetPoint(ixyCK0[il]++, global1.x(), global1.y());
1382               grEtaPhihitsCK0[il]->SetPoint(iepCK0[il]++, global1.eta(), global1.phi());
1383             } else {
1384               grXYhitsCK1[il]->SetPoint(ixyCK1[il]++, global1.x(), global1.y());
1385               grEtaPhihitsCK1[il]->SetPoint(iepCK1[il]++, global1.eta(), global1.phi());
1386             }
1387           }
1388           //The following line by Pruthvi to number the cells with id0 and id1
1389           if (rhtools_.getCell(id1).first + rhtools_.getCell(id1).second <= 2) {
1390             if (global1.z() < 0.0)
1391               grXYhitsAR0[il]->SetPoint(ixyAR0[il]++, global1.x(), global1.y());
1392             else
1393               grXYhitsAR1[il]->SetPoint(ixyAR1[il]++, global1.x(), global1.y());
1394           }
1395         } else if (rhtools_.isScintillator(id1)) {
1396           //HGCScintillatorDetId id(itHit->id());
1397           //int il = rhtools_.getLayerWithOffset(id1);
1398 
1399           if (global1.z() < 0.0) {
1400             grXYhitsB0[il]->SetPoint(ixyB0[il]++, global1.x(), global1.y());
1401             grEtaPhihitsB0[il]->SetPoint(iepB0[il]++, global1.eta(), global1.phi());
1402           } else {
1403             grXYhitsB1[il]->SetPoint(ixyB1[il]++, global1.x(), global1.y());
1404             grEtaPhihitsB1[il]->SetPoint(iepB1[il]++, global1.eta(), global1.phi());
1405           }
1406 
1407         }  //is Sci or Si
1408 
1409       }  //valid il array index distance
1410       //==============================================================================================================
1411     }  //Valid detid using topology function
1412 
1413     //==============================================================================================================
1414     // Is there any difference when geometry object is accessed via Method 1 or Method 2 ?
1415     //==============================================================================================================
1416     hDiffX->Fill(global2.x() - global1.x());
1417     hDiffY->Fill(global2.y() - global1.y());
1418     hDiffZ->Fill(global2.z() - global1.z());
1419     //==============================================================================================================
1420   }  // End of Calo hit loop
1421   //std::cout << "simhit size : " << simhit->size() << ", nof hits in Si : " << nofSiHits << ", map size : " << map_hits.size() << std::endl;
1422   //================================================================================================================
1423 
1424   //================================================================================================================
1425   // This loop to check for eloss per cell basis
1426   //================================================================================================================
1427   std::map<uint32_t, std::pair<hitsinfo, energysum> >::iterator itr;
1428   for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
1429     //uint32_t id_ = (*itr).first;
1430     hitsinfo hinfo = (*itr).second.first;
1431     energysum esum = (*itr).second.second;
1432     std::vector<int>::iterator ilyr = std::find(layerList.begin(), layerList.end(), hinfo.layer);
1433     if (ilyr != layerList.cend()) {
1434       int il = std::distance(layerList.begin(), ilyr);
1435       hELossDQMEqV[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1436     }
1437 
1438     // printf("\tCellSummed : Det : %s, first hit : %d, nhits : %u, id : %u, Edep : %5.2lf (keV), (x,y,z) : (%5.2lf,%5.2lf,%5.2lf)\n",
1439     //         name_.c_str(), hinfo.hitid, hinfo.nhits, (*itr).first, convertGeVToKeV(esum.eTime[0]), hinfo.x, hinfo.y, hinfo.z);
1440 
1441     HGCSiliconDetId id((*itr).first);
1442 
1443     DetId id1 = static_cast<DetId>((*itr).first);
1444     GlobalPoint global1 = geom->getPosition(id1);
1445 
1446     ilyr = std::find(layerList.begin(), layerList.end(), rhtools_.getLayerWithOffset(id1));
1447     if (ilyr != layerList.cend()) {
1448       int il = std::distance(layerList.begin(), ilyr);
1449 
1450       if (geom->topology().valid(id1)) {
1451         if (rhtools_.isSilicon(id1)) {
1452           HGCSiliconDetId id((*itr).first);
1453           //int il = rhtools_.getLayerWithOffset(id1);
1454           if (id.type() == HGCSiliconDetId::HGCalHD120) {
1455             if (global1.z() < 0.0) {
1456               hXYhitsF0[il]->Fill(global1.x(), global1.y());
1457               hEPhitsF0[il]->Fill(global1.eta(), global1.phi());
1458               hELossLayerF0[il]->Fill(esum.etotal * 1.0e6);
1459             } else {
1460               hXYhitsF1[il]->Fill(global1.x(), global1.y());
1461               hEPhitsF1[il]->Fill(global1.eta(), global1.phi());
1462               hELossLayerF1[il]->Fill(esum.etotal * 1.0e6);
1463             }
1464           }
1465           if (id.type() == HGCSiliconDetId::HGCalLD200) {
1466             if (global1.z() < 0.0) {
1467               hXYhitsCN0[il]->Fill(global1.x(), global1.y());
1468               hEPhitsCN0[il]->Fill(global1.eta(), global1.phi());
1469               hELossLayerCN0[il]->Fill(esum.etotal * 1.0e6);
1470             } else {
1471               hXYhitsCN1[il]->Fill(global1.x(), global1.y());
1472               hEPhitsCN1[il]->Fill(global1.eta(), global1.phi());
1473               hELossLayerCN1[il]->Fill(esum.etotal * 1.0e6);
1474             }
1475           }
1476           if (id.type() == HGCSiliconDetId::HGCalLD300) {  //case 2 :
1477 
1478             if (global1.z() < 0.0) {
1479               hXYhitsCK0[il]->Fill(global1.x(), global1.y());
1480               hEPhitsCK0[il]->Fill(global1.eta(), global1.phi());
1481               hELossLayerCK0[il]->Fill(esum.etotal * 1.0e6);
1482             } else {
1483               hXYhitsCK1[il]->Fill(global1.x(), global1.y());
1484               hEPhitsCK1[il]->Fill(global1.eta(), global1.phi());
1485               hELossLayerCK1[il]->Fill(esum.etotal * 1.0e6);
1486             }
1487           }
1488         } else if (rhtools_.isScintillator(id1)) {
1489           //HGCScintillatorDetId id(itHit->id());
1490           //int il = rhtools_.getLayerWithOffset(id1);
1491           if (global1.z() < 0.0) {
1492             hXYhitsB0[il]->Fill(global1.x(), global1.y());
1493             hEPhitsB0[il]->Fill(global1.eta(), global1.phi());
1494             hELossLayerB0[il]->Fill(esum.etotal * 1.0e6);
1495           } else {
1496             hXYhitsB1[il]->Fill(global1.x(), global1.y());
1497             hEPhitsB1[il]->Fill(global1.eta(), global1.phi());
1498             hELossLayerB1[il]->Fill(esum.etotal * 1.0e6);
1499           }
1500 
1501         }  //is Sci or Si
1502       }  //valid detid
1503       //Now for invalid detids
1504       else {
1505         if (rhtools_.isSilicon(id1)) {
1506           HGCSiliconDetId id((*itr).first);
1507           //int il = rhtools_.getLayerWithOffset(id1);
1508           if (id.type() == HGCSiliconDetId::HGCalHD120) {
1509             if (global1.z() < 0.0) {
1510               hXYFailhitsF0[il]->Fill(global1.x(), global1.y());
1511               hEPFailhitsF0[il]->Fill(global1.eta(), global1.phi());
1512             } else {
1513               hXYFailhitsF1[il]->Fill(global1.x(), global1.y());
1514               hEPFailhitsF1[il]->Fill(global1.eta(), global1.phi());
1515             }
1516           }
1517           if (id.type() == HGCSiliconDetId::HGCalLD200) {
1518             if (global1.z() < 0.0) {
1519               hXYFailhitsCN0[il]->Fill(global1.x(), global1.y());
1520               hEPFailhitsCN0[il]->Fill(global1.eta(), global1.phi());
1521             } else {
1522               hXYFailhitsCN1[il]->Fill(global1.x(), global1.y());
1523               hEPFailhitsCN1[il]->Fill(global1.eta(), global1.phi());
1524             }
1525           }
1526           if (id.type() == HGCSiliconDetId::HGCalLD300) {  //case 2 :
1527 
1528             if (global1.z() < 0.0) {
1529               hXYFailhitsCK0[il]->Fill(global1.x(), global1.y());
1530               hEPFailhitsCK0[il]->Fill(global1.eta(), global1.phi());
1531             } else {
1532               hXYFailhitsCK1[il]->Fill(global1.x(), global1.y());
1533               hEPFailhitsCK1[il]->Fill(global1.eta(), global1.phi());
1534             }
1535           }
1536         } else if (rhtools_.isScintillator(id1)) {
1537           //HGCScintillatorDetId id(itHit->id());
1538           //int il = rhtools_.getLayerWithOffset(id1);
1539           if (global1.z() < 0.0) {
1540             hXYFailhitsB0[il]->Fill(global1.x(), global1.y());
1541             hEPFailhitsB0[il]->Fill(global1.eta(), global1.phi());
1542           } else {
1543             hXYFailhitsB1[il]->Fill(global1.x(), global1.y());
1544             hEPFailhitsB1[il]->Fill(global1.eta(), global1.phi());
1545           }
1546 
1547         }  //is Sci or Si
1548 
1549       }  //Invalid detid
1550 
1551     }  //isLayerRequested
1552 
1553     if (!TMath::AreEqualAbs(convertGeVToKeV(esum.eTime[0]), 0.0, 1.e-5)) {
1554       if (name_ == "HGCalEESensitive") {
1555         hELossCSinBunchEE->Fill(convertGeVToKeV(esum.eTime[0]));
1556         if (id.type() == HGCSiliconDetId::HGCalHD120) {
1557           hELossCSinBunchEEF->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1558         }
1559         if (id.type() == HGCSiliconDetId::HGCalLD200) {
1560           hELossCSinBunchEECN->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1561         }
1562         if (id.type() == HGCSiliconDetId::HGCalLD300) {
1563           hELossCSinBunchEECK->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1564         }
1565       }
1566 
1567       if (name_ == "HGCalHESiliconSensitive") {
1568         hELossCSinBunchHEF->Fill(convertGeVToKeV(esum.eTime[0]));
1569         if (id.type() == HGCSiliconDetId::HGCalHD120) {
1570           hELossCSinBunchHEFF->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1571           if (convertGeVToKeV(esum.eTime[0]) < 35.) {
1572             hXYLowELosshitsF->Fill(hinfo.x, hinfo.y);
1573             hYZLowELosshitsF->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
1574           }
1575         }
1576         if (id.type() == HGCSiliconDetId::HGCalLD200) {
1577           hELossCSinBunchHEFCN->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1578           if (TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y) > 45.0 and
1579               TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y) < 60.0 and hinfo.layer >= 38)
1580             hELossCSinBunchHEFCNNoise->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1581           else
1582             hELossCSinBunchHEFCNFiltered->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1583           if (convertGeVToKeV(esum.eTime[0]) < 35.) {
1584             hPtLowELoss->Fill(hinfo.trkpt);
1585             hEtaLowELoss->Fill(hinfo.trketa);
1586             hPhiLowELoss->Fill(hinfo.trkphi);
1587             hChargeLowELoss->Fill(hinfo.charge);
1588             hPDGLowELoss->Fill(hinfo.pdg);
1589             hXYLowELosshitsCN->Fill(hinfo.x, hinfo.y);
1590             hYZLowELosshitsCN->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
1591             hYZLLowELosshitsHEFCN->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
1592             hXLowELosshitsHEFCN->Fill(hinfo.x);
1593             hYLowELosshitsHEFCN->Fill(hinfo.y);
1594             if (TMath::Abs(hinfo.x) < 20.0 && TMath::Abs(hinfo.y) < 20.0)
1595               hZLowELosshitsHEFCN->Fill(hinfo.z);
1596           }
1597         }
1598         if (id.type() == HGCSiliconDetId::HGCalLD300) {
1599           hELossCSinBunchHEFCK->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1600           if (convertGeVToKeV(esum.eTime[0]) < 10.) {
1601             hXYLowELosshitsCK->Fill(hinfo.x, hinfo.y);
1602             hYZLowELosshitsCK->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
1603           }
1604         }
1605       }
1606     }
1607 
1608     if (!TMath::AreEqualAbs(convertGeVToKeV(esum.eTime[2]), 0.0, 1.e-5)) {
1609       if (name_ == "HGCalEESensitive") {
1610         hELossCSmissedEE->Fill(convertGeVToKeV(esum.eTime[2]));
1611         if (id.type() == HGCSiliconDetId::HGCalHD120)
1612           hELossCSmissedEEF->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
1613         if (id.type() == HGCSiliconDetId::HGCalLD200)
1614           hELossCSmissedEECN->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
1615         if (id.type() == HGCSiliconDetId::HGCalLD300)
1616           hELossCSmissedEECK->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
1617         hXYmissedhits->Fill(hinfo.x, hinfo.y);
1618         hYZmissedhits->Fill(TMath::Abs(hinfo.z), TMath::Abs(hinfo.y));
1619       }
1620 
1621       if (name_ == "HGCalHESiliconSensitive") {
1622         hELossCSmissedHEF->Fill(convertGeVToKeV(esum.eTime[2]));
1623         if (id.type() == HGCSiliconDetId::HGCalHD120)
1624           hELossCSmissedHEFF->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
1625         if (id.type() == HGCSiliconDetId::HGCalLD200)
1626           hELossCSmissedHEFCN->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
1627         if (id.type() == HGCSiliconDetId::HGCalLD300)
1628           hELossCSmissedHEFCK->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
1629         hXYmissedhits->Fill(hinfo.x, hinfo.y);
1630         hYZmissedhits->Fill(TMath::Abs(hinfo.z), TMath::Abs(hinfo.y));
1631       }
1632     }
1633   }
1634   //================================================================================================================
1635 
1636   //================================================================================================================
1637   // This loop to find the cell with maximum deposited energy
1638   //================================================================================================================
1639   std::vector<uint32_t> cellMaxEdep;
1640   cellMaxEdep.clear();
1641   for (int il = 1; il <= 50; il++) {
1642     double energy = 0.;
1643     uint32_t maxid = 0;
1644     double maxEsum = 0.0;
1645     for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
1646       //uint32_t id_ = (*itr).first;
1647       hitsinfo hinfo = (*itr).second.first;
1648       energysum esum = (*itr).second.second;
1649       // printf("\tDet : %s, first hit : %d, nhits : %u, id : %u, Edep : %5.2lf (keV), (x,y,z) : (%lf,%lf,%lf)\n",
1650       //       name_.c_str(), hinfo.hitid, hinfo.nhits, (*itr).first, convertGeVToKeV(esum.etotal), hinfo.x, hinfo.y, hinfo.z);
1651 
1652       if (hinfo.layer == il and hinfo.z > 0.) {
1653         //energy += esum.eTime[0];
1654         energy += esum.etotal;
1655 
1656         //if (esum.eTime[0] > maxEsum) {
1657         if (esum.etotal > maxEsum) {
1658           maxEsum = esum.eTime[0];
1659           maxid = (*itr).first;
1660         }
1661 
1662       }  //match layer and z-direction
1663 
1664     }  //map loop
1665 
1666     if (convertGeVToKeV(maxEsum) > 0.)
1667       cellMaxEdep.push_back(maxid);
1668     if (convertGeVToKeV(energy) > 0.) {
1669       std::vector<int>::iterator ilyr = std::find(layerList.begin(), layerList.end(), il);
1670       if (ilyr != layerList.cend()) {
1671         int ilHist = std::distance(layerList.begin(), ilyr);
1672         hELossLayer[ilHist]->Fill(convertGeVToKeV(energy));  //in keV
1673       }
1674     }
1675   }
1676   //================================================================================================================
1677 
1678   //================================================================================================================
1679   // This loop plot energies corresponding cells with maximum deposited energy
1680   //================================================================================================================
1681   bool isPWafer = false;
1682   bool isFWafer = false;
1683   for (unsigned int ic = 0; ic < cellMaxEdep.size(); ic++) {
1684     uint32_t id_ = cellMaxEdep[ic];
1685     energysum esum = map_hits[id_].second;
1686     hitsinfo hinfo = map_hits[id_].first;
1687     DetId id1 = static_cast<DetId>(id_);
1688 
1689     if (!rhtools_.isSilicon(id1))
1690       continue;
1691 
1692     std::vector<int>::iterator ilyr = std::find(layerList.begin(), layerList.end(), rhtools_.getLayerWithOffset(id1));
1693     if (ilyr >= layerList.cend())
1694       continue;
1695     int il = std::distance(layerList.begin(), ilyr);
1696 
1697     HGCSiliconDetId id(id_);
1698     HGCalDetId hid(id);
1699 
1700     isPWafer = false;
1701     isFWafer = false;
1702     for (unsigned int iw = 0; iw < winfo.size(); iw++) {
1703       if (hinfo.layer == winfo[iw].layer and rhtools_.getWafer(id1).first == winfo[iw].u and
1704           rhtools_.getWafer(id1).second == winfo[iw].v) {
1705         if (winfo[iw].type == 0)
1706           isPWafer = true;
1707         if (winfo[iw].type == 1)
1708           isFWafer = true;
1709       }
1710     }
1711 
1712     // printf("\tDet : %s, wafertype : %d, layer : %d, (u,v) : (%d,%d), ishalf : %d, first hit : %d, nhits : %u, Edep : %5.2lf (keV), (x,y,z) : (%lf,%lf,%lf)\n",
1713     //     name_.c_str(), hid.waferType(), hinfo.layer, rhtools_.getWafer(id1).first, rhtools_.getWafer(id1).second, rhtools_.isHalfCell(id1), hinfo.hitid, hinfo.nhits, convertGeVToKeV(esum.etotal), hinfo.x, hinfo.y, hinfo.z);
1714 
1715     // printf("\tDet : %s, wafertype : %d, layer : %d, (u,v) : (%d,%d), isPWafer : %d, isFWafer : %d, (x,y,z) : (%lf,%lf,%lf)\n",
1716     //     name_.c_str(), hid.waferType(), hinfo.layer, rhtools_.getWafer(id1).first, rhtools_.getWafer(id1).second, isPWafer, isFWafer, hinfo.x, hinfo.y, hinfo.z);
1717 
1718     //for
1719 
1720     if (name_ == "HGCalEESensitive") {
1721       hCellThickness->Fill(rhtools_.getSiThickness(id1));
1722       hELossCSMaxEE->Fill(convertGeVToKeV(esum.eTime[0]));
1723       if (id.type() == HGCSiliconDetId::HGCalHD120) {
1724         hELossCSMaxEEF->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1725         hELCSMaxF[il]->Fill(convertGeVToKeV(esum.eTime[0]));   //in keV
1726         if (isPWafer) {
1727           hNHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1728           hNHxELCSMaxF[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1729           hNHxXYhitsF[il]->Fill(hinfo.x, hinfo.y);
1730         }
1731         if (isFWafer) {
1732           hHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1733           hHxELCSMaxF[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1734         }
1735       }
1736       if (id.type() == HGCSiliconDetId::HGCalLD200) {
1737         hELossCSMaxEECN->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1738         hELCSMaxCN[il]->Fill(convertGeVToKeV(esum.eTime[0]));   //in keV
1739         if (isPWafer) {
1740           hNHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1741           hNHxELCSMaxCN[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1742           hNHxXYhitsCN[il]->Fill(hinfo.x, hinfo.y);
1743         }
1744         if (isFWafer) {
1745           hHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1746           hHxELCSMaxCN[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1747         }
1748       }
1749       if (id.type() == HGCSiliconDetId::HGCalLD300) {
1750         hELossCSMaxEECK->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1751         hELCSMaxCK[il]->Fill(convertGeVToKeV(esum.eTime[0]));   //in keV
1752         if (isPWafer) {
1753           hNHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1754           hNHxELCSMaxCK[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1755           hNHxXYhitsCK[il]->Fill(hinfo.x, hinfo.y);
1756         }
1757         if (isFWafer) {
1758           hHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1759           hHxELCSMaxCK[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1760         }
1761       }
1762     }
1763 
1764     if (name_ == "HGCalHESiliconSensitive") {
1765       hCellThickness->Fill(rhtools_.getSiThickness(id1));
1766       hELossCSMaxHEF->Fill(convertGeVToKeV(esum.eTime[0]));
1767       if (id.type() == HGCSiliconDetId::HGCalHD120) {
1768         hELossCSMaxHEFF->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1769         hELCSMaxF[il]->Fill(convertGeVToKeV(esum.eTime[0]));    //in keV
1770         if (isPWafer) {
1771           hNHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1772           hNHxELCSMaxF[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1773           hNHxXYhitsF[il]->Fill(hinfo.x, hinfo.y);
1774         }
1775         if (isFWafer) {
1776           hHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1777           hHxELCSMaxF[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1778         }
1779       }
1780       if (id.type() == HGCSiliconDetId::HGCalLD200) {
1781         hELossCSMaxHEFCN->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1782         hELCSMaxCN[il]->Fill(convertGeVToKeV(esum.eTime[0]));    //in keV
1783         if (convertGeVToKeV(esum.eTime[0]) < 30. and convertGeVToKeV(esum.eTime[0]) > 10.)
1784           hXYhitsLELCN[il]->Fill(hinfo.x, hinfo.y);
1785         else
1786           hXYhitsHELCN[il]->Fill(hinfo.x, hinfo.y);
1787         if (isPWafer) {
1788           hNHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1789           hNHxELCSMaxCN[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1790           hNHxXYhitsCN[il]->Fill(hinfo.x, hinfo.y);
1791         }
1792         if (isFWafer) {
1793           hHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1794           hHxELCSMaxCN[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1795         }
1796       }
1797       if (id.type() == HGCSiliconDetId::HGCalLD300) {
1798         hELossCSMaxHEFCK->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1799         hELCSMaxCK[il]->Fill(convertGeVToKeV(esum.eTime[0]));    //in keV
1800         if (convertGeVToKeV(esum.eTime[0]) < 10.)
1801           hXYhitsLELCK[il]->Fill(hinfo.x, hinfo.y);
1802         else if (convertGeVToKeV(esum.eTime[0]) > 50.)
1803           hXYhitsHELCK[il]->Fill(hinfo.x, hinfo.y);
1804         if (isPWafer) {
1805           hNHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1806           hNHxELCSMaxCK[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1807           hNHxXYhitsCK[il]->Fill(hinfo.x, hinfo.y);
1808         }
1809         if (isFWafer) {
1810           hHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1811           hHxELCSMaxCK[il]->Fill(convertGeVToKeV(esum.eTime[0]));
1812         }
1813       }
1814     }
1815   }
1816 
1817   map_hits.clear();
1818 }
1819 
1820 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
1821 void HGCalCellHitSum::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
1822   edm::ParameterSetDescription desc;
1823   desc.add<edm::InputTag>("simtrack", edm::InputTag("g4SimHits"));
1824   desc.add<edm::InputTag>("simhits", edm::InputTag("g4SimHits", "HGCHitsEE"));
1825   desc.add<std::string>("detector", "HGCalEESensitive");
1826   desc.add<edm::FileInPath>("geometryFileName", edm::FileInPath("Validation/HGCalValidation/data/wafer_v17.csv"));
1827   desc.add<std::string>("layerList", "1");
1828   descriptions.add("hgcalCellHitSumEE", desc);
1829 }
1830 
1831 //define this as a plug-in
1832 DEFINE_FWK_MODULE(HGCalCellHitSum);