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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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, trackingPOGFilters_cfi::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  double eMIP = ptb.getParameter<double>("MIP");
84 
85  edm::LogInfo("HcalTB06Analysis")
86  << "Beam parameters: E(GeV)= " << m_ener
87  << " pdgID= " << m_PDG[0]
88  << "\n eta= " << m_eta
89  << " idx_etaEcal= " << m_idxetaEcal
90  << " idx_etaHcal= " << m_idxetaHcal
91  << " phi= " << m_phi
92  << " idx_phiEcal= " << m_idxphiEcal
93  << " idx_phiHcal= " << m_idxphiHcal
94  << "\n EcalFactor= " << m_factEcal
95  << " EcalWidth= " << m_widthEcal << " GeV"
96  << "\n HcalFactor= " << m_factHcal
97  << " HcalWidth= " << m_widthHcal << " GeV"
98  << " MIP= " << eMIP << " GeV"
99  << "\n TimeLimit= " << m_timeLimit << " ns" << "\n";
100  m_histo = new HcalTB06Histo(ptb);
101 }
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 103 of file HcalTB06Analysis.cc.

References m_histo.

103  {
104  delete m_histo;
105 }
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 116 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(), protons_cff::time, and HcalTestBeamNumbering::unpackIndex().

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

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 111 of file HcalTB06Analysis.cc.

References count.

111  {
112  edm::LogInfo("HcalTB06Analysis")
113  << " =====> End of Run; Total number of events: " << count;
114 }
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().