CMS 3D CMS Logo

BscTest.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 
4 // system include files
5 #include <iostream>
6 #include <iomanip>
7 #include <cmath>
8 #include <vector>
9 //
14 
18 // to retreive hits
22 
23 // G4 stuff
24 #include "G4SDManager.hh"
25 #include "G4Step.hh"
26 #include "G4Track.hh"
27 #include "G4VProcess.hh"
28 #include "G4HCofThisEvent.hh"
29 #include "G4UserEventAction.hh"
30 #include "G4TransportationManager.hh"
31 #include "G4ProcessManager.hh"
32 
33 #include "CLHEP/Units/GlobalSystemOfUnits.h"
34 #include "CLHEP/Units/GlobalPhysicalConstants.h"
35 
36 //================================================================
37 // Root stuff
38 
39 // Include the standard header <cassert> to effectively include
40 // the standard header <assert.h> within the std namespace.
41 #include <cassert>
42 
43 //================================================================
44 
45 //UserVerbosity BscTest::std::cout("BscTest","info","BscTest");
47 
48 //================================================================
50  //constructor
51  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("BscTest");
52  verbosity = m_Anal.getParameter<int>("Verbosity");
53  //verbosity = 1;
54 
55  fDataLabel = m_Anal.getParameter<std::string>("FDataLabel");
56  fOutputFile = m_Anal.getParameter<std::string>("FOutputFile");
57  fRecreateFile = m_Anal.getParameter<std::string>("FRecreateFile");
58 
59  if (verbosity > 0) {
60  std::cout << "============================================================================" << std::endl;
61  std::cout << "BscTestconstructor :: Initialized as observer" << std::endl;
62  }
63  // Initialization:
64 
66  bsceventntuple = new TNtuple("NTbscevent", "NTbscevent", "evt");
67  whichevent = 0;
69 
70  if (verbosity > 0) {
71  std::cout << "BscTest constructor :: Initialized BscAnalysisHistManager" << std::endl;
72  }
73 }
74 
76  // delete UserNtuples;
77  delete theBscNumberingScheme;
78 
79  TFile bscOutputFile("newntbsc.root", "RECREATE");
80  std::cout << "Bsc output root file has been created";
81  bsceventntuple->Write();
82  std::cout << ", written";
83  bscOutputFile.Close();
84  std::cout << ", closed";
85  delete bsceventntuple;
86  std::cout << ", and deleted" << std::endl;
87 
88  //------->while end
89 
90  // Write histograms to file
92  if (verbosity > 0) {
93  std::cout << std::endl << "BscTest Destructor --------> End of BscTest : " << std::endl;
94  }
95 
96  std::cout << "BscTest: End of process" << std::endl;
97 }
98 
99 //================================================================
100 // Histoes:
101 //-----------------------------------------------------------------------------
102 
104  // The Constructor
105 
106  fTypeTitle = managername;
107  fHistArray = new TObjArray(); // Array to store histos
108  fHistNamesArray = new TObjArray(); // Array to store histos's names
109 
110  BookHistos();
111 
112  fHistArray->Compress(); // Removes empty space
113  fHistNamesArray->Compress();
114 }
115 //-----------------------------------------------------------------------------
116 
118  // The Destructor
119 
120  if (fHistArray) {
121  fHistArray->Delete();
122  delete fHistArray;
123  }
124 
125  if (fHistNamesArray) {
126  fHistNamesArray->Delete();
127  delete fHistNamesArray;
128  }
129 }
130 //-----------------------------------------------------------------------------
131 
133  // at Start: (mm)
134  HistInit("TrackPhi", "Primary Phi", 100, 0., 360.);
135  HistInit("TrackTheta", "Primary Theta", 100, 0., 180.);
136  HistInit("TrackP", "Track XY position Z+ ", 80, -80., 80., 80, -80., 80.);
137  HistInit("TrackM", "Track XY position Z-", 80, -80., 80., 80, -80., 80.);
138  HistInit("DetIDs", "Track DetId - vs +", 16, -0.5, 15.5, 16, 15.5, 31.5);
139 }
140 
141 //-----------------------------------------------------------------------------
142 
143 void BscAnalysisHistManager::WriteToFile(const TString& fOutputFile, const TString& fRecreateFile) {
144  //Write to file = fOutputFile
145 
146  std::cout << "================================================================" << std::endl;
147  std::cout << " Write this Analysis to File " << fOutputFile << std::endl;
148  std::cout << "================================================================" << std::endl;
149 
150  TFile* file = new TFile(fOutputFile, fRecreateFile);
151 
152  fHistArray->Write();
153  file->Close();
154 }
155 //-----------------------------------------------------------------------------
156 
157 void BscAnalysisHistManager::HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup) {
158  // Add histograms and histograms names to the array
159 
160  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
161  strcpy(newtitle, title);
162  strcat(newtitle, " (");
163  strcat(newtitle, fTypeTitle);
164  strcat(newtitle, ") ");
165  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
166  fHistNamesArray->AddLast(new TObjString(name));
167 }
168 //-----------------------------------------------------------------------------
169 
171  const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup) {
172  // Add histograms and histograms names to the array
173 
174  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
175  strcpy(newtitle, title);
176  strcat(newtitle, " (");
177  strcat(newtitle, fTypeTitle);
178  strcat(newtitle, ") ");
179  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
180  fHistNamesArray->AddLast(new TObjString(name));
181 }
182 //-----------------------------------------------------------------------------
183 
185  // Get a histogram from the array with index = Number
186 
187  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
188  return (TH1F*)(fHistArray->At(Number));
189 
190  } else {
191  std::cout << "!!!!!!!!!!!!!!!!!!GetHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
192  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
193  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
194 
195  return (TH1F*)(fHistArray->At(0));
196  }
197 }
198 //-----------------------------------------------------------------------------
199 
201  // Get a histogram from the array with index = Number
202 
203  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
204  return (TH2F*)(fHistArray->At(Number));
205 
206  } else {
207  std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
208  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
209  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
210 
211  return (TH2F*)(fHistArray->At(0));
212  }
213 }
214 //-----------------------------------------------------------------------------
215 
216 TH1F* BscAnalysisHistManager::GetHisto(const TObjString& histname) {
217  // Get a histogram from the array with name = histname
218 
219  Int_t index = fHistNamesArray->IndexOf(&histname);
220  return GetHisto(index);
221 }
222 //-----------------------------------------------------------------------------
223 
224 TH2F* BscAnalysisHistManager::GetHisto2(const TObjString& histname) {
225  // Get a histogram from the array with name = histname
226 
227  Int_t index = fHistNamesArray->IndexOf(&histname);
228  return GetHisto2(index);
229 }
230 //-----------------------------------------------------------------------------
231 
233  // Add structure to each histogram to store the weights
234 
235  for (int i = 0; i < fHistArray->GetEntries(); i++) {
236  ((TH1F*)(fHistArray->At(i)))->Sumw2();
237  }
238 }
239 
240 //==================================================================== per JOB
241 void BscTest::update(const BeginOfJob* job) {
242  //job
243  std::cout << "BscTest:beggining of job" << std::endl;
244  ;
245 }
246 
247 //==================================================================== per RUN
249  //run
250 
251  std::cout << std::endl << "BscTest:: Begining of Run" << std::endl;
252 }
253 
254 void BscTest::update(const EndOfRun* run) { ; }
255 
256 //=================================================================== per EVENT
257 void BscTest::update(const BeginOfEvent* evt) {
258  iev = (*evt)()->GetEventID();
259  if (verbosity > 0) {
260  std::cout << "BscTest:update Event number = " << iev << std::endl;
261  }
262  whichevent++;
263 }
264 
265 //=================================================================== per Track
266 void BscTest::update(const BeginOfTrack* trk) {
267  itrk = (*trk)()->GetTrackID();
268  if (verbosity > 1) {
269  std::cout << "BscTest:update BeginOfTrack number = " << itrk << std::endl;
270  }
271  if (itrk == 1) {
272  SumEnerDeposit = 0.;
273  numofpart = 0;
274  SumStepl = 0.;
275  SumStepc = 0.;
276  tracklength0 = 0.;
277  }
278 }
279 
280 //=================================================================== per EndOfTrack
281 void BscTest::update(const EndOfTrack* trk) {
282  itrk = (*trk)()->GetTrackID();
283  if (verbosity > 1) {
284  std::cout << "BscTest:update EndOfTrack number = " << itrk << std::endl;
285  }
286  if (itrk == 1) {
287  G4double tracklength = (*trk)()->GetTrackLength(); // Accumulated track length
288 
289  TheHistManager->GetHisto("SumEDep")->Fill(SumEnerDeposit);
290  TheHistManager->GetHisto("TrackL")->Fill(tracklength);
291 
292  // direction !!!
293  G4ThreeVector vert_mom = (*trk)()->GetVertexMomentumDirection();
294  G4ThreeVector vert_pos = (*trk)()->GetVertexPosition(); // vertex ,where this track was created
295 
296  // last step information
297  const G4Step* aStep = (*trk)()->GetStep();
298  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
299  lastpo = preStepPoint->GetPosition();
300  }
301 }
302 
303 // ====================================================
304 
305 //=================================================================== each STEP
306 void BscTest::update(const G4Step* aStep) {
307  // ==========================================================================
308 
309  if (verbosity > 2) {
310  G4int stepnumber = aStep->GetTrack()->GetCurrentStepNumber();
311  std::cout << "BscTest:update Step number = " << stepnumber << std::endl;
312  }
313  // track on aStep: !
314  G4Track* theTrack = aStep->GetTrack();
315  TrackInformation* trkInfo = dynamic_cast<TrackInformation*>(theTrack->GetUserInformation());
316  if (trkInfo == nullptr) {
317  std::cout << "BscTest on aStep: No trk info !!!! abort " << std::endl;
318  }
319  G4int id = theTrack->GetTrackID();
320  G4String particleType = theTrack->GetDefinition()->GetParticleName(); // !!!
321  G4int parentID = theTrack->GetParentID(); // !!!
322  G4TrackStatus trackstatus = theTrack->GetTrackStatus(); // !!!
323  G4double tracklength = theTrack->GetTrackLength(); // Accumulated track length
324  G4ThreeVector trackmom = theTrack->GetMomentum();
325  G4double entot = theTrack->GetTotalEnergy(); // !!! deposited on step
326  G4int curstepnumber = theTrack->GetCurrentStepNumber();
327  G4double stepl = aStep->GetStepLength();
328  G4double EnerDeposit = aStep->GetTotalEnergyDeposit();
329  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
330  const G4ThreeVector& preposition = preStepPoint->GetPosition();
331  G4ThreeVector prelocalpoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(preposition);
332  G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
333  const G4String& prename = currentPV->GetName();
334 
335  const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
336  int pre_levels = detLevels(pre_touch);
337  G4String name1[20];
338  int copyno1[20];
339  for (int i = 0; i < 20; ++i) {
340  name1[i] = "";
341  copyno1[i] = 0;
342  }
343  if (pre_levels > 0) {
344  detectorLevel(pre_touch, pre_levels, copyno1, name1);
345  }
346 
347  if (id == 1) {
348  // on 1-st step:
349  if (curstepnumber == 1) {
350  entot0 = entot;
351  //UserNtuples->fillg519(entot0,1.);
352  }
353 
354  // on every step:
355 
356  // for Copper:
357  if (prename == "SBST") {
358  SumStepc += stepl;
359  // =========
360  }
361  // for ststeel:
362  // if(prename == "SBSTs") {
363  if (prename == "SBSTs") {
364  SumStepl += stepl;
365  // =========
366  }
367  // =========
368  // =========
369 
370  // exclude last track point if it is in SD (MI was started their)
371  if (trackstatus != 2) {
372  // for SD: Si Det.: SISTATION:SIPLANE:(SIDETL+BOUNDDET +SIDETR + CERAMDET)
373  if (prename == "SIDETL" || prename == "SIDETR") {
374  if (prename == "SIDETL") {
375  //UserNtuples->fillg569(EnerDeposit,1.);
376  }
377  if (prename == "SIDETR") {
378  //UserNtuples->fillg570(EnerDeposit,1.);
379  }
380 
381  G4String posname = aStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
382  if ((prename == "SIDETL" && posname != "SIDETL") || (prename == "SIDETR" && posname != "SIDETR")) {
383  if (name1[2] == "SISTATION") {
384  //UserNtuples->fillg539(copyno1[2],1.);
385  }
386  if (name1[3] == "SIPLANE") {
387  //UserNtuples->fillg540(copyno1[3],1.);
388  }
389 
390  if (prename == "SIDETL") {
391  //UserNtuples->fillg541(EnerDeposit,1.);
392  //UserNtuples->fillg561(numbcont,1.);
393  if (copyno1[2] < 2) {
394  //UserNtuples->fillg571(dx,1.);
395  } else if (copyno1[2] < 3) {
396  //UserNtuples->fillg563(dx,1.);
397  if (copyno1[3] < 2) {
398  } else if (copyno1[3] < 3) {
399  //UserNtuples->fillg572(dx,1.);
400  } else if (copyno1[3] < 4) {
401  //UserNtuples->fillg573(dx,1.);
402  } else if (copyno1[3] < 5) {
403  //UserNtuples->fillg574(dx,1.);
404  } else if (copyno1[3] < 6) {
405  //UserNtuples->fillg575(dx,1.);
406  } else if (copyno1[3] < 7) {
407  //UserNtuples->fillg576(dx,1.);
408  } else if (copyno1[3] < 8) {
409  //UserNtuples->fillg577(dx,1.);
410  } else if (copyno1[3] < 9) {
411  //UserNtuples->fillg578(dx,1.);
412  } else if (copyno1[3] < 10) {
413  //UserNtuples->fillg579(dx,1.);
414  }
415  } else if (copyno1[2] < 4) {
416  //UserNtuples->fillg565(dx,1.);
417  } else if (copyno1[2] < 5) {
418  //UserNtuples->fillg567(dx,1.);
419  }
420  }
421  if (prename == "SIDETR") {
422  //UserNtuples->fillg542(EnerDeposit,1.);
423  //UserNtuples->fillg562(numbcont,1.);
424  if (copyno1[2] < 2) {
425  //UserNtuples->fillg581(dy,1.);
426  } else if (copyno1[2] < 3) {
427  //UserNtuples->fillg564(dy,1.);
428  if (copyno1[3] < 2) {
429  } else if (copyno1[3] < 3) {
430  //UserNtuples->fillg582(dy,1.);
431  } else if (copyno1[3] < 4) {
432  //UserNtuples->fillg583(dy,1.);
433  } else if (copyno1[3] < 5) {
434  //UserNtuples->fillg584(dy,1.);
435  } else if (copyno1[3] < 6) {
436  //UserNtuples->fillg585(dy,1.);
437  } else if (copyno1[3] < 7) {
438  //UserNtuples->fillg586(dy,1.);
439  } else if (copyno1[3] < 8) {
440  //UserNtuples->fillg587(dy,1.);
441  } else if (copyno1[3] < 9) {
442  //UserNtuples->fillg588(dy,1.);
443  } else if (copyno1[3] < 10) {
444  //UserNtuples->fillg589(dy,1.);
445  }
446  } else if (copyno1[2] < 4) {
447  //UserNtuples->fillg566(dy,1.);
448  } else if (copyno1[2] < 5) {
449  //UserNtuples->fillg568(dy,1.);
450  }
451  }
452  }
453  }
454  // end of prenames SIDETL // SIDETR
455  }
456  // end of trackstatus != 2
457 
458  SumEnerDeposit += EnerDeposit;
459  if (trackstatus == 2) {
460  // primary track length
461  // //UserNtuples->fillg508(tracklength,1.);
462  tracklength0 = tracklength;
463  }
464  }
465  // end of primary track !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
466 
467  if (parentID == 1 && curstepnumber == 1) {
468  // particles deposit their energy along primary track
469  numofpart += 1;
470  if (prename == "SBST") {
471  //UserNtuples->filld225(vert_pos.y(),vert_pos.z(),1.);
472  }
473  if (prename == "SBSTs") {
474  //UserNtuples->filld226(vert_pos.y(),vert_pos.z(),1.);
475  }
476  }
477 }
478 // ==========================================================================
479 // ==========================================================================
480 int BscTest::detLevels(const G4VTouchable* touch) const {
481  //Return number of levels
482  if (touch)
483  return ((touch->GetHistoryDepth()) + 1);
484  else
485  return 0;
486 }
487 // ==========================================================================
488 
489 G4String BscTest::detName(const G4VTouchable* touch, int level, int currentlevel) const {
490  //Go down to current level
491  if (level > 0 && level >= currentlevel) {
492  int ii = level - currentlevel;
493  return touch->GetVolume(ii)->GetName();
494  } else {
495  return "NotFound";
496  }
497 }
498 
499 void BscTest::detectorLevel(const G4VTouchable* touch, int& level, int* copyno, G4String* name) const {
500  //Get name and copy numbers
501  if (level > 0) {
502  for (int ii = 0; ii < level; ii++) {
503  int i = level - ii - 1;
504  G4VPhysicalVolume* pv = touch->GetVolume(i);
505  if (pv != nullptr)
506  name[ii] = pv->GetName();
507  else
508  name[ii] = "Unknown";
509  copyno[ii] = touch->GetReplicaNumber(i);
510  }
511  }
512 }
513 // ==========================================================================
514 
515 //=================================================================== End Of Event
516 void BscTest::update(const EndOfEvent* evt) {
517  // ==========================================================================
518 
519  if (verbosity > 1) {
520  iev = (*evt)()->GetEventID();
521  std::cout << "BscTest:update EndOfEvent = " << iev << std::endl;
522  }
523  // Fill-in ntuple
525 
526  //
527  int trackID = 0;
528  G4PrimaryParticle* thePrim = nullptr;
529 
530  // prim.vertex:
531  G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
532  if (nvertex != 1)
533  std::cout << "BscTest: My warning: NumberOfPrimaryVertex != 1 --> = " << nvertex << std::endl;
534 
535  for (int i = 0; i < nvertex; i++) {
536  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
537  if (avertex == nullptr)
538  std::cout << "BscTest End Of Event ERR: pointer to vertex = 0" << std::endl;
539  G4int npart = avertex->GetNumberOfParticle();
540  if (npart != 1)
541  std::cout << "BscTest: My warning: NumberOfPrimaryPart != 1 --> = " << npart << std::endl;
542  if (npart == 0)
543  std::cout << "BscTest End Of Event ERR: no NumberOfParticle" << std::endl;
544 
545  if (thePrim == nullptr)
546  thePrim = avertex->GetPrimary(trackID);
547 
548  if (thePrim != nullptr) {
549  // primary vertex:
550  G4double vx = 0., vy = 0., vz = 0.;
551  vx = avertex->GetX0();
552  vy = avertex->GetY0();
553  vz = avertex->GetZ0();
554  //UserNtuples->fillh01(vx);
555  //UserNtuples->fillh02(vy);
556  //UserNtuples->fillh03(vz);
557  TheHistManager->GetHisto("VtxX")->Fill(vx);
558  TheHistManager->GetHisto("VtxY")->Fill(vy);
559  TheHistManager->GetHisto("VtxZ")->Fill(vz);
560  }
561  }
562  // prim.vertex loop end
563 
564  //=========================== thePrim != 0 ================================================================================
565  if (thePrim != nullptr) {
566  //
567  // number of secondary particles deposited their energy along primary track
568  //UserNtuples->fillg518(numofpart,1.);
569  if (lastpo.z() < z4 && lastpo.perp() < 100.) {
570  //UserNtuples->fillg536(numofpart,1.);
571  }
572  //
573 
574  // direction !!!
575  G4ThreeVector mom = thePrim->GetMomentum();
576 
577  double phi = atan2(mom.y(), mom.x());
578  if (phi < 0.)
579  phi += twopi;
580  double phigrad = phi * 180. / pi;
581 
582  double th = mom.theta();
583  double eta = -log(tan(th / 2));
584  TheHistManager->GetHisto("PrimaryEta")->Fill(eta);
585  TheHistManager->GetHisto("PrimaryPhigrad")->Fill(phigrad);
586  TheHistManager->GetHisto("PrimaryTh")->Fill(th * 180. / pi);
587 
588  TheHistManager->GetHisto("PrimaryLastpoZ")->Fill(lastpo.z());
589  if (lastpo.z() < z4) {
590  TheHistManager->GetHisto("PrimaryLastpoX")->Fill(lastpo.x());
591  TheHistManager->GetHisto("PrimaryLastpoY")->Fill(lastpo.y());
592  }
593  if (numofpart > 4) {
594  TheHistManager->GetHisto("XLastpoNumofpart")->Fill(lastpo.x());
595  TheHistManager->GetHisto("YLastpoNumofpart")->Fill(lastpo.y());
596  }
597 
598  // ==========================================================================
599 
600  // hit map for Bsc
601  // ==================================
602 
603  std::map<int, float, std::less<int> > themap;
604  std::map<int, float, std::less<int> > themap1;
605 
606  std::map<int, float, std::less<int> > themapxy;
607  std::map<int, float, std::less<int> > themapz;
608  // access to the G4 hit collections: -----> this work OK:
609 
610  // edm::LogInfo("BscTest") << "1";
611  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
612  // edm::LogInfo("BscTest") << "2";
613  if (verbosity > 0) {
614  std::cout << "BscTest: accessed all HC" << std::endl;
615  ;
616  }
617  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("BSCHits");
618 
619  BscG4HitCollection* theCAFI = (BscG4HitCollection*)allHC->GetHC(CAFIid);
620  if (verbosity > 0) {
621  std::cout << "BscTest: theCAFI->entries = " << theCAFI->entries() << std::endl;
622  }
623  int varia; // = 0 -all; =1 - MI; =2 - noMI
624  //varia = 0;
625  if (lastpo.z() < z4) {
626  varia = 1;
627  } else {
628  varia = 2;
629  } // no MI end:
630  int nhits = theCAFI->entries();
631  for (int j = 0; j < nhits; j++) {
632  BscG4Hit* aHit = (*theCAFI)[j];
633  const CLHEP::Hep3Vector& hitPoint = aHit->getEntry();
634  double zz = hitPoint.z();
635  TheHistManager->GetHisto("zHits")->Fill(zz);
636  if (tracklength0 > 8300.)
637  TheHistManager->GetHisto("zHitsTrLoLe")->Fill(zz);
638  }
639 
640  if (varia == 2) {
641  int nhit11 = 0, nhit12 = 0, nhit13 = 0;
642  double totallosenergy = 0.;
643  for (int j = 0; j < nhits; j++) {
644  BscG4Hit* aHit = (*theCAFI)[j];
645 
646  const CLHEP::Hep3Vector& hitEntryLocalPoint = aHit->getEntryLocalP();
647  const CLHEP::Hep3Vector& hitExitLocalPoint = aHit->getExitLocalP();
648  const CLHEP::Hep3Vector& hitPoint = aHit->getEntry();
649  int trackIDhit = aHit->getTrackID();
650  unsigned int unitID = aHit->getUnitID();
651  double losenergy = aHit->getEnergyLoss();
652 
653  double zz = hitPoint.z();
654 
655  TheHistManager->GetHisto("zHitsnoMI")->Fill(zz);
656 
657  if (verbosity > 2) {
658  std::cout << "BscTest:zHits = " << zz << std::endl;
659  }
660 
661  themap[unitID] += losenergy;
662  totallosenergy += losenergy;
663 
664  int zside, sector;
666  zside = (unitID & 32) >> 5;
667  sector = (unitID & 7);
668 
669  //
670  //=======================================
671  G4ThreeVector middle = (hitExitLocalPoint + hitEntryLocalPoint) / 2.;
672  themapz[unitID] = hitPoint.z() + middle.z();
673  //=======================================
674  // Y
675  if (zside == 1) {
676  //UserNtuples->fillg24(losenergy,1.);
677  if (losenergy > 0.00003) {
678  themap1[unitID] += 1.;
679  }
680  }
681  //X
682  if (zside == 2) {
683  //UserNtuples->fillg25(losenergy,1.);
684  if (losenergy > 0.00005) {
685  themap1[unitID] += 1.;
686  }
687  }
688  // }
689  //
690  if (sector == 1) {
691  nhit11 += 1;
692  //UserNtuples->fillg33(rr,1.);
693  //UserNtuples->fillg11(yy,1.);
694  }
695  if (sector == 2) {
696  nhit12 += 1;
697  //UserNtuples->fillg34(rr,1.);
698  //UserNtuples->fillg86(yy,1.);
699  }
700  if (sector == 3) {
701  nhit13 += 1;
702  //UserNtuples->fillg35(rr,1.);
703  //UserNtuples->fillg87(yy,1.);
704  }
705 
706  if (lastpo.z() < z4 && lastpo.perp() < 120.) {
707  // MIonly:
708  //UserNtuples->fillg16(lastpo.z(),1.);
709  //UserNtuples->fillg18(zz,1.);
710  // Station I
711  if (zz < z2) {
712  //UserNtuples->fillg54(dx,1.);
713  //UserNtuples->fillg55(dy,1.);
714  }
715  // Station II
716  if (zz < z3 && zz > z2) {
717  //UserNtuples->fillg50(dx,1.);
718  //UserNtuples->fillg51(dy,1.);
719  }
720  // Station III
721  if (zz < z4 && zz > z3) {
722  //UserNtuples->fillg64(dx,1.);
723  //UserNtuples->fillg65(dy,1.);
724  //UserNtuples->filld209(xx,yy,1.);
725  }
726  } else {
727  // no MIonly:
728  //UserNtuples->fillg17(lastpo.z(),1.);
729  //UserNtuples->fillg19(zz,1.);
730  //UserNtuples->fillg74(incidentEnergyHit,1.);
731  //UserNtuples->fillg75(float(trackIDhit),1.);
732  // Station I
733  if (zz < z2) {
734  //UserNtuples->fillg56(dx,1.);
735  //UserNtuples->fillg57(dy,1.);
736  //UserNtuples->fillg20(numofpart,1.);
737  //UserNtuples->fillg21(SumEnerDeposit,1.);
738  if (zside == 1) {
739  //UserNtuples->fillg26(losenergy,1.);
740  }
741  if (zside == 2) {
742  //UserNtuples->fillg76(losenergy,1.);
743  }
744  if (trackIDhit == 1) {
745  //UserNtuples->fillg70(dx,1.);
746  //UserNtuples->fillg71(incidentEnergyHit,1.);
747  //UserNtuples->fillg79(losenergy,1.);
748  } else {
749  //UserNtuples->fillg82(dx,1.);
750  }
751  }
752  // Station II
753  if (zz < z3 && zz > z2) {
754  //UserNtuples->fillg52(dx,1.);
755  //UserNtuples->fillg53(dy,1.);
756  //UserNtuples->fillg22(numofpart,1.);
757  //UserNtuples->fillg23(SumEnerDeposit,1.);
758  //UserNtuples->fillg80(incidentEnergyHit,1.);
759  //UserNtuples->fillg81(float(trackIDhit),1.);
760  if (zside == 1) {
761  //UserNtuples->fillg27(losenergy,1.);
762  }
763  if (zside == 2) {
764  //UserNtuples->fillg77(losenergy,1.);
765  }
766  if (trackIDhit == 1) {
767  //UserNtuples->fillg72(dx,1.);
768  //UserNtuples->fillg73(incidentEnergyHit,1.);
769  } else {
770  //UserNtuples->fillg83(dx,1.);
771  }
772  }
773  // Station III
774  if (zz < z4 && zz > z3) {
775  if (zside == 1) {
776  //UserNtuples->fillg28(losenergy,1.);
777  }
778  if (zside == 2) {
779  //UserNtuples->fillg78(losenergy,1.);
780  }
781  }
782  }
783  } // MIonly or noMIonly ENDED
784  if (totallosenergy == 0.0) {
785  std::cout << "BscTest: number of hits = " << theCAFI->entries() << std::endl;
786  for (int j = 0; j < nhits; j++) {
787  BscG4Hit* aHit = (*theCAFI)[j];
788  double losenergy = aHit->getEnergyLoss();
789  std::cout << " j hits = " << j << "losenergy = " << losenergy << std::endl;
790  }
791  }
792  // FIBRE Hit collected analysis
793  double totalEnergy = 0.;
794  int nhitsX = 0, nhitsY = 0, nsumhit = 0;
795  for (int sector = 1; sector < 4; sector++) {
796  int nhitsecX = 0, nhitsecY = 0;
797  for (int zmodule = 1; zmodule < 11; zmodule++) {
798  for (int zside = 1; zside < 3; zside++) {
799  int det = 1; // nhit = 0;
800  // int sScale = 20;
801  int index = BscNumberingScheme::packBscIndex(det, zside, sector);
802  double theTotalEnergy = themap[index];
803  // X planes
804  if (zside < 2) {
805  //UserNtuples->fillg47(theTotalEnergy,1.);
806  if (theTotalEnergy > 0.00003) {
807  nhitsX += 1;
808  // nhitsecX += themap1[index];
809  // nhit=1;
810  }
811  }
812  // Y planes
813  else {
814  //UserNtuples->fillg49(theTotalEnergy,1.);
815  if (theTotalEnergy > 0.00005) {
816  nhitsY += 1;
817  // nhitsecY += themap1[index];
818  // nhit=1;
819  }
820  }
821 
822  totalEnergy += themap[index];
823  } // for
824  } // for
825  //UserNtuples->fillg39(nhitsecY,1.);
826  if (nhitsecX > 10 || nhitsecY > 10) {
827  nsumhit += 1;
828  //UserNtuples->fillp213(float(sector),float(1.),1.);
829  } else { //UserNtuples->fillp213(float(sector),float(0.),1.);
830  }
831  } // for
832 
833  if (nsumhit >= 2) { //UserNtuples->fillp212(vy,float(1.),1.);
834  } else { //UserNtuples->fillp212(vy,float(0.),1.);
835  }
836  } // MI or no MI or all - end
837  } // primary end
838 
839  if (verbosity > 0) {
840  std::cout << "BscTest: END OF Event " << (*evt)()->GetEventID() << std::endl;
841  }
842 }
personalPlayback.level
level
Definition: personalPlayback.py:22
BscTest::SumStepc
G4double SumStepc
Definition: BscTest.h:203
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
BscTest::TheHistManager
BscAnalysisHistManager * TheHistManager
Definition: BscTest.h:218
BscTest::z2
double z2
Definition: BscTest.h:210
BscG4Hit::getEnergyLoss
float getEnergyLoss() const
Definition: BscG4Hit.h:69
BscAnalysisHistManager::WriteToFile
void WriteToFile(const TString &fOutputFile, const TString &fRecreateFile)
Definition: BscTest.cc:143
BscG4HitCollection.h
BscTest.h
BscG4Hit::getTrackID
int getTrackID() const
Definition: BscG4Hit.h:53
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
BscNumberingScheme
Definition: BscNumberingScheme.h:13
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
BscAnalysisHistManager::fTypeTitle
const char * fTypeTitle
Definition: BscTest.h:83
gather_cfg.cout
cout
Definition: gather_cfg.py:144
BscG4Hit::getEntryLocalP
const G4ThreeVector & getEntryLocalP() const
Definition: BscG4Hit.h:32
BscNumberingScheme.h
HcalTBWriter_cfi.Number
Number
Definition: HcalTBWriter_cfi.py:19
EndOfEvent.h
BscTest::entot0
G4double entot0
Definition: BscTest.h:189
BscTest::verbosity
int verbosity
Definition: BscTest.h:200
BscTest::detectorLevel
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
Definition: BscTest.cc:499
BscTest::bscOutputFile
TFile bscOutputFile
Definition: BscTest.h:215
npart
double npart
Definition: HydjetWrapper.h:46
EndOfTrack
Definition: EndOfTrack.h:6
BscG4Hit::getEntry
const G4ThreeVector & getEntry() const
Definition: BscG4Hit.h:29
BscAnalysisHistManager::~BscAnalysisHistManager
~BscAnalysisHistManager() override
Definition: BscTest.cc:117
BscTest::itrk
int itrk
Definition: BscTest.h:188
ntbsc_elements
ntbsc_elements
Definition: BscTest.cc:46
PVValHelper::eta
Definition: PVValidationHelpers.h:69
BscAnalysisHistManager::BookHistos
void BookHistos()
Definition: BscTest.cc:132
BscTest::tracklength0
G4double tracklength0
Definition: BscTest.h:189
BscTest::lastpo
G4ThreeVector lastpo
Definition: BscTest.h:207
BscNumberingScheme::unpackBscIndex
static void unpackBscIndex(const unsigned int &idx)
Definition: BscNumberingScheme.cc:95
BeginOfTrack
Definition: BeginOfTrack.h:6
BscTest::SumStepl
G4double SumStepl
Definition: BscTest.h:203
BeginOfJob
Definition: BeginOfJob.h:8
BscTest::iev
int iev
Definition: BscTest.h:187
nhits
Definition: HIMultiTrackSelector.h:42
EndOfEvent
Definition: EndOfEvent.h:6
BscAnalysisHistManager::GetHisto2
TH2F * GetHisto2(Int_t Number)
Definition: BscTest.cc:200
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BscG4HitCollection
G4THitsCollection< BscG4Hit > BscG4HitCollection
Definition: BscG4HitCollection.h:13
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
BscTest::BscTest
BscTest(const edm::ParameterSet &p)
Definition: BscTest.cc:49
BscTest::whichevent
int whichevent
Definition: BscTest.h:216
BscTest::fDataLabel
std::string fDataLabel
Definition: BscTest.h:219
BeginOfEvent.h
BscAnalysisHistManager::fHistArray
TObjArray * fHistArray
Definition: BscTest.h:84
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
BscTest::SumEnerDeposit
G4double SumEnerDeposit
Definition: BscTest.h:203
TrackInformation
Definition: TrackInformation.h:8
BscTest::detName
G4String detName(const G4VTouchable *, int, int) const
Definition: BscTest.cc:489
BscTest::update
void update(const BeginOfJob *run) override
This routine will be called when the appropriate signal arrives.
Definition: BscTest.cc:241
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
BscTest::bsceventarray
Float_t bsceventarray[1]
Definition: BscTest.h:213
BscAnalysisHistManager::BscAnalysisHistManager
BscAnalysisHistManager(const TString &managername)
Definition: BscTest.cc:103
BeginOfEvent
Definition: BeginOfEvent.h:6
BeginOfRun
Definition: BeginOfRun.h:6
EndOfRun
Definition: EndOfRun.h:6
TrackInformation.h
BscAnalysisHistManager
Definition: BscTest.h:63
BscTest::detLevels
int detLevels(const G4VTouchable *) const
Definition: BscTest.cc:480
BscAnalysisHistManager::GetHisto
TH1F * GetHisto(Int_t Number)
Definition: BscTest.cc:184
DDAxes::phi
BscG4Hit::getUnitID
uint32_t getUnitID() const
Definition: BscG4Hit.h:56
writedatasetfile.run
run
Definition: writedatasetfile.py:27
BscTest::theBscNumberingScheme
BscNumberingScheme * theBscNumberingScheme
Definition: BscTest.h:185
BscTest::fOutputFile
std::string fOutputFile
Definition: BscTest.h:220
BscAnalysisHistManager::HistInit
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:157
BscAnalysisHistManager::StoreWeights
void StoreWeights()
Definition: BscTest.cc:232
BscTest::fRecreateFile
std::string fRecreateFile
Definition: BscTest.h:221
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
BscG4Hit::getExitLocalP
const G4ThreeVector & getExitLocalP() const
Definition: BscG4Hit.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
pi
const Double_t pi
Definition: trackSplitPlot.h:36
BscG4Hit
Definition: BscG4Hit.h:17
BscNumberingScheme::packBscIndex
static unsigned int packBscIndex(int det, int zside, int station)
Definition: BscNumberingScheme.cc:83
BscTest::~BscTest
~BscTest() override
Definition: BscTest.cc:75
BscAnalysisHistManager::fHistNamesArray
TObjArray * fHistNamesArray
Definition: BscTest.h:85
PbPb_ZMuSkimMuonDPG_cff.particleType
particleType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:27
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BscTest::bsceventntuple
TNtuple * bsceventntuple
Definition: BscTest.h:214
BscTest::z3
double z3
Definition: BscTest.h:210
BscTest::z4
double z4
Definition: BscTest.h:210
cuy.ii
ii
Definition: cuy.py:590
BscTest::numofpart
int numofpart
Definition: BscTest.h:205
ntbsc_evt
Definition: BscTest.cc:46
TrackWithHistory.h