Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-01 01:02:30

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 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/ModuleFactory.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/ParameterSet/interface/FileInPath.h"
0034 #include "FWCore/ServiceRegistry/interface/Service.h"
0035 #include "FWCore/Utilities/interface/InputTag.h"
0036 
0037 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0038 
0039 #include "SimDataFormats/Track/interface/SimTrack.h"
0040 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0041 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0042 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0043 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0044 
0045 #include "DataFormats/DetId/interface/DetId.h"
0046 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0047 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0048 #include "DataFormats/Math/interface/angle_units.h"
0049 
0050 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0051 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0052 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0053 
0054 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0055 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0056 
0057 #include <TH1.h>
0058 #include <TH2.h>
0059 #include <TGraph.h>
0060 #include <TMath.h>
0061 
0062 using namespace angle_units::operators;
0063 
0064 //
0065 // class declaration
0066 //
0067 
0068 class HGCalCellHitSum : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0069 public:
0070   //Implemented following Validation/HGCalValidation/plugins/HGCalSimHitValidation.cc
0071   struct energysum {
0072     energysum() {
0073       etotal = 0;
0074       for (int i = 0; i < 6; ++i)
0075         eTime[i] = 0.;
0076     }
0077     double eTime[6], etotal;
0078   };
0079 
0080   struct waferinfo {
0081     waferinfo() { layer = u = v = type = -999; }
0082     int layer, u, v, type;
0083   };
0084 
0085   struct hitsinfo {
0086     hitsinfo() {
0087       x = y = z = phi = eta = trkpt = trketa = trkphi = 0.0;
0088       cell = cell2 = sector = sector2 = type = layer = pdg = charge = 0;
0089       hitid = nhits = 0;
0090       isMu = false;
0091     }
0092     double x, y, z, phi, eta, trkpt, trketa, trkphi;
0093     int cell, cell2, sector, sector2, type, layer, pdg, charge;
0094     unsigned int hitid, nhits;
0095     bool isMu;
0096   };
0097 
0098   explicit HGCalCellHitSum(const edm::ParameterSet &);
0099   ~HGCalCellHitSum() override = default;
0100 
0101   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0102 
0103 private:
0104   void beginJob() override {}
0105   void analyze(const edm::Event &, const edm::EventSetup &) override;
0106   void endJob() override {}
0107 
0108   // ----------member data ---------------------------
0109   const edm::EDGetTokenT<edm::SimTrackContainer> tSimTrackContainer;
0110   const edm::EDGetTokenT<edm::PCaloHitContainer> tSimCaloHitContainer;
0111   const std::string name_;
0112   const edm::FileInPath geometryFileName_;
0113   const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
0114   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0115 
0116   TH1D *hCharge;
0117   TH1D *hChargeLowELoss;
0118 
0119   TH1D *hPt;
0120   TH1D *hPtNoGen;
0121   TH1D *hPtLowELoss;
0122 
0123   TH1D *hEta;
0124   TH1D *hEtaCell;
0125   TH1D *hEtaLowELoss;
0126 
0127   TH1D *hPhi;
0128   TH1D *hPhiCell;
0129   TH1D *hPhiLowELoss;
0130 
0131   TH1D *hPDG;
0132   TH1D *hPDGLowELoss;
0133 
0134   TH1D *hELossEE;
0135   TH1D *hELossEEF;
0136   TH1D *hELossEECN;
0137   TH1D *hELossEECK;
0138   TH1D *hELossHEF;
0139   TH1D *hELossHEFF;
0140   TH1D *hELossHEFCN;
0141   TH1D *hELossHEFCK;
0142   TH1D *hELossHEB;
0143 
0144   TH1D *hELossCSinBunchEE;
0145   TH1D *hELossCSinBunchEEF;
0146   TH1D *hELossCSinBunchEECN;
0147   TH1D *hELossCSinBunchEECK;
0148   TH1D *hELossCSinBunchHEF;
0149   TH1D *hELossCSinBunchHEFF;
0150   TH1D *hELossCSinBunchHEFCN;
0151   TH1D *hELossCSinBunchHEFCK;
0152   TH1D *hELossCSinBunchHEFCNFiltered;
0153   TH1D *hELossCSinBunchHEFCNNoise;
0154 
0155   TH1D *hELossCSmissedEE;
0156   TH1D *hELossCSmissedEEF;
0157   TH1D *hELossCSmissedEECN;
0158   TH1D *hELossCSmissedEECK;
0159   TH1D *hELossCSmissedHEF;
0160   TH1D *hELossCSmissedHEFF;
0161   TH1D *hELossCSmissedHEFCN;
0162   TH1D *hELossCSmissedHEFCK;
0163 
0164   TH1D *hELossCSMaxEE;
0165   TH1D *hELossCSMaxEEF;
0166   TH1D *hELossCSMaxEECN;
0167   TH1D *hELossCSMaxEECK;
0168   TH1D *hELossCSMaxHEF;
0169   TH1D *hELossCSMaxHEFF;
0170   TH1D *hELossCSMaxHEFCN;
0171   TH1D *hELossCSMaxHEFCK;
0172 
0173   TH1D *hHxELossCSMaxF;
0174   TH1D *hHxELossCSMaxCN;
0175   TH1D *hHxELossCSMaxCK;
0176   TH1D *hNHxELossCSMaxF;
0177   TH1D *hNHxELossCSMaxCN;
0178   TH1D *hNHxELossCSMaxCK;
0179 
0180   std::vector<TH1D *> hELossDQMEqV;
0181   std::vector<TH1D *> hELossLayer;
0182 
0183   // TH2D *hYZhits;
0184   std::vector<TH2D *> hXYhits;
0185   std::vector<TH2D *> hXYhitsF;
0186   std::vector<TH2D *> hXYhitsCN;
0187   std::vector<TH2D *> hXYhitsCK;
0188   std::vector<TH2D *> hXYhitsB;
0189   std::vector<TH2D *> hXYhitsLELCN;
0190   std::vector<TH2D *> hXYhitsHELCN;
0191   std::vector<TH2D *> hXYhitsLELCK;
0192   std::vector<TH2D *> hXYhitsHELCK;
0193   std::vector<TH2D *> hNHxXYhitsF;
0194   std::vector<TH2D *> hNHxXYhitsCN;
0195   std::vector<TH2D *> hNHxXYhitsCK;
0196 
0197   // For rechittool z positions. The 0 and 1 are for -ve and +ve, respectively.
0198   std::vector<TGraph *> grXYhitsF0;
0199   std::vector<TGraph *> grXYhitsCN0;
0200   std::vector<TGraph *> grXYhitsCK0;
0201   std::vector<TGraph *> grXYhitsB0;
0202   int ixyF0[50], ixyCN0[50], ixyCK0[50], ixyB0[50];
0203 
0204   std::vector<TGraph *> grXYhitsF1;
0205   std::vector<TGraph *> grXYhitsCN1;
0206   std::vector<TGraph *> grXYhitsCK1;
0207   std::vector<TGraph *> grXYhitsB1;
0208   int ixyF1[50], ixyCN1[50], ixyCK1[50], ixyB1[50];
0209   /////////////////////////////////
0210 
0211   // For detid zside. The 0 and 1 are for -ve and +ve, respectively.
0212   std::vector<TGraph *> gXYhitsF0;
0213   std::vector<TGraph *> gXYhitsCN0;
0214   std::vector<TGraph *> gXYhitsCK0;
0215   std::vector<TGraph *> gXYhitsB0;
0216   int ixydF0[50], ixydCN0[50], ixydCK0[50], ixydB0[50];
0217 
0218   std::vector<TGraph *> gXYhitsF1;
0219   std::vector<TGraph *> gXYhitsCN1;
0220   std::vector<TGraph *> gXYhitsCK1;
0221   std::vector<TGraph *> gXYhitsB1;
0222   int ixydF1[50], ixydCN1[50], ixydCK1[50], ixydB1[50];
0223   //////////////////////////////////////////
0224 
0225   std::vector<TH1D *> hELCSMaxF;
0226   std::vector<TH1D *> hELCSMaxCN;
0227   std::vector<TH1D *> hELCSMaxCK;
0228 
0229   std::vector<TH1D *> hHxELCSMaxF;
0230   std::vector<TH1D *> hHxELCSMaxCN;
0231   std::vector<TH1D *> hHxELCSMaxCK;
0232   std::vector<TH1D *> hNHxELCSMaxF;
0233   std::vector<TH1D *> hNHxELCSMaxCN;
0234   std::vector<TH1D *> hNHxELCSMaxCK;
0235 
0236   TH2D *hXYLowELosshitsF;
0237   TH2D *hXYLowELosshitsCN;
0238   TH2D *hXYLowELosshitsCK;
0239   TH2D *hXYmissedhits;
0240   TH2D *hYZLowELosshitsF;
0241   TH2D *hYZLowELosshitsCN;
0242   TH2D *hYZLowELosshitsCK;
0243   TH2D *hYZLLowELosshitsHEFCN;
0244   TH2D *hYZmissedhits;
0245 
0246   TH1D *hXLowELosshitsHEFCN;
0247   TH1D *hYLowELosshitsHEFCN;
0248   TH1D *hZLowELosshitsHEFCN;
0249 
0250   TH2D *hYZhitsEE;
0251   TH2D *hYZhitsHEF;
0252   TH2D *hYZhitsHEB;
0253 
0254   TH2D *hYZhitsEEF;
0255   TH2D *hYZhitsEECN;
0256   TH2D *hYZhitsEECK;
0257 
0258   TH2D *hYZhitsHEFF;
0259   TH2D *hYZhitsHEFCN;
0260   TH2D *hYZhitsHEFCK;
0261 
0262   TH2D *hRHTXYhits;
0263   TH2D *hRHTYZhitsEE;
0264   TH2D *hRHTYZhitsHEF;
0265   TH2D *hRHTYZhitsHEB;
0266   TH2D *hRHTYZhitsEEF;
0267   TH2D *hRHTYZhitsEECN;
0268   TH2D *hRHTYZhitsEECK;
0269   TH2D *hRHTYZhitsHEFF;
0270   TH2D *hRHTYZhitsHEFCN;
0271   TH2D *hRHTYZhitsHEFCK;
0272 
0273   TH2D *hRHTRZhitsEE;
0274   TH2D *hRHTRZhitsHEF;
0275   TH2D *hRHTRZhitsHEB;
0276   TH2D *hRHTRZhitsEEF;
0277   TH2D *hRHTRZhitsEECN;
0278   TH2D *hRHTRZhitsEECK;
0279   TH2D *hRHTRZhitsHEFF;
0280   TH2D *hRHTRZhitsHEFCN;
0281   TH2D *hRHTRZhitsHEFCK;
0282 
0283   TH2D *hRHTGlbRZhitsF;
0284   TH2D *hRHTGlbRZhitsCN;
0285   TH2D *hRHTGlbRZhitsCK;
0286   TH2D *hRHTGlbRZhitsSci;
0287 
0288   TH1D *hDiffX;
0289   TH1D *hDiffY;
0290   TH1D *hDiffZ;
0291 
0292   TH1D *hCellThickness;
0293 
0294   hgcal::RecHitTools rhtools_;
0295   std::vector<waferinfo> winfo;
0296   int evt;
0297 };
0298 
0299 //
0300 // constructors and destructor
0301 //
0302 HGCalCellHitSum::HGCalCellHitSum(const edm::ParameterSet &iConfig)
0303     : tSimTrackContainer(consumes<edm::SimTrackContainer>(iConfig.getParameter<edm::InputTag>("simtrack"))),
0304       tSimCaloHitContainer(consumes<edm::PCaloHitContainer>(iConfig.getParameter<edm::InputTag>("simhits"))),
0305       name_(iConfig.getParameter<std::string>("detector")),
0306       geometryFileName_(iConfig.getParameter<edm::FileInPath>("geometryFileName")),
0307       geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", name_})),
0308       caloGeomToken_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
0309       evt(0) {
0310   //now do what ever initialization is needed
0311   usesResource(TFileService::kSharedResource);
0312   edm::LogVerbatim("ValidHGCal") << "HGCalCellHitSum::Initialize for " << name_ << " using " << geometryFileName_
0313                                  << " and collections for simTrack:" << iConfig.getParameter<edm::InputTag>("simtrack")
0314                                  << "; and for hits " << iConfig.getParameter<edm::InputTag>("simhits");
0315   edm::Service<TFileService> fs;
0316 
0317   hCharge = fs->make<TH1D>("charge", "Charges", 200, -20, 20);
0318   hChargeLowELoss = fs->make<TH1D>("charge LowELoss", "Charges LowELoss", 200, -20, 20);
0319 
0320   hPDG = fs->make<TH1D>("hPDG", "hPDG", 10000, -5000, 5000);
0321   hPDGLowELoss = fs->make<TH1D>("hPDGLowELoss", "hPDGLowELoss", 10000, -5000, 5000);
0322 
0323   hPt = fs->make<TH1D>("hPt", "hPt", 1000, 0., 1000.);
0324   hPtNoGen = fs->make<TH1D>("hPtNoGen", "hPtNoGen", 1000, 0., 1000.);
0325   hPtLowELoss = fs->make<TH1D>("hPtLowELoss", "hPtLowELoss", 1000, 0., 1000.);
0326 
0327   hEta = fs->make<TH1D>("hEta", "hEta", 100, -5., 5.);
0328   hEtaCell = fs->make<TH1D>("hEtaCell", "hEtaCell", 100, -5., 5.);
0329   hEtaLowELoss = fs->make<TH1D>("hEtaLowELoss", "hEtaLowELoss", 100, -5., 5.);
0330 
0331   hPhi = fs->make<TH1D>("hPhi", "hPhi", 100, -5., 5.);
0332   hPhiCell = fs->make<TH1D>("hPhiCell", "hPhiCell", 100, -5., 5.);
0333   hPhiLowELoss = fs->make<TH1D>("hPhiLowELoss", "hPhiLowELoss", 100, -5., 5.);
0334 
0335   hELossEE = fs->make<TH1D>("hELossEE", "hELossEE", 1000, 0., 1000.);
0336   hELossEEF = fs->make<TH1D>("hELossEEF", "hELossEEF", 1000, 0., 1000.);
0337   hELossEECN = fs->make<TH1D>("hELossEECN", "hELossEECN", 1000, 0., 1000.);
0338   hELossEECK = fs->make<TH1D>("hELossEECK", "hELossEECK", 1000, 0., 1000.);
0339 
0340   hELossHEF = fs->make<TH1D>("hELossHEF", "hELossHEF", 1000, 0., 1000.);
0341   hELossHEFF = fs->make<TH1D>("hELossHEFF", "hELossHEFF", 1000, 0., 1000.);
0342   hELossHEFCN = fs->make<TH1D>("hELossHEFCN", "hELossHEFCN", 1000, 0., 1000.);
0343   hELossHEFCK = fs->make<TH1D>("hELossHEFCK", "hELossHEFCK", 1000, 0., 1000.);
0344 
0345   hELossHEB = fs->make<TH1D>("hELossHEB", "hELossHEB", 1000, 0., 1000.);
0346 
0347   hELossCSinBunchEE = fs->make<TH1D>("hELossCSinBunchEE", "hELossCSinBunchEE", 1000, 0., 1000.);
0348   hELossCSinBunchEEF = fs->make<TH1D>("hELossCSinBunchEEF", "hELossCSinBunchEEF", 1000, 0., 1000.);
0349   hELossCSinBunchEECN = fs->make<TH1D>("hELossCSinBunchEECN", "hELossCSinBunchEECN", 1000, 0., 1000.);
0350   hELossCSinBunchEECK = fs->make<TH1D>("hELossCSinBunchEECK", "hELossCSinBunchEECK", 1000, 0., 1000.);
0351   hELossCSinBunchHEF = fs->make<TH1D>("hELossCSinBunchHEF", "hELossCSinBunchHEF", 1000, 0., 1000.);
0352   hELossCSinBunchHEFF = fs->make<TH1D>("hELossCSinBunchHEFF", "hELossCSinBunchHEFF", 1000, 0., 1000.);
0353   hELossCSinBunchHEFCN = fs->make<TH1D>("hELossCSinBunchHEFCN", "hELossCSinBunchHEFCN", 1000, 0., 1000.);
0354   hELossCSinBunchHEFCK = fs->make<TH1D>("hELossCSinBunchHEFCK", "hELossCSinBunchHEFCK", 1000, 0., 1000.);
0355   hELossCSinBunchHEFCNFiltered =
0356       fs->make<TH1D>("hELossCSinBunchHEFCNFiltered", "hELossCSinBunchHEFCNFiltered", 1000, 0., 1000.);
0357   hELossCSinBunchHEFCNNoise = fs->make<TH1D>("hELossCSinBunchHEFCNNoise", "hELossCSinBunchHEFCNNoise", 1000, 0., 1000.);
0358 
0359   hELossCSmissedEE = fs->make<TH1D>("hELossCSmissedEE", "hELossCSmissedEE", 1000, 0., 1000.);
0360   hELossCSmissedEEF = fs->make<TH1D>("hELossCSmissedEEF", "hELossCSmissedEEF", 1000, 0., 1000.);
0361   hELossCSmissedEECN = fs->make<TH1D>("hELossCSmissedEECN", "hELossCSmissedEECN", 1000, 0., 1000.);
0362   hELossCSmissedEECK = fs->make<TH1D>("hELossCSmissedEECK", "hELossCSmissedEECK", 1000, 0., 1000.);
0363   hELossCSmissedHEF = fs->make<TH1D>("hELossCSmissedHEF", "hELossCSmissedHEF", 1000, 0., 1000.);
0364   hELossCSmissedHEFF = fs->make<TH1D>("hELossCSmissedHEFF", "hELossCSmissedHEFF", 1000, 0., 1000.);
0365   hELossCSmissedHEFCN = fs->make<TH1D>("hELossCSmissedHEFCN", "hELossCSmissedHEFCN", 1000, 0., 1000.);
0366   hELossCSmissedHEFCK = fs->make<TH1D>("hELossCSmissedHEFCK", "hELossCSmissedHEFCK", 1000, 0., 1000.);
0367 
0368   hELossCSMaxEE = fs->make<TH1D>("hELossCSMaxEE", "hELossCSMaxEE", 1000, 0., 1000.);
0369   hELossCSMaxEEF = fs->make<TH1D>("hELossCSMaxEEF", "hELossCSMaxEEF", 1000, 0., 1000.);
0370   hELossCSMaxEECN = fs->make<TH1D>("hELossCSMaxEECN", "hELossCSMaxEECN", 1000, 0., 1000.);
0371   hELossCSMaxEECK = fs->make<TH1D>("hELossCSMaxEECK", "hELossCSMaxEECK", 1000, 0., 1000.);
0372   hELossCSMaxHEF = fs->make<TH1D>("hELossCSMaxHEF", "hELossCSMaxHEF", 1000, 0., 1000.);
0373   hELossCSMaxHEFF = fs->make<TH1D>("hELossCSMaxHEFF", "hELossCSMaxHEFF", 1000, 0., 1000.);
0374   hELossCSMaxHEFCN = fs->make<TH1D>("hELossCSMaxHEFCN", "hELossCSMaxHEFCN", 1000, 0., 1000.);
0375   hELossCSMaxHEFCK = fs->make<TH1D>("hELossCSMaxHEFCK", "hELossCSMaxHEFCK", 1000, 0., 1000.);
0376 
0377   hHxELossCSMaxF = fs->make<TH1D>("hHxELossCSMaxF", "hHxELossCSMaxF", 1000, 0., 1000.);
0378   hHxELossCSMaxCN = fs->make<TH1D>("hHxELossCSMaxCN", "hHxELossCSMaxCN", 1000, 0., 1000.);
0379   hHxELossCSMaxCK = fs->make<TH1D>("hHxELossCSMaxCK", "hHxELossCSMaxCK", 1000, 0., 1000.);
0380 
0381   hNHxELossCSMaxF = fs->make<TH1D>("hNHxELossCSMaxF", "hNHxELossCSMaxF", 1000, 0., 1000.);
0382   hNHxELossCSMaxCN = fs->make<TH1D>("hNHxELossCSMaxCN", "hNHxELossCSMaxCN", 1000, 0., 1000.);
0383   hNHxELossCSMaxCK = fs->make<TH1D>("hNHxELossCSMaxCK", "hNHxELossCSMaxCK", 1000, 0., 1000.);
0384 
0385   for (int i = 1; i <= 50; i++) {
0386     hELCSMaxF.emplace_back(
0387         fs->make<TH1D>(Form("hELCSMaxF_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0388     hELCSMaxCN.emplace_back(
0389         fs->make<TH1D>(Form("hELCSMaxCN_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0390     hELCSMaxCK.emplace_back(
0391         fs->make<TH1D>(Form("hELCSMaxCK_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0392   }
0393   for (int i = 1; i <= 50; i++) {
0394     hHxELCSMaxF.emplace_back(
0395         fs->make<TH1D>(Form("hHxELCSMaxF_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0396     hHxELCSMaxCN.emplace_back(
0397         fs->make<TH1D>(Form("hHxELCSMaxCN_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0398     hHxELCSMaxCK.emplace_back(
0399         fs->make<TH1D>(Form("hHxELCSMaxCK_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0400     hNHxELCSMaxF.emplace_back(
0401         fs->make<TH1D>(Form("hNHxELCSMaxF_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0402     hNHxELCSMaxCN.emplace_back(
0403         fs->make<TH1D>(Form("hNHxELCSMaxCN_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0404     hNHxELCSMaxCK.emplace_back(
0405         fs->make<TH1D>(Form("hNHxELCSMaxCK_layer_%02d", i), Form("Energy for layer %d", i), 500, 0., 500.));
0406     hELossDQMEqV.emplace_back(
0407         fs->make<TH1D>(Form("hELossDQMEqV_layer_%02d", i), Form("hELossDQMEqV_layer_%02d", i), 100, 0, 0.1));
0408     hELossLayer.emplace_back(fs->make<TH1D>(Form("hELossLayer_%02d", i), Form("hELossLayer_%02d", i), 1000, 0., 1000.));
0409   }
0410   for (int i = 1; i <= 50; i++) {
0411     hXYhits.emplace_back(fs->make<TH2D>(
0412         Form("hXYhits_layer_%02d", i), Form("Hits in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0413     hXYhitsF.emplace_back(fs->make<TH2D>(
0414         Form("hXYhitsF_layer_%02d", i), Form("HitsF in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0415     hXYhitsCN.emplace_back(fs->make<TH2D>(
0416         Form("hXYhitsCN_layer_%02d", i), Form("HitsCN in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0417     hXYhitsCK.emplace_back(fs->make<TH2D>(
0418         Form("hXYhitsCK_layer_%02d", i), Form("HitsCK in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0419     hXYhitsB.emplace_back(fs->make<TH2D>(
0420         Form("hXYhitsB_layer_%02d", i), Form("HitsB in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0421     hXYhitsLELCN.emplace_back(fs->make<TH2D>(
0422         Form("hXYhitsLELCN_layer_%02d", i), Form("LELCN in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0423     hXYhitsHELCN.emplace_back(fs->make<TH2D>(
0424         Form("hXYhitsHELCN_layer_%02d", i), Form("HELCN in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0425     hXYhitsLELCK.emplace_back(fs->make<TH2D>(
0426         Form("hXYhitsLELCK_layer_%02d", i), Form("LELCK in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0427     hXYhitsHELCK.emplace_back(fs->make<TH2D>(
0428         Form("hXYhitsHELCK_layer_%02d", i), Form("HELCK in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0429   }
0430   for (int i = 1; i <= 50; i++) {
0431     grXYhitsF0.emplace_back(fs->make<TGraph>(0));
0432     grXYhitsF0[i - 1]->SetNameTitle(Form("grXYhitsF0_layer_%02d", i), Form("HitsF0 in XY for layer %d", i));
0433     grXYhitsCN0.emplace_back(fs->make<TGraph>(0));
0434     grXYhitsCN0[i - 1]->SetNameTitle(Form("grXYhitsCN0_layer_%02d", i), Form("HitsCN0 in XY for layer %d", i));
0435     grXYhitsCK0.emplace_back(fs->make<TGraph>(0));
0436     grXYhitsCK0[i - 1]->SetNameTitle(Form("grXYhitsCK0_layer_%02d", i), Form("HitsCK0 in XY for layer %d", i));
0437     grXYhitsB0.emplace_back(fs->make<TGraph>(0));
0438     grXYhitsB0[i - 1]->SetNameTitle(Form("grXYhitsB0_layer_%02d", i), Form("HitsB0 in XY for layer %d", i));
0439     ixyF0[i - 1] = 0;
0440     ixyCN0[i - 1] = 0;
0441     ixyCK0[i - 1] = 0;
0442     ixyB0[i - 1] = 0;
0443     grXYhitsF1.emplace_back(fs->make<TGraph>(0));
0444     grXYhitsF1[i - 1]->SetNameTitle(Form("grXYhitsF1_layer_%02d", i), Form("HitsF1 in XY for layer %d", i));
0445     grXYhitsCN1.emplace_back(fs->make<TGraph>(0));
0446     grXYhitsCN1[i - 1]->SetNameTitle(Form("grXYhitsCN1_layer_%02d", i), Form("HitsCN1 in XY for layer %d", i));
0447     grXYhitsCK1.emplace_back(fs->make<TGraph>(0));
0448     grXYhitsCK1[i - 1]->SetNameTitle(Form("grXYhitsCK1_layer_%02d", i), Form("HitsCK1 in XY for layer %d", i));
0449     grXYhitsB1.emplace_back(fs->make<TGraph>(0));
0450     grXYhitsB1[i - 1]->SetNameTitle(Form("grXYhitsB1_layer_%02d", i), Form("HitsB1 in XY for layer %d", i));
0451     ixyF1[i - 1] = 0;
0452     ixyCN1[i - 1] = 0;
0453     ixyCK1[i - 1] = 0;
0454     ixyB1[i - 1] = 0;
0455     gXYhitsF0.emplace_back(fs->make<TGraph>(0));
0456     gXYhitsF0[i - 1]->SetNameTitle(Form("gXYhitsF0_layer_%02d", i), Form("HitsF0 in XY for layer %d", i));
0457     gXYhitsCN0.emplace_back(fs->make<TGraph>(0));
0458     gXYhitsCN0[i - 1]->SetNameTitle(Form("gXYhitsCN0_layer_%02d", i), Form("HitsCN0 in XY for layer %d", i));
0459     gXYhitsCK0.emplace_back(fs->make<TGraph>(0));
0460     gXYhitsCK0[i - 1]->SetNameTitle(Form("gXYhitsCK0_layer_%02d", i), Form("HitsCK0 in XY for layer %d", i));
0461     gXYhitsB0.emplace_back(fs->make<TGraph>(0));
0462     gXYhitsB0[i - 1]->SetNameTitle(Form("gXYhitsB0_layer_%02d", i), Form("HitsB0 in XY for layer %d", i));
0463     ixydF0[i - 1] = 0;
0464     ixydCN0[i - 1] = 0;
0465     ixydCK0[i - 1] = 0;
0466     ixydB0[i - 1] = 0;
0467     gXYhitsF1.emplace_back(fs->make<TGraph>(0));
0468     gXYhitsF1[i - 1]->SetNameTitle(Form("gXYhitsF1_layer_%02d", i), Form("HitsF1 in XY for layer %d", i));
0469     gXYhitsCN1.emplace_back(fs->make<TGraph>(0));
0470     gXYhitsCN1[i - 1]->SetNameTitle(Form("gXYhitsCN1_layer_%02d", i), Form("HitsCN1 in XY for layer %d", i));
0471     gXYhitsCK1.emplace_back(fs->make<TGraph>(0));
0472     gXYhitsCK1[i - 1]->SetNameTitle(Form("gXYhitsCK1_layer_%02d", i), Form("HitsCK1 in XY for layer %d", i));
0473     gXYhitsB1.emplace_back(fs->make<TGraph>(0));
0474     gXYhitsB1[i - 1]->SetNameTitle(Form("gXYhitsB1_layer_%02d", i), Form("HitsB1 in XY for layer %d", i));
0475     ixydF1[i - 1] = 0;
0476     ixydCN1[i - 1] = 0;
0477     ixydCK1[i - 1] = 0;
0478     ixydB1[i - 1] = 0;
0479   }
0480   for (int i = 1; i <= 50; i++) {
0481     hNHxXYhitsF.emplace_back(fs->make<TH2D>(
0482         Form("hNHxXYhitsF_layer_%02d", i), Form("NHx HitsF in XY for layer %d", i), 600, -300., 300., 600, -300., 300.));
0483     hNHxXYhitsCN.emplace_back(fs->make<TH2D>(Form("hNHxXYhitsCN_layer_%02d", i),
0484                                              Form("NHx HitsCN in XY for layer %d", i),
0485                                              600,
0486                                              -300.,
0487                                              300.,
0488                                              600,
0489                                              -300.,
0490                                              300.));
0491     hNHxXYhitsCK.emplace_back(fs->make<TH2D>(Form("hNHxXYhitsCK_layer_%02d", i),
0492                                              Form("NHx HitsCK in XY for layer %d", i),
0493                                              600,
0494                                              -300.,
0495                                              300.,
0496                                              600,
0497                                              -300.,
0498                                              300.));
0499   }
0500   hXYmissedhits = fs->make<TH2D>("hXYmissedhits", "hXYmissedhits", 600, -300., 300., 600, -300., 300.);
0501   hXYLowELosshitsF = fs->make<TH2D>("hXYLowELosshitsF", "hXYLowELosshitsF", 600, -300., 300., 600, -300., 300.);
0502   hXYLowELosshitsCN = fs->make<TH2D>("hXYLowELosshitsCN", "hXYLowELosshitsCN", 600, -300., 300., 600, -300., 300.);
0503   hXYLowELosshitsCK = fs->make<TH2D>("hXYLowELosshitsCK", "hXYLowELosshitsCK", 600, -300., 300., 600, -300., 300.);
0504 
0505   hYZmissedhits = fs->make<TH2D>("hYZmissedhits", "hYZmissedhits", 250, 300., 550., 300, 0., 300.);
0506   hYZLowELosshitsF = fs->make<TH2D>("hYZLowELosshitsF", "hYZLowELosshitsF", 250, 300., 550., 300, 0., 300.);
0507   hYZLowELosshitsCN = fs->make<TH2D>("hYZLowELosshitsCN", "hYZLowELosshitsCN", 250, 300., 550., 300, 0., 300.);
0508   hYZLowELosshitsCK = fs->make<TH2D>("hYZLowELosshitsCK", "hYZLowELosshitsCK", 250, 300., 550., 300, 0., 300.);
0509   hYZLLowELosshitsHEFCN =
0510       fs->make<TH2D>("hYZLLowELosshitsHEFCN", "hYZLLowELosshitsHEFCN", 600, -50., 550., 350, -50., 300.);
0511 
0512   hXLowELosshitsHEFCN = fs->make<TH1D>("hXLowELosshitsHEFCN", "hXLowELosshitsHEFCN", 600, -300., 300.);
0513   hYLowELosshitsHEFCN = fs->make<TH1D>("hYLowELosshitsHEFCN", "hYLowELosshitsHEFCN", 600, -300., 300.);
0514   hZLowELosshitsHEFCN = fs->make<TH1D>("hZLowELosshitsHEFCN", "hZLowELosshitsHEFCN", 2400, -1200., 1200.);
0515 
0516   hYZhitsEE = fs->make<TH2D>("hYZhitsEE", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0517   hYZhitsHEF = fs->make<TH2D>("hYZhitsHEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0518   hYZhitsHEB = fs->make<TH2D>("hYZhitsHEB", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0519 
0520   hYZhitsEEF = fs->make<TH2D>("hYZhitsEEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0521   hYZhitsEECN = fs->make<TH2D>("hYZhitsEECN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0522   hYZhitsEECK = fs->make<TH2D>("hYZhitsEECK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0523 
0524   hYZhitsHEFF = fs->make<TH2D>("hYZhitsHEFF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0525   hYZhitsHEFCN = fs->make<TH2D>("hYZhitsHEFCN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0526   hYZhitsHEFCK = fs->make<TH2D>("hYZhitsHEFCK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0527 
0528   hRHTXYhits = fs->make<TH2D>("hRHTXYhits", "Hits in XY", 600, -300., 300., 600, -300., 300.);
0529   hRHTYZhitsEE = fs->make<TH2D>("hRHTYZhitsEE", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0530   hRHTYZhitsHEF = fs->make<TH2D>("hRHTYZhitsHEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0531   hRHTYZhitsHEB = fs->make<TH2D>("hRHTYZhitsHEB", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0532   hRHTYZhitsEEF = fs->make<TH2D>("hRHTYZhitsEEF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0533   hRHTYZhitsEECN = fs->make<TH2D>("hRHTYZhitsEECN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0534   hRHTYZhitsEECK = fs->make<TH2D>("hRHTYZhitsEECK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0535   hRHTYZhitsHEFF = fs->make<TH2D>("hRHTYZhitsHEFF", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0536   hRHTYZhitsHEFCN =
0537       fs->make<TH2D>("hRHTYZhitsHEFCN", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0538   hRHTYZhitsHEFCK =
0539       fs->make<TH2D>("hRHTYZhitsHEFCK", "Hits in YZ plane for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0540 
0541   hRHTRZhitsEE =
0542       fs->make<TH2D>("hRHTRZhitsEE", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0543   hRHTRZhitsHEF =
0544       fs->make<TH2D>("hRHTRZhitsHEF", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0545   hRHTRZhitsHEB =
0546       fs->make<TH2D>("hRHTRZhitsHEB", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0547   hRHTRZhitsEEF =
0548       fs->make<TH2D>("hRHTRZhitsEEF", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0549   hRHTRZhitsEECN =
0550       fs->make<TH2D>("hRHTRZhitsEECN", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0551   hRHTRZhitsEECK =
0552       fs->make<TH2D>("hRHTRZhitsEECK", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0553   hRHTRZhitsHEFF =
0554       fs->make<TH2D>("hRHTRZhitsHEFF", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0555   hRHTRZhitsHEFCN =
0556       fs->make<TH2D>("hRHTRZhitsHEFCN", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0557   hRHTRZhitsHEFCK =
0558       fs->make<TH2D>("hRHTRZhitsHEFCK", "Hits for R_{xy} vs z-axis for |X| < 20 cm", 250, 300., 550., 300, 0., 300.);
0559 
0560   hRHTGlbRZhitsF = fs->make<TH2D>("hRHTGlbRZhitsF", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
0561   hRHTGlbRZhitsCN = fs->make<TH2D>("hRHTGlbRZhitsCN", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
0562   hRHTGlbRZhitsCK = fs->make<TH2D>("hRHTGlbRZhitsCK", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
0563   hRHTGlbRZhitsSci = fs->make<TH2D>("hRHTGlbRZhitsSci", "Hits for R_{xy} vs z-axis", 250, 300., 550., 300, 0., 300.);
0564 
0565   hDiffX = fs->make<TH1D>("hDiffX", "Difference of x-position (testHGCalGeometry - RecHitTools)", 200, -20, 20);
0566   hDiffX->GetXaxis()->SetTitle("x-axis (cm)");
0567   hDiffY = fs->make<TH1D>("hDiffY", "Difference of y-position (testHGCalGeometry - RecHitTools)", 200, -20, 20);
0568   hDiffY->GetXaxis()->SetTitle("y-axis (cm)");
0569   hDiffZ = fs->make<TH1D>("hDiffZ", "Difference of z-position (testHGCalGeometry - RecHitTools)", 200, -20, 20);
0570   hDiffZ->GetXaxis()->SetTitle("z-axis (cm)");
0571 
0572   hCellThickness = fs->make<TH1D>("hCellThickness", "Cell Thickness", 500, 0, 500);
0573   hDiffZ->GetXaxis()->SetTitle("thickness (#mum)");
0574 
0575   evt = 0;
0576   winfo.clear();
0577 }
0578 
0579 //
0580 // member functions
0581 //
0582 
0583 // ------------ method called for each event  ------------
0584 void HGCalCellHitSum::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0585   if (evt == 0) {
0586     std::string fileName = geometryFileName_.fullPath();
0587     std::ifstream fin(fileName);
0588     std::string s;
0589     waferinfo wafer;
0590     //std::cout << "evt : " << evt << std::endl;
0591     while (std::getline(fin, s)) {
0592       //std::cout << "line " << s.data() << std::endl;
0593       sscanf(s.c_str(), "%d,%d,%d,%d", &wafer.layer, &wafer.u, &wafer.v, &wafer.type);
0594       //printf("%d | %d | %d | %d\n",wafer.layer,wafer.u,wafer.v,wafer.type);
0595       //wafer.layer =
0596       winfo.push_back(wafer);
0597     }
0598     fin.close();
0599   }
0600   evt++;
0601 
0602   const edm::Handle<edm::SimTrackContainer> &simtrack = iEvent.getHandle(tSimTrackContainer);
0603   int itrk = 0;
0604   //double muonpt = 0.0;
0605   edm::SimTrackContainer::const_iterator itTrack;
0606   for (itTrack = simtrack->begin(); itTrack != simtrack->end(); ++itTrack) {
0607     // int charge = itTrack->charge();
0608     int charge = itTrack->charge();
0609     hCharge->Fill(charge);
0610     if (!itTrack->noGenpart()) {
0611       hPt->Fill(itTrack->momentum().pt());
0612       hEta->Fill(itTrack->momentum().eta());
0613       hPhi->Fill(itTrack->momentum().phi());
0614     }
0615     hPDG->Fill(itTrack->type());
0616 
0617     if (itTrack->noGenpart())
0618       hPtNoGen->Fill(itTrack->momentum().pt());
0619 
0620     itrk++;
0621   }
0622 
0623   const CaloGeometry &geomCalo = iSetup.getData(caloGeomToken_);
0624   rhtools_.setGeometry(geomCalo);
0625 
0626   const HGCalGeometry *geom = &iSetup.getData(geomToken_);
0627 
0628   std::map<uint32_t, std::pair<hitsinfo, energysum> > map_hits;
0629   map_hits.clear();
0630   unsigned int nofSiHits = 0;
0631   const edm::Handle<edm::PCaloHitContainer> &simhit = iEvent.getHandle(tSimCaloHitContainer);
0632   for (edm::PCaloHitContainer::const_iterator itHit = simhit->begin(); itHit != simhit->end(); ++itHit) {
0633     if ((name_ == "HGCalEESensitive") || (name_ == "HGCalHESiliconSensitive")) {
0634       HGCSiliconDetId id(itHit->id());
0635 
0636       if (name_ == "HGCalEESensitive") {
0637         hELossEE->Fill(convertGeVToKeV(itHit->energy()));
0638         if (id.type() == HGCSiliconDetId::HGCalFine)
0639           hELossEEF->Fill(convertGeVToKeV(itHit->energy()));  //in keV
0640         if (id.type() == HGCSiliconDetId::HGCalCoarseThin)
0641           hELossEECN->Fill(convertGeVToKeV(itHit->energy()));  //in keV
0642         if (id.type() == HGCSiliconDetId::HGCalCoarseThick)
0643           hELossEECK->Fill(convertGeVToKeV(itHit->energy()));  //in keV
0644       }
0645 
0646       if (name_ == "HGCalHESiliconSensitive") {
0647         hELossHEF->Fill(convertGeVToKeV(itHit->energy()));
0648         if (id.type() == HGCSiliconDetId::HGCalFine)
0649           hELossHEFF->Fill(convertGeVToKeV(itHit->energy()));  //in keV
0650         if (id.type() == HGCSiliconDetId::HGCalCoarseThin)
0651           hELossHEFCN->Fill(convertGeVToKeV(itHit->energy()));  //in keV
0652         if (id.type() == HGCSiliconDetId::HGCalCoarseThick)
0653           hELossHEFCK->Fill(convertGeVToKeV(itHit->energy()));  //in keV
0654       }
0655     }
0656 
0657     if (name_ == "HGCalHEScintillatorSensitive")
0658       hELossHEB->Fill(convertGeVToKeV(itHit->energy()));
0659 
0660     DetId id1 = static_cast<DetId>(itHit->id());
0661     GlobalPoint global2 = rhtools_.getPosition(id1);
0662     double RXY = TMath::Sqrt(global2.x() * global2.x() + global2.y() * global2.y());
0663 
0664     // std::cout << "DetId (" << det << ": position ("<< global2.x() << ", " << global2.y() << ", " << global2.z()
0665     //        << "), Si thickness "<< rhtools_.getSiThickness(id1)
0666     //        << ", IsSi "<< rhtools_.isSilicon(id1)
0667     //        << ", IsSci "<< rhtools_.isScintillator(id1)
0668     //        << ", Layer1 "<< rhtools_.getLayer(id1)
0669     //        << ", Layer2 "<< rhtools_.getLayerWithOffset(id1)
0670     //        << ", lastLayerEE  "<< rhtools_.lastLayerEE()
0671     //        << ", lastLayerFH  "<< rhtools_.lastLayerFH()
0672     //        << ", firstLayerBH  "<< rhtools_.firstLayerBH()
0673     //        << ", lastLayerBH  "<< rhtools_.lastLayerBH()
0674     //        << ", lastLayer  "<< rhtools_.lastLayer()
0675     //        << std::endl;
0676 
0677     //if ((rhtools_.isSilicon(id1) or rhtools_.isScintillator(id1)) and TMath::Abs(global2.x())<20.0){
0678     if ((rhtools_.isSilicon(id1)) || (rhtools_.isScintillator(id1))) {
0679       if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 120., 1.e-7))
0680         hRHTGlbRZhitsF->Fill(TMath::Abs(global2.z()), RXY);
0681       else if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 200., 1.e-7))
0682         hRHTGlbRZhitsCN->Fill(TMath::Abs(global2.z()), RXY);
0683       else if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 300., 1.e-7))
0684         hRHTGlbRZhitsCK->Fill(TMath::Abs(global2.z()), RXY);
0685       else
0686         hRHTGlbRZhitsSci->Fill(TMath::Abs(global2.z()), RXY);
0687     }
0688 
0689     ///////////////////////////////////////////////////////////////////////////////////////////////
0690     if ((rhtools_.isSilicon(id1)) || (rhtools_.isScintillator(id1))) {
0691       uint32_t id_ = itHit->id();
0692 
0693       energysum esum;
0694       hitsinfo hinfo;
0695 
0696       if (map_hits.count(id_) != 0) {
0697         hinfo = map_hits[id_].first;
0698         esum = map_hits[id_].second;
0699       } else {
0700         hinfo.hitid = nofSiHits;
0701         hinfo.x = global2.x();
0702         hinfo.y = global2.y();
0703         hinfo.z = global2.z();
0704         hinfo.layer = rhtools_.getLayerWithOffset(id1);
0705         hinfo.phi = rhtools_.getPhi(id1);
0706         hinfo.eta = rhtools_.getEta(id1);
0707         for (itTrack = simtrack->begin(); itTrack != simtrack->end(); ++itTrack) {
0708           if (itTrack->trackId() == UInt_t(itHit->geantTrackId())) {
0709             hinfo.trkpt = itTrack->momentum().pt();
0710             hinfo.trketa = itTrack->momentum().eta();
0711             hinfo.trkphi = itTrack->momentum().phi();
0712             hinfo.charge = itTrack->charge();
0713             hinfo.pdg = itTrack->type();
0714           }
0715         }
0716       }
0717       esum.etotal += itHit->energy();
0718       hinfo.nhits++;
0719 
0720       HepGeom::Point3D<float> gcoord = HepGeom::Point3D<float>(global2.x(), global2.y(), global2.z());
0721       double tof = (gcoord.mag() * CLHEP::cm) / CLHEP::c_light;
0722       double time = itHit->time();
0723       time -= tof;
0724 
0725       for (unsigned int k = 0; k < 2; ++k) {
0726         if (time > 0 && time < 25.)
0727           esum.eTime[k] += itHit->energy();
0728         else {
0729           esum.eTime[k + 2] += itHit->energy();
0730         }
0731       }
0732 
0733       map_hits[id_] = std::pair<hitsinfo, energysum>(hinfo, esum);
0734       nofSiHits++;
0735     }
0736 
0737     ///////////////////////////////////////////////////////////////////////////////////////////////
0738     hEtaCell->Fill(rhtools_.getEta(id1));
0739     hPhiCell->Fill(rhtools_.getPhi(id1));
0740     ///////////////////////////////////////////////////////////////////////////////////////////////
0741 
0742     GlobalPoint global1 = geom->getPosition(id1);
0743 
0744     if (geom->topology().valid(id1)) {
0745       //std::cout << "DetId (" << det << ": position ("<< global1.x() << ", " << global1.y() << ", " << global1.z() << ") " << std::endl;
0746 
0747       //hYZhits->Fill(global1.z(),global1.y());
0748       if (TMath::Abs(global1.x()) < 20.0) {
0749         if ((name_ == "HGCalEESensitive") || (name_ == "HGCalHESiliconSensitive")) {
0750           HGCSiliconDetId id(itHit->id());
0751 
0752           if (name_ == "HGCalEESensitive") {
0753             hYZhitsEE->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0754             if (id.type() == HGCSiliconDetId::HGCalFine)
0755               hYZhitsEEF->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0756             if (id.type() == HGCSiliconDetId::HGCalCoarseThin)
0757               hYZhitsEECN->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0758             if (id.type() == HGCSiliconDetId::HGCalCoarseThick)
0759               hYZhitsEECK->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0760           }
0761 
0762           if (name_ == "HGCalHESiliconSensitive") {
0763             hYZhitsHEF->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0764             if (id.type() == HGCSiliconDetId::HGCalFine)
0765               hYZhitsHEFF->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0766             if (id.type() == HGCSiliconDetId::HGCalCoarseThin)
0767               hYZhitsHEFCN->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0768             if (id.type() == HGCSiliconDetId::HGCalCoarseThick)
0769               hYZhitsHEFCK->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0770           }
0771         }
0772 
0773         if (name_ == "HGCalHEScintillatorSensitive")
0774           hYZhitsHEB->Fill(TMath::Abs(global1.z()), TMath::Abs(global1.y()));
0775       }
0776 
0777       /// Using rechit tools
0778       //===============================================================================
0779       if (TMath::Abs(global2.x()) < 20.0) {
0780         if (rhtools_.isSilicon(id1)) {
0781           if (rhtools_.getLayerWithOffset(id1) <= rhtools_.lastLayerEE()) {
0782             hRHTYZhitsEE->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0783             hRHTRZhitsEE->Fill(TMath::Abs(global2.z()), RXY);
0784 
0785             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 120., 1.e-7)) {
0786               hRHTYZhitsEEF->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0787               hRHTRZhitsEEF->Fill(TMath::Abs(global2.z()), RXY);
0788             }
0789             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 200., 1.e-7)) {
0790               hRHTYZhitsEECN->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0791               hRHTRZhitsEECN->Fill(TMath::Abs(global2.z()), RXY);
0792             }
0793             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 300., 1.e-7)) {
0794               hRHTYZhitsEECK->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0795               hRHTRZhitsEECK->Fill(TMath::Abs(global2.z()), RXY);
0796             }
0797 
0798           } else {
0799             hRHTYZhitsHEF->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0800             hRHTRZhitsHEF->Fill(TMath::Abs(global2.z()), RXY);
0801 
0802             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 120., 1.e-7)) {
0803               hRHTYZhitsHEFF->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0804               hRHTRZhitsHEFF->Fill(TMath::Abs(global2.z()), RXY);
0805             }
0806             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 200., 1.e-7)) {
0807               hRHTYZhitsHEFCN->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0808               hRHTRZhitsHEFCN->Fill(TMath::Abs(global2.z()), RXY);
0809             }
0810             if (TMath::AreEqualAbs(rhtools_.getSiThickness(id1), 300., 1.e-7)) {
0811               hRHTYZhitsHEFCK->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0812               hRHTRZhitsHEFCK->Fill(TMath::Abs(global2.z()), RXY);
0813             }
0814           }
0815 
0816         }  //is Si
0817 
0818         if (rhtools_.isScintillator(id1)) {
0819           hRHTYZhitsHEB->Fill(TMath::Abs(global2.z()), TMath::Abs(global2.y()));
0820           hRHTRZhitsHEB->Fill(TMath::Abs(global2.z()), RXY);
0821         }
0822       }
0823       //===============================================================================
0824       hRHTXYhits->Fill(global2.x(), global2.y());
0825 
0826       hXYhits[rhtools_.getLayerWithOffset(id1) - 1]->Fill(global2.x(), global2.y());
0827 
0828       if (rhtools_.isSilicon(id1)) {
0829         HGCSiliconDetId id(itHit->id());
0830         HGCalDetId hid(itHit->id());
0831         int il = rhtools_.getLayerWithOffset(id1) - 1;
0832         if (id.type() == HGCSiliconDetId::HGCalFine) {
0833           hXYhitsF[il]->Fill(global2.x(), global2.y());
0834 
0835           if (global2.z() < 0.0)
0836             grXYhitsF0[il]->SetPoint(ixyF0[il]++, global2.x(), global2.y());
0837           else
0838             grXYhitsF1[il]->SetPoint(ixyF1[il]++, global2.x(), global2.y());
0839           if (id.zside() == -1)
0840             gXYhitsF0[il]->SetPoint(ixydF0[il]++, global2.x(), global2.y());
0841           else
0842             gXYhitsF1[il]->SetPoint(ixydF1[il]++, global2.x(), global2.y());
0843         }
0844         if (id.type() == HGCSiliconDetId::HGCalCoarseThin) {
0845           hXYhitsCN[il]->Fill(global2.x(), global2.y());
0846 
0847           if (global2.z() < 0.0)
0848             grXYhitsCN0[il]->SetPoint(ixyCN0[il]++, global2.x(), global2.y());
0849           else
0850             grXYhitsCN1[il]->SetPoint(ixyCN1[il]++, global2.x(), global2.y());
0851           if (id.zside() == -1)
0852             gXYhitsCN0[il]->SetPoint(ixydCN0[il]++, global2.x(), global2.y());
0853           else
0854             gXYhitsCN1[il]->SetPoint(ixydCN1[il]++, global2.x(), global2.y());
0855         }
0856         if (id.type() == HGCSiliconDetId::HGCalCoarseThick) {  //case 2 :
0857           hXYhitsCK[il]->Fill(global2.x(), global2.y());
0858 
0859           if (global2.z() < 0.0)
0860             grXYhitsCK0[il]->SetPoint(ixyCK0[il]++, global2.x(), global2.y());
0861           else
0862             grXYhitsCK1[il]->SetPoint(ixyCK1[il]++, global2.x(), global2.y());
0863           if (id.zside() == -1)
0864             gXYhitsCK0[il]->SetPoint(ixydCK0[il]++, global2.x(), global2.y());
0865           else
0866             gXYhitsCK1[il]->SetPoint(ixydCK1[il]++, global2.x(), global2.y());
0867         }
0868       } else if (rhtools_.isScintillator(id1)) {
0869         HGCScintillatorDetId id(itHit->id());
0870         int il = rhtools_.getLayerWithOffset(id1) - 1;
0871 
0872         hXYhitsB[il]->Fill(global2.x(), global2.y());
0873 
0874         if (global2.z() < 0.0)
0875           grXYhitsB0[il]->SetPoint(ixyB0[il]++, global2.x(), global2.y());
0876         else
0877           grXYhitsB1[il]->SetPoint(ixyB1[il]++, global2.x(), global2.y());
0878         if (id.zside() == -1)
0879           gXYhitsB0[il]->SetPoint(ixydB0[il]++, global2.x(), global2.y());
0880         else
0881           gXYhitsB1[il]->SetPoint(ixydB1[il]++, global2.x(), global2.y());
0882       }
0883     }
0884 
0885     hDiffX->Fill(global1.x() - global2.x());
0886     hDiffY->Fill(global1.y() - global2.y());
0887     hDiffZ->Fill(global1.z() - global2.z());
0888   }
0889   //std::cout << "simhit size : " << simhit->size() << ", nof hits in Si : " << nofSiHits << ", map size : " << map_hits.size() << std::endl;
0890 
0891   bool isPWafer = false;
0892   bool isFWafer = false;
0893 
0894   std::map<uint32_t, std::pair<hitsinfo, energysum> >::iterator itr;
0895   for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
0896     //uint32_t id_ = (*itr).first;
0897     hitsinfo hinfo = (*itr).second.first;
0898     energysum esum = (*itr).second.second;
0899     hELossDQMEqV[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
0900 
0901     // 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",
0902     //         name_.c_str(), hinfo.hitid, hinfo.nhits, (*itr).first, convertGeVToKeV(esum.eTime[0]), hinfo.x, hinfo.y, hinfo.z);
0903 
0904     HGCSiliconDetId id((*itr).first);
0905 
0906     // DetId id1 = static_cast<DetId>((*itr).first);
0907 
0908     // isPWafer = false;
0909     // isFWafer = false;
0910     // if(rhtools_.isSilicon(id1)){
0911     //   for(unsigned int iw = 0 ; iw < winfo.size() ; iw++){
0912     //  if(hinfo.layer == winfo[iw].layer and rhtools_.getWafer(id1).first == winfo[iw].u and rhtools_.getWafer(id1).second == winfo[iw].v){
0913     //    if(winfo[iw].type == 0)
0914     //      isPWafer = true;
0915     //    if(winfo[iw].type == 1)
0916     //      isFWafer = true;
0917     //  }
0918     //   }
0919     // }
0920 
0921     if (!TMath::AreEqualAbs(convertGeVToKeV(esum.eTime[0]), 0.0, 1.e-5)) {
0922       if (name_ == "HGCalEESensitive") {
0923         hELossCSinBunchEE->Fill(convertGeVToKeV(esum.eTime[0]));
0924         if (id.type() == HGCSiliconDetId::HGCalFine) {
0925           hELossCSinBunchEEF->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0926         }
0927         if (id.type() == HGCSiliconDetId::HGCalCoarseThin) {
0928           hELossCSinBunchEECN->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0929         }
0930         if (id.type() == HGCSiliconDetId::HGCalCoarseThick) {
0931           hELossCSinBunchEECK->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0932         }
0933       }
0934 
0935       if (name_ == "HGCalHESiliconSensitive") {
0936         hELossCSinBunchHEF->Fill(convertGeVToKeV(esum.eTime[0]));
0937         if (id.type() == HGCSiliconDetId::HGCalFine) {
0938           hELossCSinBunchHEFF->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0939           if (convertGeVToKeV(esum.eTime[0]) < 35.) {
0940             hXYLowELosshitsF->Fill(hinfo.x, hinfo.y);
0941             hYZLowELosshitsF->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
0942           }
0943         }
0944         if (id.type() == HGCSiliconDetId::HGCalCoarseThin) {
0945           hELossCSinBunchHEFCN->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0946           if (TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y) > 45.0 and
0947               TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y) < 60.0 and hinfo.layer >= 38)
0948             hELossCSinBunchHEFCNNoise->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0949           else
0950             hELossCSinBunchHEFCNFiltered->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0951           if (convertGeVToKeV(esum.eTime[0]) < 35.) {
0952             hPtLowELoss->Fill(hinfo.trkpt);
0953             hEtaLowELoss->Fill(hinfo.trketa);
0954             hPhiLowELoss->Fill(hinfo.trkphi);
0955             hChargeLowELoss->Fill(hinfo.charge);
0956             hPDGLowELoss->Fill(hinfo.pdg);
0957             hXYLowELosshitsCN->Fill(hinfo.x, hinfo.y);
0958             hYZLowELosshitsCN->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
0959             hYZLLowELosshitsHEFCN->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
0960             hXLowELosshitsHEFCN->Fill(hinfo.x);
0961             hYLowELosshitsHEFCN->Fill(hinfo.y);
0962             if (TMath::Abs(hinfo.x) < 20.0 && TMath::Abs(hinfo.y) < 20.0)
0963               hZLowELosshitsHEFCN->Fill(hinfo.z);
0964           }
0965         }
0966         if (id.type() == HGCSiliconDetId::HGCalCoarseThick) {
0967           hELossCSinBunchHEFCK->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
0968           if (convertGeVToKeV(esum.eTime[0]) < 10.) {
0969             hXYLowELosshitsCK->Fill(hinfo.x, hinfo.y);
0970             hYZLowELosshitsCK->Fill(TMath::Abs(hinfo.z), TMath::Sqrt(hinfo.x * hinfo.x + hinfo.y * hinfo.y));
0971           }
0972         }
0973       }
0974     }
0975 
0976     if (!TMath::AreEqualAbs(convertGeVToKeV(esum.eTime[2]), 0.0, 1.e-5)) {
0977       if (name_ == "HGCalEESensitive") {
0978         hELossCSmissedEE->Fill(convertGeVToKeV(esum.eTime[2]));
0979         if (id.type() == HGCSiliconDetId::HGCalFine)
0980           hELossCSmissedEEF->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
0981         if (id.type() == HGCSiliconDetId::HGCalCoarseThin)
0982           hELossCSmissedEECN->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
0983         if (id.type() == HGCSiliconDetId::HGCalCoarseThick)
0984           hELossCSmissedEECK->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
0985         hXYmissedhits->Fill(hinfo.x, hinfo.y);
0986         hYZmissedhits->Fill(TMath::Abs(hinfo.z), TMath::Abs(hinfo.y));
0987       }
0988 
0989       if (name_ == "HGCalHESiliconSensitive") {
0990         hELossCSmissedHEF->Fill(convertGeVToKeV(esum.eTime[2]));
0991         if (id.type() == HGCSiliconDetId::HGCalFine)
0992           hELossCSmissedHEFF->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
0993         if (id.type() == HGCSiliconDetId::HGCalCoarseThin)
0994           hELossCSmissedHEFCN->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
0995         if (id.type() == HGCSiliconDetId::HGCalCoarseThick)
0996           hELossCSmissedHEFCK->Fill(convertGeVToKeV(esum.eTime[2]));  //in keV
0997         hXYmissedhits->Fill(hinfo.x, hinfo.y);
0998         hYZmissedhits->Fill(TMath::Abs(hinfo.z), TMath::Abs(hinfo.y));
0999       }
1000     }
1001   }
1002 
1003   std::vector<uint32_t> cellMaxEdep;
1004   cellMaxEdep.clear();
1005   for (int il = 1; il <= 50; il++) {
1006     double energy = 0.;
1007     uint32_t maxid = 0;
1008     double maxEsum = 0.0;
1009     for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
1010       //uint32_t id_ = (*itr).first;
1011       hitsinfo hinfo = (*itr).second.first;
1012       energysum esum = (*itr).second.second;
1013       // printf("\tDet : %s, first hit : %d, nhits : %u, id : %u, Edep : %5.2lf (keV), (x,y,z) : (%lf,%lf,%lf)\n",
1014       //       name_.c_str(), hinfo.hitid, hinfo.nhits, (*itr).first, convertGeVToKeV(esum.etotal), hinfo.x, hinfo.y, hinfo.z);
1015 
1016       if (hinfo.layer == il and hinfo.z > 0.) {
1017         energy += esum.eTime[0];
1018 
1019         if (esum.eTime[0] > maxEsum) {
1020           maxEsum = esum.eTime[0];
1021           maxid = (*itr).first;
1022         }
1023 
1024       }  //match layer and z-direction
1025 
1026     }  //map loop
1027 
1028     if (convertGeVToKeV(maxEsum) > 0.)
1029       cellMaxEdep.push_back(maxid);
1030     if (convertGeVToKeV(energy) > 0.)
1031       hELossLayer[il - 1]->Fill(convertGeVToKeV(energy));  //in keV
1032   }
1033 
1034   // waferinfo wafer;
1035   // winfo.push_back(wafer);
1036   //std::cout<<"size :: "<<winfo.size()<<std::endl;
1037 
1038   for (unsigned int ic = 0; ic < cellMaxEdep.size(); ic++) {
1039     uint32_t id_ = cellMaxEdep[ic];
1040     energysum esum = map_hits[id_].second;
1041     hitsinfo hinfo = map_hits[id_].first;
1042     DetId id1 = static_cast<DetId>(id_);
1043 
1044     if (!rhtools_.isSilicon(id1))
1045       continue;
1046 
1047     HGCSiliconDetId id(id_);
1048     HGCalDetId hid(id);
1049 
1050     isPWafer = false;
1051     isFWafer = false;
1052     for (unsigned int iw = 0; iw < winfo.size(); iw++) {
1053       if (hinfo.layer == winfo[iw].layer and rhtools_.getWafer(id1).first == winfo[iw].u and
1054           rhtools_.getWafer(id1).second == winfo[iw].v) {
1055         if (winfo[iw].type == 0)
1056           isPWafer = true;
1057         if (winfo[iw].type == 1)
1058           isFWafer = true;
1059       }
1060     }
1061 
1062     // 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",
1063     //     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);
1064 
1065     // printf("\tDet : %s, wafertype : %d, layer : %d, (u,v) : (%d,%d), isPWafer : %d, isFWafer : %d, (x,y,z) : (%lf,%lf,%lf)\n",
1066     //     name_.c_str(), hid.waferType(), hinfo.layer, rhtools_.getWafer(id1).first, rhtools_.getWafer(id1).second, isPWafer, isFWafer, hinfo.x, hinfo.y, hinfo.z);
1067 
1068     //for
1069 
1070     if (name_ == "HGCalEESensitive") {
1071       hCellThickness->Fill(rhtools_.getSiThickness(id1));
1072       hELossCSMaxEE->Fill(convertGeVToKeV(esum.eTime[0]));
1073       if (id.type() == HGCSiliconDetId::HGCalFine) {
1074         hELossCSMaxEEF->Fill(convertGeVToKeV(esum.eTime[0]));              //in keV
1075         hELCSMaxF[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1076         if (isPWafer) {
1077           hNHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1078           hNHxELCSMaxF[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1079           hNHxXYhitsF[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1080         }
1081         if (isFWafer) {
1082           hHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1083           hHxELCSMaxF[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1084         }
1085       }
1086       if (id.type() == HGCSiliconDetId::HGCalCoarseThin) {
1087         hELossCSMaxEECN->Fill(convertGeVToKeV(esum.eTime[0]));              //in keV
1088         hELCSMaxCN[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1089         if (isPWafer) {
1090           hNHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1091           hNHxELCSMaxCN[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1092           hNHxXYhitsCN[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1093         }
1094         if (isFWafer) {
1095           hHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1096           hHxELCSMaxCN[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1097         }
1098       }
1099       if (id.type() == HGCSiliconDetId::HGCalCoarseThick) {
1100         hELossCSMaxEECK->Fill(convertGeVToKeV(esum.eTime[0]));              //in keV
1101         hELCSMaxCK[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1102         if (isPWafer) {
1103           hNHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1104           hNHxELCSMaxCK[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1105           hNHxXYhitsCK[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1106         }
1107         if (isFWafer) {
1108           hHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1109           hHxELCSMaxCK[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1110         }
1111       }
1112     }
1113 
1114     if (name_ == "HGCalHESiliconSensitive") {
1115       hCellThickness->Fill(rhtools_.getSiThickness(id1));
1116       hELossCSMaxHEF->Fill(convertGeVToKeV(esum.eTime[0]));
1117       if (id.type() == HGCSiliconDetId::HGCalFine) {
1118         hELossCSMaxHEFF->Fill(convertGeVToKeV(esum.eTime[0]));             //in keV
1119         hELCSMaxF[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1120         if (isPWafer) {
1121           hNHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1122           hNHxELCSMaxF[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1123           hNHxXYhitsF[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1124         }
1125         if (isFWafer) {
1126           hHxELossCSMaxF->Fill(convertGeVToKeV(esum.eTime[0]));
1127           hHxELCSMaxF[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1128         }
1129       }
1130       if (id.type() == HGCSiliconDetId::HGCalCoarseThin) {
1131         hELossCSMaxHEFCN->Fill(convertGeVToKeV(esum.eTime[0]));             //in keV
1132         hELCSMaxCN[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1133         if (convertGeVToKeV(esum.eTime[0]) < 30. and convertGeVToKeV(esum.eTime[0]) > 10.)
1134           hXYhitsLELCN[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1135         else
1136           hXYhitsHELCN[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1137         if (isPWafer) {
1138           hNHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1139           hNHxELCSMaxCN[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1140           hNHxXYhitsCN[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1141         }
1142         if (isFWafer) {
1143           hHxELossCSMaxCN->Fill(convertGeVToKeV(esum.eTime[0]));
1144           hHxELCSMaxCN[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1145         }
1146       }
1147       if (id.type() == HGCSiliconDetId::HGCalCoarseThick) {
1148         hELossCSMaxHEFCK->Fill(convertGeVToKeV(esum.eTime[0]));             //in keV
1149         hELCSMaxCK[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));  //in keV
1150         if (convertGeVToKeV(esum.eTime[0]) < 10.)
1151           hXYhitsLELCK[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1152         else if (convertGeVToKeV(esum.eTime[0]) > 50.)
1153           hXYhitsHELCK[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1154         if (isPWafer) {
1155           hNHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1156           hNHxELCSMaxCK[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1157           hNHxXYhitsCK[hinfo.layer - 1]->Fill(hinfo.x, hinfo.y);
1158         }
1159         if (isFWafer) {
1160           hHxELossCSMaxCK->Fill(convertGeVToKeV(esum.eTime[0]));
1161           hHxELCSMaxCK[hinfo.layer - 1]->Fill(convertGeVToKeV(esum.eTime[0]));
1162         }
1163       }
1164     }
1165   }
1166 
1167   map_hits.clear();
1168 }
1169 
1170 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
1171 void HGCalCellHitSum::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
1172   edm::ParameterSetDescription desc;
1173   desc.add<edm::InputTag>("simtrack", edm::InputTag("g4SimHits"));
1174   desc.add<edm::InputTag>("simhits", edm::InputTag("g4SimHits", "HGCHitsEE"));
1175   desc.add<std::string>("detector", "HGCalEESensitive");
1176   desc.add<edm::FileInPath>("geometryFileName", edm::FileInPath("Validation/HGCalValidation/data/wafer_v17.csv"));
1177   descriptions.add("hgcalCellHitSum", desc);
1178 }
1179 
1180 //define this as a plug-in
1181 DEFINE_FWK_MODULE(HGCalCellHitSum);