Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-11 02:41:12

0001 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0002 // Package:    ZdcSimHitStudy
0003 // Class:      ZdcSimHitStudy
0004 //
0005 /*
0006   Description:
0007   This code has been developed to be a check for the ZDC sim. In 2009, it was
0008   found that the ZDC Simulation was unrealistic and needed repair. The aim of
0009   this code is to show the user the input and output of a ZDC MinBias
0010   simulation.
0011 
0012   Implementation:
0013   First a MinBias simulation should be run, it could be pythia,hijin,or hydjet.
0014   This will output a .root file which should have information about
0015   recoGenParticles, and g4SimHits_ZDCHits. Use this .root file as the input into
0016   the cfg.py which is found in the main directory of this package. This output
0017   will be another .root file which is meant to be viewed in a TBrowser.
0018 
0019 */
0020 //
0021 // Original Author: Jaime Gomez (U. of Maryland) with SIGNIFICANT assistance of
0022 // Dr. Jefferey Temple (U. of Maryland) Adapted from: E. Garcia-Solis' (CSU)
0023 // original code
0024 //
0025 //         Created:  Summer 2012
0026 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0027 
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/Frameworkfwd.h"
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/ServiceRegistry/interface/Service.h"
0034 #include "FWCore/Utilities/interface/Exception.h"
0035 
0036 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0037 #include "DQMServices/Core/interface/DQMStore.h"
0038 
0039 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0040 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0041 
0042 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0043 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0044 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
0045 
0046 #include <fstream>
0047 #include <iostream>
0048 #include <map>
0049 #include <memory>
0050 #include <string>
0051 #include <vector>
0052 
0053 class ZdcSimHitStudy : public DQMEDAnalyzer {
0054 public:
0055   ZdcSimHitStudy(const edm::ParameterSet &ps);
0056   ~ZdcSimHitStudy() override = default;
0057 
0058 protected:
0059   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0060 
0061   void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0062   void analyzeHits(std::vector<PCaloHit> &);
0063   int FillHitValHist(int side, int section, int channel, double energy, double time);
0064 
0065 private:
0066   double enetotEmN, enetotHadN, enetotN;
0067   double enetotEmP, enetotHadP, enetotP;
0068   double enetot;
0069 
0070   /////////////////////////////////////////
0071   //#   Below all the monitoring elements #
0072   //# are simply the plots "code names"  #
0073   //# they will be filled in the .cc file #
0074   /////////////////////////////////////////
0075 
0076   const std::string g4Label, zdcHits, outFile_;
0077   const bool verbose_, checkHit_;
0078   const edm::EDGetTokenT<reco::GenParticleCollection> tok_gen_;
0079   const edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
0080 
0081   MonitorElement *meAllZdcNHit_, *meBadZdcDetHit_, *meBadZdcSecHit_, *meBadZdcIdHit_;
0082   MonitorElement *meZdcNHit_, *meZdcDetectHit_, *meZdcSideHit_, *meZdcETime_;
0083   MonitorElement *meZdcNHitEM_, *meZdcNHitHad_, *meZdcNHitLum_, *meZdc10Ene_;
0084   MonitorElement *meZdcSectionHit_, *meZdcChannelHit_, *meZdcEnergyHit_, *meZdcTimeWHit_;
0085   MonitorElement *meZdcHadEnergyHit_, *meZdcEMEnergyHit_, *meZdcTimeHit_, *meZdcHadL10EneP_;
0086   MonitorElement *meZdc10EneP_, *meZdcEHadCh_, *meZdcEEMCh_, *meZdcEML10EneP_;
0087   MonitorElement *meZdcEneEmN1_, *meZdcEneEmN2_, *meZdcEneEmN3_, *meZdcEneEmN4_, *meZdcEneEmN5_;
0088   MonitorElement *meZdcEneHadN1_, *meZdcEneHadN2_, *meZdcEneHadN3_, *meZdcEneHadN4_;
0089   MonitorElement *meZdcEneTEmN1_, *meZdcEneTEmN2_, *meZdcEneTEmN3_, *meZdcEneTEmN4_, *meZdcEneTEmN5_;
0090   MonitorElement *meZdcEneTHadN1_, *meZdcEneTHadN2_, *meZdcEneTHadN3_, *meZdcEneTHadN4_;
0091   MonitorElement *meZdcEneHadNTot_, *meZdcEneEmNTot_, *meZdcEneNTot_;
0092   MonitorElement *meZdcCorEEmNEHadN_;
0093   MonitorElement *meZdcEneEmP1_, *meZdcEneEmP2_, *meZdcEneEmP3_, *meZdcEneEmP4_, *meZdcEneEmP5_;
0094   MonitorElement *meZdcEneHadP1_, *meZdcEneHadP2_, *meZdcEneHadP3_, *meZdcEneHadP4_;
0095   MonitorElement *meZdcEneTEmP1_, *meZdcEneTEmP2_, *meZdcEneTEmP3_, *meZdcEneTEmP4_, *meZdcEneTEmP5_;
0096   MonitorElement *meZdcEneTHadP1_, *meZdcEneTHadP2_, *meZdcEneTHadP3_, *meZdcEneTHadP4_;
0097   MonitorElement *meZdcEneHadPTot_, *meZdcEneEmPTot_, *meZdcEnePTot_;
0098   MonitorElement *meZdcCorEEmPEHadP_, *meZdcCorEtotNEtotP_, *meZdcEneTot_;
0099 
0100   ///////////////////New Plots/////////////
0101 
0102   ////////GenParticle Plots///////
0103   MonitorElement *genpart_Pi0F;
0104   MonitorElement *genpart_Pi0F_energydist;
0105   MonitorElement *genpart_Pi0B;
0106   MonitorElement *genpart_Pi0B_energydist;
0107   MonitorElement *genpart_NeutF;
0108   MonitorElement *genpart_NeutF_energydist;
0109   MonitorElement *genpart_NeutB;
0110   MonitorElement *genpart_NeutB_energydist;
0111   MonitorElement *genpart_GammaF;
0112   MonitorElement *genpart_GammaF_energydist;
0113   MonitorElement *genpart_GammaB;
0114   MonitorElement *genpart_GammaB_energydist;
0115   //////////////////////////////
0116 
0117   // N counts plots
0118   MonitorElement *genpart_Pi0F_counts;
0119   MonitorElement *genpart_Pi0B_counts;
0120   MonitorElement *genpart_NeutF_counts;
0121   MonitorElement *genpart_NeutB_counts;
0122   MonitorElement *genpart_GammaF_counts;
0123   MonitorElement *genpart_GammaB_counts;
0124 };
0125 
0126 ZdcSimHitStudy::ZdcSimHitStudy(const edm::ParameterSet &ps)
0127     : g4Label(ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits")),
0128       zdcHits(ps.getUntrackedParameter<std::string>("HitCollection", "ZdcHits")),
0129       outFile_(ps.getUntrackedParameter<std::string>("outputFile", "zdcHitStudy.root")),
0130       verbose_(ps.getUntrackedParameter<bool>("Verbose", false)),
0131       checkHit_(true),
0132       tok_gen_(consumes<reco::GenParticleCollection>(edm::InputTag("genParticles"))),
0133       tok_hits_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, zdcHits))) {
0134   edm::LogVerbatim("ZdcSimHitStudy") << "Module Label: " << g4Label << "   Hits: " << zdcHits << " / " << checkHit_
0135                                      << "   Output: " << outFile_;
0136 }
0137 
0138 void ZdcSimHitStudy::bookHistograms(DQMStore::IBooker &ib, edm::Run const &run, edm::EventSetup const &es) {
0139   ib.setCurrentFolder("ZDCValidation");
0140   // Histograms for Hits
0141   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0142   //# Below we are filling the histograms made in the .h file. The syntax is as
0143   // follows:                                      # # plot_code_name =
0144   // ib.TypeofPlot[(1,2,3)-D,(F,I,D)]("Name as it will appear","Title",axis
0145   // options);                    # # They will be stored in the TFile
0146   // subdirectory set by :    ib.setCurrentFolder("FolderIwant") # # axis
0147   // options are like (#ofbins,min,max) #
0148   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0149 
0150   if (checkHit_) {
0151     /////////////////////////1///////////////////////////
0152     ib.setCurrentFolder("ZDCValidation/ZdcSimHits");
0153     meAllZdcNHit_ = ib.book1D("ZDC Hits", "Number of All Hits in ZDC", 100, 0., 100.);
0154     meAllZdcNHit_->setAxisTitle("Total Hits", 1);
0155     meAllZdcNHit_->setAxisTitle("Counts", 2);
0156     /////////////////////////2///////////////////////////
0157     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/Excess_Info/Debug_Helper");
0158     meBadZdcDetHit_ = ib.book1D("Hiits with the wrong Det", "Hits with wrong Det in ZDC", 100, 0., 100.);
0159     meBadZdcDetHit_->setAxisTitle("Wrong Hits", 1);
0160     meBadZdcDetHit_->setAxisTitle("Counts", 2);
0161     /////////////////////////3///////////////////////////
0162     meBadZdcSecHit_ = ib.book1D("Wrong Section Hits", "Hits with wrong Section in ZDC", 100, 0., 100.);
0163     meBadZdcSecHit_->setAxisTitle("Hits in wrong section", 1);
0164     meBadZdcSecHit_->setAxisTitle("Counts", 2);
0165     /////////////////////////4///////////////////////////
0166     meBadZdcIdHit_ = ib.book1D("Wrong_ID_Hits", "Hits with wrong ID in ZDC", 100, 0., 100.);
0167     meBadZdcIdHit_->setAxisTitle("Hits with wrong ID", 1);
0168     meBadZdcIdHit_->setAxisTitle("Counts", 2);
0169     /////////////////////////5///////////////////////////
0170     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/Excess_Info/BasicHitInfo");
0171     meZdcNHitEM_ = ib.book1D("Hits in EM", "Number of Hits in ZDC EM", 100, 0., 100.);
0172     meZdcNHitEM_->setAxisTitle("EM Hits", 1);
0173     meZdcNHitEM_->setAxisTitle("Counts", 2);
0174     /////////////////////////6///////////////////////////
0175     meZdcNHitHad_ = ib.book1D("Hits in HAD", "Number of Hits in ZDC Had", 100, 0., 100.);
0176     meZdcNHitHad_->setAxisTitle("HAD Hits", 1);
0177     meZdcNHitHad_->setAxisTitle("Counts", 2);
0178     /////////////////////////7///////////////////////////
0179     meZdcNHitLum_ = ib.book1D("Hits in LUM", "Number of Hits in ZDC Lum", 100, 0., 100.);
0180     meZdcNHitLum_->setAxisTitle("LUM Hits", 1);
0181     meZdcNHitLum_->setAxisTitle("Counts", 2);
0182     /////////////////////////8///////////////////////////
0183     meZdcDetectHit_ = ib.book1D("Calo Detector ID", "Calo Detector ID", 50, 0., 50.);
0184     meZdcDetectHit_->setAxisTitle("Detector Hits", 1);
0185     meZdcDetectHit_->setAxisTitle("Counts", 2);
0186     /////////////////////////9///////////////////////////
0187     meZdcSideHit_ = ib.book1D("ZDC Side", "Side in ZDC", 4, -2, 2.);
0188     meZdcSideHit_->setAxisTitle("ZDC Side", 1);
0189     meZdcSideHit_->setAxisTitle("Counts", 2);
0190     /////////////////////////10///////////////////////////
0191     meZdcSectionHit_ = ib.book1D("ZDC Section", "Section in ZDC", 4, 0., 4.);
0192     meZdcSectionHit_->setAxisTitle("ZDC Section", 1);
0193     meZdcSectionHit_->setAxisTitle("Counts", 2);
0194     /////////////////////////11///////////////////////////
0195     meZdcChannelHit_ = ib.book1D("ZDC Channel", "Channel in ZDC", 10, 0., 10.);
0196     meZdcChannelHit_->setAxisTitle("ZDC Channel", 1);
0197     meZdcChannelHit_->setAxisTitle("Counts", 2);
0198     /////////////////////////12///////////////////////////
0199     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/");
0200     meZdcEnergyHit_ = ib.book1D("Hit Energy", "Hits Energy", 4000, 0., 8000.);
0201     meZdcEnergyHit_->setAxisTitle("Counts", 2);
0202     meZdcEnergyHit_->setAxisTitle("Energy (GeV)", 1);
0203     /////////////////////////13///////////////////////////
0204     meZdcHadEnergyHit_ = ib.book1D("Hit Energy HAD", "Hits Energy in Had Section", 4000, 0., 8000.);
0205     meZdcHadEnergyHit_->setAxisTitle("Counts", 2);
0206     meZdcHadEnergyHit_->setAxisTitle("Energy (GeV)", 1);
0207     /////////////////////////14///////////////////////////
0208     meZdcEMEnergyHit_ = ib.book1D("Hit Energy EM", "Hits Energy in EM Section", 4000, 0., 8000.);
0209     meZdcEMEnergyHit_->setAxisTitle("Counts", 2);
0210     meZdcEMEnergyHit_->setAxisTitle("Energy (GeV)", 1);
0211     /////////////////////////15///////////////////////////
0212     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/Excess_Info/BasicHitInfo");
0213     meZdcTimeHit_ = ib.book1D("Time in ZDC", "Time in ZDC", 300, 0., 600.);
0214     meZdcTimeHit_->setAxisTitle("Time (ns)", 1);
0215     meZdcTimeHit_->setAxisTitle("Counts", 2);
0216     /////////////////////////16///////////////////////////
0217     meZdcTimeWHit_ = ib.book1D("Energy Weighted Time in ZDC", "Time in ZDC (E wtd)", 300, 0., 600.);
0218     meZdcTimeWHit_->setAxisTitle("Time (ns)", 1);
0219     meZdcTimeWHit_->setAxisTitle("Counts", 2);
0220     /////////////////////////17///////////////////////////
0221     meZdc10Ene_ = ib.book1D("ZDC Log(E)", "Log10Energy in ZDC", 140, -20., 20.);
0222     meZdc10Ene_->setAxisTitle("Log(E) (GeV)", 1);
0223     meZdc10Ene_->setAxisTitle("Counts", 2);
0224     /////////////////////////18///////////////////////////
0225     meZdcHadL10EneP_ = ib.bookProfile(
0226         "Log(EHAD) vs Contribution", "Log10Energy in Had ZDC vs Hit contribution", 140, -1., 20., 100, 0., 1.);
0227     meZdcHadL10EneP_->setAxisTitle("Log(EHAD) (GeV)", 1);
0228     meZdcHadL10EneP_->setAxisTitle("Counts", 2);
0229     /////////////////////////19///////////////////////////
0230     meZdcEML10EneP_ = ib.bookProfile(
0231         "Log(EEM) vs Contribution", "Log10Energy in EM ZDC vs Hit contribution", 140, -1., 20., 100, 0., 1.);
0232     meZdcEML10EneP_->setAxisTitle("Log(EEM) (GeV)", 1);
0233     meZdcEML10EneP_->setAxisTitle("Counts", 2);
0234     /////////////////////////20///////////////////////////
0235     ib.setCurrentFolder("ZDCValidation/ZdcSimHits");
0236     meZdcEHadCh_ = ib.book2D("ZDC EHAD vs Channel", "ZDC Had Section Energy vs Channel", 4000, 0., 8000., 6, 0., 6.);
0237     meZdcEHadCh_->setAxisTitle("Hadronic Channel Number", 2);
0238     meZdcEHadCh_->setAxisTitle("Energy (GeV)", 1);
0239     /////////////////////////21///////////////////////////
0240     meZdcEEMCh_ = ib.book2D("ZDC EEM vs Channel", "ZDC EM Section Energy vs Channel", 4000, 0., 8000., 6, 0., 6.);
0241     meZdcEEMCh_->setAxisTitle("EM Channel Number", 2);
0242     meZdcEEMCh_->setAxisTitle("Energy (GeV)", 1);
0243     /////////////////////////22///////////////////////////
0244     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/Excess_Info/BasicHitInfo");
0245     meZdcETime_ = ib.book2D("E vs T", "Hits ZDC Energy vs Time", 4000, 0., 8000., 300, 0., 600.);
0246     meZdcETime_->setAxisTitle("Energy (GeV)", 1);
0247     meZdcETime_->setAxisTitle("Time (ns)", 2);
0248     /////////////////////////23///////////////////////////
0249     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS/Individual_Channels/NZDC");
0250     meZdcEneEmN1_ = ib.book1D("NZDC EM1 Energy", "Energy EM module N1", 4000, 0., 8000.);
0251     meZdcEneEmN1_->setAxisTitle("Energy (GeV)", 1);
0252     meZdcEneEmN1_->setAxisTitle("Counts", 2);
0253     /////////////////////////24///////////////////////////
0254     meZdcEneEmN2_ = ib.book1D("NZDC EM2 Energy", "Energy EM module N2", 4000, 0., 8000.);
0255     meZdcEneEmN2_->setAxisTitle("Energy (GeV)", 1);
0256     meZdcEneEmN2_->setAxisTitle("Counts", 2);
0257     /////////////////////////25///////////////////////////
0258     meZdcEneEmN3_ = ib.book1D("NZDC EM3 Energy", "Energy EM module N3", 4000, 0., 8000.);
0259     meZdcEneEmN3_->setAxisTitle("Energy (GeV)", 1);
0260     meZdcEneEmN3_->setAxisTitle("Counts", 2);
0261     /////////////////////////26///////////////////////////
0262     meZdcEneEmN4_ = ib.book1D("NZDC EM4 Energy", "Energy EM module N4", 4000, 0., 8000.);
0263     meZdcEneEmN4_->setAxisTitle("Energy (GeV)", 1);
0264     meZdcEneEmN4_->setAxisTitle("Counts", 2);
0265     /////////////////////////27///////////////////////////
0266     meZdcEneEmN5_ = ib.book1D("NZDC EM5 Energy", "Energy EM module N5", 4000, 0., 8000.);
0267     meZdcEneEmN5_->setAxisTitle("Energy (GeV)", 1);
0268     meZdcEneEmN5_->setAxisTitle("Counts", 2);
0269     /////////////////////////28///////////////////////////
0270     meZdcEneHadN1_ = ib.book1D("NZDC HAD1 Energy", "Energy HAD module N1", 4000, 0., 8000.);
0271     meZdcEneHadN1_->setAxisTitle("Energy (GeV)", 1);
0272     meZdcEneHadN1_->setAxisTitle("Counts", 2);
0273     /////////////////////////29///////////////////////////
0274     meZdcEneHadN2_ = ib.book1D("NZDC HAD2 Energy", "Energy HAD module N2", 4000, 0., 8000.);
0275     meZdcEneHadN2_->setAxisTitle("Energy (GeV)", 1);
0276     meZdcEneHadN2_->setAxisTitle("Counts", 2);
0277     /////////////////////////30///////////////////////////
0278     meZdcEneHadN3_ = ib.book1D("NZDC HAD3 Energy", "Energy HAD module N3", 4000, 0., 8000.);
0279     meZdcEneHadN3_->setAxisTitle("Energy (GeV)", 1);
0280     meZdcEneHadN3_->setAxisTitle("Counts", 2);
0281     /////////////////////////31///////////////////////////
0282     meZdcEneHadN4_ = ib.book1D("NZDC HAD4 Energy", "Energy HAD module N4", 4000, 0., 8000.);
0283     meZdcEneHadN4_->setAxisTitle("Energy (GeV)", 1);
0284     meZdcEneHadN4_->setAxisTitle("Counts", 2);
0285     /////////////////////////32///////////////////////////
0286     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/Excess_Info/Individual_ChannelvsTime/NZDC");
0287     meZdcEneTEmN1_ = ib.book2D("NZDC EM1 Energy vs Time", "Energy EM mod N1 vs Time", 4000, 0., 8000., 300, 0., 600.);
0288     meZdcEneTEmN1_->setAxisTitle("Energy (GeV)", 1);
0289     meZdcEneTEmN1_->setAxisTitle("Time (ns)", 2);
0290     /////////////////////////33///////////////////////////
0291     meZdcEneTEmN2_ = ib.book2D("NZDC EM2 Energy vs Time", "Energy EM mod N2 vs Time", 4000, 0., 8000., 300, 0., 600.);
0292     meZdcEneTEmN2_->setAxisTitle("Energy (GeV)", 1);
0293     meZdcEneTEmN2_->setAxisTitle("Time (ns)", 2);
0294     /////////////////////////34///////////////////////////
0295     meZdcEneTEmN3_ = ib.book2D("NZDC EM3 Energy vs Time", "Energy EM mod N3 vs Time", 4000, 0., 8000., 300, 0., 600.);
0296     meZdcEneTEmN3_->setAxisTitle("Energy (GeV)", 1);
0297     meZdcEneTEmN3_->setAxisTitle("Time (ns)", 2);
0298     /////////////////////////35///////////////////////////
0299     meZdcEneTEmN4_ = ib.book2D("NZDC EM4 Energy vs Time", "Energy EM mod N4 vs Time", 4000, 0., 8000., 300, 0., 600.);
0300     meZdcEneTEmN4_->setAxisTitle("Energy (GeV)", 1);
0301     meZdcEneTEmN4_->setAxisTitle("Time (ns)", 2);
0302     /////////////////////////36///////////////////////////
0303     meZdcEneTEmN5_ = ib.book2D("NZDC EM5 Energy vs Time", "Energy EM mod N5 vs Time", 4000, 0., 8000., 300, 0., 600.);
0304     meZdcEneTEmN5_->setAxisTitle("Energy (GeV)", 1);
0305     meZdcEneTEmN5_->setAxisTitle("Time (ns)", 2);
0306     /////////////////////////37///////////////////////////
0307     meZdcEneTHadN1_ =
0308         ib.book2D("NZDC HAD1 Energy vs Time", "Energy HAD mod N1 vs Time", 4000, 0., 8000., 300, 0., 600.);
0309     meZdcEneTHadN1_->setAxisTitle("Energy (GeV)", 1);
0310     meZdcEneTHadN1_->setAxisTitle("Time (ns)", 2);
0311     /////////////////////////38///////////////////////////
0312     meZdcEneTHadN2_ =
0313         ib.book2D("NZDC HAD2 Energy vs Time", "Energy HAD mod N2 vs Time", 4000, 0., 8000., 300, 0., 600.);
0314     meZdcEneTHadN2_->setAxisTitle("Energy (GeV)", 1);
0315     meZdcEneTHadN2_->setAxisTitle("Time (ns)", 2);
0316     /////////////////////////39///////////////////////////
0317     meZdcEneTHadN3_ =
0318         ib.book2D("NZDC HAD3 Energy vs Time", "Energy HAD mod N3 vs Time", 4000, 0., 8000., 300, 0., 600.);
0319     meZdcEneTHadN3_->setAxisTitle("Energy (GeV)", 1);
0320     meZdcEneTHadN3_->setAxisTitle("Time (ns)", 2);
0321     /////////////////////////40///////////////////////////
0322     meZdcEneTHadN4_ =
0323         ib.book2D("NZDC HAD4 Energy vs Time", "Energy HAD mod N4 vs Time", 4000, 0., 8000., 300, 0., 600.);
0324     meZdcEneTHadN4_->setAxisTitle("Energy (GeV)", 1);
0325     meZdcEneTHadN4_->setAxisTitle("Time (ns)", 2);
0326     /////////////////////////41///////////////////////////
0327     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS/NZDC");
0328     meZdcEneHadNTot_ = ib.book1D("NZDC EHAD", "Total N-ZDC HAD Energy", 4000, 0., 4000.);
0329     meZdcEneHadNTot_->setAxisTitle("Counts", 2);
0330     meZdcEneHadNTot_->setAxisTitle("Energy (GeV)", 1);
0331     /////////////////////////42///////////////////////////
0332     meZdcEneEmNTot_ = ib.book1D("NZDC EEM", "Total N-ZDC EM Energy", 3000, 0., 3000.);
0333     meZdcEneEmNTot_->setAxisTitle("Counts", 2);
0334     meZdcEneEmNTot_->setAxisTitle("Energy (GeV)", 1);
0335     /////////////////////////43///////////////////////////
0336     meZdcEneNTot_ = ib.book1D("NZDC ETOT", "Total N-ZDC Energy ", 7000, 0., 7000.);
0337     meZdcEneNTot_->setAxisTitle("Counts", 2);
0338     meZdcEneNTot_->setAxisTitle("Energy (GeV)", 1);
0339     /////////////////////////44///////////////////////////
0340     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS/Individual_Channels/PZDC");
0341     meZdcEneEmP1_ = ib.book1D("PZDC EM1 Energy", "Energy EM module P1", 3000, 0., 3000.);
0342     meZdcEneEmP1_->setAxisTitle("Energy (GeV)", 1);
0343     meZdcEneEmP1_->setAxisTitle("Counts", 2);
0344     /////////////////////////45///////////////////////////
0345     meZdcEneEmP2_ = ib.book1D("PZDC EM2 Energy", "Energy EM module P2", 3000, 0., 3000.);
0346     meZdcEneEmP2_->setAxisTitle("Energy (GeV)", 1);
0347     meZdcEneEmP2_->setAxisTitle("Counts", 2);
0348     /////////////////////////46///////////////////////////
0349     meZdcEneEmP3_ = ib.book1D("PZDC EM3 Energy", "Energy EM module P3", 3000, 0., 3000.);
0350     meZdcEneEmP3_->setAxisTitle("Energy (GeV)", 1);
0351     meZdcEneEmP3_->setAxisTitle("Counts", 2);
0352     /////////////////////////47///////////////////////////
0353     meZdcEneEmP4_ = ib.book1D("PZDC EM4 Energy", "Energy EM module P4", 3000, 0., 3000.);
0354     meZdcEneEmP4_->setAxisTitle("Energy (GeV)", 1);
0355     meZdcEneEmP4_->setAxisTitle("Counts", 2);
0356     /////////////////////////48///////////////////////////
0357     meZdcEneEmP5_ = ib.book1D("PZDC EM5 Energy", "Energy EM module P5", 3000, 0., 3000.);
0358     meZdcEneEmP5_->setAxisTitle("Energy (GeV)", 1);
0359     meZdcEneEmP5_->setAxisTitle("Counts", 2);
0360     /////////////////////////49///////////////////////////
0361     meZdcEneHadP1_ = ib.book1D("PZDC HAD1 Energy", "Energy HAD module P1", 3000, 0., 3000.);
0362     meZdcEneHadP1_->setAxisTitle("Energy (GeV)", 1);
0363     meZdcEneHadP1_->setAxisTitle("Counts", 2);
0364     /////////////////////////50///////////////////////////
0365     meZdcEneHadP2_ = ib.book1D("PZDC HAD2 Energy", "Energy HAD module P2", 3000, 0., 3000.);
0366     meZdcEneHadP2_->setAxisTitle("Energy (GeV)", 1);
0367     meZdcEneHadP2_->setAxisTitle("Counts", 2);
0368     /////////////////////////51///////////////////////////
0369     meZdcEneHadP3_ = ib.book1D("PZDC HAD3 Energy", "Energy HAD module P3", 3000, 0., 3000.);
0370     meZdcEneHadP3_->setAxisTitle("Energy (GeV)", 1);
0371     meZdcEneHadP3_->setAxisTitle("Counts", 2);
0372     /////////////////////////52///////////////////////////
0373     meZdcEneHadP4_ = ib.book1D("PZDC HAD4 Energy", "Energy HAD module P4", 3000, 0., 3000.);
0374     meZdcEneHadP4_->setAxisTitle("Energy (GeV)", 1);
0375     meZdcEneHadP4_->setAxisTitle("Counts", 2);
0376     /////////////////////////53///////////////////////////
0377     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/Excess_Info/Individual_ChannelvsTime/PZDC");
0378     meZdcEneTEmP1_ = ib.book2D("PZDC EM1 Energy vs Time", "Energy EM mod P1 vs Time", 4000, 0., 8000., 300, 0., 600.);
0379     meZdcEneTEmP1_->setAxisTitle("Energy (GeV)", 1);
0380     meZdcEneTEmP1_->setAxisTitle("Time (ns)", 2);
0381     /////////////////////////54///////////////////////////
0382     meZdcEneTEmP2_ = ib.book2D("PZDC EM2 Energy vs Time", "Energy EM mod P2 vs Time", 4000, 0., 8000., 300, 0., 600.);
0383     meZdcEneTEmP2_->setAxisTitle("Energy (GeV)", 1);
0384     meZdcEneTEmP2_->setAxisTitle("Time (ns)", 2);
0385     /////////////////////////55///////////////////////////
0386     meZdcEneTEmP3_ = ib.book2D("PZDC EM3 Energy vs Time", "Energy EM mod P3 vs Time", 4000, 0., 8000., 300, 0., 600.);
0387     meZdcEneTEmP3_->setAxisTitle("Energy (GeV)", 1);
0388     meZdcEneTEmP3_->setAxisTitle("Time (ns)", 2);
0389     /////////////////////////56///////////////////////////
0390     meZdcEneTEmP4_ = ib.book2D("PZDC EM4 Energy vs Time", "Energy EM mod P4 vs Time", 4000, 0., 8000., 300, 0., 600.);
0391     meZdcEneTEmP4_->setAxisTitle("Energy (GeV)", 1);
0392     meZdcEneTEmP4_->setAxisTitle("Time (ns)", 2);
0393     /////////////////////////57///////////////////////////
0394     meZdcEneTEmP5_ = ib.book2D("PZDC EM5 Energy vs Time", "Energy EM mod P5 vs Time", 4000, 0., 8000., 300, 0., 600.);
0395     meZdcEneTEmP5_->setAxisTitle("Energy (GeV)", 1);
0396     meZdcEneTEmP5_->setAxisTitle("Time (ns)", 2);
0397     /////////////////////////58///////////////////////////
0398     meZdcEneTHadP1_ =
0399         ib.book2D("PZDC HAD1 Energy vs Time", "Energy HAD mod P1 vs Time", 4000, 0., 8000., 300, 0., 600.);
0400     meZdcEneTHadP1_->setAxisTitle("Energy (GeV)", 1);
0401     meZdcEneTHadP1_->setAxisTitle("Time (ns)", 2);
0402     /////////////////////////59///////////////////////////
0403     meZdcEneTHadP2_ =
0404         ib.book2D("PZDC HAD2 Energy vs Time", "Energy HAD mod P2 vs Time", 4000, 0., 8000., 300, 0., 600.);
0405     meZdcEneTHadP2_->setAxisTitle("Energy (GeV)", 1);
0406     meZdcEneTHadP2_->setAxisTitle("Time (ns)", 2);
0407     /////////////////////////60///////////////////////////
0408     meZdcEneTHadP3_ =
0409         ib.book2D("PZDC HAD3 Energy vs Time", "Energy HAD mod P3 vs Time", 4000, 0., 8000., 300, 0., 600.);
0410     meZdcEneTHadP3_->setAxisTitle("Energy (GeV)", 1);
0411     meZdcEneTHadP3_->setAxisTitle("Time (ns)", 2);
0412     /////////////////////////61///////////////////////////
0413     meZdcEneTHadP4_ =
0414         ib.book2D("PZDC HAD4 Energy vs Time", "Energy HAD mod P4 vs Time", 4000, 0., 8000., 300, 0., 600.);
0415     meZdcEneTHadP4_->setAxisTitle("Energy (GeV)", 1);
0416     meZdcEneTHadP4_->setAxisTitle("Time (ns)", 2);
0417     /////////////////////////62/////////////////////////////
0418     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS/PZDC");
0419     meZdcEneHadPTot_ = ib.book1D("PZDC EHAD", "Total P-ZDC HAD Energy", 10000, 0., 10000.);
0420     meZdcEneHadPTot_->setAxisTitle("Energy (GeV)", 1);
0421     meZdcEneHadPTot_->setAxisTitle("Counts", 2);
0422     /////////////////////////63///////////////////////////
0423     meZdcEneEmPTot_ = ib.book1D("PZDC EEM", "Total P-ZDC EM Energy", 10000, 0., 10000.);
0424     meZdcEneEmPTot_->setAxisTitle("Energy (GeV)", 1);
0425     meZdcEneEmPTot_->setAxisTitle("Counts", 2);
0426     /////////////////////////64///////////////////////////
0427     meZdcEnePTot_ = ib.book1D("PZDC ETOT", "Total P-ZDC Energy", 10000, 0., 10000.);
0428     meZdcEnePTot_->setAxisTitle("Energy (GeV)", 1);
0429     meZdcEnePTot_->setAxisTitle("Counts", 2);
0430     /////////////////////////65///////////////////////////
0431     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS/NZDC");
0432     meZdcCorEEmNEHadN_ = ib.book2D("NZDC EMvHAD", "N-ZDC Energy EM vs HAD", 3000, 0., 3000., 3000, 0., 3000.);
0433     meZdcCorEEmNEHadN_->setAxisTitle("EM Energy (GeV)", 1);
0434     meZdcCorEEmNEHadN_->setAxisTitle("HAD Energy (GeV)", 2);
0435     /////////////////////////66///////////////////////////
0436     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS/PZDC");
0437     meZdcCorEEmPEHadP_ = ib.book2D("PZDC EMvHAD", "P-ZDC Energy EM vs HAD", 3000, 0., 3000., 3000, 0., 3000.);
0438     meZdcCorEEmPEHadP_->setAxisTitle("EM Energy (GeV)", 1);
0439     meZdcCorEEmPEHadP_->setAxisTitle("HAD Energy (GeV)", 2);
0440     /////////////////////////67///////////////////////////
0441     ib.setCurrentFolder("ZDCValidation/ZdcSimHits/ENERGY_SUMS");
0442     meZdcCorEtotNEtotP_ = ib.book2D("PZDC vs NZDC", "Energy N-ZDC vs P-ZDC", 3000, 0., 3000., 3000, 0., 3000.);
0443     meZdcCorEtotNEtotP_->setAxisTitle("N-ZDC Total Energy (GeV)", 1);
0444     meZdcCorEtotNEtotP_->setAxisTitle("P-ZDC Total Energy (GeV)", 2);
0445     /////////////////////////68///////////////////////////
0446     meZdcEneTot_ = ib.book1D("ETOT ZDCs", "Total Energy ZDCs", 3000, 0., 3000.);
0447     meZdcEneTot_->setAxisTitle("Counts", 2);
0448     meZdcEneTot_->setAxisTitle("Energy (GeV)", 1);
0449     ///////////////////////////////////////////////////////////
0450 
0451     //////////////////New Plots////////////////////////////////
0452 
0453     ////////////////////// GenParticle
0454     /// Plots///////////////////////////////////////
0455     ib.setCurrentFolder("ZDCValidation/GenParticles/Forward");
0456     //////////////////////////////////////////////////////////////////////////////
0457     ///////////////////////////////69/////////////////////////////////////////////
0458     genpart_Pi0F = ib.book2D("Pi0_Forward", "Forward Generated Pi0s", 200, 7.5, 13, 100, -3.15, 3.15);
0459     genpart_Pi0F->setAxisTitle("Eta", 1);
0460     genpart_Pi0F->setAxisTitle("Phi (radians)", 2);
0461     genpart_Pi0F->setAxisTitle("Energy (GeV)", 3);
0462     genpart_Pi0F->setOption("lego2z,prof");
0463     genpart_Pi0F->getTH2F()->SetTitleOffset(1.4, "x");
0464     genpart_Pi0F->getTH2F()->SetTitleOffset(1.4, "y");
0465 
0466     genpart_Pi0F_counts =
0467         ib.book2D("Pi0_Forward_Counts", "Number of Forward Generated Pi0s", 200, 7.5, 13, 100, -3.15, 3.15);
0468     genpart_Pi0F_counts->setAxisTitle("#eta", 1);
0469     genpart_Pi0F_counts->setAxisTitle("#phi (radians)", 2);
0470     genpart_Pi0F_counts->setAxisTitle("Energy (GeV)", 3);
0471     genpart_Pi0F_counts->setOption("lego2z,prof");
0472     genpart_Pi0F_counts->getTH2F()->SetTitleOffset(1.4, "x");
0473     genpart_Pi0F_counts->getTH2F()->SetTitleOffset(1.4, "y");
0474 
0475     /////////////////////////////////////////////////////////////////////////////////
0476     ///////////////////////////////70/////////////////////////////////////////////
0477     genpart_NeutF = ib.book2D("Neutron_Forward", "Forward Generated Neutrons", 200, 7.5, 13, 100, -3.15, 3.15);
0478     genpart_NeutF->setAxisTitle("Eta", 1);
0479     genpart_NeutF->setAxisTitle("Phi (radians)", 2);
0480     genpart_NeutF->setAxisTitle("Energy (GeV)", 3);
0481     genpart_NeutF->setOption("lego2z,prof");
0482     genpart_NeutF->getTH2F()->SetTitleOffset(1.4, "x");
0483     genpart_NeutF->getTH2F()->SetTitleOffset(1.4, "y");
0484 
0485     genpart_NeutF_counts =
0486         ib.book2D("Neutron_Forward_Counts", "Number of Forward Generated Neutrons", 200, 7.5, 13, 100, -3.15, 3.15);
0487     genpart_NeutF_counts->setAxisTitle("#eta", 1);
0488     genpart_NeutF_counts->setAxisTitle("#phi (radians)", 2);
0489     genpart_NeutF_counts->setAxisTitle("Energy (GeV)", 3);
0490     genpart_NeutF_counts->setOption("lego2z,prof");
0491     genpart_NeutF_counts->getTH2F()->SetTitleOffset(1.4, "x");
0492     genpart_NeutF_counts->getTH2F()->SetTitleOffset(1.4, "y");
0493 
0494     /////////////////////////////////////////////////////////////////////////////////
0495     ///////////////////////////////71/////////////////////////////////////////////
0496     genpart_GammaF = ib.book2D("Gamma_Forward", "Forward Generated Gammas", 200, 7.5, 13, 100, -3.15, 3.15);
0497     genpart_GammaF->setAxisTitle("Eta", 1);
0498     genpart_GammaF->setAxisTitle("Phi (radians)", 2);
0499     genpart_GammaF->setAxisTitle("Energy (GeV)", 3);
0500     genpart_GammaF->setOption("lego2z,prof");
0501     genpart_GammaF->getTH2F()->SetTitleOffset(1.4, "x");
0502     genpart_GammaF->getTH2F()->SetTitleOffset(1.4, "y");
0503 
0504     genpart_GammaF_counts =
0505         ib.book2D("Gamma_Forward_Counts", "Number of Forward Generated Gammas", 200, 7.5, 13, 100, -3.15, 3.15);
0506     genpart_GammaF_counts->setAxisTitle("#eta", 1);
0507     genpart_GammaF_counts->setAxisTitle("#phi (radians)", 2);
0508     genpart_GammaF_counts->setAxisTitle("Energy (GeV)", 3);
0509     genpart_GammaF_counts->setOption("lego2z,prof");
0510     genpart_GammaF_counts->getTH2F()->SetTitleOffset(1.4, "x");
0511     genpart_GammaF_counts->getTH2F()->SetTitleOffset(1.4, "y");
0512 
0513     ////////////////////////////////////////////////////////////////////////////////
0514     //////////////////////////////////////////////////////////////////////////////
0515     genpart_Pi0F_energydist = ib.book1D("Pi0_Forward_EDistribution", "Gen-Level Forward Pi0 Energy", 1500, 0, 1500);
0516     genpart_Pi0F_energydist->setAxisTitle("Energy (GeV)", 1);
0517     genpart_Pi0F_energydist->setAxisTitle("Counts", 2);
0518     ////////////////////////////////////////////////////////////////////////////////
0519     //////////////////////////////////////////////////////////////////////////////
0520     genpart_NeutF_energydist = ib.book1D("N_Forward_EDistribution", "Gen-Level Forward Neutron Energy", 1500, 0, 1500);
0521     genpart_NeutF_energydist->setAxisTitle("Energy (GeV)", 1);
0522     genpart_NeutF_energydist->setAxisTitle("Counts", 2);
0523     ///////////////////////////////////////////////////////////////////////////////
0524     ///////////////////////////////////////////////////////////////////////////////
0525     genpart_GammaF_energydist =
0526         ib.book1D("Gamma_Forward_EDistribution", "Gen-Level Fowarad Gamma Energy", 1500, 0, 1500);
0527     genpart_GammaF_energydist->setAxisTitle("Energy (GeV)", 1);
0528     genpart_GammaF_energydist->setAxisTitle("Counts", 2);
0529     /////////////////////////////////////////////////////////////////////////////////
0530     ib.setCurrentFolder("ZDCValidation/GenParticles/Backward");
0531     ////////////////////////////////////////////////////////////////////////////////
0532     ///////////////////////////////72/////////////////////////////////////////////
0533     genpart_Pi0B = ib.book2D("Pi0_Backward", "Backward Generated Pi0s", 1000, -13, -7.5, 100, -3.15, 3.15);
0534     genpart_Pi0B->setAxisTitle("Eta", 1);
0535     genpart_Pi0B->setAxisTitle("Phi (radians)", 2);
0536     genpart_Pi0B->setAxisTitle("Energy (GeV)", 3);
0537     genpart_Pi0B->setOption("lego2z,prof");
0538     genpart_Pi0B->getTH2F()->SetTitleOffset(1.4, "x");
0539     genpart_Pi0B->getTH2F()->SetTitleOffset(1.4, "y");
0540 
0541     genpart_Pi0B_counts =
0542         ib.book2D("Pi0_Backwards_Counts", "Number of Backward Generated Pi0s", 200, -13, -7.5, 100, -3.15, 3.15);
0543     genpart_Pi0B_counts->setAxisTitle("#eta", 1);
0544     genpart_Pi0B_counts->setAxisTitle("#phi (radians)", 2);
0545     genpart_Pi0B_counts->setAxisTitle("Energy (GeV)", 3);
0546     genpart_Pi0B_counts->setOption("lego2z,prof");
0547     genpart_Pi0B_counts->getTH2F()->SetTitleOffset(1.4, "x");
0548     genpart_Pi0B_counts->getTH2F()->SetTitleOffset(1.4, "y");
0549 
0550     /////////////////////////////////////////////////////////////////////////////////
0551     ///////////////////////////////73/////////////////////////////////////////////
0552     genpart_NeutB = ib.book2D("Neutron_Backward", "Backward Generated Neutrons", 1000, -13, -7.5, 100, -3.15, 3.15);
0553     genpart_NeutB->setAxisTitle("Eta", 1);
0554     genpart_NeutB->setAxisTitle("Phi (radians)", 2);
0555     genpart_NeutB->setAxisTitle("Energy (GeV)", 3);
0556     genpart_NeutB->setOption("lego2z,prof");
0557     genpart_NeutB->getTH2F()->SetTitleOffset(1.4, "x");
0558     genpart_NeutB->getTH2F()->SetTitleOffset(1.4, "y");
0559 
0560     genpart_NeutB_counts = ib.book2D(
0561         "Neutron_Backwards_Counts", "Number of Backward Generated Neutrons", 200, -13, -7.5, 100, -3.15, 3.15);
0562     genpart_NeutB_counts->setAxisTitle("#eta", 1);
0563     genpart_NeutB_counts->setAxisTitle("#phi (radians)", 2);
0564     genpart_NeutB_counts->setAxisTitle("Energy (GeV)", 3);
0565     genpart_NeutB_counts->setOption("lego2z,prof");
0566     genpart_NeutB_counts->getTH2F()->SetTitleOffset(1.4, "x");
0567     genpart_NeutB_counts->getTH2F()->SetTitleOffset(1.4, "y");
0568 
0569     ///////////////////////////////74/////////////////////////////////////////////
0570     genpart_GammaB = ib.book2D("Gamma_Backward", "Backward Generated Gammas", 1000, -13, -7.5, 100, -3.15, 3.15);
0571     genpart_GammaB->setAxisTitle("Eta", 1);
0572     genpart_GammaB->setAxisTitle("Phi (radians)", 2);
0573     genpart_GammaB->setAxisTitle("Energy (GeV)", 3);
0574     genpart_GammaB->setOption("lego2z,prof");
0575     genpart_GammaB->getTH2F()->SetTitleOffset(1.4, "x");
0576     genpart_GammaB->getTH2F()->SetTitleOffset(1.4, "y");
0577 
0578     genpart_GammaB_counts =
0579         ib.book2D("Gamma_Backwards_Counts", "Number of Backward Generated Gammas", 200, -13, -7.5, 100, -3.15, 3.15);
0580     genpart_GammaB_counts->setAxisTitle("#eta", 1);
0581     genpart_GammaB_counts->setAxisTitle("#phi (radians)", 2);
0582     genpart_GammaB_counts->setAxisTitle("Energy (GeV)", 3);
0583     genpart_GammaB_counts->setOption("lego2z,prof");
0584     genpart_GammaB_counts->getTH2F()->SetTitleOffset(1.4, "x");
0585     genpart_GammaB_counts->getTH2F()->SetTitleOffset(1.4, "y");
0586 
0587     /////////////////////////////////////////////////////////////////////////////////
0588     ///////////////////////////////GEN Particle Energy
0589     /// Distributions/////////////////////
0590     ///////////////////////////////////////////////////////////////////////////////////////////////
0591     genpart_Pi0B_energydist = ib.book1D("Pi0_Backward_EDistribution", "Gen-Level Backward Pi0 Energy", 1500, 0, 1500);
0592     genpart_Pi0B_energydist->setAxisTitle("Energy (GeV)", 1);
0593     genpart_Pi0B_energydist->setAxisTitle("Counts", 2);
0594     //////////////////////////////////////////////////////////////////////////////////////////////
0595     //////////////////////////////////////////////////////////////////////////////////////////////////////////
0596     genpart_NeutB_energydist = ib.book1D("N_Backward_EDistribution", "Gen-Level Foward Neutron Energy", 1500, 0, 1500);
0597     genpart_NeutB_energydist->setAxisTitle("Energy (GeV)", 1);
0598     genpart_NeutB_energydist->setAxisTitle("Counts", 2);
0599     ///////////////////////////////////////////////////////////////////////////////////////////
0600     //////////////////////////////////////////////////////////////////////////////////////////
0601     genpart_GammaB_energydist =
0602         ib.book1D("Gamma_Backward_EDistribution", "Gen-Level Backward Gamma Energy", 1500, 0, 1500);
0603     genpart_GammaB_energydist->setAxisTitle("Energy (GeV)", 1);
0604     genpart_GammaB_energydist->setAxisTitle("Counts", 2);
0605     /////////////////////////////////////////////////////////////////////////////////////////
0606   }
0607 }
0608 
0609 // let's see if this breaks anything
0610 /*void ZdcSimHitStudy::endJob() {
0611   if (dbe_ && outFile_.size() > 0) dbe_->save(outFile_);
0612   }*/
0613 
0614 // void ZdcSimHitStudy::analyze(const edm::Event& e, const edm::EventSetup& ) {
0615 void ZdcSimHitStudy::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0616   //////////NEW STUFF//////////////////////
0617 
0618   using namespace edm;
0619   bool gotGenParticles = true;
0620 
0621   const edm::Handle<reco::GenParticleCollection> &genhandle = iEvent.getHandle(tok_gen_);
0622 
0623   if (!(genhandle.isValid())) {
0624     gotGenParticles = false;  // this is the same kind of boolean except for the
0625   }
0626 
0627   // Handle<edm::PCaloHitContainer> zdcsimhandle;
0628 
0629   ////////////////////////////////////GEN PARTICLE
0630   /// HISTOS///////////////////////////////////
0631 
0632   if (gotGenParticles) {  // if the boolean was able to find the leaf
0633                           // "genparticles" then do this
0634     for (reco::GenParticleCollection::const_iterator gen = genhandle->begin(); gen != genhandle->end();
0635          ++gen)  // here we iterate over all generated particles
0636     {
0637       //         double energy=gen->energy();
0638       reco::GenParticle thisParticle = (reco::GenParticle)(*gen);  // get the particle "gen" points to
0639       double energy_2 = thisParticle.energy();  // here I grab some of the attributes of the generated
0640                                                 // particle....like its energy, its phi and its eta and
0641                                                 // what kind of particle it is
0642       double gen_phi = thisParticle.phi();
0643       double gen_eta = thisParticle.eta();
0644       int gen_id = thisParticle.pdgId();
0645 
0646       if (gen_id == 111) {    // here i require a pi0
0647         if (gen_eta > 8.3) {  // eta requirement
0648 
0649           //////////////////////////////////////////////////////////////////////////////////////
0650           //# IMPORTANT     IMPORTANT         IMPORTANT            IMPORTANT #
0651           //# The real eta of the ZDC is |eta| > 8.3, I have only changed it
0652           // here to 3 because# # in the PG simulation the ZDC is at an eta of
0653           // about 4.5-7, in the real GEANT the # # ZDC is in its appropriate
0654           // place at the very foward region...please edit this if # # looking
0655           // at MinBias data or the like # # # # IMPORTANT     IMPORTANT
0656           // IMPORTANT IMPORTANT                          #
0657           /////////////////////////////////////////////////////////////////////////////////////
0658 
0659           genpart_Pi0F->Fill(gen_eta, gen_phi, energy_2);  // fill the lego plot
0660           genpart_Pi0F_counts->Fill(gen_eta, gen_phi, 1);
0661           // genpart_Pi0F_profile->Fill(gen_eta,gen_phi,energy_2);
0662           genpart_Pi0F_energydist->Fill(energy_2);  // fill the 1D distribution
0663         }
0664         if (gen_eta < -8.3) {  // neg eta requirement
0665           genpart_Pi0B->Fill(gen_eta, gen_phi, energy_2);
0666           // genpart_Pi0B_profile->Fill(gen_eta,gen_phi,energy_2);
0667           genpart_Pi0B_counts->Fill(gen_eta, gen_phi, 1);
0668           genpart_Pi0B_energydist->Fill(energy_2);
0669         }
0670       }
0671       if (gen_id == 2112) {  // require neutron
0672         if (gen_eta > 8.3) {
0673           genpart_NeutF->Fill(gen_eta, gen_phi, energy_2);
0674           // genpart_NeutF_profile->Fill(gen_eta,gen_phi,energy_2);
0675           genpart_NeutF_counts->Fill(gen_eta, gen_phi, 1);
0676           genpart_NeutF_energydist->Fill(energy_2);
0677         }
0678         if (gen_eta < -8.3) {
0679           genpart_NeutB->Fill(gen_eta, gen_phi, energy_2);
0680           // genpart_NeutB_profile->Fill(gen_eta,gen_phi,energy_2);
0681           genpart_NeutB_counts->Fill(gen_eta, gen_phi, 1);
0682           genpart_NeutB_energydist->Fill(energy_2);
0683         }
0684       }
0685 
0686       if (gen_id == 22) {  // require gamma
0687         if (gen_eta > 8.3) {
0688           genpart_GammaF->Fill(gen_eta, gen_phi, energy_2);
0689           // genpart_GammaF_profile->Fill(gen_eta,gen_phi,energy_2);
0690           genpart_GammaF_counts->Fill(gen_eta, gen_phi, 1);
0691           genpart_GammaF_energydist->Fill(energy_2);
0692         }
0693         if (gen_eta < -8.3) {
0694           genpart_GammaB->Fill(gen_eta, gen_phi, energy_2);
0695           // genpart_GammaB_profile->Fill(gen_eta,gen_phi,energy_2);
0696           genpart_GammaB_counts->Fill(gen_eta, gen_phi, 1);
0697           genpart_GammaB_energydist->Fill(energy_2);
0698         }
0699       }
0700 
0701     }  // end of GEN loop
0702   }
0703 
0704   /////////////////////////////////////////////////////////////////////
0705 
0706   // Below is the old script which I will comment later
0707 
0708   edm::LogVerbatim("ZdcSimHitStudy") << "Run = " << iEvent.id().run() << " Event = " << iEvent.id().event();
0709 
0710   bool getHits = false;
0711   if (checkHit_) {
0712     const edm::Handle<edm::PCaloHitContainer> &hitsZdc = iEvent.getHandle(tok_hits_);
0713     if (hitsZdc.isValid()) {
0714       getHits = true;
0715       std::vector<PCaloHit> caloHits;
0716       caloHits.insert(caloHits.end(), hitsZdc->begin(), hitsZdc->end());
0717       edm::LogVerbatim("ZdcSimHitStudy") << "ZdcValidation: Hit buffer " << caloHits.size();
0718       analyzeHits(caloHits);
0719     }
0720   }
0721 
0722   edm::LogVerbatim("ZdcSim") << "ZdcValidation: Input flags Hits " << getHits;
0723 }
0724 
0725 void ZdcSimHitStudy::analyzeHits(std::vector<PCaloHit> &hits) {
0726   int nHit = hits.size();
0727   int nZdcEM = 0, nZdcHad = 0, nZdcLum = 0;
0728   int nBad1 = 0, nBad2 = 0, nBad = 0;
0729   std::vector<double> encontZdcEM(140, 0.);
0730   std::vector<double> encontZdcHad(140, 0.);
0731   double entotZdcEM = 0;
0732   double entotZdcHad = 0;
0733 
0734   enetotEmN = 0;
0735   enetotHadN = 0.;
0736   enetotN = 0;
0737   enetotEmP = 0;
0738   enetotHadP = 0;
0739   enetotP = 0;
0740   enetot = 0;
0741 
0742   for (int i = 0; i < nHit; i++) {
0743     double energy = hits[i].energy();
0744     double log10en = log10(energy);
0745     int log10i = int((log10en + 10.) * 10.);
0746     double time = hits[i].time();
0747     unsigned int id_ = hits[i].id();
0748     HcalZDCDetId id = HcalZDCDetId(id_);
0749     int det = id.det();
0750     int side = id.zside();
0751     int section = id.section();
0752     int channel = id.channel();
0753 
0754     FillHitValHist(side, section, channel, energy, time);
0755 
0756     edm::LogVerbatim("ZdcSimHitStudy") << "Hit[" << i << "] ID " << std::hex << id_ << std::dec << " DetID " << id
0757                                        << " Det " << det << " side " << side << " Section " << section << " channel "
0758                                        << channel << " E " << energy << " time \n"
0759                                        << time;
0760 
0761     if (det == 5) {  // Check DetId.h
0762       if (section == HcalZDCDetId::EM)
0763         nZdcEM++;
0764       else if (section == HcalZDCDetId::HAD)
0765         nZdcHad++;
0766       else if (section == HcalZDCDetId::LUM)
0767         nZdcLum++;
0768       else {
0769         nBad++;
0770         nBad2++;
0771       }
0772     } else {
0773       nBad++;
0774       nBad1++;
0775     }
0776 
0777     meZdcDetectHit_->Fill(double(det));
0778     if (det == 5) {
0779       meZdcSideHit_->Fill(double(side));
0780       meZdcSectionHit_->Fill(double(section));
0781       meZdcChannelHit_->Fill(double(channel));
0782       meZdcEnergyHit_->Fill(energy);
0783       if (section == HcalZDCDetId::EM) {
0784         meZdcEMEnergyHit_->Fill(energy);
0785         meZdcEEMCh_->Fill(energy, channel);
0786         if (log10i >= 0 && log10i < 140)
0787           encontZdcEM[log10i] += energy;
0788         entotZdcEM += energy;
0789       }
0790       if (section == HcalZDCDetId::HAD) {
0791         meZdcHadEnergyHit_->Fill(energy);
0792         meZdcEHadCh_->Fill(energy, channel);
0793         if (log10i >= 0 && log10i < 140)
0794           encontZdcHad[log10i] += energy;
0795         entotZdcHad += energy;
0796       }
0797       meZdcTimeHit_->Fill(time);
0798       meZdcTimeWHit_->Fill(double(time), energy);
0799       meZdc10Ene_->Fill(log10en);
0800       meZdcETime_->Fill(energy, double(time));
0801     }
0802   }
0803 
0804   if (entotZdcEM != 0)
0805     for (int i = 0; i < 140; i++)
0806       meZdcEML10EneP_->Fill(-10. + (float(i) + 0.5) / 10., encontZdcEM[i] / entotZdcEM);
0807   if (entotZdcHad != 0)
0808     for (int i = 0; i < 140; i++)
0809       meZdcHadL10EneP_->Fill(-10. + (float(i) + 0.5) / 10., encontZdcHad[i] / entotZdcHad);
0810 
0811   if (nHit > 0) {
0812     meAllZdcNHit_->Fill(double(nHit));
0813     meBadZdcDetHit_->Fill(double(nBad1));
0814     meBadZdcSecHit_->Fill(double(nBad2));
0815     meBadZdcIdHit_->Fill(double(nBad));
0816     meZdcNHitEM_->Fill(double(nZdcEM));
0817     meZdcNHitHad_->Fill(double(nZdcHad));
0818     meZdcNHitLum_->Fill(double(nZdcLum));
0819     meZdcEnePTot_->Fill(enetotP);
0820     meZdcEneNTot_->Fill(enetotN);
0821     meZdcEneHadNTot_->Fill(enetotHadN);
0822     meZdcEneHadPTot_->Fill(enetotHadP);
0823     meZdcEneEmNTot_->Fill(enetotEmN);
0824     meZdcEneEmPTot_->Fill(enetotEmP);
0825     meZdcCorEEmNEHadN_->Fill(enetotEmN, enetotHadN);
0826     meZdcCorEEmPEHadP_->Fill(enetotEmP, enetotHadP);
0827     meZdcCorEtotNEtotP_->Fill(enetotN, enetotP);
0828     meZdcEneTot_->Fill(enetot);
0829   }
0830   edm::LogVerbatim("HcalSimHitStudy") << "HcalSimHitStudy::analyzeHits: Had " << nZdcHad << " EM " << nZdcEM << " Bad "
0831                                       << nBad << " All " << nHit;
0832 }
0833 
0834 int ZdcSimHitStudy::FillHitValHist(int side, int section, int channel, double energy, double time) {
0835   enetot += enetot;
0836   if (side == -1) {
0837     enetotN += energy;
0838     if (section == HcalZDCDetId::EM) {
0839       enetotEmN += energy;
0840       switch (channel) {
0841         case 1:
0842           meZdcEneEmN1_->Fill(energy);
0843           meZdcEneTEmN1_->Fill(energy, time);
0844           break;
0845         case 2:
0846           meZdcEneEmN2_->Fill(energy);
0847           meZdcEneTEmN2_->Fill(energy, time);
0848           break;
0849         case 3:
0850           meZdcEneEmN3_->Fill(energy);
0851           meZdcEneTEmN3_->Fill(energy, time);
0852           break;
0853         case 4:
0854           meZdcEneEmN4_->Fill(energy);
0855           meZdcEneTEmN4_->Fill(energy, time);
0856           break;
0857         case 5:
0858           meZdcEneEmN4_->Fill(energy);
0859           meZdcEneTEmN4_->Fill(energy, time);
0860           break;
0861       }
0862     }
0863     if (section == HcalZDCDetId::HAD) {
0864       enetotHadN += energy;
0865       switch (channel) {
0866         case 1:
0867           meZdcEneHadN1_->Fill(energy);
0868           meZdcEneTHadN1_->Fill(energy, time);
0869           break;
0870         case 2:
0871           meZdcEneHadN2_->Fill(energy);
0872           meZdcEneTHadN2_->Fill(energy, time);
0873           break;
0874         case 3:
0875           meZdcEneHadN3_->Fill(energy);
0876           meZdcEneTHadN3_->Fill(energy, time);
0877           break;
0878         case 4:
0879           meZdcEneHadN4_->Fill(energy);
0880           meZdcEneTHadN4_->Fill(energy, time);
0881           break;
0882       }
0883     }
0884   }
0885   if (side == 1) {
0886     enetotP += energy;
0887     if (section == HcalZDCDetId::EM) {
0888       enetotEmP += energy;
0889       switch (channel) {
0890         case 1:
0891           meZdcEneEmP1_->Fill(energy);
0892           meZdcEneTEmP1_->Fill(energy, time);
0893           break;
0894         case 2:
0895           meZdcEneEmP2_->Fill(energy);
0896           meZdcEneTEmP2_->Fill(energy, time);
0897           break;
0898         case 3:
0899           meZdcEneEmP3_->Fill(energy);
0900           meZdcEneTEmP3_->Fill(energy, time);
0901           break;
0902         case 4:
0903           meZdcEneEmP4_->Fill(energy);
0904           meZdcEneTEmP4_->Fill(energy, time);
0905           break;
0906         case 5:
0907           meZdcEneEmP4_->Fill(energy);
0908           meZdcEneTEmP4_->Fill(energy, time);
0909           break;
0910       }
0911     }
0912     if (section == HcalZDCDetId::HAD) {
0913       enetotHadP += energy;
0914       switch (channel) {
0915         case 1:
0916           meZdcEneHadP1_->Fill(energy);
0917           meZdcEneTHadP1_->Fill(energy, time);
0918           break;
0919         case 2:
0920           meZdcEneHadP2_->Fill(energy);
0921           meZdcEneTHadP2_->Fill(energy, time);
0922           break;
0923         case 3:
0924           meZdcEneHadP3_->Fill(energy);
0925           meZdcEneTHadP3_->Fill(energy, time);
0926           break;
0927         case 4:
0928           meZdcEneHadP4_->Fill(energy);
0929           meZdcEneTHadP4_->Fill(energy, time);
0930           break;
0931       }
0932     }
0933   }
0934   return 0;
0935 }
0936 
0937 #include "FWCore/Framework/interface/MakerMacros.h"
0938 #include "FWCore/PluginManager/interface/ModuleDef.h"
0939 
0940 DEFINE_FWK_MODULE(ZdcSimHitStudy);