CMS 3D CMS Logo

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

#include <DoCastorAnalysis.h>

Inheritance diagram for DoCastorAnalysis:
SimWatcher Observer< const BeginOfJob * > Observer< const BeginOfRun * > Observer< const EndOfRun * > Observer< const BeginOfEvent * > Observer< const EndOfEvent * > Observer< const G4Step * >

Public Member Functions

 DoCastorAnalysis (const edm::ParameterSet &p)
 
 ~DoCastorAnalysis () override
 
- Public Member Functions inherited from SimWatcher
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfRun * >
 Observer ()
 
void slotForUpdate (const EndOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Member Functions

void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfJob *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

TFile * CastorOutputEventFile
 
TTree * CastorTree
 
int eventIndex
 
std::vector< double > * psimhit_energy
 
std::vector< double > * psimhit_eta
 
std::vector< int > * psimhit_module
 
std::vector< double > * psimhit_phi
 
std::vector< int > * psimhit_sector
 
std::vector< double > * psimhit_x
 
std::vector< double > * psimhit_y
 
std::vector< double > * psimhit_z
 
std::vector< double > simhit_energy
 
std::vector< double > simhit_eta
 
double simhit_etot
 
std::vector< int > simhit_module
 
std::vector< double > simhit_phi
 
std::vector< int > simhit_sector
 
std::vector< double > simhit_x
 
std::vector< double > simhit_y
 
std::vector< double > simhit_z
 
std::string TreeFileName
 
int verbosity
 

Additional Inherited Members

Detailed Description

Definition at line 62 of file DoCastorAnalysis.h.

Constructor & Destructor Documentation

◆ DoCastorAnalysis()

DoCastorAnalysis::DoCastorAnalysis ( const edm::ParameterSet p)

Definition at line 29 of file DoCastorAnalysis.cc.

29  {
30  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("DoCastorAnalysis");
31  verbosity = m_Anal.getParameter<int>("Verbosity");
32 
33  TreeFileName = m_Anal.getParameter<std::string>("CastorTreeFileName");
34 
35  if (verbosity > 0) {
36  edm::LogVerbatim("ForwardSim") << std::endl;
37  edm::LogVerbatim("ForwardSim") << "============================================================================";
38  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis:: Initialized as observer";
39 
40  edm::LogVerbatim("ForwardSim") << " Castor Tree will be created";
41  edm::LogVerbatim("ForwardSim") << " Castor Tree will be in file: " << TreeFileName;
42 #ifdef EDM_ML_DEBUG
43  getchar();
44 #endif
45  edm::LogVerbatim("ForwardSim") << "============================================================================";
46  edm::LogVerbatim("ForwardSim") << std::endl;
47  }
48 
49  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: output event root file created";
50  TString treefilename = TreeFileName;
51  CastorOutputEventFile = new TFile(treefilename, "RECREATE");
52 
53  CastorTree = new TTree("Sim", "Sim");
54 
55  CastorTree->Branch("simhit_x", "std::vector<double>", &psimhit_x);
56  CastorTree->Branch("simhit_y", "std::vector<double>", &psimhit_y);
57  CastorTree->Branch("simhit_z", "std::vector<double>", &psimhit_z);
58 
59  CastorTree->Branch("simhit_eta", "std::vector<double>", &psimhit_eta);
60  CastorTree->Branch("simhit_phi", "std::vector<double>", &psimhit_phi);
61  CastorTree->Branch("simhit_energy", "std::vector<double>", &psimhit_energy);
62 
63  // CastorTree->Branch("simhit_time","std::vector<double>",&psimhit_time);
64  CastorTree->Branch("simhit_sector", "std::vector<int>", &psimhit_sector);
65  CastorTree->Branch("simhit_module", "std::vector<int>", &psimhit_module);
66 
67  CastorTree->Branch("simhit_etot", &simhit_etot, "simhit_etot/D");
68 }

References CastorOutputEventFile, CastorTree, edm::ParameterSet::getParameter(), AlCaHLTBitMon_ParallelJobs::p, psimhit_energy, psimhit_eta, psimhit_module, psimhit_phi, psimhit_sector, psimhit_x, psimhit_y, psimhit_z, simhit_etot, AlCaHLTBitMon_QueryRunRegistry::string, TreeFileName, and verbosity.

◆ ~DoCastorAnalysis()

DoCastorAnalysis::~DoCastorAnalysis ( )
override

Definition at line 70 of file DoCastorAnalysis.cc.

70  {
71  //destructor of DoCastorAnalysis
72 
74  //-- CastorOutputEventFile->Write();
75  CastorTree->Write("", TObject::kOverwrite);
76  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Ntuple event written";
77 #ifdef EDM_ML_DEBUG
78  getchar();
79 #endif
80  CastorOutputEventFile->Close();
81  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Event file closed";
82 #ifdef EDM_ML_DEBUG
83  getchar();
84 #endif
85 
86  if (verbosity > 0) {
87  edm::LogVerbatim("ForwardSim") << std::endl << "DoCastorAnalysis: end of process";
88 #ifdef EDM_ML_DEBUG
89  getchar();
90 #endif
91  }
92 }

References CastorOutputEventFile, CastorTree, and verbosity.

Member Function Documentation

◆ update() [1/6]

void DoCastorAnalysis::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 110 of file DoCastorAnalysis.cc.

110  {
111  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Processing Event Number: " << eventIndex;
112  eventIndex++;
113 }

References eventIndex.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [2/6]

void DoCastorAnalysis::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 96 of file DoCastorAnalysis.cc.

96 { edm::LogVerbatim("ForwardSim") << " Starting new job "; }

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [3/6]

void DoCastorAnalysis::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 100 of file DoCastorAnalysis.cc.

100  {
101  edm::LogVerbatim("ForwardSim") << std::endl << "DoCastorAnalysis: Starting Run";
102 
103  // edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: output event root file created";
104  // TString treefilename = TreeFileName;
105  // CastorOutputEventFile = new TFile(treefilename,"RECREATE");
106 
107  eventIndex = 1;
108 }

References eventIndex.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [4/6]

void DoCastorAnalysis::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 117 of file DoCastorAnalysis.cc.

117  {
118  // Look for the Hit Collection
119 
120  // access to the G4 hit collections
121  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
122 
123  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI");
124  CaloG4HitCollection* theCAFI = (CaloG4HitCollection*)allHC->GetHC(CAFIid);
125 
126  CastorNumberingScheme* theCastorNumScheme = new CastorNumberingScheme();
127 
128  unsigned int volumeID = 0;
129  // std::map<int,float,std::less<int> > themap;
130 
131  int nentries = theCAFI->entries();
132 #ifdef EDM_ML_DEBUG
133  edm::LogVerbatim("ForwardSim") << "nentries in CAFI: " << nentries;
134  getchar();
135 #endif
136 
137  psimhit_x = &simhit_x;
138  psimhit_x->clear();
139  psimhit_x->reserve(nentries);
140 
141  psimhit_y = &simhit_y;
142  psimhit_y->clear();
143  psimhit_y->reserve(nentries);
144 
145  psimhit_z = &simhit_z;
146  psimhit_z->clear();
147  psimhit_z->reserve(nentries);
148 
150  psimhit_eta->clear();
151  psimhit_eta->reserve(nentries);
152 
154  psimhit_phi->clear();
155  psimhit_phi->reserve(nentries);
156 
158  psimhit_energy->clear();
159  psimhit_energy->reserve(nentries);
160 
161  //psimhit_time=&simhit_time;
162  //psimhit_time->clear();
163  //psimhit_time->reserve(nentries);
164 
166  psimhit_sector->clear();
167  psimhit_sector->reserve(nentries);
168 
170  psimhit_module->clear();
171  psimhit_module->reserve(nentries);
172 
173  simhit_etot = 0;
174 
175  if (nentries > 0) {
176  for (int ihit = 0; ihit < nentries; ihit++) {
177  CaloG4Hit* aHit = (*theCAFI)[ihit];
178  volumeID = aHit->getUnitID();
179 
180  //themap[volumeID] += aHit->getEnergyDeposit();
181  int zside, sector, zmodule;
182 
183  theCastorNumScheme->unpackIndex(volumeID, zside, sector, zmodule);
184 
185  double energy = aHit->getEnergyDeposit() / GeV;
186  //double time = aHit->getTimeSlice();
187 
188  math::XYZPoint pos = aHit->getPosition();
189  double theta = pos.theta();
190  double eta = -log(tan(theta / 2.));
191  double phi = pos.phi();
192 
193  psimhit_x->push_back(pos.x());
194  psimhit_y->push_back(pos.y());
195  psimhit_z->push_back(pos.z());
196 
197  psimhit_eta->push_back(eta);
198  psimhit_phi->push_back(phi);
199  psimhit_energy->push_back(energy);
200 
201  // psimhit_time->push_back(time);
202  psimhit_sector->push_back(sector);
203  psimhit_module->push_back(zmodule);
204 
205  simhit_etot += energy;
206 
207 #ifdef EDM_ML_DEBUG
208  edm::LogVerbatim("ForwardSim") << "hit " << ihit + 1 << " : x = " << (*psimhit_x)[ihit]
209  << " , eta = " << (*psimhit_eta)[ihit] << " , phi = " << (*psimhit_phi)[ihit]
210  << " , energy = " << (*psimhit_energy)[ihit];
211 #endif
212  }
213 
214  //if (debug) edm::LogVerbatim("ForwardSim") << " total energy = " << simhit_etot;
215 #ifdef EDM_ML_DEBUG
216  getchar();
217 #endif
218  CastorTree->Fill();
219 
220  } // nentries > 0
221  delete theCastorNumScheme;
222 }

References CastorTree, HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getPosition(), CaloG4Hit::getUnitID(), GeV, dqm-mbProfile::log, phi, psimhit_energy, psimhit_eta, psimhit_module, psimhit_phi, psimhit_sector, psimhit_x, psimhit_y, psimhit_z, simhit_energy, simhit_eta, simhit_etot, simhit_module, simhit_phi, simhit_sector, simhit_x, simhit_y, simhit_z, funct::tan(), theta(), CastorNumberingScheme::unpackIndex(), and ecaldqm::zside().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [5/6]

void DoCastorAnalysis::update ( const EndOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

Definition at line 224 of file DoCastorAnalysis.cc.

224 { ; }

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [6/6]

void DoCastorAnalysis::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 226 of file DoCastorAnalysis.cc.

226 { ; }

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

Member Data Documentation

◆ CastorOutputEventFile

TFile* DoCastorAnalysis::CastorOutputEventFile
private

Definition at line 87 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and ~DoCastorAnalysis().

◆ CastorTree

TTree* DoCastorAnalysis::CastorTree
private

Definition at line 88 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), update(), and ~DoCastorAnalysis().

◆ eventIndex

int DoCastorAnalysis::eventIndex
private

Definition at line 90 of file DoCastorAnalysis.h.

Referenced by update().

◆ psimhit_energy

std::vector<double> * DoCastorAnalysis::psimhit_energy
private

Definition at line 98 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_eta

std::vector<double>* DoCastorAnalysis::psimhit_eta
private

Definition at line 98 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_module

std::vector<int> * DoCastorAnalysis::psimhit_module
private

Definition at line 99 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_phi

std::vector<double> * DoCastorAnalysis::psimhit_phi
private

Definition at line 98 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_sector

std::vector<int>* DoCastorAnalysis::psimhit_sector
private

Definition at line 99 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_x

std::vector<double>* DoCastorAnalysis::psimhit_x
private

Definition at line 97 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_y

std::vector<double> * DoCastorAnalysis::psimhit_y
private

Definition at line 97 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_z

std::vector<double> * DoCastorAnalysis::psimhit_z
private

Definition at line 97 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ simhit_energy

std::vector<double> DoCastorAnalysis::simhit_energy
private

Definition at line 93 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_eta

std::vector<double> DoCastorAnalysis::simhit_eta
private

Definition at line 93 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_etot

double DoCastorAnalysis::simhit_etot
private

Definition at line 102 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and update().

◆ simhit_module

std::vector<int> DoCastorAnalysis::simhit_module
private

Definition at line 94 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_phi

std::vector<double> DoCastorAnalysis::simhit_phi
private

Definition at line 93 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_sector

std::vector<int> DoCastorAnalysis::simhit_sector
private

Definition at line 94 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_x

std::vector<double> DoCastorAnalysis::simhit_x
private

Definition at line 92 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_y

std::vector<double> DoCastorAnalysis::simhit_y
private

Definition at line 92 of file DoCastorAnalysis.h.

Referenced by update().

◆ simhit_z

std::vector<double> DoCastorAnalysis::simhit_z
private

Definition at line 92 of file DoCastorAnalysis.h.

Referenced by update().

◆ TreeFileName

std::string DoCastorAnalysis::TreeFileName
private

Definition at line 85 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis().

◆ verbosity

int DoCastorAnalysis::verbosity
private

Definition at line 83 of file DoCastorAnalysis.h.

Referenced by DoCastorAnalysis(), and ~DoCastorAnalysis().

DoCastorAnalysis::CastorOutputEventFile
TFile * CastorOutputEventFile
Definition: DoCastorAnalysis.h:87
DoCastorAnalysis::simhit_sector
std::vector< int > simhit_sector
Definition: DoCastorAnalysis.h:94
DoCastorAnalysis::psimhit_sector
std::vector< int > * psimhit_sector
Definition: DoCastorAnalysis.h:99
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
CaloG4Hit::getUnitID
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
pos
Definition: PixelAliasList.h:18
DoCastorAnalysis::simhit_etot
double simhit_etot
Definition: DoCastorAnalysis.h:102
DoCastorAnalysis::eventIndex
int eventIndex
Definition: DoCastorAnalysis.h:90
DoCastorAnalysis::TreeFileName
std::string TreeFileName
Definition: DoCastorAnalysis.h:85
DoCastorAnalysis::simhit_energy
std::vector< double > simhit_energy
Definition: DoCastorAnalysis.h:93
PVValHelper::eta
Definition: PVValidationHelpers.h:70
DoCastorAnalysis::psimhit_module
std::vector< int > * psimhit_module
Definition: DoCastorAnalysis.h:99
CaloG4Hit::getEnergyDeposit
double getEnergyDeposit() const
Definition: CaloG4Hit.h:78
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
DoCastorAnalysis::simhit_module
std::vector< int > simhit_module
Definition: DoCastorAnalysis.h:94
DoCastorAnalysis::psimhit_z
std::vector< double > * psimhit_z
Definition: DoCastorAnalysis.h:97
DoCastorAnalysis::verbosity
int verbosity
Definition: DoCastorAnalysis.h:83
DoCastorAnalysis::simhit_z
std::vector< double > simhit_z
Definition: DoCastorAnalysis.h:92
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
DoCastorAnalysis::psimhit_x
std::vector< double > * psimhit_x
Definition: DoCastorAnalysis.h:97
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CastorNumberingScheme
Definition: CastorNumberingScheme.h:30
CastorNumberingScheme::unpackIndex
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
Definition: CastorNumberingScheme.cc:193
GeV
const double GeV
Definition: MathUtil.h:16
DoCastorAnalysis::simhit_x
std::vector< double > simhit_x
Definition: DoCastorAnalysis.h:92
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
DoCastorAnalysis::simhit_eta
std::vector< double > simhit_eta
Definition: DoCastorAnalysis.h:93
CaloG4Hit
Definition: CaloG4Hit.h:32
CaloG4Hit::getPosition
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
DoCastorAnalysis::psimhit_energy
std::vector< double > * psimhit_energy
Definition: DoCastorAnalysis.h:98
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDAxes::phi
DoCastorAnalysis::CastorTree
TTree * CastorTree
Definition: DoCastorAnalysis.h:88
DoCastorAnalysis::psimhit_phi
std::vector< double > * psimhit_phi
Definition: DoCastorAnalysis.h:98
DoCastorAnalysis::psimhit_y
std::vector< double > * psimhit_y
Definition: DoCastorAnalysis.h:97
DoCastorAnalysis::simhit_phi
std::vector< double > simhit_phi
Definition: DoCastorAnalysis.h:93
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CaloG4HitCollection
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
Definition: CaloG4HitCollection.h:11
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
DoCastorAnalysis::simhit_y
std::vector< double > simhit_y
Definition: DoCastorAnalysis.h:92
DoCastorAnalysis::psimhit_eta
std::vector< double > * psimhit_eta
Definition: DoCastorAnalysis.h:98