CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTB06Analysis.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalTestBeam
4 // Class : HcalTB06Analysis
5 //
6 // Implementation:
7 // Main analysis class for Hcal Test Beam 2006 Analysis
8 //
9 // Original Author:
10 // Created: 19 November 2015
11 //
12 
13 // user include files
16 
17 // to retreive hits
20 
23 
27 
29 
30 #include "CLHEP/Units/GlobalSystemOfUnits.h"
31 #include "CLHEP/Units/GlobalPhysicalConstants.h"
32 #include "globals.hh"
33 #include "Randomize.hh"
34 
35 // system include files
36 #include <iostream>
37 #include <iomanip>
38 
39 //
40 // constructors and destructor
41 //
42 
44  : count(0), m_EcalTag(edm::InputTag("g4SimHits","EcalHitsEB")),
45  m_HcalTag(edm::InputTag("g4SimHits","HcalHits"))
46 {
47  m_ECAL = p.getParameter<bool>("ECAL");
48  if(m_ECAL) {
49  consumes<edm::PCaloHitContainer>(m_EcalTag);
50  }
51  consumes<edm::PCaloHitContainer>(m_HcalTag);
52  m_eta = p.getParameter<double>("MinEta");
53  m_phi = p.getParameter<double>("MinPhi");
54  m_ener= p.getParameter<double>("MinE");
55  m_PDG = p.getParameter<std::vector<int> >("PartID");
56 
57  edm::ParameterSet ptb = p.getParameter<edm::ParameterSet>("TestBeamAnalysis");
58  m_widthEcal = ptb.getParameter<double>("EcalWidth");
59  m_factEcal = ptb.getParameter<double>("EcalFactor");
60  m_factHcal = ptb.getParameter<double>("HcalFactor");
61 
62  edm::LogInfo("HcalTB06Analysis")
63  << "Beam parameters: E(GeV)= " << m_ener
64  << " pdgID= " << m_PDG[0]
65  << " eta= " << m_eta
66  << " phi= " << m_phi
67  << "\n EcalFactor= " << m_factEcal
68  << " EcalWidth= " << m_widthEcal << " GeV"
69  << "\n HcalFactor= " << m_factHcal;
70  m_histo = new HcalTB06Histo(ptb);
71 }
72 
74 {
75  delete m_histo;
76 }
77 
79 {
80  edm::LogInfo("HcalTB06Analysis") <<" =====> Begin of Run";
81 }
82 
84 {
85  edm::LogInfo("HcalTB06Analysis")
86  << " =====> End of Run; Total number of events: " << count;
87 }
88 
90 {
91  ++count;
92 
93  //Beam Information
95 
98 
99  const std::vector<PCaloHit>* EcalHits = nullptr;
100  if(m_ECAL) {
101  evt.getByLabel(m_EcalTag, Ecal);
102  EcalHits = Ecal.product();
103  }
104  evt.getByLabel(m_HcalTag, Hcal);
105  const std::vector<PCaloHit>* HcalHits = Hcal.product();
106 
107  // Total Energy
108  double eecals = 0.;
109  double ehcals = 0.;
110 
111  unsigned int ne = 0;
112  unsigned int nh = 0;
113 
114  if(EcalHits) {
115  ne = EcalHits->size();
116  for (unsigned int i=0; i<ne; ++i) {
117  eecals += (*EcalHits)[i].energy();
118  }
119  if(m_widthEcal > 0.0) {
120  eecals += G4RandGauss::shoot(0.0,m_widthEcal);
121  }
122  eecals *= m_factEcal;
123  }
124  if(HcalHits) {
125  nh = HcalHits->size();
126  for (unsigned int i=0; i<nh; ++i) {
127  ehcals += (*HcalHits)[i].energy();
128  }
129  ehcals *= m_factHcal;
130  }
131  double etots = eecals + ehcals;
132  LogDebug("HcalTBSim") << "HcalTB06Analysis:: Etot(MeV)= " << etots
133  << " E(Ecal)= " << eecals
134  << " E(Hcal)= " << ehcals
135  << " Nhits(ECAL)= " << ne
136  << " Nhits(HCAL)= " << nh;
137  m_histo->fillEdep(etots, eecals, ehcals);
138 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual void beginJob() override
virtual void analyze(const edm::Event &e, const edm::EventSetup &c) override
void fillEdep(double etots, double eecals, double ehcals)
HcalTB06Histo * m_histo
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
T const * product() const
Definition: Handle.h:81
HcalTB06Analysis(const edm::ParameterSet &p)
std::vector< int > m_PDG
edm::InputTag m_EcalTag
void fillPrimary(double energy, double eta, double phi)
virtual ~HcalTB06Analysis()
edm::InputTag m_HcalTag
virtual void endJob() override