37 #include "G4RunManager.hh" 38 #include "G4SDManager.hh" 39 #include "G4VPhysicalVolume.hh" 43 #include "G4ClassificationOfNewTrack.hh" 44 #include "G4TrackStatus.hh" 49 #include "G4Trajectory.hh" 66 #include "TClonesArray.h" 74 storeTracksFlag(
"off"), storeTrackHistosFlag(
"off"),
75 storeEventsFlag(
"off"), storeSimpleTracksFlag(
"on"),
76 storeHistogramsFlag(
"off"), beamInteractionFlag(
"off") {
79 if(gSystem) gSystem->ProcessEvents();
81 if(gActarSimROOTAnalysis)
83 gActarSimROOTAnalysis =
this;
129 if (gActarSimROOTAnalysis ==
this)
134 if (gSystem) gSystem->ProcessEvents();
145 simFile =
new TFile(
"root_files/sim_files/simFile.root",
"RECREATE");
148 eventTree =
new TTree(
"The_ACTAR_Event_Tree",
"Event_Tree");
149 tracksTree =
new TTree(
"The_ACTAR_Tracks_Tree",
"Tracks_Tree");
153 beamInfoCA =
new TClonesArray(
"ActarSimBeamInfo",1);
155 theDataCA =
new TClonesArray(
"ActarSimData",1);
186 if (theWorldVolume) {;}
187 if (gSystem) gSystem->ProcessEvents();
195 if (gSystem) gSystem->ProcessEvents();
203 if (gSystem) gSystem->ProcessEvents();
211 if (gSystem) gSystem->ProcessEvents();
239 if (gSystem) gSystem->ProcessEvents();
244 Double_t aTheta1 = (Theta1 / CLHEP::deg);
245 Double_t aTheta2 = (Theta2 / CLHEP::deg);
246 Double_t aEnergy1 = (Energy1 / CLHEP::MeV);
247 Double_t aEnergy2 = (Energy2 / CLHEP::MeV);
249 G4int nbOfPrimaryVertex = anEvent->GetNumberOfPrimaryVertex();
250 G4int* nbOfPrimaries =
new G4int[nbOfPrimaryVertex];
251 G4int totalPrimaries = 0;
253 for(G4int nbVertexes = 0 ; nbVertexes < nbOfPrimaryVertex ; nbVertexes++){
254 nbOfPrimaries[nbVertexes] = anEvent->GetPrimaryVertex(nbVertexes)->GetNumberOfParticle();
255 totalPrimaries += nbOfPrimaries[nbVertexes];
258 G4int countingPrimaries = 0;
266 for(G4int i=0;i<nbOfPrimaryVertex;i++) {
267 for(G4int j=0;j<nbOfPrimaries[i];j++) {
275 anEvent->GetPrimaryVertex(i)->GetY0() / CLHEP::mm,
276 anEvent->GetPrimaryVertex(i)->GetZ0() / CLHEP::mm );
284 for (G4int i=0;i<totalPrimaries;i++)
292 delete [] nbOfPrimaries;
311 if (gSystem) gSystem->ProcessEvents();
320 G4int nbOfPrimaryVertex = anEvent->GetNumberOfPrimaryVertex();
321 G4int* nbOfPrimaries =
new G4int[nbOfPrimaryVertex];
322 G4int totalPrimaries = 0;
324 for(G4int nbVertexes = 0 ; nbVertexes < nbOfPrimaryVertex ; nbVertexes++){
325 nbOfPrimaries[nbVertexes] = anEvent->GetPrimaryVertex(nbVertexes)->GetNumberOfParticle();
326 totalPrimaries += nbOfPrimaries[nbVertexes];
329 G4int countingPrimaries = 0;
337 for(G4int i=0;i<nbOfPrimaryVertex;i++) {
338 for(G4int j=0;j<nbOfPrimaries[i];j++) {
346 anEvent->GetPrimaryVertex(i)->GetY0() / CLHEP::mm,
347 anEvent->GetPrimaryVertex(i)->GetZ0() / CLHEP::mm );
356 for (G4int i=0;i<totalPrimaries;i++){
363 delete [] nbOfPrimaries;
381 if (gSystem) gSystem->ProcessEvents();
387 G4cout <<
"##################################################################" << G4endl
388 <<
"######## ActarSimROOTAnalysis::BeginOfRunAction() ############" << G4endl;
389 G4cout <<
"######## New Run With Number " << aRun->GetRunID() <<
" Detected!! ######" << G4endl;
390 G4cout <<
"#### A new directory will be opened in the output ROOT file ####" << G4endl;
391 G4cout <<
"################################################################## " << G4endl;
394 sprintf(
newDirName,
"%s%i",
"Histos",aRun->GetRunID());
403 (TH2F *)gROOT->FindObject(
"hScatteredIonKinematic");
407 "Cine Kinematic for the Scattered Ion",
408 2, 0., 180, 2, 0., 100.);
418 (TH2F *)gROOT->FindObject(
"hRecoilIonKinematic");
422 "Cine Kinematic for the Recoil Ion",
423 2, 0., 10, 2, 0., 1000.);
434 hPrimTheta = (TH1D *)gROOT->FindObject(
"hPrimTheta");
438 "Primary Theta angle",
444 hPrimPhi = (TH1D *)gROOT->FindObject(
"hPrimPhi");
454 hPrimEnergy = (TH1D *)gROOT->FindObject(
"hPrimEnergy");
458 "Primary Energy (first particle)",
465 (TH2D *)gROOT->FindObject(
"hPrimEnergyVsTheta");
469 "Primary Energy vs Theta angle",
470 100, -0.01, 3.15, 100, 0, 301);
495 if (gSystem) gSystem->ProcessEvents();
497 G4cout <<
"##################################################################" << G4endl
498 <<
"######## ActarSimROOTAnalysis::EndOfRunAction() ############" << G4endl;
499 G4cout <<
"######## Run With Number " << aRun->GetRunID() <<
" finished! ######" << G4endl;
500 G4cout <<
"################################################################## " << G4endl;
510 if (gSystem) gSystem->ProcessEvents();
526 if (gSystem) gSystem->ProcessEvents();
528 G4PrimaryVertex* myPVertex1 = anEvent->GetPrimaryVertex(0);
529 G4PrimaryVertex* myPVertex2 = 0;
530 if(anEvent->GetNumberOfPrimaryVertex()>1)
531 myPVertex2 = anEvent->GetPrimaryVertex(1);
536 G4PrimaryParticle* myPrim1 = myPVertex1->GetPrimary();
537 G4PrimaryParticle* myPrim2 = 0;
538 if(myPVertex2) myPrim2 = myPVertex2->GetPrimary();
539 G4ThreeVector momentumPrim1 = myPrim1->GetMomentum();
540 G4ThreeVector momentumPrim2;
541 if(myPrim2) momentumPrim2 = myPrim2->GetMomentum();
542 G4double massPrim1 = myPrim1->GetMass();
543 G4double massPrim2=0.0;
544 if(myPrim2) massPrim2 = myPrim2->GetMass();
547 G4double energyPrim1 = sqrt(momentumPrim1.mag2()+massPrim1*massPrim1) - massPrim1;
548 G4double energyPrim2 = sqrt(momentumPrim2.mag2()+massPrim2*massPrim2) - massPrim2;
556 hPrimPhi->Fill(momentumPrim1.phi());
608 G4ClassificationOfNewTrack *classification_ptr) {
610 if (classification_ptr){;}
613 if (gSystem) gSystem->ProcessEvents();
623 if (gSystem) gSystem->ProcessEvents();
631 G4TrackStatus *status_ptr) {
635 if (gSystem) gSystem->ProcessEvents();
660 if(aStep->GetTrack()->GetParentID()==0){
661 if(aStep->GetPreStepPoint()->GetPosition().z() < zVertex &&
662 aStep->GetPostStepPoint()->GetPosition().z() > zVertex){
663 const G4int verboseLevel = G4RunManager::GetRunManager()->GetVerboseLevel();
666 <<
" *************************************************** " << G4endl
667 <<
" * ActarSimROOTAnalysis::UserSteppingAction() " << G4endl
668 <<
" * beamInteractionFlag=on, beam.Status=1, primary particle (ion beam) " << G4endl
669 <<
" * zVertex at " << aStep->GetPreStepPoint()->GetPosition().z() << G4endl
670 <<
" * aborting the present event and moving to "<< G4endl;
671 G4cout <<
" *************************************************** "<< G4endl;
688 G4RunManager::GetRunManager()->AbortEvent();
698 time_t Now = time(0);
699 if ( (!DoItNow) && (
LastDoItTime > (Now - 10)) )
return;
702 if (gSystem) gSystem->ProcessEvents();
void BeginOfRunAction(const G4Run *)
Actions to perform in the SciRingntillator anal at the begining of the run.
void SetMinStrideLength(G4double val)
void UserSteppingAction(const G4Step *)
Actions to perform in the scintillator detector analysis after each step.
Double_t GetThetaEntrance() const
void EndOfRunAction(const G4Run *)
Actions to perform in the analysis at the end of the run.
Double_t GetXVertex() const
TClonesArray * theDataCA
ClonesArray of the data objects.
void GeneratePrimaries(const G4Event *, G4double, G4double, G4double, G4double)
void SetNbPrimariesInEvent(Int_t nb)
void GeneratePrimaries(const G4Event *)
Actions to perform in the SciRingntillator anal when generating the primaries.
void SetTimeVertex(Double_t t)
ActarSimROOTAnalysis()
Constructor.
void BeginOfRunAction(const G4Run *)
Actions to perform in the silicon anal at the begining of the run.
ActarSimROOTAnalSciRing * sciRingAnal
Pointer to detector specific (scintillator ring) analysis class.
void BeginOfEventAction(const G4Event *)
Actions to perform in the silicon anal at the begining of the event.
Double_t GetYVertex() const
void SetPhiVertex(Double_t p)
void EndOfRunAction(const G4Run *)
Actions to perform in the analysis at the end of the run.
void ConstructProcess()
Actions to perform in the analysis during the processes construction.
void SetRunID(UInt_t rID)
void SetXVertex(Double_t x)
TH1D * hPrimEnergy
Histogram of primary energy.
G4int theEventID
Particle Event ID.
Double_t GetZVertex() const
ActarSimROOTAnalGas * gasAnal
Pointer to detector specific (gas chamber) analysis class.
void EndOfEventAction(const G4Event *)
void EndOfEventAction(const G4Event *)
Actions to perform in the analysis at the end of the event.
void PostUserTrackingAction(const G4Track *, G4TrackStatus *)
Actions to perform in the analysis after the user tracking.
G4int plaAnalIncludedFlag
Flag to turn on(1)/off(0) the plastic analysis.
void SetTheEventID(G4int id)
void SetEnergyPrim1(Double_t energy)
void ClassifyNewTrack(const G4Track *, G4ClassificationOfNewTrack *)
Actions to perform in the analysis when classifying new tracks.
TFile * simFile
The ROOT file.
Double_t GetXEntrance() const
void SetMinStrideLength(Double_t value)
Setter of the minimum stride length in the gas.
void EndOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the beginning of the run.
void SetEventID(UInt_t eID)
G4int sciAnalIncludedFlag
Flag to turn on(1)/off(0) the scintillator analysis.
void UserSteppingAction(const G4Step *)
Actions to perform in the scintillator detector analysis after each step.
G4int sciRingAnalIncludedFlag
Flag to turn on(1)/off(0) the scintillator ring analysis.
void UserSteppingAction(const G4Step *)
Actions to perform in the analysis after each step.
void SetPhiPrim2(Double_t phi)
ActarSimROOTAnalSilRing * silRingAnal
Pointer to detector specific (silicon ring) analysis class.
G4int silRingAnalIncludedFlag
Flag to turn on(1)/off(0) the silicon ring analysis.
G4int theRunID
Particle Run ID.
void BeginOfRunAction(const G4Run *)
Actions to perform in the scintillator anal at the begining of the run.
void BeginOfEventAction(const G4Event *)
Actions to perform in the analysis at the begining of the event.
void BeginOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the begining of the event.
void BeginOfRunAction(const G4Run *)
Actions to perform in the analysis at the begining of the run.
void BeginOfEventAction(const G4Event *)
Actions to perform in the silicon anal at the begining of the event.
G4String beamInteractionFlag
Flag to turn "on"/"off" the beam interaction analysis.
void SetTheRunID(G4int id)
TClonesArray * primaryInfoCA
ClonesArray of primaries info objects.
void InitAnalysisForExistingDetectors()
TH2F * hRecoilIonKinematic
Histogram with Cine Kinematic results for recoil ions.
void BeginOfEventAction(const G4Event *)
Actions to perform in the analysis at the beginning of the event.
TTree * eventTree
Events tree.
G4String storeHistogramsFlag
Flag to turn "on"/"off" the storage of general histograms.
G4String storeEventsFlag
Flag to turn "on"/"off" the storage fo events.
TH2D * hPrimEnergyVsTheta
Histogram of primary Energy vs Theta angle.
ActarSimPrimaryInfo ** thePrimaryInfo
Primary particles data.
void SetRunID(UInt_t rID)
void Construct(const G4VPhysicalVolume *)
Things to do while contructing...
Double_t GetZEntrance() const
void GeneratePrimaries(const G4Event *)
Actions to perform in the analysis when generating the primaries.
time_t LastDoItTime
Used in OnceAWhileDoIt method for recursivity.
ActarSimROOTAnalSci * sciAnal
Pointer to detector specific (scintillator) analysis class.
G4int gasAnalIncludedFlag
Flag to turn on(1)/off(0) the gas chamber analysis.
void SetCuts()
Actions to perform in the analysis during the cut setting.
void SetVertexPosition(Double_t x, Double_t y, Double_t z)
Sets the position of the vertex (origin of the primary particle)
void PreUserTrackingAction(const G4Track *)
Actions to perform in the analysis before the user tracking.
void GenerateBeam(const G4Event *)
Defining any beam related histogram or information in the output file.
void OnceAWhileDoIt(const G4bool DoItNow=false)
Recursive controller.
Double_t GetEnergyVertex() const
void SetThetaPrim2(Double_t theta)
ActarSimData * theData
Pointer to data object.
void GeneratePrimaries(const G4Event *)
Actions to perform in the scintillator anal when generating the primaries.
TH1D * hPrimTheta
Histogram of primary Theta angle.
void BeginOfRunAction(const G4Run *)
Actions to perform in the analysis at the beginning of the run.
void EndOfEventAction(const G4Event *)
void UserSteppingAction(const G4Step *)
Actions to perform in the ACTAR gas detector analysis after each step.
void SetPhiPrim1(Double_t phi)
ActarSimROOTAnalPla * plaAnal
Pointer to detector specific (plastic) analysis class.
void SetEnergyPrim2(Double_t energy)
TH2F * hScatteredIonKinematic
Histogram with Cine Kinematic results for scattered ions.
void GeneratePrimaries(const G4Event *)
Actions to perform in the silicon anal when generating the primaries.
char * newDirName
Directory name within ROOT file.
ActarSimROOTAnalysis * gActarSimROOTAnalysis
Global pointer to this soliton.
Double_t GetYEntrance() const
G4int silAnalIncludedFlag
Flag to turn on(1)/off(0) the silicon analysis.
void BeginOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the begining of the event.
void SetYVertex(Double_t y)
TClonesArray * beamInfoCA
ClonesArray of the beam info objects.
TH1D * hPrimPhi
Histogram of primary Phi angle.
~ActarSimROOTAnalysis()
Constructor. Save and close Files.
void SetZVertex(Double_t z)
void UserSteppingAction(const G4Step *)
Actions to perform in the ACTAR gas detector analysis after each step.
Double_t GetThetaVertex() const
void GeneratePrimaries(const G4Event *)
Actions to perform in the scintillator anal when generating the primaries.
void SetThetaVertex(Double_t t)
void UserSteppingAction(const G4Step *)
Actions to perform in the scintillator detector analysis after each step.
void GeneratePrimaries(const G4Event *)
Actions to perform in the silicon anal when generating the primaries.
TTree * tracksTree
Tracks tree.
ActarSimBeamInfo * pBeamInfo
Pointer to beam information object.
void SetThetaPrim1(Double_t theta)
ActarSimAnalysisMessenger * analMessenger
Pointer to the corresponding messenger.
Double_t GetEnergyEntrance() const
void EndOfEventAction(const G4Event *)
Actions to perform in the analysis at the end of the event.
void BeginOfRunAction(const G4Run *)
Actions to perform in the scintillator anal at the begining of the run.
ActarSimROOTAnalSil * silAnal
Pointer to detector specific (silicon) analysis class.
void BeginOfRunAction(const G4Run *)
Actions to perform in the silicon anal at the begining of the run.
void EndOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the beginning of the run.
void SetEnergyVertex(Double_t e)
void EndOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the beginning of the run.
void ConstructParticle()
Actions to perform in the analysis during the particle construction.
void UserSteppingAction(const G4Step *)
Actions to perform in the ACTAR gas detector analysis after each step.
void SetEventID(UInt_t eID)