ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimROOTAnalGas.cc
Go to the documentation of this file.
1 // - AUTHOR: Hector Alvarez-Pol 05/2005
2 /******************************************************************
3  * Copyright (C) 2005-2016, Hector Alvarez-Pol *
4  * All rights reserved. *
5  * *
6  * License according to GNU LESSER GPL (see lgpl-3.0.txt). *
7  * For the list of contributors see CREDITS. *
8  ******************************************************************/
9 //////////////////////////////////////////////////////////////////
10 /// \class ActarSimROOTAnalGas
11 /// The gas detector part of the ROOT Analysis
12 /////////////////////////////////////////////////////////////////
13 
14 #include "ActarSimROOTAnalGas.hh"
15 
16 #include "G4ios.hh"
17 #include "G4RunManager.hh"
18 #include "G4SDManager.hh"
19 #include "G4Event.hh"
20 #include "G4Run.hh"
21 #include "G4Track.hh"
22 #include "G4ClassificationOfNewTrack.hh"
23 #include "G4TrackStatus.hh"
24 #include "G4Step.hh"
25 #include "G4Types.hh"
26 
27 //#include "G4PhysicalConstants.hh"
28 //#include "G4SystemOfUnits.hh"
29 
30 #include "ActarSimTrack.hh"
31 #include "ActarSimSimpleTrack.hh"
32 #include "ActarSimData.hh"
33 
34 //ROOT INCLUDES
35 #include "TROOT.h"
36 //#include "TApplication.h"
37 //#include "TSystem.h"
38 #include "TH1.h"
39 #include "TH2.h"
40 #include "TH3.h"
41 //#include "TPad.h"
42 //#include "TCanvas.h"
43 #include "TTree.h"
44 #include "TFile.h"
45 #include "TClonesArray.h"
46 #include "TProfile.h"
47 
48 #include "Randomize.hh"
49 
50 //////////////////////////////////////////////////////////////////
51 /// Default constructor... Simply inits
53  init();
54 }
55 
56 //////////////////////////////////////////////////////////////////
57 /// Makes most of the work of a constructor...
59  G4cout << "##################################################################" << G4endl
60  << "########### ActarSimROOTAnalGas::init() ####################" << G4endl;
61 
62  //The simulation file
64  simFile->cd();
65 
66  //histograms of example
67  hStepSumLengthOnGas1 = (TH1D *)0;
68  hStepSumLengthOnGas2 = (TH1D *)0;
69 
70  htrackInPads = (TH2D *)0;
71  htrack1InPads = (TH2D *)0;
72  htrack2InPads = (TH2D *)0;
73  htrackFromBeam = (TH2D *)0;
74  htrack = (TH3D *)0;
75 
76  hEdepInGas = (TH1D *)0;
77 
78  // The accumulated energy loss and track length of each step
79  hbeamEnergyAtRange=(TProfile *)0;
80 
81  //energy loss on the Gas
82  hTotELossOnGas1 = (TH1D *)0; //Energy Loss
83  hTotELossOnGas2 = (TH1D *)0; //Energy Loss
84 
85  //The tree
86  eventTree =
87  ((ActarSimROOTAnalysis*)gActarSimROOTAnalysis)->GetEventTree();
88  tracksTree =
89  ((ActarSimROOTAnalysis*)gActarSimROOTAnalysis)->GetTracksTree();
90 
91  //The clones array of Crystal Hits
92  simpleTrackCA = new TClonesArray("ActarSimSimpleTrack",100);
93 
94  //theData should be initiated in ActarSimROOTAnalysis, as is going to be
95  //used at several levels, while tracks are only relevant to gas...
96  theData =
98 
99  theTracks = new ActarSimTrack();
100 
101  //Let us create 2 simpleTrack's for the primaries...
103  for (G4int i=0;i<2;i++)
104  simpleTrack[i] = new ActarSimSimpleTrack();
105 
106  //eventTree->Branch("theData","ActarSimData",&theData,128000,99);
107  tracksTree->Branch("trackData","ActarSimTrack",&theTracks,128000,99);
108  //Now, simple track as a TClonesArray
109  eventTree->Branch("simpleTrackData",&simpleTrackCA);
110 
111  //minStrideLength = 0.1 * mm; //default value for the minimum stride length
112  minStrideLength = 1.0 * CLHEP::mm; //default value for the minimum stride length
113 }
114 
115 //////////////////////////////////////////////////////////////////
116 /// Destructor. Makes nothing
118 }
119 
120 //////////////////////////////////////////////////////////////////
121 /// Actions to perform in the analysis when generating the primaries
122 void ActarSimROOTAnalGas::GeneratePrimaries(const G4Event *anEvent){
123  /// NOT VALID !!! ONLY GAMMAS ALLOWED, MODIFY FOR OTHER PARTICLES!!!
124  //Filling the primary accessing on other functions
125  //(in particular during UserSteppingAction()
126  G4PrimaryVertex* myPVertex = anEvent->GetPrimaryVertex();
127  //Modify this code in future for allowing several primary
128  //particles and select on the gammas
129  primNbOfParticles = myPVertex->GetNumberOfParticle();
130  primary = myPVertex->GetPrimary();
131  G4ThreeVector momentumPrim = primary->GetMomentum();
132  primTheta = momentumPrim.theta();
133  primPhi = momentumPrim.phi();
134  // P^2 = E^2 - M^2 = (T + M)^2 - M^2
135  // E = Ekin + M
136  primEnergy = momentumPrim.mag(); //in case the mass is not zero, NOT VALID
137 }
138 
139 //////////////////////////////////////////////////////////////////
140 /// Actions to perform in the analysis at the begining of the run
141 void ActarSimROOTAnalGas::BeginOfRunAction(const G4Run *aRun) {
142  //Storing the runID
143  SetTheRunID(aRun->GetRunID());
144 
145  char newDirName[255];
146  sprintf(newDirName,"%s%i","Histos",aRun->GetRunID());
147  simFile->cd(newDirName);
148 
149  dirName = new char[255];
150 
151  sprintf(dirName,"%s","gas");
152  gDirectory->mkdir(dirName,dirName);
153  gDirectory->cd(dirName);
154 
155  // Step Sum Length
156  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreHistogramsFlag()== "on") {
157  hStepSumLengthOnGas1 = (TH1D *)gROOT->FindObject("hStepSumLengthOnGas1");
159  else {
160  hStepSumLengthOnGas1 = new TH1D("hStepSumLengthOnGas1","Step Sum Length On Gas for first primary", 1000, 0.0, 1000.0);// in [cm]
161  if (hStepSumLengthOnGas1) hStepSumLengthOnGas1->SetXTitle("[mm]");
162  }
163  // Step Sum Length
164  hStepSumLengthOnGas2 = (TH1D *)gROOT->FindObject("hStepSumLengthOnGas2");
166  else {
167  hStepSumLengthOnGas2 = new TH1D("hStepSumLengthOnGas2","Step Sum Length On Gas for second primary", 1000, 0.0, 1000.0);// in [cm]
168  if (hStepSumLengthOnGas2) hStepSumLengthOnGas2->SetXTitle("[mm]");
169  }
170  }
171  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreTrackHistosFlag()== "on") {
172  htrackInPads =
173  (TH2D *)gROOT->FindObject("htrackInPads");
174  if(htrackInPads) htrackInPads->Reset();
175  else {
176  htrackInPads = new TH2D("htrackInPads",
177  "All tracks in the XZ Pads Plane",
178  250, -500, 500, 250, -500, 500);
179  htrackInPads->SetYTitle("Z [mm]");
180  htrackInPads->SetXTitle("X [mm]");
181  }
182 
183  //
184  htrack1InPads =
185  (TH2D *)gROOT->FindObject("htrack1InPads");
186  if(htrack1InPads) htrack1InPads->Reset();
187  else {
188  htrack1InPads = new TH2D("htrack1InPads",
189  "track 1 In the XZ Pads Plane",
190  250, -500, 500, 250, -500, 500);
191  htrack1InPads->SetYTitle("Z [mm]");
192  htrack1InPads->SetXTitle("X [mm]");
193  }
194 
195  // The accumulated energy loss and track length of each step
197  (TProfile *)gROOT->FindObject("hbeamEnergyAtRange");
199  else {
200  hbeamEnergyAtRange = new TProfile("hbeamEnergyAtRange",
201  "Accumulated beam energy loss and trajectory length",
202  500, 0, 500);
203  hbeamEnergyAtRange->SetYTitle("Accumulated energy loss [MeV]");
204  hbeamEnergyAtRange->SetXTitle("trajectory length [mm]");
205  }
206 
207  //
208  htrack2InPads =
209  (TH2D *)gROOT->FindObject("htrack2InPads");
210  if(htrack2InPads) htrack2InPads->Reset();
211  else {
212  htrack2InPads = new TH2D("htrack2InPads",
213  "track 2 In the XZ Pads Plane",
214  250, -500, 500, 250, -500, 500);
215  htrack2InPads->SetYTitle("Z [mm]");
216  htrack2InPads->SetXTitle("X [mm]");
217  }
218  //
220  (TH2D *)gROOT->FindObject("htrackFromBeam");
221  if(htrackFromBeam) htrackFromBeam->Reset();
222  else {
223  htrackFromBeam = new TH2D("htrackFromBeam",
224  "All tracks from a beam view ",
225  250, -500, 500, 250, -500, 500);
226  htrackInPads->SetYTitle("Y [mm]");
227  htrackInPads->SetXTitle("X [mm]");
228  }
229 
230  //
231  htrack =
232  (TH3D *)gROOT->FindObject("htrack");
233  if(htrack) htrack->Reset();
234  else {
235  htrack = new TH3D("htrack",
236  "All tracks from a beam view ",
237  100, -500, 500, 100, -500, 500, 100, -500, 500);
238  htrack->SetZTitle("Z [mm]");
239  htrack->SetYTitle("Y [mm]");
240  htrack->SetXTitle("X [mm]");
241  }
242 
243  hEdepInGas =
244  (TH1D *)gROOT->FindObject("hEdepInGas");
245  if(hEdepInGas) hEdepInGas->Reset();
246  else {
247  hEdepInGas = new TH1D("hEdepInGas",
248  "Edep along Gas chamber (normalized!)",
249  300, 0, 300);
250  hEdepInGas->SetXTitle("Z [mm]");
251  }
252 
253  //Now, I will introduce the information of interest!
254  // Total Energy Loss on Gas1
255  hTotELossOnGas1 = (TH1D *)gROOT->FindObject("hTotELossOnGas1");
256  if(hTotELossOnGas1) hTotELossOnGas1->Reset();
257  else {
258  hTotELossOnGas1 = new TH1D("hTotELossOnGas1",
259  "Total Energy Loss inside the Gas for primary 1",
260  1000, 0.0, 301.0); // in [MeV]
261  hTotELossOnGas1->SetXTitle("[MeV]");
262  }
263 
264  // Total Energy Loss on the gas
266  (TH1D *)gROOT->FindObject("hTotELossOnGas2");
267  if(hTotELossOnGas2) hTotELossOnGas2->Reset();
268  else {
269  hTotELossOnGas2 = new TH1D("hTotELossOnGas2",
270  "Total Energy Loss inside the Gas for primary 2",
271  1000, 0.0, 301.0); // in [MeV]
272  hTotELossOnGas2->SetXTitle("[MeV]");
273  }
274  }
275 
276  simFile->cd();
277 }
278 
279 //////////////////////////////////////////////////////////////////
280 /// Actions to perform in the analysis at the end of the run
281 void ActarSimROOTAnalGas::EndOfRunAction(const G4Run *aRun) {
282  G4int nbofEvents = aRun->GetNumberOfEvent();
283 
284  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreTrackHistosFlag() == "on") {
285  //G4double binWidth = hEdepInGas->GetBinWidth();
286  hEdepInGas->Scale(1./nbofEvents);
287  //G4cout << "Number of events: "<< nbofEvents << G4endl;
288  }
289 }
290 
291 //////////////////////////////////////////////////////////////////
292 /// Actions to perform in the analysis at the begining of the event
293 void ActarSimROOTAnalGas::BeginOfEventAction(const G4Event *anEvent) {
294  SetTheEventID(anEvent->GetEventID());
295 }
296 
297 //////////////////////////////////////////////////////////////////
298 /// Actions to perform in the analysis at the end of the event
299 void ActarSimROOTAnalGas::EndOfEventAction(const G4Event *anEvent) {
300  Double_t aEnergyInGas1 =0;// (EnerGas1 / MeV); // in [MeV]
301  Double_t aEnergyInGas2 =0;// (EnerGas2 / MeV); // in [MeV]
302  Double_t aTLInGas1 =0;// (TLGas1 / mm); // in [mm]
303  Double_t aTLInGas2 =0;// (TLGas2 / mm); // in [mm]
304 
305  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreSimpleTracksFlag()=="on"){
306  //moving here the recollection of the steps info into strides
307  //which was previously made in the UserSteppingAction() function
308  //Now we will use the GeantHits to recover the steps from the gas
309 
310  //Hit Container ID for ActarSimGasGeantHit
311  G4int hitsCollectionID =
312  G4SDManager::GetSDMpointer()->GetCollectionID("gasCollection");
313 
314  G4HCofThisEvent* HCofEvent = anEvent->GetHCofThisEvent();
315 
316  ActarSimGasGeantHitsCollection* hitsCollection =
317  (ActarSimGasGeantHitsCollection*) HCofEvent->GetHC(hitsCollectionID);
318 
319  //Number of ActarSimGasGeantHit (or steps) in the hitsCollection
320  G4int NbHits = hitsCollection->entries();
321  G4int NbStrides = 0;
322  G4int strideOrdinal[2];
323  strideOrdinal[0]=0;
324  strideOrdinal[1]=0;
325 
326  simpleTrackCA->Clear();
327 
328  // G4cout << "Information on the collection..." << G4endl
329  // << "Number of GasGeantHits in the collection: " << NbHits
330  // << G4endl;
331 
332  // for (G4int i=0;i<NbHits;i++) {
333  //if((*hitsCollection)[i]->GetStepLength()>1)
334  // G4cout << (*hitsCollection)[i]->GetPrePos().x() <<", "
335  // << (*hitsCollection)[i]->GetPrePos().y() <<", "
336  // << (*hitsCollection)[i]->GetPrePos().z() <<" "
337  // << (*hitsCollection)[i]->GetPostPos().x() <<", "
338  // << (*hitsCollection)[i]->GetPostPos().y() <<", "
339  // << (*hitsCollection)[i]->GetPostPos().z() <<" "
340  // << (*hitsCollection)[i]->GetEdep() <<" "
341  // << (*hitsCollection)[i]->GetStepLength() <<" " << G4endl;
342  //}
343 
344  //init values
345  for (G4int i=0;i<NbHits;i++) {
346  //G4cout << (*hitsCollection)[i]->GetDetName() << G4endl;
347  for(G4int j=0;j<2;j++) { //that is, for 2 primaries
348  if((*hitsCollection)[i]->GetTrackID()==(j+1) &&
349  (*hitsCollection)[i]->GetParentID()==0){ //this step comes from a primary
350  //New algorithm to reduce the number of GEANT4 steps to a few strides...
351  if(simpleTrack[j]->GetNumberSteps() == 0) {
352  //the first step in the stride!
353  simpleTrack[j]->SetXPre((*hitsCollection)[i]->GetPrePos().x());
354  simpleTrack[j]->SetYPre((*hitsCollection)[i]->GetPrePos().y());
355  simpleTrack[j]->SetZPre((*hitsCollection)[i]->GetPrePos().z());
356  simpleTrack[j]->SetXPost((*hitsCollection)[i]->GetPostPos().x());
357  simpleTrack[j]->SetYPost((*hitsCollection)[i]->GetPostPos().y());
358  simpleTrack[j]->SetZPost((*hitsCollection)[i]->GetPostPos().z());
359  simpleTrack[j]->SetEnergyStride ((*hitsCollection)[i]->GetEdep());
360  simpleTrack[j]->SetParticleCharge((*hitsCollection)[i]->GetParticleCharge());
361  simpleTrack[j]->SetParticleMass((*hitsCollection)[i]->GetParticleMass());
362  simpleTrack[j]->SetParticleID((*hitsCollection)[i]->GetParticleID());
363  simpleTrack[j]->SetStrideLength((*hitsCollection)[i]->GetStepLength());
364  //G4cout << "Step lenth: " << (*hitsCollection)[i]->GetStepLength() << G4endl;
365  simpleTrack[j]->SetParticleEnergy((*hitsCollection)[i]->GetStepEnergy());
366  simpleTrack[j]->SetTimePre((*hitsCollection)[i]->GetPreToF());
367  simpleTrack[j]->SetTimePost((*hitsCollection)[i]->GetPostToF());
369  simpleTrack[j]->SetTrackID((*hitsCollection)[i]->GetTrackID());
370  simpleTrack[j]->SetParentTrackID((*hitsCollection)[i]->GetParentID());
373  simpleTrack[j]->SetStrideOrdinal(strideOrdinal[j]);
374 
375  //G4cout << "First step in stride (type" << j << ")" << G4endl
376  //<< "preTime " << (*hitsCollection)[i]->GetPreToF()
377  //<< " postTime" << (*hitsCollection)[i]->GetPostToF()
378  //<< "initPos: " << (*hitsCollection)[i]->GetPrePos()
379  //<< " finalPos: " << (*hitsCollection)[i]->GetPostPos()<< G4endl;
380  }
381  else {
382  simpleTrack[j]->SetXPost((*hitsCollection)[i]->GetPostPos().x());
383  simpleTrack[j]->SetYPost((*hitsCollection)[i]->GetPostPos().y());
384  simpleTrack[j]->SetZPost((*hitsCollection)[i]->GetPostPos().z());
385  simpleTrack[j]->SetTimePost((*hitsCollection)[i]->GetPostToF());
386  simpleTrack[j]->SetEnergyStride(simpleTrack[j]->GetEnergyStride() +
387  (*hitsCollection)[i]->GetEdep());
388  simpleTrack[j]->SetStrideLength(simpleTrack[j]->GetStrideLength() +
389  (*hitsCollection)[i]->GetStepLength());
390  simpleTrack[j]->SetNumberSteps(simpleTrack[j]->GetNumberSteps()+1);
391 
392  //G4cout << "next step of type " << j << G4endl
393  // << " postTime" << (*hitsCollection)[i]->GetPostToF()
394  // << "length up to now: " << simpleTrack[j]->GetStrideLength()<< G4endl;
395  }
396  if(simpleTrack[j]->GetStrideLength() > minStrideLength || (*hitsCollection)[i]->GetParticleCharge()<=2 ){
397  //the sum of steps is larger that the given parameter... the stride goes to the Tree
398  //G4cout << "...larger than minStrideLength and stored (type "
399  // << j << ") " << NbStrides << " "<< strideOrdinal[j] << " "
400  //<< simpleTrack[j]->GetTimePre()<< " "<<simpleTrack[j]->GetTimePost()<< G4endl;
401  //G4cout<<"ActarSimROOTAnalGas------->EndOfEventAction() "<<simpleTrack[j]<<G4endl;
402  new((*simpleTrackCA)[NbStrides])ActarSimSimpleTrack(*simpleTrack[j]);
403  //G4cout<<"ActarSimROOTAnalGas------->EndOfEventAction()"<<simpleTrackCA<<G4endl;
404  NbStrides++;
405  strideOrdinal[j]++;
406  simpleTrack[j]->Reset();
407  }
408  //David Perez Loureiro 28-10-2011-----------------------------------------//
409  if(j==0){
410  aEnergyInGas1 += (*hitsCollection)[i]->GetEdep();
411  aTLInGas1 +=(*hitsCollection)[i]->GetStepLength();
412  }
413  else {
414  aEnergyInGas2 += (*hitsCollection)[i]->GetEdep();
415  aTLInGas2 +=(*hitsCollection)[i]->GetStepLength();
416  }
417  }
418  }//end of loop in primaries
419  }//end of loop on hits
420 
421  for(G4int j=0;j<2;j++) {
422  if(simpleTrack[j]->GetNumberSteps() > 0){
423  if(simpleTrack[j]->GetStrideLength() > minStrideLength)
424  G4cout << "ERROR in ActarSimRootAnalysis::EndOfEventAction: "
425  << "Something does not match !? Consult an expert :-)" << G4endl;
426  //even if the sum of steps is not larger that the given parameter...
427  //the stride goes to the Tree (last steps of the track...)
428  //G4cout<<"End of loop (type "<< j << ") " << NbStrides << " "
429  //<< strideOrdinal[j] << " "<< simpleTrack[j]->GetTimePre()
430  //<< " "<<simpleTrack[j]->GetTimePost()<< G4endl;
431  //<<" with length " << simpleTrack[j]->GetStrideLength() << G4endl;
432  new((*simpleTrackCA)[NbStrides])ActarSimSimpleTrack(*simpleTrack[j]);
433  NbStrides++;
434  strideOrdinal[j]++;
435  simpleTrack[j]->Reset();
436  }
437  }
438  }
439  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreEventsFlag()=="on"){
440  theData->SetEnergyOnGasPrim1(aEnergyInGas1);
441  theData->SetEnergyOnGasPrim2(aEnergyInGas2);
444  theData->SetEventID(anEvent->GetEventID());
446  }
447 
448  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreTrackHistosFlag()=="on"){
449  if (hStepSumLengthOnGas1) hStepSumLengthOnGas1->Fill(aTLInGas1);
450  if (hStepSumLengthOnGas2) hStepSumLengthOnGas2->Fill(aTLInGas2);
451  if (hTotELossOnGas1) hTotELossOnGas1->Fill(aEnergyInGas1);
452  if (hTotELossOnGas2) hTotELossOnGas2->Fill(aEnergyInGas2);
453  }
454  /*
455  //checking the number of electrons created on the ion path...
456  G4TrajectoryContainer* myTraCon = anEvent->GetTrajectoryContainer();
457  G4int numTracks = 0;
458  if(myTraCon) numTracks = myTraCon->entries();//entries of the container
459  G4cout << " INFO numTracks=" << numTracks << G4endl;
460  for(G4int i=0;i<numTracks;i++) {
461  G4Trajectory* traje =(G4Trajectory*)((*(anEvent->GetTrajectoryContainer()))[i]);
462  //if(traje->GetParticleName() == "e-")
463  G4cout << " INFO -- TrackID: " << traje->GetTrackID()
464  << " ParentID: " << traje->GetParentID()
465  << " ParticleName: " << traje->GetParticleName() << G4endl
466  << " Charge: " << traje->GetCharge()
467  << " PDGEncoding: " << traje->GetPDGEncoding() << G4endl
468  << " InitialMomentum: " << traje->GetInitialMomentum().x()
469  << " , " << traje->GetInitialMomentum().y()
470  << " , " << traje->GetInitialMomentum().z() << G4endl;
471  // << " Energy: " << traje->GetInitialMomentum().x()
472  // << " : " << traje->Get()
473  // << " : " << traje->Get()
474  }
475  */
476 }
477 
478 //////////////////////////////////////////////////////////////////
479 /// Actions to perform in the ACTAR gas detector analysis after each step
480 void ActarSimROOTAnalGas::UserSteppingAction(const G4Step *aStep){
481  G4Track* myTrack = aStep->GetTrack();
482  G4ThreeVector prePoint = aStep->GetPreStepPoint()->GetPosition();
483  G4ThreeVector postPoint = aStep->GetPostStepPoint()->GetPosition();
484 
485  G4double z1 = prePoint.z();
486  G4double z2 = postPoint.z();
487  G4double z = z1 + G4UniformRand()*(z2-z1);// + 0.5*(fDetector->GetAbsorSizeX());
488 
489  G4double edep = aStep->GetTotalEnergyDeposit();
490  if (edep <= 0.) return;
491 
492  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreTrackHistosFlag() == "on") {
493  if(hEdepInGas && z2<300) hEdepInGas->Fill(z,edep);
494  if(htrack) htrack->Fill(postPoint.x(),
495  postPoint.y(),
496  postPoint.z());
497  if(htrackFromBeam) htrackFromBeam->Fill(postPoint.x(),
498  postPoint.y(),
499  aStep->GetTotalEnergyDeposit());
500  if(htrackInPads) htrackInPads->Fill(postPoint.x(),
501  postPoint.z(),
502  aStep->GetTotalEnergyDeposit());
503  if(myTrack->GetTrackID()==1 && myTrack->GetParentID()==0)
504  if(htrack1InPads) htrack1InPads->Fill(postPoint.x(),
505  postPoint.z(),
506  aStep->GetTotalEnergyDeposit());
507  if(myTrack->GetTrackID()==2 && myTrack->GetParentID()==0)
508  if(htrack2InPads) htrack2InPads->Fill(postPoint.x(),
509  postPoint.z(),
510  aStep->GetTotalEnergyDeposit());
511  }
512 
513  if(((ActarSimROOTAnalysis*) gActarSimROOTAnalysis)->GetStoreTracksFlag() == "on") {
514  theTracks->SetXCoord(postPoint.x());
515  theTracks->SetYCoord(postPoint.y());
516  theTracks->SetZCoord(postPoint.z());
517  theTracks->SetXPreCoord(prePoint.x());
518  theTracks->SetYPreCoord(prePoint.y());
519  theTracks->SetZPreCoord(prePoint.z());
520  theTracks->SetEnergyStep(aStep->GetTotalEnergyDeposit());
521  theTracks->SetTrackID(myTrack->GetTrackID());
522  theTracks->SetParentTrackID(myTrack->GetParentID());
525  tracksTree->Fill();
526  }
527 }
void SetZCoord(Double_t zc)
void SetZPreCoord(Double_t zc)
void SetTrackID(Int_t track)
void SetStepSumLengthOnGasPrim1(Double_t step)
Definition: ActarSimData.hh:56
void SetParentTrackID(Int_t pt)
TTree * eventTree
Local pointer to the event tree.
void SetRunID(Int_t ev)
TH1D * hStepSumLengthOnGas1
Histogram: step Length on gas for first primary.
ActarSimROOTAnalGas()
Default constructor... Simply inits.
TTree * tracksTree
Local pointer to the tracks tree.
void SetTheRunID(G4int id)
void SetParentTrackID(Int_t pt)
void SetParticleID(Int_t piD)
void SetEnergyOnGasPrim2(Double_t energy)
Definition: ActarSimData.hh:55
void SetTimePre(Double_t te)
void EndOfRunAction(const G4Run *)
Actions to perform in the analysis at the end of the run.
TH3D * htrack
Histogram: 3D track.
void Reset(void)
Clearing to defaults.
G4PrimaryParticle * primary
Storing the primary for accesing during UserStep.
TH2D * htrackInPads
Histogram: all tracks projected in pads.
TClonesArray * simpleTrackCA
ClonesArray for simple tracks.
G4double primTheta
Theta of primary.
G4THitsCollection< ActarSimGasGeantHit > ActarSimGasGeantHitsCollection
void SetStrideOrdinal(Int_t num)
void SetStepSumLengthOnGasPrim2(Double_t step)
Definition: ActarSimData.hh:57
void SetEventID(Int_t ev)
void SetParticleCharge(Double_t parcha)
void SetXCoord(Double_t xc)
void SetYPre(Double_t yc)
ActarSimTrack * theTracks
Pointer to tracks.
~ActarSimROOTAnalGas()
Destructor. Makes nothing.
void SetYPreCoord(Double_t yc)
void SetEnergyStride(Double_t energy)
void BeginOfEventAction(const G4Event *)
Actions to perform in the analysis at the begining of the event.
void BeginOfRunAction(const G4Run *)
Actions to perform in the analysis at the begining of the run.
G4double primPhi
Phi of primary.
void SetNumberSteps(Int_t num)
TH2D * htrack2InPads
Histogram: second primary track projected in pads.
void SetTheEventID(G4int id)
void SetEnergyStep(Double_t energy)
void SetTimePost(Double_t te)
ActarSimData * theData
Pointer to data.
void GeneratePrimaries(const G4Event *)
Actions to perform in the analysis when generating the primaries.
TProfile * hbeamEnergyAtRange
Histogram profile: ccumulated energy loss and track length of each step.
void SetXPreCoord(Double_t xc)
G4int primNbOfParticles
Number of primaries.
void SetParticleEnergy(Double_t penergy)
void SetStrideLength(Double_t len)
ActarSimROOTAnalysis * gActarSimROOTAnalysis
Global pointer to this soliton.
void SetZPost(Double_t zc)
void SetParticleMass(Double_t pm)
TFile * simFile
Local pointer to simFile.
G4double primEnergy
Energy of primary.
void SetRunID(Int_t ev)
Definition: ActarSimData.hh:59
TH1D * hEdepInGas
Histogram: energy deposit in Gas over the distance.
void SetYCoord(Double_t yc)
void SetEventID(Int_t ev)
Definition: ActarSimData.hh:58
TH1D * hTotELossOnGas1
Histogram: energy Loss on gas for first primary.
void SetTrackID(Int_t track)
void SetXPost(Double_t xc)
G4double minStrideLength
Control of minimum simpleTrack stride length.
TH1D * hStepSumLengthOnGas2
Histogram: step Length on gas for second primary.
void init()
Makes most of the work of a constructor...
void SetYPost(Double_t yc)
void SetZPre(Double_t zc)
ActarSimSimpleTrack ** simpleTrack
Pointer to simple tracks.
void SetEnergyOnGasPrim1(Double_t energy)
Definition: ActarSimData.hh:54
void EndOfEventAction(const G4Event *)
Actions to perform in the analysis at the end of the event.
TH2D * htrackFromBeam
Histogram: tracks from beam direction.
TH2D * htrack1InPads
Histogram: first primary track projected in pads.
void SetXPre(Double_t xc)
void UserSteppingAction(const G4Step *)
Actions to perform in the ACTAR gas detector analysis after each step.
TH1D * hTotELossOnGas2
Histogram: energy Loss on gas for second primary.