CMS 3D CMS Logo

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 66 of file CastorTestAnalysis.h.

Constructor & Destructor Documentation

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

Definition at line 34 of file CastorTestAnalysis.cc.

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

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

Definition at line 65 of file CastorTestAnalysis.cc.

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

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

Member Function Documentation

void CastorTestAnalysis::Finish ( )
private

Definition at line 353 of file CastorTestAnalysis.cc.

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

Referenced by ~CastorTestAnalysis().

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

Definition at line 296 of file CastorTestAnalysis.cc.

References castoreventarray, castoreventntuple, eventGlobalHit, eventIndex, objects.autophobj::float, 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 HcalDigiParam_cfi::zside.

Referenced by update().

296  {
297 
298  int nentries = hc->entries();
299 
300  if (nentries > 0) {
301 
302  unsigned int volumeID=0;
303  int det=0, zside, sector, zmodule;
304  std::map<int,float,std::less<int> > themap;
305  double totalEnergy = 0;
306  double hitEnergy = 0;
307  double en_in_sd = 0.;
308 
309  for (int ihit = 0; ihit < nentries; ihit++) {
310  CaloG4Hit* aHit = (*hc)[ihit];
311  totalEnergy += aHit->getEnergyDeposit();
312  }
313 
314  for (int ihit = 0; ihit < nentries; ihit++) {
315  CaloG4Hit* aHit = (*hc)[ihit];
316  volumeID = aHit->getUnitID();
317  hitEnergy = aHit->getEnergyDeposit();
318  en_in_sd += aHit->getEnergyDeposit();
319 // double enEm = aHit->getEM();
320 // double enHad = aHit->getHadr();
321 
322  themap[volumeID] += aHit->getEnergyDeposit();
323  // int det, zside, sector, zmodule;
324  theCastorNumScheme->unpackIndex(volumeID, zside, sector,zmodule);
325 
326  // det = 2 ; // det=2/3 for CAFI/CAPL
327 
329 // castoreventarray[ntcastore_ihit] = (float)ihit;
334  castoreventarray[ntcastore_enem] = en_in_sd;
335  castoreventarray[ntcastore_enhad] = totalEnergy;
340 // castoreventarray[ntcastore_x] = aHit->getEntry().x();
341 // castoreventarray[ntcastore_y] = aHit->getEntry().y();
342 // castoreventarray[ntcastore_z] = aHit->getEntry().z();
343 
345 
346  eventGlobalHit++ ;
347  }
348  } // nentries > 0
349 }
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
Float_t castoreventarray[11]
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 79 of file CastorTestAnalysis.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().

79  {
80 
81  std::cout << " Starting new job " << std::endl;
82 }
void CastorTestAnalysis::update ( const BeginOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 85 of file CastorTestAnalysis.cc.

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

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().

85  {
86 
87  std::cout << std::endl << "CastorTestAnalysis: Starting Run"<< std::endl;
88  if (doNTcastorstep) {
89  std::cout << "CastorTestAnalysis: output step root file created"<< std::endl;
90  TString stepfilename = stepNtFileName;
91  castorOutputStepFile = new TFile(stepfilename,"RECREATE");
92 
93  }
94 
95  if (doNTcastorevent) {
96  std::cout << "CastorTestAnalysis: output event root file created"<< std::endl;
97  TString stepfilename = eventNtFileName;
98  castorOutputEventFile = new TFile(stepfilename,"RECREATE");
99  }
100 
101  eventIndex = 0;
102 }
std::string stepNtFileName
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 293 of file CastorTestAnalysis.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().

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 104 of file CastorTestAnalysis.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().

104  {
105  std::cout << "CastorTestAnalysis: Processing Event Number: "<<eventIndex<< std::endl;
106  eventIndex++;
107  stepIndex = 0;
108 }
void CastorTestAnalysis::update ( const EndOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 198 of file CastorTestAnalysis.cc.

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

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().

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 113 of file CastorTestAnalysis.cc.

References castorsteparray, castorstepntuple, gather_cfg::cout, doNTcastorstep, PVValHelper::eta, eventIndex, objects.autophobj::float, 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, AlignmentTrackSelector_cfi::theCharge, and verbosity.

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().

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

Member Data Documentation

Float_t CastorTestAnalysis::castoreventarray[11]
private

Definition at line 111 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData().

TNtuple* CastorTestAnalysis::castoreventntuple
private

Definition at line 102 of file CastorTestAnalysis.h.

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

TFile* CastorTestAnalysis::castorOutputEventFile
private

Definition at line 98 of file CastorTestAnalysis.h.

Referenced by Finish(), and update().

TFile* CastorTestAnalysis::castorOutputStepFile
private

Definition at line 99 of file CastorTestAnalysis.h.

Referenced by Finish(), and update().

Float_t CastorTestAnalysis::castorsteparray[14]
private

Definition at line 110 of file CastorTestAnalysis.h.

Referenced by update().

TNtuple* CastorTestAnalysis::castorstepntuple
private

Definition at line 101 of file CastorTestAnalysis.h.

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

int CastorTestAnalysis::doNTcastorevent
private

Definition at line 94 of file CastorTestAnalysis.h.

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

int CastorTestAnalysis::doNTcastorstep
private

Definition at line 93 of file CastorTestAnalysis.h.

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

int CastorTestAnalysis::eventGlobalHit
private

Definition at line 108 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData(), and update().

int CastorTestAnalysis::eventIndex
private

Definition at line 106 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData(), and update().

std::string CastorTestAnalysis::eventNtFileName
private

Definition at line 96 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), and update().

int CastorTestAnalysis::stepIndex
private

Definition at line 107 of file CastorTestAnalysis.h.

Referenced by update().

std::string CastorTestAnalysis::stepNtFileName
private

Definition at line 95 of file CastorTestAnalysis.h.

Referenced by CastorTestAnalysis(), and update().

CastorNumberingScheme* CastorTestAnalysis::theCastorNumScheme
private

Definition at line 104 of file CastorTestAnalysis.h.

Referenced by getCastorBranchData(), and update().

int CastorTestAnalysis::verbosity
private

Definition at line 92 of file CastorTestAnalysis.h.

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