17 #include "G4RunManager.hh" 18 #include "G4SDManager.hh" 22 #include "G4ClassificationOfNewTrack.hh" 23 #include "G4TrackStatus.hh" 45 #include "TClonesArray.h" 48 #include "Randomize.hh" 59 G4cout <<
"##################################################################" << G4endl
60 <<
"########### ActarSimROOTAnalGas::init() ####################" << G4endl;
103 for (G4int i=0;i<2;i++)
126 G4PrimaryVertex* myPVertex = anEvent->GetPrimaryVertex();
130 primary = myPVertex->GetPrimary();
131 G4ThreeVector momentumPrim =
primary->GetMomentum();
145 char newDirName[255];
146 sprintf(newDirName,
"%s%i",
"Histos",aRun->GetRunID());
160 hStepSumLengthOnGas1 =
new TH1D(
"hStepSumLengthOnGas1",
"Step Sum Length On Gas for first primary", 1000, 0.0, 1000.0);
167 hStepSumLengthOnGas2 =
new TH1D(
"hStepSumLengthOnGas2",
"Step Sum Length On Gas for second primary", 1000, 0.0, 1000.0);
173 (TH2D *)gROOT->FindObject(
"htrackInPads");
177 "All tracks in the XZ Pads Plane",
178 250, -500, 500, 250, -500, 500);
185 (TH2D *)gROOT->FindObject(
"htrack1InPads");
189 "track 1 In the XZ Pads Plane",
190 250, -500, 500, 250, -500, 500);
197 (TProfile *)gROOT->FindObject(
"hbeamEnergyAtRange");
201 "Accumulated beam energy loss and trajectory length",
209 (TH2D *)gROOT->FindObject(
"htrack2InPads");
213 "track 2 In the XZ Pads Plane",
214 250, -500, 500, 250, -500, 500);
220 (TH2D *)gROOT->FindObject(
"htrackFromBeam");
224 "All tracks from a beam view ",
225 250, -500, 500, 250, -500, 500);
232 (TH3D *)gROOT->FindObject(
"htrack");
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]");
244 (TH1D *)gROOT->FindObject(
"hEdepInGas");
248 "Edep along Gas chamber (normalized!)",
259 "Total Energy Loss inside the Gas for primary 1",
266 (TH1D *)gROOT->FindObject(
"hTotELossOnGas2");
270 "Total Energy Loss inside the Gas for primary 2",
282 G4int nbofEvents = aRun->GetNumberOfEvent();
300 Double_t aEnergyInGas1 =0;
301 Double_t aEnergyInGas2 =0;
302 Double_t aTLInGas1 =0;
303 Double_t aTLInGas2 =0;
311 G4int hitsCollectionID =
312 G4SDManager::GetSDMpointer()->GetCollectionID(
"gasCollection");
314 G4HCofThisEvent* HCofEvent = anEvent->GetHCofThisEvent();
320 G4int NbHits = hitsCollection->entries();
322 G4int strideOrdinal[2];
345 for (G4int i=0;i<NbHits;i++) {
347 for(G4int j=0;j<2;j++) {
348 if((*hitsCollection)[i]->GetTrackID()==(j+1) &&
349 (*hitsCollection)[i]->GetParentID()==0){
387 (*hitsCollection)[i]->GetEdep());
389 (*hitsCollection)[i]->GetStepLength());
410 aEnergyInGas1 += (*hitsCollection)[i]->GetEdep();
411 aTLInGas1 +=(*hitsCollection)[i]->GetStepLength();
414 aEnergyInGas2 += (*hitsCollection)[i]->GetEdep();
415 aTLInGas2 +=(*hitsCollection)[i]->GetStepLength();
421 for(G4int j=0;j<2;j++) {
424 G4cout <<
"ERROR in ActarSimRootAnalysis::EndOfEventAction: " 425 <<
"Something does not match !? Consult an expert :-)" << G4endl;
481 G4Track* myTrack = aStep->GetTrack();
482 G4ThreeVector prePoint = aStep->GetPreStepPoint()->GetPosition();
483 G4ThreeVector postPoint = aStep->GetPostStepPoint()->GetPosition();
485 G4double z1 = prePoint.z();
486 G4double z2 = postPoint.z();
487 G4double z = z1 + G4UniformRand()*(z2-z1);
489 G4double edep = aStep->GetTotalEnergyDeposit();
490 if (edep <= 0.)
return;
499 aStep->GetTotalEnergyDeposit());
502 aStep->GetTotalEnergyDeposit());
503 if(myTrack->GetTrackID()==1 && myTrack->GetParentID()==0)
506 aStep->GetTotalEnergyDeposit());
507 if(myTrack->GetTrackID()==2 && myTrack->GetParentID()==0)
510 aStep->GetTotalEnergyDeposit());
void SetZCoord(Double_t zc)
void SetZPreCoord(Double_t zc)
void SetEventID(Int_t ev)
void SetTrackID(Int_t track)
void SetStepSumLengthOnGasPrim1(Double_t step)
void SetParentTrackID(Int_t pt)
TTree * eventTree
Local pointer to the event tree.
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)
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)
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.
TH1D * hEdepInGas
Histogram: energy deposit in Gas over the distance.
void SetYCoord(Double_t yc)
void SetEventID(Int_t ev)
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)
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.