CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CastorTestAnalysis Class Reference

#include <CastorTestAnalysis.h>

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

Public Member Functions

 CastorTestAnalysis (const edm::ParameterSet &p)
 
virtual ~CastorTestAnalysis ()
 
- 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 Finish ()
 
void getCastorBranchData (const CaloG4HitCollection *hc)
 
void update (const BeginOfJob *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfRun *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step)
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

Float_t castoreventarray [11]
 
TNtuple * castoreventntuple
 
TFile * castorOutputEventFile
 
TFile * castorOutputStepFile
 
Float_t castorsteparray [14]
 
TNtuple * castorstepntuple
 
int doNTcastorevent
 
int doNTcastorstep
 
int eventGlobalHit
 
int eventIndex
 
std::string eventNtFileName
 
int stepIndex
 
std::string stepNtFileName
 
CastorNumberingSchemetheCastorNumScheme
 
int verbosity
 

Additional Inherited Members

Detailed Description

Definition at line 65 of file CastorTestAnalysis.h.

Constructor & Destructor Documentation

CastorTestAnalysis::CastorTestAnalysis ( const edm::ParameterSet p)

Definition at line 35 of file CastorTestAnalysis.cc.

References castoreventntuple, castorstepntuple, gather_cfg::cout, doNTcastorevent, doNTcastorstep, eventNtFileName, edm::ParameterSet::getParameter(), stepNtFileName, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity.

35  {
36 
37  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("CastorTestAnalysis");
38  verbosity = m_Anal.getParameter<int>("Verbosity");
39  doNTcastorstep = m_Anal.getParameter<int>("StepNtupleFlag");
40  doNTcastorevent = m_Anal.getParameter<int>("EventNtupleFlag");
41  stepNtFileName = m_Anal.getParameter<std::string>("StepNtupleFileName");
42  eventNtFileName = m_Anal.getParameter<std::string>("EventNtupleFileName");
43 
44  if (verbosity > 0)
45  std::cout<<std::endl;
46  std::cout<<"============================================================================"<<std::endl;
47  std::cout << "CastorTestAnalysis:: Initialized as observer"<< std::endl;
48  if (doNTcastorstep > 0){
49  std::cout <<" Step Ntuple will be created"<< std::endl;
50  std::cout <<" Step Ntuple file: "<<stepNtFileName<<std::endl;
51  }
52  if (doNTcastorevent > 0){
53  std::cout <<" Event Ntuple will be created"<< std::endl;
54  std::cout <<" Step Ntuple file: "<<stepNtFileName<<std::endl;
55  }
56  std::cout<<"============================================================================"<<std::endl;
57  std::cout<<std::endl;
58 
59  if (doNTcastorstep > 0)
60  castorstepntuple = new TNtuple("NTcastorstep","NTcastorstep","evt:trackid:charge:pdgcode:x:y:z:stepl:stepe:eta:phi:vpx:vpy:vpz");
61 
62  if (doNTcastorevent > 0)
63  castoreventntuple = new TNtuple("NTcastorevent","NTcastorevent","evt:ihit:detector:sector:module:enem:totalenergy:hitenergy:x:y:z");
64 }
T getParameter(std::string const &) const
std::string stepNtFileName
tuple cout
Definition: gather_cfg.py:121
std::string eventNtFileName
CastorTestAnalysis::~CastorTestAnalysis ( )
virtual

Definition at line 66 of file CastorTestAnalysis.cc.

References gather_cfg::cout, Finish(), and verbosity.

66  {
67  //destructor of CastorTestAnalysis
68 
69  Finish();
70  if (verbosity > 0) {
71  std::cout << std::endl << "End of CastorTestAnalysis"
72  << std::endl;
73  }
74 
75  std::cout<<"CastorTestAnalysis: End of process"<<std::endl;
76 
77 }
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

void CastorTestAnalysis::Finish ( )
private

Definition at line 354 of file CastorTestAnalysis.cc.

References castoreventntuple, castorOutputEventFile, castorOutputStepFile, castorstepntuple, gather_cfg::cout, doNTcastorevent, and doNTcastorstep.

Referenced by ~CastorTestAnalysis().

354  {
355  if (doNTcastorstep) {
356  castorOutputStepFile->cd();
357  castorstepntuple->Write();
358  std::cout << "CastorTestAnalysis: Ntuple step written" <<std::endl;
359  castorOutputStepFile->Close();
360  std::cout << "CastorTestAnalysis: Step file closed" << std::endl;
361  }
362 
363  if (doNTcastorevent) {
364  castorOutputEventFile->cd();
365  castoreventntuple->Write("",TObject::kOverwrite);
366  std::cout << "CastorTestAnalysis: Ntuple event written" << std::endl;
367  castorOutputEventFile->Close();
368  std::cout << "CastorTestAnalysis: Event file closed" << std::endl;
369  }
370 
371 }
tuple cout
Definition: gather_cfg.py:121
void CastorTestAnalysis::getCastorBranchData ( const CaloG4HitCollection hc)
private

Definition at line 297 of file CastorTestAnalysis.cc.

References castoreventarray, castoreventntuple, eventGlobalHit, eventIndex, CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getPosition(), CaloG4Hit::getUnitID(), ntcastore_detector, ntcastore_enem, ntcastore_enhad, ntcastore_evt, ntcastore_hitenergy, ntcastore_ihit, ntcastore_module, ntcastore_sector, ntcastore_x, ntcastore_y, ntcastore_z, theCastorNumScheme, CastorNumberingScheme::unpackIndex(), and ecaldqm::zside().

Referenced by update().

297  {
298 
299  int nentries = hc->entries();
300 
301  if (nentries > 0) {
302 
303  unsigned int volumeID=0;
304  int det=0, zside, sector, zmodule;
305  std::map<int,float,std::less<int> > themap;
306  double totalEnergy = 0;
307  double hitEnergy = 0;
308  double en_in_sd = 0.;
309 
310  for (int ihit = 0; ihit < nentries; ihit++) {
311  CaloG4Hit* aHit = (*hc)[ihit];
312  totalEnergy += aHit->getEnergyDeposit();
313  }
314 
315  for (int ihit = 0; ihit < nentries; ihit++) {
316  CaloG4Hit* aHit = (*hc)[ihit];
317  volumeID = aHit->getUnitID();
318  hitEnergy = aHit->getEnergyDeposit();
319  en_in_sd += aHit->getEnergyDeposit();
320 // double enEm = aHit->getEM();
321 // double enHad = aHit->getHadr();
322 
323  themap[volumeID] += aHit->getEnergyDeposit();
324  // int det, zside, sector, zmodule;
325  theCastorNumScheme->unpackIndex(volumeID, zside, sector,zmodule);
326 
327  // det = 2 ; // det=2/3 for CAFI/CAPL
328 
330 // castoreventarray[ntcastore_ihit] = (float)ihit;
332  castoreventarray[ntcastore_detector] = (float)det;
333  castoreventarray[ntcastore_sector] = (float)sector;
334  castoreventarray[ntcastore_module] = (float)zmodule;
335  castoreventarray[ntcastore_enem] = en_in_sd;
336  castoreventarray[ntcastore_enhad] = totalEnergy;
341 // castoreventarray[ntcastore_x] = aHit->getEntry().x();
342 // castoreventarray[ntcastore_y] = aHit->getEntry().y();
343 // castoreventarray[ntcastore_z] = aHit->getEntry().z();
344 
346 
347  eventGlobalHit++ ;
348  }
349  } // nentries > 0
350 }
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
Float_t castoreventarray[11]
int zside(DetId const &)
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
CastorNumberingScheme * theCastorNumScheme
susybsm::HSCParticleCollection hc
Definition: classes.h:25
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
void CastorTestAnalysis::update ( const BeginOfJob )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 80 of file CastorTestAnalysis.cc.

References gather_cfg::cout.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

80  {
81 
82  std::cout << " Starting new job " << std::endl;
83 }
tuple cout
Definition: gather_cfg.py:121
void CastorTestAnalysis::update ( const BeginOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 86 of file CastorTestAnalysis.cc.

References castorOutputEventFile, castorOutputStepFile, gather_cfg::cout, doNTcastorevent, doNTcastorstep, eventIndex, eventNtFileName, and stepNtFileName.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

86  {
87 
88  std::cout << std::endl << "CastorTestAnalysis: Starting Run"<< std::endl;
89  if (doNTcastorstep) {
90  std::cout << "CastorTestAnalysis: output step root file created"<< std::endl;
91  TString stepfilename = stepNtFileName;
92  castorOutputStepFile = new TFile(stepfilename,"RECREATE");
93 
94  }
95 
96  if (doNTcastorevent) {
97  std::cout << "CastorTestAnalysis: output event root file created"<< std::endl;
98  TString stepfilename = eventNtFileName;
99  castorOutputEventFile = new TFile(stepfilename,"RECREATE");
100  }
101 
102  eventIndex = 0;
103 }
std::string stepNtFileName
tuple cout
Definition: gather_cfg.py:121
std::string eventNtFileName
void CastorTestAnalysis::update ( const EndOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

Definition at line 294 of file CastorTestAnalysis.cc.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

294 {;}
void CastorTestAnalysis::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 105 of file CastorTestAnalysis.cc.

References gather_cfg::cout, eventIndex, and stepIndex.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

105  {
106  std::cout << "CastorTestAnalysis: Processing Event Number: "<<eventIndex<< std::endl;
107  eventIndex++;
108  stepIndex = 0;
109 }
tuple cout
Definition: gather_cfg.py:121
void CastorTestAnalysis::update ( const EndOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 199 of file CastorTestAnalysis.cc.

References gather_cfg::cout, doNTcastorevent, eta(), eventGlobalHit, getCastorBranchData(), i, cmsBatch::log, LogDebug, bookConverter::max, min(), npart, HLT_25ns14e33_v1_cff::particleType, phi, funct::pow(), mathSSE::sqrt(), funct::tan(), theCastorNumScheme, and theta().

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

199  {
200 
201  // Look for the Hit Collection
202  std::cout << std::endl << "CastorTest::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID() << std::endl;
203 
204  // access to the G4 hit collections
205  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
206  std::cout << "update(*evt) --> accessed all HC";
207 
208  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI");
209 
210  CaloG4HitCollection* theCAFI = (CaloG4HitCollection*) allHC->GetHC(CAFIid);
211 
213  // CastorNumberingScheme *theCastorNumScheme = new CastorNumberingScheme();
214 
215 /*
216  unsigned int volumeID=0;
217  int det, zside, sector, zmodule;
218  std::map<int,float,std::less<int> > themap;
219  double totalEnergy = 0;
220  double hitEnergy = 0;
221  double en_in_fi = 0.;
222  double en_in_pl = 0.;
223 */
224 // double en_in_bu = 0.;
225 // double en_in_tu = 0.;
226 
227  if (doNTcastorevent) {
228 
229  eventGlobalHit = 0 ;
230  // int eventGlobalHit = 0 ;
231 
232  // Check FI TBranch for Hits
233  if (theCAFI->entries() > 0) getCastorBranchData(theCAFI) ;
234 
235  // Find Primary info:
236  int trackID = 0;
237  int particleType = 0;
238  G4PrimaryParticle* thePrim=0;
239  G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
240  std::cout << "Event has " << nvertex << " vertex" << std::endl;
241  if (nvertex==0) std::cout << "CASTORTest End Of Event ERROR: no vertex" << std::endl;
242 
243  for (int i = 0 ; i<nvertex; i++) {
244  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
245  if (avertex == 0)
246  std::cout << "CASTORTest End Of Event ERR: pointer to vertex = 0" << std::endl;
247  std::cout << "Vertex number :" <<i << std::endl;
248  int npart = avertex->GetNumberOfParticle();
249  if (npart ==0)
250  std::cout << "CASTORTest End Of Event ERR: no primary!" << std::endl;
251  if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
252  }
253 
254  double px=0.,py=0.,pz=0., pInit=0;
255  double eta = 0., phi = 0.;
256 
257  if (thePrim != 0) {
258  px = thePrim->GetPx();
259  py = thePrim->GetPy();
260  pz = thePrim->GetPz();
261  pInit = sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
262  if (pInit==0) {
263  std::cout << "CASTORTest End Of Event ERR: primary has p=0 " << std::endl;
264  } else {
265  float costheta = pz/pInit;
266  float theta = acos(std::min(std::max(costheta,float(-1.)),float(1.)));
267  eta = -log(tan(theta/2));
268 
269  if (px != 0) phi = atan(py/px);
270  }
271  particleType = thePrim->GetPDGcode();
272  } else {
273  std::cout << "CASTORTest End Of Event ERR: could not find primary "
274  << std::endl;
275  }
276  LogDebug("ForwardSim") << "CastorTestAnalysis: Particle Type "
277  << particleType << " p/eta/phi " << pInit << ", "
278  << eta << ", " << phi;
279  }
280 
281  int iEvt = (*evt)()->GetEventID();
282  if (iEvt < 10)
283  std::cout << " CastorTest Event " << iEvt << std::endl;
284  else if ((iEvt < 100) && (iEvt%10 == 0))
285  std::cout << " CastorTest Event " << iEvt << std::endl;
286  else if ((iEvt < 1000) && (iEvt%100 == 0))
287  std::cout << " CastorTest Event " << iEvt << std::endl;
288  else if ((iEvt < 10000) && (iEvt%1000 == 0))
289  std::cout << " CastorTest Event " << iEvt << std::endl;
290 
291  std::cout << std::endl << "===>>> Done writing user histograms " << std::endl;
292 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Geom::Theta< T > theta() const
double npart
Definition: HydjetWrapper.h:44
T eta() const
CastorNumberingScheme * theCastorNumScheme
T sqrt(T t)
Definition: SSEVec.h:48
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T min(T a, T b)
Definition: MathUtil.h:58
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
tuple cout
Definition: gather_cfg.py:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void getCastorBranchData(const CaloG4HitCollection *hc)
tuple log
Definition: cmsBatch.py:347
Definition: DDAxes.h:10
void CastorTestAnalysis::update ( const G4Step *  )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 114 of file CastorTestAnalysis.cc.

References castorsteparray, castorstepntuple, gather_cfg::cout, doNTcastorstep, eta(), eventIndex, cmsBatch::log, LogDebug, ntcastors_charge, ntcastors_eta, ntcastors_evt, ntcastors_pdgcode, ntcastors_phi, ntcastors_stepe, ntcastors_stepl, ntcastors_trackid, ntcastors_vpx, ntcastors_vpy, ntcastors_vpz, ntcastors_x, ntcastors_y, ntcastors_z, phi, stepIndex, and verbosity.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

114  {
115  stepIndex++;
116 
117 
118  if (doNTcastorstep) {
119 
120  G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
121 // G4StepPoint * postStepPoint= aStep->GetPostStepPoint();
122  G4double stepL = aStep->GetStepLength();
123  G4double stepE = aStep->GetTotalEnergyDeposit();
124 
125  if (verbosity >= 2)
126  std::cout << "Step " << stepL << ", " << stepE << std::endl;
127 
128  G4Track * theTrack = aStep->GetTrack();
129  G4int theTrackID = theTrack->GetTrackID();
130  G4double theCharge = theTrack->GetDynamicParticle()->GetCharge();
131  // G4String particleType = theTrack->GetDefinition()->GetParticleName();
132  G4int pdgcode = theTrack->GetDefinition()->GetPDGEncoding();
133 
134  G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
135  G4double vpx = vert_mom.x();
136  G4double vpy = vert_mom.y();
137  G4double vpz = vert_mom.z();
138  double eta = 0.5 * log( (1.+vpz) / (1.-vpz) );
139  double phi = atan2(vpy,vpx);
140 
141  G4ThreeVector hitPoint = preStepPoint->GetPosition();
142 
143  // Fill-in ntuple
144  // castorsteparray[ntcastors_evt] = (*evt)()->GetEventID();
146  castorsteparray[ntcastors_trackid] = (float)theTrackID;
147  castorsteparray[ntcastors_charge] = theCharge;
149  castorsteparray[ntcastors_x] = hitPoint.x();
150  castorsteparray[ntcastors_y] = hitPoint.y();
151  castorsteparray[ntcastors_z] = hitPoint.z();
159 
160  /*
161  std::cout<<"TrackID: "<< theTrackID<<std::endl;
162  std::cout<<" StepN: "<< theTrack->GetCurrentStepNumber() <<std::endl;
163  std::cout<<" ParentID: "<< aStep->GetTrack()->GetParentID() <<std::endl;
164  std::cout<<" PDG: "<< pdgcode <<std::endl;
165  std::cout<<" X,Y,Z (mm): "<< theTrack->GetPosition().x() <<","<< theTrack->GetPosition().y() <<","<< theTrack->GetPosition().z() <<std::endl;
166  std::cout<<" KE (MeV): "<< theTrack->GetKineticEnergy() <<std::endl;
167  std::cout<<" Total EDep (MeV): "<< aStep->GetTotalEnergyDeposit() <<std::endl;
168  std::cout<<" StepLength (mm): "<< aStep->GetStepLength() <<std::endl;
169  std::cout<<" TrackLength (mm): "<< theTrack->GetTrackLength() <<std::endl;
170 
171  if ( theTrack->GetNextVolume() != 0 )
172  std::cout<<" NextVolume: "<< theTrack->GetNextVolume()->GetName() <<std::endl;
173  else
174  std::cout<<" NextVolume: OutOfWorld"<<std::endl;
175 
176  if(aStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL)
177  std::cout<<" ProcessName: "<< aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() <<std::endl;
178  else
179  std::cout<<" ProcessName: UserLimit"<<std::endl;
180 
181 
182  std::cout<<std::endl;
183  */
184 
185 #ifdef DebugLog
186  if ( theTrack->GetNextVolume() != 0 )
187  LogDebug("ForwardSim") << " NextVolume: " << theTrack->GetNextVolume()->GetName() ;
188  else
189  LogDebug("ForwardSim") << " NextVolume: OutOfWorld" ;
190 #endif
191 
192 
193 //fill ntuple with step level information
195  }
196 }
#define LogDebug(id)
T eta() const
tuple cout
Definition: gather_cfg.py:121
tuple log
Definition: cmsBatch.py:347
Definition: DDAxes.h:10

Member Data Documentation

Float_t CastorTestAnalysis::castoreventarray[11]
private

Definition at line 110 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData().

TNtuple* CastorTestAnalysis::castoreventntuple
private

Definition at line 101 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), Finish(), and getCastorBranchData().

TFile* CastorTestAnalysis::castorOutputEventFile
private

Definition at line 97 of file CastorTestAnalysis.h.

Referenced by Finish(), and update().

TFile* CastorTestAnalysis::castorOutputStepFile
private

Definition at line 98 of file CastorTestAnalysis.h.

Referenced by Finish(), and update().

Float_t CastorTestAnalysis::castorsteparray[14]
private

Definition at line 109 of file CastorTestAnalysis.h.

Referenced by update().

TNtuple* CastorTestAnalysis::castorstepntuple
private

Definition at line 100 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), Finish(), and update().

int CastorTestAnalysis::doNTcastorevent
private

Definition at line 93 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), Finish(), and update().

int CastorTestAnalysis::doNTcastorstep
private

Definition at line 92 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), Finish(), and update().

int CastorTestAnalysis::eventGlobalHit
private

Definition at line 107 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData(), and update().

int CastorTestAnalysis::eventIndex
private

Definition at line 105 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData(), and update().

std::string CastorTestAnalysis::eventNtFileName
private

Definition at line 95 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), and update().

int CastorTestAnalysis::stepIndex
private

Definition at line 106 of file CastorTestAnalysis.h.

Referenced by update().

std::string CastorTestAnalysis::stepNtFileName
private

Definition at line 94 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), and update().

CastorNumberingScheme* CastorTestAnalysis::theCastorNumScheme
private

Definition at line 103 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData(), and update().

int CastorTestAnalysis::verbosity
private

Definition at line 91 of file CastorTestAnalysis.h.

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