CMS 3D CMS Logo

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

#include <ZdcTestAnalysis.h>

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

Public Member Functions

 ZdcTestAnalysis (const edm::ParameterSet &p)
 
virtual ~ZdcTestAnalysis ()
 
- 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 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

int doNTzdcevent
 
int doNTzdcstep
 
int eventIndex
 
std::string eventNtFileName
 
int stepIndex
 
std::string stepNtFileName
 
ZdcNumberingSchemetheZdcNumScheme
 
int verbosity
 
Float_t zdceventarray [16]
 
TNtuple * zdceventntuple
 
TFile * zdcOutputEventFile
 
TFile * zdcOutputStepFile
 
Float_t zdcsteparray [18]
 
TNtuple * zdcstepntuple
 

Additional Inherited Members

Detailed Description

Definition at line 63 of file ZdcTestAnalysis.h.

Constructor & Destructor Documentation

ZdcTestAnalysis::ZdcTestAnalysis ( const edm::ParameterSet p)

Definition at line 25 of file ZdcTestAnalysis.cc.

References gather_cfg::cout, doNTzdcevent, doNTzdcstep, eventNtFileName, edm::ParameterSet::getParameter(), stepNtFileName, AlCaHLTBitMon_QueryRunRegistry::string, theZdcNumScheme, verbosity, zdceventntuple, and zdcstepntuple.

25  {
26  //constructor
27  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("ZdcTestAnalysis");
28  verbosity = m_Anal.getParameter<int>("Verbosity");
29  doNTzdcstep = m_Anal.getParameter<int>("StepNtupleFlag");
30  doNTzdcevent = m_Anal.getParameter<int>("EventNtupleFlag");
31  stepNtFileName = m_Anal.getParameter<std::string>("StepNtupleFileName");
32  eventNtFileName = m_Anal.getParameter<std::string>("EventNtupleFileName");
33 
34  if (verbosity > 0)
35  std::cout<<std::endl;
36  std::cout<<"============================================================================"<<std::endl;
37  std::cout << "ZdcTestAnalysis:: Initialized as observer"<< std::endl;
38  if (doNTzdcstep > 0){
39  std::cout <<" Step Ntuple will be created"<< std::endl;
40  std::cout <<" Step Ntuple file: "<<stepNtFileName<<std::endl;
41  }
42  if (doNTzdcevent > 0){
43  std::cout <<" Event Ntuple will be created"<< std::endl;
44  std::cout <<" Step Ntuple file: "<<stepNtFileName<<std::endl;
45  }
46  std::cout<<"============================================================================"<<std::endl;
47  std::cout<<std::endl;
48 
49  if (doNTzdcstep > 0)
50  zdcstepntuple =
51  new TNtuple("NTzdcstep","NTzdcstep",
52  "evt:trackid:charge:pdgcode:x:y:z:stepl:stepe:eta:phi:vpx:vpy:vpz:idx:idl:pvtype:ncherphot");
53 
54  if (doNTzdcevent > 0)
56  new TNtuple("NTzdcevent","NTzdcevent",
57  "evt:ihit:fiberid:zside:subdet:layer:fiber:channel:enem:enhad:hitenergy:x:y:z:time:etot");
58 
59  theZdcNumScheme = nullptr;
60  //theZdcSD = new ZdcSD("ZDCHITSB", new ZdcNumberingScheme());
61 }
T getParameter(std::string const &) const
std::string stepNtFileName
TNtuple * zdceventntuple
ZdcNumberingScheme * theZdcNumScheme
TNtuple * zdcstepntuple
std::string eventNtFileName
ZdcTestAnalysis::~ZdcTestAnalysis ( )
virtual

Definition at line 63 of file ZdcTestAnalysis.cc.

References finish(), and theZdcNumScheme.

63  {
64  // destructor
65  finish();
66  delete theZdcNumScheme;
67 }
ZdcNumberingScheme * theZdcNumScheme

Member Function Documentation

void ZdcTestAnalysis::finish ( )
private

Definition at line 378 of file ZdcTestAnalysis.cc.

References gather_cfg::cout, doNTzdcevent, doNTzdcstep, eventIndex, zdceventntuple, zdcOutputEventFile, zdcOutputStepFile, and zdcstepntuple.

Referenced by progressbar.ProgressBar::__next__(), and ~ZdcTestAnalysis().

378  {
379  if (doNTzdcstep) {
380  zdcOutputStepFile->cd();
381  zdcstepntuple->Write();
382  std::cout << "ZdcTestAnalysis: Ntuple step written for event: "<<eventIndex<<std::endl;
383  zdcOutputStepFile->Close();
384  std::cout << "ZdcTestAnalysis: Step file closed" << std::endl;
385  }
386 
387 
388  if (doNTzdcevent) {
389  zdcOutputEventFile->cd();
390  zdceventntuple->Write("",TObject::kOverwrite);
391  std::cout << "ZdcTestAnalysis: Ntuple event written for event: "<<eventIndex<<std::endl;
392  zdcOutputEventFile->Close();
393  std::cout << "ZdcTestAnalysis: Event file closed" << std::endl;
394  }
395 }
TFile * zdcOutputEventFile
TFile * zdcOutputStepFile
TNtuple * zdceventntuple
TNtuple * zdcstepntuple
void ZdcTestAnalysis::update ( const BeginOfJob )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 69 of file ZdcTestAnalysis.cc.

References gather_cfg::cout.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.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(), MatrixUtil.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().

69  {
70  //job
71  std::cout<<"beggining of job"<<std::endl;;
72 }
void ZdcTestAnalysis::update ( const BeginOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 75 of file ZdcTestAnalysis.cc.

References gather_cfg::cout, doNTzdcevent, doNTzdcstep, eventIndex, eventNtFileName, stepNtFileName, zdcOutputEventFile, and zdcOutputStepFile.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.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(), MatrixUtil.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().

75  {
76  //run
77 
78  std::cout << std::endl << "ZdcTestAnalysis: Begining of Run"<< std::endl;
79  if (doNTzdcstep) {
80  std::cout << "ZDCTestAnalysis: output step file created"<< std::endl;
81  TString stepfilename = stepNtFileName;
82  zdcOutputStepFile = new TFile(stepfilename,"RECREATE");
83 
84  }
85 
86  if (doNTzdcevent) {
87  std::cout << "ZDCTestAnalysis: output event file created"<< std::endl;
88  TString stepfilename = eventNtFileName;
89  zdcOutputEventFile = new TFile(stepfilename,"RECREATE");
90  }
91 
92  eventIndex = 0;
93 }
TFile * zdcOutputEventFile
std::string stepNtFileName
TFile * zdcOutputStepFile
std::string eventNtFileName
void ZdcTestAnalysis::update ( const EndOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

Definition at line 376 of file ZdcTestAnalysis.cc.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.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(), MatrixUtil.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().

376 {;}
void ZdcTestAnalysis::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 95 of file ZdcTestAnalysis.cc.

References gather_cfg::cout, eventIndex, and stepIndex.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.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(), MatrixUtil.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().

95  {
96  //event
97  std::cout << "ZdcTest: Processing Event Number: "<<eventIndex<< std::endl;
98  eventIndex++;
99  stepIndex = 0;
100 }
void ZdcTestAnalysis::update ( const EndOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 230 of file ZdcTestAnalysis.cc.

References gather_cfg::cout, TauDecayModes::dec, doNTzdcevent, eventIndex, objects.autophobj::float, CaloG4Hit::getEM(), CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getHadr(), CaloG4Hit::getPosition(), CaloG4Hit::getTimeSliceID(), CaloG4Hit::getTrackID(), CaloG4Hit::getUnitID(), i, createfilelist::int, genParticles_cff::map, DTLinearDriftAlgo_cfi::maxTime, ntzdce_channel, ntzdce_enem, ntzdce_enhad, ntzdce_etot, ntzdce_evt, ntzdce_fiber, ntzdce_fiberid, ntzdce_hitenergy, ntzdce_ihit, ntzdce_layer, ntzdce_subdet, ntzdce_time, ntzdce_x, ntzdce_y, ntzdce_z, ntzdce_zside, funct::pow(), mathSSE::sqrt(), stepIndex, theZdcNumScheme, ntuplemaker::time, ZdcNumberingScheme::unpackZdcIndex(), verbosity, zdceventarray, and zdceventntuple.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.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(), MatrixUtil.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().

230  {
231  //end of event
232 
233  // Look for the Hit Collection
234  std::cout << std::endl << "ZdcTest::upDate(const EndOfEvent * evt) - event #" << (*evt)()->GetEventID()
235  << std::endl << " # of aSteps followed in event = " << stepIndex << std::endl;
236 
237  // access to the G4 hit collections
238  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
239  std::cout << " accessed all HC";
240 
241  int theZDCHCid = G4SDManager::GetSDMpointer()->GetCollectionID("ZDCHITS");
242  std::cout << " - theZDCHCid = " << theZDCHCid;
243 
244  CaloG4HitCollection* theZDCHC = (CaloG4HitCollection*) allHC->GetHC(theZDCHCid);
245  std::cout << " - theZDCHC = " << theZDCHC << std::endl;
246 
248 
249  float ETot=0., SEnergy=0.;
250  int maxTime=0;
251  int fiberID=0;
252  unsigned int unsignedfiberID=0;
253  std::map<int,float,std::less<int> > energyInFibers;
254  std::map<int,float,std::less<int> > primaries;
255  float totalEnergy = 0;
256  int nentries = theZDCHC->entries();
257  std::cout << " theZDCHC has " << nentries << " entries" << std::endl;
258 
259  if (doNTzdcevent) {
260  if (nentries > 0) {
261  for (int ihit = 0; ihit < nentries; ihit++) {
262  CaloG4Hit* caloHit = (*theZDCHC)[ihit];
263  totalEnergy += caloHit->getEnergyDeposit();
264  }
265 
266  for (int ihit = 0; ihit < nentries; ihit++) {
267  CaloG4Hit* aHit = (*theZDCHC)[ihit];
268  fiberID = aHit->getUnitID();
269  unsignedfiberID = aHit->getUnitID();
270  double enEm = aHit->getEM();
271  double enHad = aHit->getHadr();
272  math::XYZPoint hitPoint = aHit->getPosition();
273  double hitEnergy = aHit->getEnergyDeposit();
274  if (verbosity >= 1)
275  std::cout << " entry #" << ihit << ": fiberID=0x" << std::hex
276  << fiberID << std::dec << "; enEm=" << enEm
277  << "; enHad=" << enHad << "; hitEnergy=" << hitEnergy
278  << "z=" << hitPoint.z() << std::endl;
279  energyInFibers[fiberID]+= enEm + enHad;
280  primaries[aHit->getTrackID()]+= enEm + enHad;
281  float time = aHit->getTimeSliceID();
282  if (time > maxTime) maxTime=(int)time;
283 
284  int thesubdet, thelayer, thefiber, thechannel, thez;
285  theZdcNumScheme->unpackZdcIndex(fiberID, thesubdet, thelayer, thefiber, thechannel, thez);
286  int unsignedsubdet, unsignedlayer, unsignedfiber, unsignedchannel, unsignedz;
287  theZdcNumScheme->unpackZdcIndex(unsignedfiberID, unsignedsubdet,
288  unsignedlayer, unsignedfiber, unsignedchannel, unsignedz);
289 
290  // unsigned int packidx1 = packZdcIndex(thesubdet, thelayer, thefiber, thechannel, thez);
291  // unsigned int packidx1 = packZdcIndex(thesubdet, thelayer, thefiber, thechannel, thez);
292  // unsigned int packidx1 = packZdcIndex(thesubdet, thelayer, thefiber, thechannel, thez);
293  // unsigned int packidx1 = packZdcIndex(thesubdet, thelayer, thefiber, thechannel, thez);
294 
297  zdceventarray[ntzdce_fiberid] = (float)fiberID;
299  zdceventarray[ntzdce_subdet] = (float)thesubdet;
300  zdceventarray[ntzdce_layer] = (float)thelayer;
301  zdceventarray[ntzdce_fiber] = (float)thefiber;
302  zdceventarray[ntzdce_channel] = (float)thechannel;
303  zdceventarray[ntzdce_enem] = enEm;
304  zdceventarray[ntzdce_enhad] = enHad;
305  zdceventarray[ntzdce_hitenergy] = hitEnergy;
306  zdceventarray[ntzdce_x] = hitPoint.x();
307  zdceventarray[ntzdce_y] = hitPoint.y();
308  zdceventarray[ntzdce_z] = hitPoint.z();
310  zdceventarray[ntzdce_etot] = totalEnergy;
312  }
313 
314  for (std::map<int,float,std::less<int> >::iterator is = energyInFibers.begin();
315  is!= energyInFibers.end(); is++)
316  {
317  ETot = (*is).second;
318  SEnergy += ETot;
319  }
320 
321  // Find Primary info:
322  int trackID = 0;
323  G4PrimaryParticle* thePrim=0;
324  G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
325  std::cout << "Event has " << nvertex << " vertex" << std::endl;
326  if (nvertex==0)
327  std::cout << "ZdcTest End Of Event ERROR: no vertex" << std::endl;
328 
329  for (int i = 0 ; i<nvertex; i++) {
330 
331  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
332  if (avertex == 0) {
333  std::cout << "ZdcTest End Of Event ERR: pointer to vertex = 0"
334  << std::endl;
335  } else {
336  std::cout << "Vertex number :" <<i << std::endl;
337  int npart = avertex->GetNumberOfParticle();
338  if (npart ==0)
339  std::cout << "ZdcTest End Of Event ERR: no primary!" << std::endl;
340  if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
341  }
342  }
343 
344  double px=0.,py=0.,pz=0.;
345  double pInit = 0.;
346 
347  if (thePrim != 0) {
348  px = thePrim->GetPx();
349  py = thePrim->GetPy();
350  pz = thePrim->GetPz();
351  pInit = sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
352  if (pInit==0) {
353  std::cout << "ZdcTest End Of Event ERR: primary has p=0 " << std::endl;
354  }
355  } else {
356  std::cout << "ZdcTest End Of Event ERR: could not find primary "
357  << std::endl;
358  }
359 
360  } // nentries > 0
361 
362 
363  } // createNTzdcevent
364 
365  int iEvt = (*evt)()->GetEventID();
366  if (iEvt < 10)
367  std::cout << " ZdcTest Event " << iEvt << std::endl;
368  else if ((iEvt < 100) && (iEvt%10 == 0))
369  std::cout << " ZdcTest Event " << iEvt << std::endl;
370  else if ((iEvt < 1000) && (iEvt%100 == 0))
371  std::cout << " ZdcTest Event " << iEvt << std::endl;
372  else if ((iEvt < 10000) && (iEvt%1000 == 0))
373  std::cout << " ZdcTest Event " << iEvt << std::endl;
374 }
int i
Definition: DBlmapReader.cc:9
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
Float_t zdceventarray[16]
T sqrt(T t)
Definition: SSEVec.h:18
TNtuple * zdceventntuple
ZdcNumberingScheme * theZdcNumScheme
int getTrackID() const
Definition: CaloG4Hit.h:68
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
static void unpackZdcIndex(const unsigned int &idx, int &subDet, int &layer, int &fiber, int &channel, int &z)
int getTimeSliceID() const
Definition: CaloG4Hit.h:71
double getEM() const
Definition: CaloG4Hit.h:59
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double getHadr() const
Definition: CaloG4Hit.h:62
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
void ZdcTestAnalysis::update ( const G4Step *  )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 102 of file ZdcTestAnalysis.cc.

References gather_cfg::cout, doNTzdcstep, stringResolutionProvider_cfi::eta, eventIndex, objects.autophobj::float, training_settings::idx, findQualityFiles::jj, cmsBatch::log, ntzdcs_charge, ntzdcs_eta, ntzdcs_evt, ntzdcs_idl, ntzdcs_idx, ntzdcs_ncherphot, ntzdcs_pdgcode, ntzdcs_phi, ntzdcs_pvtype, ntzdcs_stepe, ntzdcs_stepl, ntzdcs_trackid, ntzdcs_vpx, ntzdcs_vpy, ntzdcs_vpz, ntzdcs_x, ntzdcs_y, ntzdcs_z, objects.autophobj::particleType, phi, stepIndex, AlignmentTrackSelector_cfi::theCharge, verbosity, zdcsteparray, and zdcstepntuple.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.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(), MatrixUtil.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().

102  {
103  //step;
104  stepIndex++;
105 
106  if (doNTzdcstep) {
107  G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
108  // G4StepPoint * postStepPoint= aStep->GetPostStepPoint();
109  G4double stepL = aStep->GetStepLength();
110  G4double stepE = aStep->GetTotalEnergyDeposit();
111 
112  if (verbosity >= 2)
113  std::cout << "Step " << stepL << "," << stepE <<std::endl;
114 
115  G4Track * theTrack = aStep->GetTrack();
116  G4int theTrackID = theTrack->GetTrackID();
117  G4double theCharge = theTrack->GetDynamicParticle()->GetCharge();
118  G4String particleType = theTrack->GetDefinition()->GetParticleName();
119  G4int pdgcode = theTrack->GetDefinition()->GetPDGEncoding();
120 
121  G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
122  G4double vpx = vert_mom.x();
123  G4double vpy = vert_mom.y();
124  G4double vpz = vert_mom.z();
125  double eta = 0.5 * log( (1.+vpz) / (1.-vpz) );
126  double phi = atan2(vpy,vpx);
127 
128  G4ThreeVector hitPoint = preStepPoint->GetPosition();
129  G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->
130  GetTopTransform().TransformPoint(hitPoint);
131 
132  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
133  int idx = touch->GetReplicaNumber(0);
134  int idLayer = -1;
135  int thePVtype = -1;
136 
137  int historyDepth = touch->GetHistoryDepth();
138 
139  if (historyDepth > 0) {
140  std::vector<int> theReplicaNumbers(historyDepth);
141  std::vector<G4VPhysicalVolume*> thePhysicalVolumes(historyDepth);
142  std::vector<G4String> thePVnames(historyDepth);
143  std::vector<G4LogicalVolume*> theLogicalVolumes(historyDepth);
144  std::vector<G4String> theLVnames(historyDepth);
145  std::vector<G4Material*> theMaterials(historyDepth);
146  std::vector<G4String> theMaterialNames(historyDepth);
147 
148  for (int jj = 0; jj < historyDepth; jj++) {
149  theReplicaNumbers[jj] = touch->GetReplicaNumber(jj);
150  thePhysicalVolumes[jj] = touch->GetVolume(jj);
151  thePVnames[jj] = thePhysicalVolumes[jj]->GetName();
152  theLogicalVolumes[jj] = thePhysicalVolumes[jj]->GetLogicalVolume();
153  theLVnames[jj] = theLogicalVolumes[jj]->GetName();
154  theMaterials[jj] = theLogicalVolumes[jj]->GetMaterial();
155  theMaterialNames[jj] = theMaterials[jj]->GetName();
156  if (verbosity >= 2)
157  std::cout << " GHD " << jj << ": " << theReplicaNumbers[jj] << ","
158  << thePVnames[jj] << "," << theLVnames[jj] << ","
159  << theMaterialNames[jj] << std::endl;
160  }
161 
162  idLayer = theReplicaNumbers[1];
163  if (thePVnames[0] == "ZDC_EMLayer")
164  thePVtype = 1;
165  else if (thePVnames[0] == "ZDC_EMAbsorber")
166  thePVtype = 2;
167  else if (thePVnames[0] == "ZDC_EMFiber")
168  thePVtype = 3;
169  else if (thePVnames[0] == "ZDC_HadLayer")
170  thePVtype = 7;
171  else if (thePVnames[0] == "ZDC_HadAbsorber")
172  thePVtype = 8;
173  else if (thePVnames[0] == "ZDC_HadFiber")
174  thePVtype = 9;
175  else if (thePVnames[0] == "ZDC_PhobosLayer")
176  thePVtype = 11;
177  else if (thePVnames[0] == "ZDC_PhobosAbsorber")
178  thePVtype = 12;
179  else if (thePVnames[0] == "ZDC_PhobosFiber")
180  thePVtype = 13;
181  else {
182  thePVtype = 0;
183  if (verbosity >= 2)
184  std::cout << " pvtype=0 hd=" << historyDepth << " " << theReplicaNumbers[0] << ","
185  << thePVnames[0] << "," << theLVnames[0] << "," << theMaterialNames[0] << std::endl;
186  }
187  }
188  else if (historyDepth == 0) {
189  int theReplicaNumber = touch->GetReplicaNumber(0);
190  G4VPhysicalVolume* thePhysicalVolume = touch->GetVolume(0);
191  G4String thePVname = thePhysicalVolume->GetName();
192  G4LogicalVolume * theLogicalVolume = thePhysicalVolume->GetLogicalVolume();
193  G4String theLVname = theLogicalVolume->GetName();
194  G4Material * theMaterial = theLogicalVolume->GetMaterial();
195  G4String theMaterialName = theMaterial->GetName();
196  if (verbosity >= 2)
197  std::cout << " hd=0 " << theReplicaNumber << ","
198  << thePVname << "," << theLVname << ","
199  << theMaterialName << std::endl;
200  }
201  else {
202  std::cout << " hd<0: hd=" << historyDepth << std::endl;
203  }
204 
205 
206  double NCherPhot = -1;
208  zdcsteparray[ntzdcs_trackid] = (float)theTrackID;
210  zdcsteparray[ntzdcs_pdgcode] = (float)pdgcode;
211  zdcsteparray[ntzdcs_x] = hitPoint.x();
212  zdcsteparray[ntzdcs_y] = hitPoint.y();
213  zdcsteparray[ntzdcs_z] = hitPoint.z();
214  zdcsteparray[ntzdcs_stepl] = stepL;
215  zdcsteparray[ntzdcs_stepe] = stepE;
218  zdcsteparray[ntzdcs_vpx] = vpx;
219  zdcsteparray[ntzdcs_vpy] = vpy;
220  zdcsteparray[ntzdcs_vpz] = vpz;
221  zdcsteparray[ntzdcs_idx] = (float)idx;
222  zdcsteparray[ntzdcs_idl] = (float)idLayer;
223  zdcsteparray[ntzdcs_pvtype] = thePVtype;
224  zdcsteparray[ntzdcs_ncherphot] = NCherPhot;
226 
227  }
228 }
TNtuple * zdcstepntuple
Float_t zdcsteparray[18]

Member Data Documentation

int ZdcTestAnalysis::doNTzdcevent
private

Definition at line 90 of file ZdcTestAnalysis.h.

Referenced by finish(), update(), and ZdcTestAnalysis().

int ZdcTestAnalysis::doNTzdcstep
private

Definition at line 89 of file ZdcTestAnalysis.h.

Referenced by finish(), update(), and ZdcTestAnalysis().

int ZdcTestAnalysis::eventIndex
private

Definition at line 100 of file ZdcTestAnalysis.h.

Referenced by finish(), and update().

std::string ZdcTestAnalysis::eventNtFileName
private

Definition at line 92 of file ZdcTestAnalysis.h.

Referenced by update(), and ZdcTestAnalysis().

int ZdcTestAnalysis::stepIndex
private

Definition at line 101 of file ZdcTestAnalysis.h.

Referenced by update().

std::string ZdcTestAnalysis::stepNtFileName
private

Definition at line 91 of file ZdcTestAnalysis.h.

Referenced by update(), and ZdcTestAnalysis().

ZdcNumberingScheme* ZdcTestAnalysis::theZdcNumScheme
private

Definition at line 106 of file ZdcTestAnalysis.h.

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

int ZdcTestAnalysis::verbosity
private

Definition at line 88 of file ZdcTestAnalysis.h.

Referenced by update(), and ZdcTestAnalysis().

Float_t ZdcTestAnalysis::zdceventarray[16]
private

Definition at line 104 of file ZdcTestAnalysis.h.

Referenced by update().

TNtuple* ZdcTestAnalysis::zdceventntuple
private

Definition at line 98 of file ZdcTestAnalysis.h.

Referenced by finish(), update(), and ZdcTestAnalysis().

TFile* ZdcTestAnalysis::zdcOutputEventFile
private

Definition at line 94 of file ZdcTestAnalysis.h.

Referenced by finish(), and update().

TFile* ZdcTestAnalysis::zdcOutputStepFile
private

Definition at line 95 of file ZdcTestAnalysis.h.

Referenced by finish(), and update().

Float_t ZdcTestAnalysis::zdcsteparray[18]
private

Definition at line 103 of file ZdcTestAnalysis.h.

Referenced by update().

TNtuple* ZdcTestAnalysis::zdcstepntuple
private

Definition at line 97 of file ZdcTestAnalysis.h.

Referenced by finish(), update(), and ZdcTestAnalysis().