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
 SimWatcher ()
 
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 28 of file DoCastorAnalysis.cc.

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

References CastorOutputEventFile, CastorTree, gather_cfg::cout, debug, 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 69 of file DoCastorAnalysis.cc.

69  {
70  //destructor of DoCastorAnalysis
71 
73  //-- CastorOutputEventFile->Write();
74  CastorTree->Write("", TObject::kOverwrite);
75  std::cout << "DoCastorAnalysis: Ntuple event written" << std::endl;
76  if (debug)
77  getchar();
78  CastorOutputEventFile->Close();
79  std::cout << "DoCastorAnalysis: Event file closed" << std::endl;
80  if (debug)
81  getchar();
82 
83  if (verbosity > 0) {
84  std::cout << std::endl << "DoCastorAnalysis: end of process" << std::endl;
85  if (debug)
86  getchar();
87  }
88 }

References CastorOutputEventFile, CastorTree, gather_cfg::cout, debug, 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 106 of file DoCastorAnalysis.cc.

106  {
107  std::cout << "DoCastorAnalysis: Processing Event Number: " << eventIndex << std::endl;
108  eventIndex++;
109 }

References gather_cfg::cout, and 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 92 of file DoCastorAnalysis.cc.

92 { std::cout << " Starting new job " << std::endl; }

References gather_cfg::cout.

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 96 of file DoCastorAnalysis.cc.

96  {
97  std::cout << std::endl << "DoCastorAnalysis: Starting Run" << std::endl;
98 
99  // std::cout << "DoCastorAnalysis: output event root file created"<< std::endl;
100  // TString treefilename = TreeFileName;
101  // CastorOutputEventFile = new TFile(treefilename,"RECREATE");
102 
103  eventIndex = 1;
104 }

References gather_cfg::cout, and 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 113 of file DoCastorAnalysis.cc.

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

References CastorTree, gather_cfg::cout, debug, 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 217 of file DoCastorAnalysis.cc.

217 { ; }

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 219 of file DoCastorAnalysis.cc.

219 { ; }

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:65
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
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:69
DoCastorAnalysis::psimhit_module
std::vector< int > * psimhit_module
Definition: DoCastorAnalysis.h:99
CaloG4Hit::getEnergyDeposit
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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
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
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::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
debug
#define debug
Definition: DoCastorAnalysis.cc:26
DoCastorAnalysis::simhit_y
std::vector< double > simhit_y
Definition: DoCastorAnalysis.h:92
DoCastorAnalysis::psimhit_eta
std::vector< double > * psimhit_eta
Definition: DoCastorAnalysis.h:98