CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HcalTB06Analysis Class Reference

#include <HcalTB06Analysis.h>

Inheritance diagram for HcalTB06Analysis:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
void endJob () override
 
 HcalTB06Analysis (const edm::ParameterSet &p)
 
 HcalTB06Analysis (const HcalTB06Analysis &)=delete
 
const HcalTB06Analysisoperator= (const HcalTB06Analysis &)=delete
 
 ~HcalTB06Analysis () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

int count
 
edm::EDGetTokenT< edm::PCaloHitContainerm_BeamToken
 
bool m_ECAL
 
edm::EDGetTokenT< edm::PCaloHitContainerm_EcalToken
 
double m_ener
 
double m_eta
 
double m_factEcal
 
double m_factHcal
 
edm::EDGetTokenT< edm::PCaloHitContainerm_HcalToken
 
HcalTB06Histom_histo
 
int m_idxetaEcal
 
int m_idxetaHcal
 
int m_idxphiEcal
 
int m_idxphiHcal
 
std::vector< int > m_PDG
 
double m_phi
 
double m_timeLimit
 
double m_widthEcal
 
double m_widthHcal
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file HcalTB06Analysis.h.

Constructor & Destructor Documentation

HcalTB06Analysis::HcalTB06Analysis ( const edm::ParameterSet p)
explicit

Definition at line 47 of file HcalTB06Analysis.cc.

References edm::ParameterSet::getParameter(), createfilelist::int, m_BeamToken, m_ECAL, m_EcalToken, m_ener, m_eta, m_factEcal, m_factHcal, m_HcalToken, m_histo, m_idxetaEcal, m_idxetaHcal, m_idxphiEcal, m_idxphiHcal, m_PDG, m_phi, m_timeLimit, m_widthEcal, m_widthHcal, maxEta, trackingParticleSelector_cfi::maxPhi, cutBasedElectronID_CSA14_50ns_V0_cff::minEta, and trackingParticleSelector_cfi::minPhi.

47  : count(0) {
48 
49  usesResource("TFileService");
50 
51  m_ECAL = p.getParameter<bool>("ECAL");
52  if(m_ECAL) {
53  m_EcalToken = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","EcalHitsEB"));
54  }
55  m_HcalToken = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","HcalHits"));
56  m_BeamToken = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","HcalTB06BeamHits"));
57  m_eta = p.getParameter<double>("MinEta");
58  m_phi = p.getParameter<double>("MinPhi");
59  m_ener= p.getParameter<double>("MinE");
60  m_PDG = p.getParameter<std::vector<int> >("PartID");
61 
62  double minEta = p.getParameter<double>("MinEta");
63  double maxEta = p.getParameter<double>("MaxEta");
64  double minPhi = p.getParameter<double>("MinPhi");
65  double maxPhi = p.getParameter<double>("MaxPhi");
66  double beamEta = (maxEta+minEta)*0.5;
67  double beamPhi = (maxPhi+minPhi)*0.5;
68  if (beamPhi < 0) { beamPhi += twopi; }
69 
70  m_idxetaEcal = 13;
71  m_idxphiEcal = 13;
72 
73  m_idxetaHcal = (int)(beamEta/0.087) + 1;
74  m_idxphiHcal = (int)(beamPhi/0.087) + 6;
75  if(m_idxphiHcal > 72) { m_idxphiHcal -= 73; }
76 
77  edm::ParameterSet ptb = p.getParameter<edm::ParameterSet>("TestBeamAnalysis");
78  m_timeLimit = ptb.getParameter<double>("TimeLimit");
79  m_widthEcal = ptb.getParameter<double>("EcalWidth");
80  m_widthHcal = ptb.getParameter<double>("HcalWidth");
81  m_factEcal = ptb.getParameter<double>("EcalFactor");
82  m_factHcal = ptb.getParameter<double>("HcalFactor");
83 
84  edm::LogInfo("HcalTB06Analysis")
85  << "Beam parameters: E(GeV)= " << m_ener
86  << " pdgID= " << m_PDG[0]
87  << "\n eta= " << m_eta
88  << " idx_etaEcal= " << m_idxetaEcal
89  << " idx_etaHcal= " << m_idxetaHcal
90  << " phi= " << m_phi
91  << " idx_phiEcal= " << m_idxphiEcal
92  << " idx_phiHcal= " << m_idxphiHcal
93  << "\n EcalFactor= " << m_factEcal
94  << " EcalWidth= " << m_widthEcal << " GeV"
95  << "\n HcalFactor= " << m_factHcal
96  << " HcalWidth= " << m_widthHcal << " GeV"
97  << "\n TimeLimit= " << m_timeLimit << " ns" << "\n";
98  m_histo = new HcalTB06Histo(ptb);
99 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::PCaloHitContainer > m_BeamToken
double maxEta
HcalTB06Histo * m_histo
edm::EDGetTokenT< edm::PCaloHitContainer > m_HcalToken
std::vector< int > m_PDG
edm::EDGetTokenT< edm::PCaloHitContainer > m_EcalToken
HcalTB06Analysis::~HcalTB06Analysis ( )
override

Definition at line 101 of file HcalTB06Analysis.cc.

References m_histo.

101  {
102  delete m_histo;
103 }
HcalTB06Histo * m_histo
HcalTB06Analysis::HcalTB06Analysis ( const HcalTB06Analysis )
delete

Member Function Documentation

void HcalTB06Analysis::analyze ( const edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 114 of file HcalTB06Analysis.cc.

References funct::abs(), count, gather_cfg::cout, ModuleToSequenceAssign::Ecal, HcalTB06Histo::fillEdep(), HcalTB06Histo::fillPrimary(), HcalTB06Histo::fillTree(), edm::Event::getByToken(), HcalOuter, mps_fire::i, EBDetId::ieta(), HcalDetId::ieta(), EBDetId::iphi(), HcalDetId::iphi(), m_BeamToken, m_ECAL, m_EcalToken, m_ener, m_eta, m_factEcal, m_factHcal, m_HcalToken, m_histo, m_idxetaEcal, m_idxetaHcal, m_idxphiEcal, m_idxphiHcal, m_phi, m_timeLimit, m_widthEcal, m_widthHcal, Vispa.Plugins.EdmBrowser.EdmDataAccessor::ne(), edm::Handle< T >::product(), HcalDetId::subdet(), ntuplemaker::time, and HcalTestBeamNumbering::unpackIndex().

115 {
116  ++count;
117 
118  //Beam Information
120 
124  std::vector<double> eCalo(6,0), eTrig(7,0);
125 
126  const std::vector<PCaloHit>* EcalHits = nullptr;
127  if(m_ECAL) {
128  evt.getByToken(m_EcalToken, Ecal);
129  EcalHits = Ecal.product();
130  }
131  evt.getByToken(m_HcalToken, Hcal);
132  const std::vector<PCaloHit>* HcalHits = Hcal.product();
133  evt.getByToken(m_BeamToken, Beam);
134  const std::vector<PCaloHit>* BeamHits = Beam.product();
135 
136  // Total Energy
137  double eecals = 0.;
138  double ehcals = 0.;
139 
140  unsigned int ne = 0;
141  unsigned int nh = 0;
142  if(m_ECAL) {
143  ne = EcalHits->size();
144  for (unsigned int i=0; i<ne; ++i) {
145  EBDetId ecalid((*EcalHits)[i].id());
146 #ifdef EDM_ML_DEBUG
147  std::cout << "EB " << i << " " << ecalid.ieta() << ":" << m_idxetaEcal
148  << " " << ecalid.iphi() << ":" << m_idxphiEcal << " "
149  << (*EcalHits)[i].time() << ":" << m_timeLimit << " "
150  << (*EcalHits)[i].energy() << std::endl;
151 #endif
152  // 7x7 crystal selection
153  if(std::abs(m_idxetaEcal - ecalid.ieta()) <= 3 &&
154  std::abs(m_idxphiEcal - ecalid.iphi()) <= 3 &&
155  (*EcalHits)[i].time() < m_timeLimit) {
156  eCalo[0] += (*EcalHits)[i].energy();
157  }
158  }
159  if(m_widthEcal > 0.0) {
160  eCalo[1] = G4RandGauss::shoot(0.0,m_widthEcal);
161  }
162  eecals = m_factEcal*(eCalo[0]+eCalo[1]);
163  }
164  if(HcalHits) {
165  nh = HcalHits->size();
166  for (unsigned int i=0; i<nh; ++i) {
167  HcalDetId hcalid((*HcalHits)[i].id());
168 #ifdef EDM_ML_DEBUG
169  std::cout << "HC " << i << " " << hcalid.subdet() << " "
170  << hcalid.ieta() << ":" << m_idxetaHcal << " "
171  << hcalid.iphi() << ":" << m_idxphiHcal << " "
172  << (*HcalHits)[i].time() << ":" << m_timeLimit << " "
173  << (*HcalHits)[i].energy() << std::endl;
174 #endif
175  // 3x3 towers selection
176  if(std::abs(m_idxetaHcal - hcalid.ieta()) <= 1 &&
177  std::abs(m_idxphiHcal - hcalid.iphi()) <= 1 &&
178  (*HcalHits)[i].time() < m_timeLimit) {
179  if (hcalid.subdet() != HcalOuter) {
180  eCalo[2] += (*HcalHits)[i].energy();
181  } else {
182  eCalo[4] += (*HcalHits)[i].energy();
183  }
184  }
185  }
186  if(m_widthHcal > 0.0) {
187  eCalo[3] = G4RandGauss::shoot(0.0,m_widthHcal);
188  eCalo[5] = G4RandGauss::shoot(0.0,m_widthHcal);
189  }
190  ehcals = m_factHcal*eCalo[2] + eCalo[3];
191  }
192  double etots = eecals + ehcals;
193 
194  edm::LogInfo("HcalTBSim") << "HcalTB06Analysis:: Etot(MeV)= " << etots
195  << " E(Ecal)= " << eecals
196  << " E(Hcal)= " << ehcals
197  << " Nhits(ECAL)= " << ne
198  << " Nhits(HCAL)= " << nh;
199  m_histo->fillEdep(etots, eecals, ehcals);
200 
201  if(BeamHits) {
202  for (unsigned int i=0; i<BeamHits->size(); ++i) {
203  unsigned int id = ((*BeamHits)[i].id());
204  int det, lay, ix, iy;
205  HcalTestBeamNumbering::unpackIndex(id,det,lay,ix,iy);
206  if ((det == 1) && ((*BeamHits)[i].time() < m_timeLimit)) {
207  if (lay > 0 && lay <= 4) {
208  eTrig[lay-1] += (*BeamHits)[i].energy();
209  } else if (lay == 7 || lay == 8) {
210  eTrig[lay-2] += (*BeamHits)[i].energy();
211  } else if (lay >= 11 && lay <= 14) {
212  eTrig[4] += (*BeamHits)[i].energy();
213  }
214  }
215  }
216  }
217 
218  edm::LogInfo("HcalTBSim") << "HcalTB06Analysis:: Trigger Info: "
219  << eTrig[0] << ":" << eTrig[1] << ":" << eTrig[2]
220  << ":" << eTrig[3] << ":" << eTrig[4] << ":"
221  << eTrig[5] << ":" << eTrig[6];
222 
223  m_histo->fillTree(eCalo,eTrig);
224 }
edm::EDGetTokenT< edm::PCaloHitContainer > m_BeamToken
void fillEdep(double etots, double eecals, double ehcals)
void fillTree(std::vector< double > &ecalo, std::vector< double > &etrig)
HcalTB06Histo * m_histo
edm::EDGetTokenT< edm::PCaloHitContainer > m_HcalToken
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T const * product() const
Definition: Handle.h:81
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
void fillPrimary(double energy, double eta, double phi)
edm::EDGetTokenT< edm::PCaloHitContainer > m_EcalToken
void HcalTB06Analysis::beginJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 105 of file HcalTB06Analysis.cc.

105  {
106  edm::LogInfo("HcalTB06Analysis") <<" =====> Begin of Run";
107 }
void HcalTB06Analysis::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 109 of file HcalTB06Analysis.cc.

References count.

109  {
110  edm::LogInfo("HcalTB06Analysis")
111  << " =====> End of Run; Total number of events: " << count;
112 }
const HcalTB06Analysis& HcalTB06Analysis::operator= ( const HcalTB06Analysis )
delete

Member Data Documentation

int HcalTB06Analysis::count
private

Definition at line 47 of file HcalTB06Analysis.h.

Referenced by analyze(), and endJob().

edm::EDGetTokenT<edm::PCaloHitContainer> HcalTB06Analysis::m_BeamToken
private

Definition at line 44 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

bool HcalTB06Analysis::m_ECAL
private

Definition at line 45 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

edm::EDGetTokenT<edm::PCaloHitContainer> HcalTB06Analysis::m_EcalToken
private

Definition at line 42 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_ener
private

Definition at line 55 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_eta
private

Definition at line 53 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_factEcal
private

Definition at line 59 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_factHcal
private

Definition at line 60 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

edm::EDGetTokenT<edm::PCaloHitContainer> HcalTB06Analysis::m_HcalToken
private

Definition at line 43 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

HcalTB06Histo* HcalTB06Analysis::m_histo
private

Definition at line 63 of file HcalTB06Analysis.h.

Referenced by analyze(), HcalTB06Analysis(), and ~HcalTB06Analysis().

int HcalTB06Analysis::m_idxetaEcal
private

Definition at line 48 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

int HcalTB06Analysis::m_idxetaHcal
private

Definition at line 50 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

int HcalTB06Analysis::m_idxphiEcal
private

Definition at line 49 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

int HcalTB06Analysis::m_idxphiHcal
private

Definition at line 51 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

std::vector<int> HcalTB06Analysis::m_PDG
private

Definition at line 61 of file HcalTB06Analysis.h.

Referenced by HcalTB06Analysis().

double HcalTB06Analysis::m_phi
private

Definition at line 54 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_timeLimit
private

Definition at line 56 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_widthEcal
private

Definition at line 57 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().

double HcalTB06Analysis::m_widthHcal
private

Definition at line 58 of file HcalTB06Analysis.h.

Referenced by analyze(), and HcalTB06Analysis().