CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
BscTest Class Reference
Inheritance diagram for BscTest:
Observer< const EndOfEvent *> Observer< const EndOfTrack *> Observer< const G4Step *> Observer< const BeginOfTrack *> Observer< const BeginOfEvent *> Observer< const EndOfRun *> Observer< const BeginOfRun *> Observer< const BeginOfJob *> SimWatcher

Public Member Functions

 BscTest (const edm::ParameterSet &p)
 
 ~BscTest () 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 BeginOfTrack *>
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step *>
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack *>
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent *>
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Private Member Functions

void detectorLevel (const G4VTouchable *, int &, int *, G4String *) const
 
int detLevels (const G4VTouchable *) const
 
G4String detName (const G4VTouchable *, int, int) const
 
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 BeginOfTrack *trk) 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...
 
void update (const EndOfTrack *trk) 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...
 

Private Attributes

Float_t bsceventarray [1]
 
TNtuple * bsceventntuple
 
TFile bscOutputFile
 
G4double entot0
 
std::string fDataLabel
 
std::string fOutputFile
 
std::string fRecreateFile
 
int iev
 
int itrk
 
G4ThreeVector lastpo
 
int lastTrackID
 
int numofpart
 
double rinCalo
 
G4double sumEnerDeposit
 
G4double sumStepc
 
G4double sumStepl
 
BscNumberingSchemetheBscNumberingScheme
 
BscAnalysisHistManagerTheHistManager
 
G4double tracklength0
 
int verbosity
 
int whichevent
 
double z1
 
double z2
 
double z3
 
double z4
 
double zinCalo
 

Additional Inherited Members

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

Detailed Description

Definition at line 100 of file BscTest.cc.

Constructor & Destructor Documentation

◆ BscTest()

BscTest::BscTest ( const edm::ParameterSet p)

Definition at line 166 of file BscTest.cc.

References bsceventntuple, fDataLabel, fOutputFile, fRecreateFile, edm::ParameterSet::getParameter(), AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, theBscNumberingScheme, TheHistManager, verbosity, and whichevent.

166  {
167  //constructor
168  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("BscTest");
169  verbosity = m_Anal.getParameter<int>("Verbosity");
170  //verbosity = 1;
171 
172  fDataLabel = m_Anal.getParameter<std::string>("FDataLabel");
173  fOutputFile = m_Anal.getParameter<std::string>("FOutputFile");
174  fRecreateFile = m_Anal.getParameter<std::string>("FRecreateFile");
175 
176  if (verbosity > 0) {
177  edm::LogVerbatim("BscTest") << "============================================================================";
178  edm::LogVerbatim("BscTest") << "BscTestconstructor :: Initialized as observer";
179  }
180  // Initialization:
181 
183  bsceventntuple = new TNtuple("NTbscevent", "NTbscevent", "evt");
184  whichevent = 0;
186 
187  if (verbosity > 0) {
188  edm::LogVerbatim("BscTest") << "BscTest constructor :: Initialized BscAnalysisHistManager";
189  }
190 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string fOutputFile
Definition: BscTest.cc:159
std::string fRecreateFile
Definition: BscTest.cc:160
int verbosity
Definition: BscTest.cc:139
int whichevent
Definition: BscTest.cc:155
std::string fDataLabel
Definition: BscTest.cc:158
BscAnalysisHistManager * TheHistManager
Definition: BscTest.cc:157
BscNumberingScheme * theBscNumberingScheme
Definition: BscTest.cc:125
TNtuple * bsceventntuple
Definition: BscTest.cc:153

◆ ~BscTest()

BscTest::~BscTest ( )
override

Definition at line 192 of file BscTest.cc.

References bsceventntuple, bscOutputFile, fOutputFile, fRecreateFile, theBscNumberingScheme, TheHistManager, verbosity, and BscAnalysisHistManager::writeToFile().

192  {
193  // delete UserNtuples;
194  delete theBscNumberingScheme;
195 
196  TFile bscOutputFile("newntbsc.root", "RECREATE");
197  edm::LogVerbatim("BscTest") << "Bsc output root file has been created";
198  bsceventntuple->Write();
199  edm::LogVerbatim("BscTest") << ", written";
200  bscOutputFile.Close();
201  edm::LogVerbatim("BscTest") << ", closed";
202  delete bsceventntuple;
203  edm::LogVerbatim("BscTest") << ", and deleted";
204 
205  //------->while end
206 
207  // Write histograms to file
209  if (verbosity > 0) {
210  edm::LogVerbatim("BscTest") << std::endl << "BscTest Destructor --------> End of BscTest : ";
211  }
212 
213  edm::LogVerbatim("BscTest") << "BscTest: End of process";
214 }
Log< level::Info, true > LogVerbatim
std::string fOutputFile
Definition: BscTest.cc:159
std::string fRecreateFile
Definition: BscTest.cc:160
int verbosity
Definition: BscTest.cc:139
BscAnalysisHistManager * TheHistManager
Definition: BscTest.cc:157
BscNumberingScheme * theBscNumberingScheme
Definition: BscTest.cc:125
TNtuple * bsceventntuple
Definition: BscTest.cc:153
TFile bscOutputFile
Definition: BscTest.cc:154
void writeToFile(const TString &fOutputFile, const TString &fRecreateFile)
Definition: BscTest.cc:260

Member Function Documentation

◆ detectorLevel()

void BscTest::detectorLevel ( const G4VTouchable *  touch,
int &  level,
int *  copyno,
G4String *  name 
) const
private

Definition at line 616 of file BscTest.cc.

References mps_fire::i, cuy::ii, personalPlayback::level, and Skims_PA_cff::name.

Referenced by update().

616  {
617  //Get name and copy numbers
618  if (level > 0) {
619  for (int ii = 0; ii < level; ii++) {
620  int i = level - ii - 1;
621  G4VPhysicalVolume* pv = touch->GetVolume(i);
622  if (pv != nullptr)
623  name[ii] = pv->GetName();
624  else
625  name[ii] = "Unknown";
626  copyno[ii] = touch->GetReplicaNumber(i);
627  }
628  }
629 }
ii
Definition: cuy.py:589

◆ detLevels()

int BscTest::detLevels ( const G4VTouchable *  touch) const
private

Definition at line 597 of file BscTest.cc.

Referenced by update().

597  {
598  //Return number of levels
599  if (touch)
600  return ((touch->GetHistoryDepth()) + 1);
601  else
602  return 0;
603 }

◆ detName()

G4String BscTest::detName ( const G4VTouchable *  touch,
int  level,
int  currentlevel 
) const
private

Definition at line 606 of file BscTest.cc.

References cuy::ii, and personalPlayback::level.

606  {
607  //Go down to current level
608  if (level > 0 && level >= currentlevel) {
609  int ii = level - currentlevel;
610  return touch->GetVolume(ii)->GetName();
611  } else {
612  return "NotFound";
613  }
614 }
ii
Definition: cuy.py:589

◆ update() [1/8]

void BscTest::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob *>.

Definition at line 358 of file BscTest.cc.

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

358  {
359  //job
360  edm::LogVerbatim("BscTest") << "BscTest:beggining of job";
361  ;
362 }
Log< level::Info, true > LogVerbatim

◆ update() [2/8]

void BscTest::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 365 of file BscTest.cc.

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

365  {
366  //run
367 
368  edm::LogVerbatim("BscTest") << std::endl << "BscTest:: Begining of Run";
369 }
Log< level::Info, true > LogVerbatim

◆ update() [3/8]

void BscTest::update ( const EndOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun *>.

Definition at line 371 of file BscTest.cc.

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

371 { ; }

◆ update() [4/8]

void BscTest::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 374 of file BscTest.cc.

References iev, verbosity, and whichevent.

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

374  {
375  iev = (*evt)()->GetEventID();
376  if (verbosity > 0) {
377  edm::LogVerbatim("BscTest") << "BscTest:update Event number = " << iev;
378  }
379  whichevent++;
380 }
Log< level::Info, true > LogVerbatim
int iev
Definition: BscTest.cc:127
int verbosity
Definition: BscTest.cc:139
int whichevent
Definition: BscTest.cc:155

◆ update() [5/8]

void BscTest::update ( const BeginOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack *>.

Definition at line 383 of file BscTest.cc.

References itrk, numofpart, sumEnerDeposit, sumStepc, sumStepl, tracklength0, and verbosity.

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

383  {
384  itrk = (*trk)()->GetTrackID();
385  if (verbosity > 1) {
386  edm::LogVerbatim("BscTest") << "BscTest:update BeginOfTrack number = " << itrk;
387  }
388  if (itrk == 1) {
389  sumEnerDeposit = 0.;
390  numofpart = 0;
391  sumStepl = 0.;
392  sumStepc = 0.;
393  tracklength0 = 0.;
394  }
395 }
Log< level::Info, true > LogVerbatim
int numofpart
Definition: BscTest.cc:144
G4double sumStepc
Definition: BscTest.cc:142
int verbosity
Definition: BscTest.cc:139
G4double sumEnerDeposit
Definition: BscTest.cc:142
G4double sumStepl
Definition: BscTest.cc:142
int itrk
Definition: BscTest.cc:128
G4double tracklength0
Definition: BscTest.cc:129

◆ update() [6/8]

void BscTest::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 423 of file BscTest.cc.

References detectorLevel(), detLevels(), entot0, mps_fire::i, numofpart, PbPb_ZMuSkimMuonDPG_cff::particleType, sumEnerDeposit, sumStepc, sumStepl, tracklength0, and verbosity.

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

423  {
424  // ==========================================================================
425 
426  if (verbosity > 2) {
427  G4int stepnumber = aStep->GetTrack()->GetCurrentStepNumber();
428  edm::LogVerbatim("BscTest") << "BscTest:update Step number = " << stepnumber;
429  }
430  // track on aStep: !
431  G4Track* theTrack = aStep->GetTrack();
432  TrackInformation* trkInfo = dynamic_cast<TrackInformation*>(theTrack->GetUserInformation());
433  if (trkInfo == nullptr) {
434  edm::LogVerbatim("BscTest") << "BscTest on aStep: No trk info !!!! abort ";
435  }
436  G4int id = theTrack->GetTrackID();
437  G4String particleType = theTrack->GetDefinition()->GetParticleName(); // !!!
438  G4int parentID = theTrack->GetParentID(); // !!!
439  G4TrackStatus trackstatus = theTrack->GetTrackStatus(); // !!!
440  G4double tracklength = theTrack->GetTrackLength(); // Accumulated track length
441  G4ThreeVector trackmom = theTrack->GetMomentum();
442  G4double entot = theTrack->GetTotalEnergy(); // !!! deposited on step
443  G4int curstepnumber = theTrack->GetCurrentStepNumber();
444  G4double stepl = aStep->GetStepLength();
445  G4double EnerDeposit = aStep->GetTotalEnergyDeposit();
446  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
447  const G4ThreeVector& preposition = preStepPoint->GetPosition();
448  G4ThreeVector prelocalpoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(preposition);
449  G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
450  const G4String& prename = currentPV->GetName();
451 
452  const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
453  int pre_levels = detLevels(pre_touch);
454  G4String name1[20];
455  int copyno1[20];
456  for (int i = 0; i < 20; ++i) {
457  name1[i] = "";
458  copyno1[i] = 0;
459  }
460  if (pre_levels > 0) {
461  detectorLevel(pre_touch, pre_levels, copyno1, name1);
462  }
463 
464  if (id == 1) {
465  // on 1-st step:
466  if (curstepnumber == 1) {
467  entot0 = entot;
468  //UserNtuples->fillg519(entot0,1.);
469  }
470 
471  // on every step:
472 
473  // for Copper:
474  if (prename == "SBST") {
475  sumStepc += stepl;
476  // =========
477  }
478  // for ststeel:
479  // if(prename == "SBSTs") {
480  if (prename == "SBSTs") {
481  sumStepl += stepl;
482  // =========
483  }
484  // =========
485  // =========
486 
487  // exclude last track point if it is in SD (MI was started their)
488  if (trackstatus != 2) {
489  // for SD: Si Det.: SISTATION:SIPLANE:(SIDETL+BOUNDDET +SIDETR + CERAMDET)
490  if (prename == "SIDETL" || prename == "SIDETR") {
491  if (prename == "SIDETL") {
492  //UserNtuples->fillg569(EnerDeposit,1.);
493  }
494  if (prename == "SIDETR") {
495  //UserNtuples->fillg570(EnerDeposit,1.);
496  }
497 
498  G4String posname = aStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
499  if ((prename == "SIDETL" && posname != "SIDETL") || (prename == "SIDETR" && posname != "SIDETR")) {
500  if (name1[2] == "SISTATION") {
501  //UserNtuples->fillg539(copyno1[2],1.);
502  }
503  if (name1[3] == "SIPLANE") {
504  //UserNtuples->fillg540(copyno1[3],1.);
505  }
506 
507  if (prename == "SIDETL") {
508  //UserNtuples->fillg541(EnerDeposit,1.);
509  //UserNtuples->fillg561(numbcont,1.);
510  if (copyno1[2] < 2) {
511  //UserNtuples->fillg571(dx,1.);
512  } else if (copyno1[2] < 3) {
513  //UserNtuples->fillg563(dx,1.);
514  if (copyno1[3] < 2) {
515  } else if (copyno1[3] < 3) {
516  //UserNtuples->fillg572(dx,1.);
517  } else if (copyno1[3] < 4) {
518  //UserNtuples->fillg573(dx,1.);
519  } else if (copyno1[3] < 5) {
520  //UserNtuples->fillg574(dx,1.);
521  } else if (copyno1[3] < 6) {
522  //UserNtuples->fillg575(dx,1.);
523  } else if (copyno1[3] < 7) {
524  //UserNtuples->fillg576(dx,1.);
525  } else if (copyno1[3] < 8) {
526  //UserNtuples->fillg577(dx,1.);
527  } else if (copyno1[3] < 9) {
528  //UserNtuples->fillg578(dx,1.);
529  } else if (copyno1[3] < 10) {
530  //UserNtuples->fillg579(dx,1.);
531  }
532  } else if (copyno1[2] < 4) {
533  //UserNtuples->fillg565(dx,1.);
534  } else if (copyno1[2] < 5) {
535  //UserNtuples->fillg567(dx,1.);
536  }
537  }
538  if (prename == "SIDETR") {
539  //UserNtuples->fillg542(EnerDeposit,1.);
540  //UserNtuples->fillg562(numbcont,1.);
541  if (copyno1[2] < 2) {
542  //UserNtuples->fillg581(dy,1.);
543  } else if (copyno1[2] < 3) {
544  //UserNtuples->fillg564(dy,1.);
545  if (copyno1[3] < 2) {
546  } else if (copyno1[3] < 3) {
547  //UserNtuples->fillg582(dy,1.);
548  } else if (copyno1[3] < 4) {
549  //UserNtuples->fillg583(dy,1.);
550  } else if (copyno1[3] < 5) {
551  //UserNtuples->fillg584(dy,1.);
552  } else if (copyno1[3] < 6) {
553  //UserNtuples->fillg585(dy,1.);
554  } else if (copyno1[3] < 7) {
555  //UserNtuples->fillg586(dy,1.);
556  } else if (copyno1[3] < 8) {
557  //UserNtuples->fillg587(dy,1.);
558  } else if (copyno1[3] < 9) {
559  //UserNtuples->fillg588(dy,1.);
560  } else if (copyno1[3] < 10) {
561  //UserNtuples->fillg589(dy,1.);
562  }
563  } else if (copyno1[2] < 4) {
564  //UserNtuples->fillg566(dy,1.);
565  } else if (copyno1[2] < 5) {
566  //UserNtuples->fillg568(dy,1.);
567  }
568  }
569  }
570  }
571  // end of prenames SIDETL // SIDETR
572  }
573  // end of trackstatus != 2
574 
575  sumEnerDeposit += EnerDeposit;
576  if (trackstatus == 2) {
577  // primary track length
578  // //UserNtuples->fillg508(tracklength,1.);
579  tracklength0 = tracklength;
580  }
581  }
582  // end of primary track !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
583 
584  if (parentID == 1 && curstepnumber == 1) {
585  // particles deposit their energy along primary track
586  numofpart += 1;
587  if (prename == "SBST") {
588  //UserNtuples->filld225(vert_pos.y(),vert_pos.z(),1.);
589  }
590  if (prename == "SBSTs") {
591  //UserNtuples->filld226(vert_pos.y(),vert_pos.z(),1.);
592  }
593  }
594 }
Log< level::Info, true > LogVerbatim
int numofpart
Definition: BscTest.cc:144
int detLevels(const G4VTouchable *) const
Definition: BscTest.cc:597
G4double sumStepc
Definition: BscTest.cc:142
int verbosity
Definition: BscTest.cc:139
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
Definition: BscTest.cc:616
G4double entot0
Definition: BscTest.cc:129
G4double sumEnerDeposit
Definition: BscTest.cc:142
G4double sumStepl
Definition: BscTest.cc:142
G4double tracklength0
Definition: BscTest.cc:129

◆ update() [7/8]

void BscTest::update ( const EndOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack *>.

Definition at line 398 of file BscTest.cc.

References BscAnalysisHistManager::getHisto(), itrk, lastpo, sumEnerDeposit, TheHistManager, and verbosity.

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

398  {
399  itrk = (*trk)()->GetTrackID();
400  if (verbosity > 1) {
401  edm::LogVerbatim("BscTest") << "BscTest:update EndOfTrack number = " << itrk;
402  }
403  if (itrk == 1) {
404  G4double tracklength = (*trk)()->GetTrackLength(); // Accumulated track length
405 
406  TheHistManager->getHisto("SumEDep")->Fill(sumEnerDeposit);
407  TheHistManager->getHisto("TrackL")->Fill(tracklength);
408 
409  // direction !!!
410  G4ThreeVector vert_mom = (*trk)()->GetVertexMomentumDirection();
411  G4ThreeVector vert_pos = (*trk)()->GetVertexPosition(); // vertex ,where this track was created
412 
413  // last step information
414  const G4Step* aStep = (*trk)()->GetStep();
415  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
416  lastpo = preStepPoint->GetPosition();
417  }
418 }
Log< level::Info, true > LogVerbatim
TH1F * getHisto(Int_t Number)
Definition: BscTest.cc:301
G4ThreeVector lastpo
Definition: BscTest.cc:146
int verbosity
Definition: BscTest.cc:139
BscAnalysisHistManager * TheHistManager
Definition: BscTest.cc:157
G4double sumEnerDeposit
Definition: BscTest.cc:142
int itrk
Definition: BscTest.cc:128

◆ update() [8/8]

void BscTest::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent *>.

Definition at line 633 of file BscTest.cc.

References bsceventarray, PVValHelper::eta, dqmMemoryStats::float, BscG4Hit::getEnergyLoss(), BscG4Hit::getEntry(), BscG4Hit::getEntryLocalP(), BscG4Hit::getExitLocalP(), BscAnalysisHistManager::getHisto(), BscG4Hit::getUnitID(), mps_fire::i, iev, dqmiolumiharvest::j, lastpo, dqm-mbProfile::log, nhits, npart, ntbsc_evt, numofpart, phi, pi, funct::tan(), TheHistManager, tracklength0, BscNumberingScheme::unpackBscIndex(), verbosity, whichevent, z4, ecaldqm::zside(), and geometryCSVtoXML::zz.

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

633  {
634  // ==========================================================================
635 
636  if (verbosity > 1) {
637  iev = (*evt)()->GetEventID();
638  edm::LogVerbatim("BscTest") << "BscTest:update EndOfEvent = " << iev;
639  }
640  // Fill-in ntuple
642 
643  //
644  int trackID = 0;
645  G4PrimaryParticle* thePrim = nullptr;
646 
647  // prim.vertex:
648  G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
649  if (nvertex != 1)
650  edm::LogVerbatim("BscTest") << "BscTest: My warning: NumberOfPrimaryVertex != 1 --> = " << nvertex;
651 
652  for (int i = 0; i < nvertex; i++) {
653  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
654  if (avertex == nullptr) {
655  edm::LogVerbatim("BscTest") << "BscTest End Of Event ERR: pointer to vertex = 0";
656  continue;
657  }
658  G4int npart = avertex->GetNumberOfParticle();
659  if (npart != 1)
660  edm::LogVerbatim("BscTest") << "BscTest: My warning: NumberOfPrimaryPart != 1 --> = " << npart;
661  if (npart == 0)
662  edm::LogVerbatim("BscTest") << "BscTest End Of Event ERR: no NumberOfParticle";
663 
664  if (thePrim == nullptr)
665  thePrim = avertex->GetPrimary(trackID);
666 
667  if (thePrim != nullptr) {
668  // primary vertex:
669  G4double vx = 0., vy = 0., vz = 0.;
670  vx = avertex->GetX0();
671  vy = avertex->GetY0();
672  vz = avertex->GetZ0();
673  //UserNtuples->fillh01(vx);
674  //UserNtuples->fillh02(vy);
675  //UserNtuples->fillh03(vz);
676  TheHistManager->getHisto("VtxX")->Fill(vx);
677  TheHistManager->getHisto("VtxY")->Fill(vy);
678  TheHistManager->getHisto("VtxZ")->Fill(vz);
679  }
680  }
681  // prim.vertex loop end
682 
683  //=========================== thePrim != 0 ================================================================================
684  if (thePrim != nullptr) {
685  //
686  // number of secondary particles deposited their energy along primary track
687  //UserNtuples->fillg518(numofpart,1.);
688  if (lastpo.z() < z4 && lastpo.perp() < 100.) {
689  //UserNtuples->fillg536(numofpart,1.);
690  }
691  //
692 
693  // direction !!!
694  G4ThreeVector mom = thePrim->GetMomentum();
695 
696  double phi = atan2(mom.y(), mom.x());
697  if (phi < 0.)
698  phi += twopi;
699  double phigrad = phi * 180. / pi;
700 
701  double th = mom.theta();
702  double eta = -log(tan(th / 2));
703  TheHistManager->getHisto("PrimaryEta")->Fill(eta);
704  TheHistManager->getHisto("PrimaryPhigrad")->Fill(phigrad);
705  TheHistManager->getHisto("PrimaryTh")->Fill(th * 180. / pi);
706 
707  TheHistManager->getHisto("PrimaryLastpoZ")->Fill(lastpo.z());
708  if (lastpo.z() < z4) {
709  TheHistManager->getHisto("PrimaryLastpoX")->Fill(lastpo.x());
710  TheHistManager->getHisto("PrimaryLastpoY")->Fill(lastpo.y());
711  }
712  if (numofpart > 4) {
713  TheHistManager->getHisto("XLastpoNumofpart")->Fill(lastpo.x());
714  TheHistManager->getHisto("YLastpoNumofpart")->Fill(lastpo.y());
715  }
716 
717  // ==========================================================================
718 
719  // hit map for Bsc
720  // ==================================
721 
722  std::map<int, float, std::less<int> > themap;
723  std::map<int, float, std::less<int> > themap1;
724 
725  std::map<int, float, std::less<int> > themapxy;
726  std::map<int, float, std::less<int> > themapz;
727  // access to the G4 hit collections: -----> this work OK:
728 #ifdef EDM_ML_DEBUG
729  edm::LogVerbatim("BscTest") << "1";
730 #endif
731  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
732 #ifdef EDM_ML_DEBUG
733  edm::LogVerbatim("BscTest") << "2";
734 #endif
735  if (verbosity > 0) {
736  edm::LogVerbatim("BscTest") << "BscTest: accessed all HC";
737  ;
738  }
739  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("BSCHits");
740 
741  BscG4HitCollection* theCAFI = (BscG4HitCollection*)allHC->GetHC(CAFIid);
742  if (verbosity > 0) {
743  edm::LogVerbatim("BscTest") << "BscTest: theCAFI->entries = " << theCAFI->entries();
744  }
745  int varia; // = 0 -all; =1 - MI; =2 - noMI
746  //varia = 0;
747  if (lastpo.z() < z4) {
748  varia = 1;
749  } else {
750  varia = 2;
751  } // no MI end:
752  int nhits = theCAFI->entries();
753  for (int j = 0; j < nhits; j++) {
754  BscG4Hit* aHit = (*theCAFI)[j];
755  const CLHEP::Hep3Vector& hitPoint = aHit->getEntry();
756  double zz = hitPoint.z();
757  TheHistManager->getHisto("zHits")->Fill(zz);
758  if (tracklength0 > 8300.)
759  TheHistManager->getHisto("zHitsTrLoLe")->Fill(zz);
760  }
761 
762  if (varia == 2) {
763  //int nhit11 = 0, nhit12 = 0, nhit13 = 0;
764  double totallosenergy = 0.;
765  for (int j = 0; j < nhits; j++) {
766  BscG4Hit* aHit = (*theCAFI)[j];
767 
768  const CLHEP::Hep3Vector& hitEntryLocalPoint = aHit->getEntryLocalP();
769  const CLHEP::Hep3Vector& hitExitLocalPoint = aHit->getExitLocalP();
770  const CLHEP::Hep3Vector& hitPoint = aHit->getEntry();
771  //int trackIDhit = aHit->getTrackID();
772  unsigned int unitID = aHit->getUnitID();
773  double losenergy = aHit->getEnergyLoss();
774 
775  double zz = hitPoint.z();
776 
777  TheHistManager->getHisto("zHitsnoMI")->Fill(zz);
778 
779  if (verbosity > 2) {
780  edm::LogVerbatim("BscTest") << "BscTest:zHits = " << zz;
781  }
782 
783  themap[unitID] += losenergy;
784  totallosenergy += losenergy;
785 
786  int zside;
787  //int sector;
789  zside = (unitID & 32) >> 5;
790  //sector = (unitID & 7);
791 
792  //
793  //=======================================
794  G4ThreeVector middle = (hitExitLocalPoint + hitEntryLocalPoint) / 2.;
795  themapz[unitID] = hitPoint.z() + middle.z();
796  //=======================================
797  // Y
798  if (zside == 1) {
799  //UserNtuples->fillg24(losenergy,1.);
800  if (losenergy > 0.00003) {
801  themap1[unitID] += 1.;
802  }
803  }
804  //X
805  else if (zside == 2) {
806  //UserNtuples->fillg25(losenergy,1.);
807  if (losenergy > 0.00005) {
808  themap1[unitID] += 1.;
809  }
810  }
811  // }
812  //
813  /*
814  if (sector == 1) {
815  nhit11 += 1;
816  //UserNtuples->fillg33(rr,1.);
817  //UserNtuples->fillg11(yy,1.);
818  }
819  if (sector == 2) {
820  nhit12 += 1;
821  //UserNtuples->fillg34(rr,1.);
822  //UserNtuples->fillg86(yy,1.);
823  }
824  if (sector == 3) {
825  nhit13 += 1;
826  //UserNtuples->fillg35(rr,1.);
827  //UserNtuples->fillg87(yy,1.);
828  }
829 
830  if (lastpo.z() < z4 && lastpo.perp() < 120.) {
831  // MIonly:
832  //UserNtuples->fillg16(lastpo.z(),1.);
833  //UserNtuples->fillg18(zz,1.);
834  // Station I
835  if (zz < z2) {
836  //UserNtuples->fillg54(dx,1.);
837  //UserNtuples->fillg55(dy,1.);
838  }
839  // Station II
840  if (zz < z3 && zz > z2) {
841  //UserNtuples->fillg50(dx,1.);
842  //UserNtuples->fillg51(dy,1.);
843  }
844  // Station III
845  if (zz < z4 && zz > z3) {
846  //UserNtuples->fillg64(dx,1.);
847  //UserNtuples->fillg65(dy,1.);
848  //UserNtuples->filld209(xx,yy,1.);
849  }
850  } else {
851  // no MIonly:
852  //UserNtuples->fillg17(lastpo.z(),1.);
853  //UserNtuples->fillg19(zz,1.);
854  //UserNtuples->fillg74(incidentEnergyHit,1.);
855  //UserNtuples->fillg75(float(trackIDhit),1.);
856  // Station I
857  if (zz < z2) {
858  //UserNtuples->fillg56(dx,1.);
859  //UserNtuples->fillg57(dy,1.);
860  //UserNtuples->fillg20(numofpart,1.);
861  //UserNtuples->fillg21(sumEnerDeposit,1.);
862  if (zside == 1) {
863  //UserNtuples->fillg26(losenergy,1.);
864  }
865  if (zside == 2) {
866  //UserNtuples->fillg76(losenergy,1.);
867  }
868  if (trackIDhit == 1) {
869  //UserNtuples->fillg70(dx,1.);
870  //UserNtuples->fillg71(incidentEnergyHit,1.);
871  //UserNtuples->fillg79(losenergy,1.);
872  } else {
873  //UserNtuples->fillg82(dx,1.);
874  }
875  }
876  // Station II
877  if (zz < z3 && zz > z2) {
878  //UserNtuples->fillg52(dx,1.);
879  //UserNtuples->fillg53(dy,1.);
880  //UserNtuples->fillg22(numofpart,1.);
881  //UserNtuples->fillg23(sumEnerDeposit,1.);
882  //UserNtuples->fillg80(incidentEnergyHit,1.);
883  //UserNtuples->fillg81(float(trackIDhit),1.);
884  if (zside == 1) {
885  //UserNtuples->fillg27(losenergy,1.);
886  }
887  if (zside == 2) {
888  //UserNtuples->fillg77(losenergy,1.);
889  }
890  if (trackIDhit == 1) {
891  //UserNtuples->fillg72(dx,1.);
892  //UserNtuples->fillg73(incidentEnergyHit,1.);
893  } else {
894  //UserNtuples->fillg83(dx,1.);
895  }
896  }
897  // Station III
898  if (zz < z4 && zz > z3) {
899  if (zside == 1) {
900  //UserNtuples->fillg28(losenergy,1.);
901  }
902  if (zside == 2) {
903  //UserNtuples->fillg78(losenergy,1.);
904  }
905  }
906  }
907  */
908  } // MIonly or noMIonly ENDED
909  if (totallosenergy == 0.0) {
910  edm::LogVerbatim("BscTest") << "BscTest: number of hits = " << theCAFI->entries();
911  for (int j = 0; j < nhits; j++) {
912  BscG4Hit* aHit = (*theCAFI)[j];
913  double losenergy = aHit->getEnergyLoss();
914  edm::LogVerbatim("BscTest") << " j hits = " << j << "losenergy = " << losenergy;
915  }
916  }
917  // FIBRE Hit collected analysis
918  /*
919  double totalEnergy = 0.;
920  int nhitsX = 0, nhitsY = 0, nsumhit = 0;
921  for (int sector = 1; sector < 4; sector++) {
922  int nhitsecX = 0, nhitsecY = 0;
923  for (int zmodule = 1; zmodule < 11; zmodule++) {
924  for (int zside = 1; zside < 3; zside++) {
925  int det = 1; // nhit = 0;
926  // int sScale = 20;
927  int index = BscNumberingScheme::packBscIndex(det, zside, sector);
928  double theTotalEnergy = themap[index];
929  // X planes
930  if (zside < 2) {
931  //UserNtuples->fillg47(theTotalEnergy,1.);
932  if (theTotalEnergy > 0.00003) {
933  nhitsX += 1;
934  // nhitsecX += themap1[index];
935  // nhit=1;
936  }
937  }
938  // Y planes
939  else {
940  //UserNtuples->fillg49(theTotalEnergy,1.);
941  if (theTotalEnergy > 0.00005) {
942  nhitsY += 1;
943  // nhitsecY += themap1[index];
944  // nhit=1;
945  }
946  }
947 
948  totalEnergy += themap[index];
949  } // for
950  } // for
951  //UserNtuples->fillg39(nhitsecY,1.);
952  if (nhitsecX > 10 || nhitsecY > 10) {
953  nsumhit += 1;
954  //UserNtuples->fillp213(float(sector),float(1.),1.);
955  } else { //UserNtuples->fillp213(float(sector),float(0.),1.);
956  }
957  } // for
958 
959  if (nsumhit >= 2) { //UserNtuples->fillp212(vy,float(1.),1.);
960  } else { //UserNtuples->fillp212(vy,float(0.),1.);
961  }
962  */
963  } // MI or no MI or all - end
964  } // primary end
965 
966  if (verbosity > 0) {
967  edm::LogVerbatim("BscTest") << "BscTest: END OF Event " << (*evt)()->GetEventID();
968  }
969 }
Log< level::Info, true > LogVerbatim
int numofpart
Definition: BscTest.cc:144
uint32_t getUnitID() const
Definition: BscG4Hit.h:56
TH1F * getHisto(Int_t Number)
Definition: BscTest.cc:301
double npart
Definition: HydjetWrapper.h:46
int zside(DetId const &)
G4ThreeVector lastpo
Definition: BscTest.cc:146
int iev
Definition: BscTest.cc:127
const Double_t pi
int verbosity
Definition: BscTest.cc:139
double z4
Definition: BscTest.cc:149
int whichevent
Definition: BscTest.cc:155
BscAnalysisHistManager * TheHistManager
Definition: BscTest.cc:157
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static void unpackBscIndex(const unsigned int &idx)
float getEnergyLoss() const
Definition: BscG4Hit.h:69
const G4ThreeVector & getEntry() const
Definition: BscG4Hit.h:29
const G4ThreeVector & getExitLocalP() const
Definition: BscG4Hit.h:35
Float_t bsceventarray[1]
Definition: BscTest.cc:152
G4THitsCollection< BscG4Hit > BscG4HitCollection
const G4ThreeVector & getEntryLocalP() const
Definition: BscG4Hit.h:32
G4double tracklength0
Definition: BscTest.cc:129

Member Data Documentation

◆ bsceventarray

Float_t BscTest::bsceventarray[1]
private

Definition at line 152 of file BscTest.cc.

Referenced by update().

◆ bsceventntuple

TNtuple* BscTest::bsceventntuple
private

Definition at line 153 of file BscTest.cc.

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

◆ bscOutputFile

TFile BscTest::bscOutputFile
private

Definition at line 154 of file BscTest.cc.

Referenced by ~BscTest().

◆ entot0

G4double BscTest::entot0
private

Definition at line 129 of file BscTest.cc.

Referenced by update().

◆ fDataLabel

std::string BscTest::fDataLabel
private

Definition at line 158 of file BscTest.cc.

Referenced by BscTest().

◆ fOutputFile

std::string BscTest::fOutputFile
private

Definition at line 159 of file BscTest.cc.

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

◆ fRecreateFile

std::string BscTest::fRecreateFile
private

Definition at line 160 of file BscTest.cc.

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

◆ iev

int BscTest::iev
private

Definition at line 127 of file BscTest.cc.

Referenced by update().

◆ itrk

int BscTest::itrk
private

Definition at line 128 of file BscTest.cc.

Referenced by update().

◆ lastpo

G4ThreeVector BscTest::lastpo
private

Definition at line 146 of file BscTest.cc.

Referenced by update().

◆ lastTrackID

int BscTest::lastTrackID
private

Definition at line 138 of file BscTest.cc.

◆ numofpart

int BscTest::numofpart
private

Definition at line 144 of file BscTest.cc.

Referenced by update().

◆ rinCalo

double BscTest::rinCalo
private

Definition at line 137 of file BscTest.cc.

◆ sumEnerDeposit

G4double BscTest::sumEnerDeposit
private

Definition at line 142 of file BscTest.cc.

Referenced by update().

◆ sumStepc

G4double BscTest::sumStepc
private

Definition at line 142 of file BscTest.cc.

Referenced by update().

◆ sumStepl

G4double BscTest::sumStepl
private

Definition at line 142 of file BscTest.cc.

Referenced by update().

◆ theBscNumberingScheme

BscNumberingScheme* BscTest::theBscNumberingScheme
private

Definition at line 125 of file BscTest.cc.

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

◆ TheHistManager

BscAnalysisHistManager* BscTest::TheHistManager
private

Definition at line 157 of file BscTest.cc.

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

◆ tracklength0

G4double BscTest::tracklength0
private

Definition at line 129 of file BscTest.cc.

Referenced by update().

◆ verbosity

int BscTest::verbosity
private

Definition at line 139 of file BscTest.cc.

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

◆ whichevent

int BscTest::whichevent
private

Definition at line 155 of file BscTest.cc.

Referenced by BscTest(), and update().

◆ z1

double BscTest::z1
private

Definition at line 149 of file BscTest.cc.

◆ z2

double BscTest::z2
private

Definition at line 149 of file BscTest.cc.

◆ z3

double BscTest::z3
private

Definition at line 149 of file BscTest.cc.

◆ z4

double BscTest::z4
private

Definition at line 149 of file BscTest.cc.

Referenced by update().

◆ zinCalo

double BscTest::zinCalo
private

Definition at line 137 of file BscTest.cc.