CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DoCastorAnalysis Class Reference
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
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 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 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 EndOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt) 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 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

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 67 of file DoCastorAnalysis.cc.

Constructor & Destructor Documentation

◆ DoCastorAnalysis()

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

Definition at line 108 of file DoCastorAnalysis.cc.

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.

108  {
109  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("DoCastorAnalysis");
110  verbosity = m_Anal.getParameter<int>("Verbosity");
111 
112  TreeFileName = m_Anal.getParameter<std::string>("CastorTreeFileName");
113 
114  if (verbosity > 0) {
115  edm::LogVerbatim("ForwardSim") << std::endl;
116  edm::LogVerbatim("ForwardSim") << "============================================================================";
117  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis:: Initialized as observer";
118 
119  edm::LogVerbatim("ForwardSim") << " Castor Tree will be created";
120  edm::LogVerbatim("ForwardSim") << " Castor Tree will be in file: " << TreeFileName;
121 #ifdef EDM_ML_DEBUG
122  getchar();
123 #endif
124  edm::LogVerbatim("ForwardSim") << "============================================================================";
125  edm::LogVerbatim("ForwardSim") << std::endl;
126  }
127 
128  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: output event root file created";
129  TString treefilename = TreeFileName;
130  CastorOutputEventFile = new TFile(treefilename, "RECREATE");
131 
132  CastorTree = new TTree("Sim", "Sim");
133 
134  CastorTree->Branch("simhit_x", "std::vector<double>", &psimhit_x);
135  CastorTree->Branch("simhit_y", "std::vector<double>", &psimhit_y);
136  CastorTree->Branch("simhit_z", "std::vector<double>", &psimhit_z);
137 
138  CastorTree->Branch("simhit_eta", "std::vector<double>", &psimhit_eta);
139  CastorTree->Branch("simhit_phi", "std::vector<double>", &psimhit_phi);
140  CastorTree->Branch("simhit_energy", "std::vector<double>", &psimhit_energy);
141 
142  CastorTree->Branch("simhit_sector", "std::vector<int>", &psimhit_sector);
143  CastorTree->Branch("simhit_module", "std::vector<int>", &psimhit_module);
144 
145  CastorTree->Branch("simhit_etot", &simhit_etot, "simhit_etot/D");
146 }
Log< level::Info, true > LogVerbatim
std::vector< double > * psimhit_z
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< double > * psimhit_x
std::vector< double > * psimhit_energy
std::vector< double > * psimhit_phi
std::vector< double > * psimhit_y
std::vector< double > * psimhit_eta
TFile * CastorOutputEventFile
std::vector< int > * psimhit_sector
std::string TreeFileName
std::vector< int > * psimhit_module

◆ ~DoCastorAnalysis()

DoCastorAnalysis::~DoCastorAnalysis ( )
override

Definition at line 148 of file DoCastorAnalysis.cc.

References CastorOutputEventFile, CastorTree, and verbosity.

148  {
149  //destructor of DoCastorAnalysis
150 
151  CastorOutputEventFile->cd();
152  //-- CastorOutputEventFile->Write();
153  CastorTree->Write("", TObject::kOverwrite);
154  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Ntuple event written";
155 #ifdef EDM_ML_DEBUG
156  getchar();
157 #endif
158  CastorOutputEventFile->Close();
159  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Event file closed";
160 #ifdef EDM_ML_DEBUG
161  getchar();
162 #endif
163 
164  if (verbosity > 0) {
165  edm::LogVerbatim("ForwardSim") << std::endl << "DoCastorAnalysis: end of process";
166 #ifdef EDM_ML_DEBUG
167  getchar();
168 #endif
169  }
170 }
Log< level::Info, true > LogVerbatim
TFile * CastorOutputEventFile

Member Function Documentation

◆ update() [1/6]

void DoCastorAnalysis::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob *>.

Definition at line 174 of file DoCastorAnalysis.cc.

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

174 { edm::LogVerbatim("ForwardSim") << " Starting new job "; }
Log< level::Info, true > LogVerbatim

◆ update() [2/6]

void DoCastorAnalysis::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 178 of file DoCastorAnalysis.cc.

References eventIndex.

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

178  {
179  edm::LogVerbatim("ForwardSim") << std::endl << "DoCastorAnalysis: Starting Run";
180 
181  // edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: output event root file created";
182  // TString treefilename = TreeFileName;
183  // CastorOutputEventFile = new TFile(treefilename,"RECREATE");
184 
185  eventIndex = 1;
186 }
Log< level::Info, true > LogVerbatim

◆ update() [3/6]

void DoCastorAnalysis::update ( const EndOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun *>.

Definition at line 297 of file DoCastorAnalysis.cc.

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

297 { ; }

◆ update() [4/6]

void DoCastorAnalysis::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 188 of file DoCastorAnalysis.cc.

References eventIndex.

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

188  {
189  edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Processing Event Number: " << eventIndex;
190  eventIndex++;
191 }
Log< level::Info, true > LogVerbatim

◆ update() [5/6]

void DoCastorAnalysis::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent *>.

Definition at line 195 of file DoCastorAnalysis.cc.

References CastorTree, hcalRecHitTable_cff::energy, PVValHelper::eta, CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getPosition(), CaloG4Hit::getUnitID(), dqm-mbProfile::log, phi, psimhit_energy, psimhit_eta, psimhit_module, psimhit_phi, psimhit_sector, psimhit_x, psimhit_y, psimhit_z, nano_mu_digi_cff::sector, 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().

195  {
196  // Look for the Hit Collection
197 
198  // access to the G4 hit collections
199  G4HCofThisEvent *allHC = (*evt)()->GetHCofThisEvent();
200 
201  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI");
202  CaloG4HitCollection *theCAFI = (CaloG4HitCollection *)allHC->GetHC(CAFIid);
203 
204  CastorNumberingScheme *theCastorNumScheme = new CastorNumberingScheme();
205 
206  unsigned int volumeID = 0;
207  // std::map<int,float,std::less<int> > themap;
208 
209  int nentries = theCAFI->entries();
210 #ifdef EDM_ML_DEBUG
211  edm::LogVerbatim("ForwardSim") << "nentries in CAFI: " << nentries;
212  getchar();
213 #endif
214 
215  psimhit_x = &simhit_x;
216  psimhit_x->clear();
217  psimhit_x->reserve(nentries);
218 
219  psimhit_y = &simhit_y;
220  psimhit_y->clear();
221  psimhit_y->reserve(nentries);
222 
223  psimhit_z = &simhit_z;
224  psimhit_z->clear();
225  psimhit_z->reserve(nentries);
226 
228  psimhit_eta->clear();
229  psimhit_eta->reserve(nentries);
230 
232  psimhit_phi->clear();
233  psimhit_phi->reserve(nentries);
234 
236  psimhit_energy->clear();
237  psimhit_energy->reserve(nentries);
238 
240  psimhit_sector->clear();
241  psimhit_sector->reserve(nentries);
242 
244  psimhit_module->clear();
245  psimhit_module->reserve(nentries);
246 
247  simhit_etot = 0;
248 
249  if (nentries > 0) {
250  for (int ihit = 0; ihit < nentries; ihit++) {
251  CaloG4Hit *aHit = (*theCAFI)[ihit];
252  volumeID = aHit->getUnitID();
253 
254  //themap[volumeID] += aHit->getEnergyDeposit();
255  int zside, sector, zmodule;
256 
257  theCastorNumScheme->unpackIndex(volumeID, zside, sector, zmodule);
258 
259  double energy = aHit->getEnergyDeposit() / CLHEP::GeV;
260  //double time = aHit->getTimeSlice();
261 
262  math::XYZPoint pos = aHit->getPosition();
263  double theta = pos.theta();
264  double eta = -log(tan(theta / 2.));
265  double phi = pos.phi();
266 
267  psimhit_x->push_back(pos.x());
268  psimhit_y->push_back(pos.y());
269  psimhit_z->push_back(pos.z());
270 
271  psimhit_eta->push_back(eta);
272  psimhit_phi->push_back(phi);
273  psimhit_energy->push_back(energy);
274 
275  psimhit_sector->push_back(sector);
276  psimhit_module->push_back(zmodule);
277 
278  simhit_etot += energy;
279 
280 #ifdef EDM_ML_DEBUG
281  edm::LogVerbatim("ForwardSim") << "hit " << ihit + 1 << " : x = " << (*psimhit_x)[ihit]
282  << " , eta = " << (*psimhit_eta)[ihit] << " , phi = " << (*psimhit_phi)[ihit]
283  << " , energy = " << (*psimhit_energy)[ihit];
284 #endif
285  }
286 
287  //if (debug) edm::LogVerbatim("ForwardSim") << " total energy = " << simhit_etot;
288 #ifdef EDM_ML_DEBUG
289  getchar();
290 #endif
291  CastorTree->Fill();
292 
293  } // nentries > 0
294  delete theCastorNumScheme;
295 }
Log< level::Info, true > LogVerbatim
std::vector< double > * psimhit_z
std::vector< double > simhit_eta
std::vector< double > * psimhit_x
std::vector< double > * psimhit_energy
std::vector< double > simhit_x
std::vector< double > * psimhit_phi
int zside(DetId const &)
std::vector< double > simhit_phi
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
std::vector< double > * psimhit_y
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
std::vector< double > simhit_y
std::vector< double > * psimhit_eta
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< int > simhit_sector
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< int > * psimhit_sector
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
std::vector< double > simhit_energy
std::vector< int > * psimhit_module
Geom::Theta< T > theta() const
std::vector< int > simhit_module
std::vector< double > simhit_z

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

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

299 { ; }

Member Data Documentation

◆ CastorOutputEventFile

TFile* DoCastorAnalysis::CastorOutputEventFile
private

Definition at line 92 of file DoCastorAnalysis.cc.

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

◆ CastorTree

TTree* DoCastorAnalysis::CastorTree
private

Definition at line 93 of file DoCastorAnalysis.cc.

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

◆ eventIndex

int DoCastorAnalysis::eventIndex
private

Definition at line 95 of file DoCastorAnalysis.cc.

Referenced by update().

◆ psimhit_energy

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

Definition at line 102 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_eta

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

Definition at line 102 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_module

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

Definition at line 103 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_phi

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

Definition at line 102 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_sector

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

Definition at line 103 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_x

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

Definition at line 101 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_y

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

Definition at line 101 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ psimhit_z

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

Definition at line 101 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ simhit_energy

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

Definition at line 98 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_eta

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

Definition at line 98 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_etot

double DoCastorAnalysis::simhit_etot
private

Definition at line 105 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis(), and update().

◆ simhit_module

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

Definition at line 99 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_phi

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

Definition at line 98 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_sector

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

Definition at line 99 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_x

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

Definition at line 97 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_y

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

Definition at line 97 of file DoCastorAnalysis.cc.

Referenced by update().

◆ simhit_z

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

Definition at line 97 of file DoCastorAnalysis.cc.

Referenced by update().

◆ TreeFileName

std::string DoCastorAnalysis::TreeFileName
private

Definition at line 90 of file DoCastorAnalysis.cc.

Referenced by DoCastorAnalysis().

◆ verbosity

int DoCastorAnalysis::verbosity
private

Definition at line 88 of file DoCastorAnalysis.cc.

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