19 #include "G4RunManager.hh" 20 #include "G4SDManager.hh" 24 #include "G4ClassificationOfNewTrack.hh" 25 #include "G4TrackStatus.hh" 41 #include "TClonesArray.h" 57 sciHitCA =
new TClonesArray(
"ActarSimSciHit",2);
82 sprintf(newDirName,
"%s%i",
"Histos",aRun->GetRunID());
117 G4int hitsCollectionID =
118 G4SDManager::GetSDMpointer()->GetCollectionID(
"SciCollection");
120 G4HCofThisEvent* HCofEvent = anEvent->GetHCofThisEvent();
126 G4int NbHits = hitsCollection->entries();
127 G4int NbHitsWithSomeEnergy = NbHits;
132 for (G4int i=0;i<NbHits;i++)
133 if((*hitsCollection)[i]->GetEdep()==0.)
134 NbHitsWithSomeEnergy--;
137 G4int NbCrystalsWithHit=NbHitsWithSomeEnergy;
138 G4String* nameWithSomeEnergy;
139 G4int* detIDWithSomeEnergy;
140 detIDWithSomeEnergy =
new G4int[NbHitsWithSomeEnergy];
141 nameWithSomeEnergy =
new G4String[NbHitsWithSomeEnergy];
144 G4int hitsWithEnergyCounter=0;
145 for (G4int i=0;i<NbHits;i++) {
146 if((*hitsCollection)[i]->GetEdep()>0.){
147 nameWithSomeEnergy[hitsWithEnergyCounter] = (*hitsCollection)[i]->GetDetName();
148 detIDWithSomeEnergy[hitsWithEnergyCounter] = (*hitsCollection)[i]->GetDetID();
151 hitsWithEnergyCounter++;
162 for (G4int i=0;i<NbHitsWithSomeEnergy;i++) {
163 for(G4int j=0;j<i;j++){
164 if(nameWithSomeEnergy[i] == nameWithSomeEnergy[j] && detIDWithSomeEnergy[i] == detIDWithSomeEnergy[j]){
172 G4String* nameWithHit;
174 detIDWithHit =
new G4int[NbCrystalsWithHit];
175 nameWithHit =
new G4String[NbCrystalsWithHit];
176 hitsWithEnergyCounter=0;
180 for (G4int i=0;i<NbHits;i++) {
181 if ((*hitsCollection)[i]->GetEdep()>0.) {
183 nameWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetName();
184 detIDWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetID();
190 for (G4int j=0;j<hitsCounter;j++) {
191 if ( (*hitsCollection)[i]->GetDetName() == nameWithHit[j] &&
192 (*hitsCollection)[i]->GetDetID() == detIDWithHit[j] ) {
195 if(j==hitsCounter-1){
196 nameWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetName();
197 detIDWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetID();
216 for (G4int i=0;i<NbCrystalsWithHit;i++)
232 detID =
new G4int[NbCrystalsWithHit];
233 name =
new G4String[NbCrystalsWithHit];
235 G4bool shouldThisBeStored = 0;
237 for (G4int i=0;i<NbHits;i++) {
240 shouldThisBeStored=0;
244 for (G4int j=0;j<NbCrystalsWithHit;j++) {
245 if( (*hitsCollection)[i]->GetDetName() == nameWithHit[j] &&
246 (*hitsCollection)[i]->GetDetID() == detIDWithHit[j] ) {
247 shouldThisBeStored=1;
251 if(!shouldThisBeStored)
continue;
253 name[hitsCounter] = (*hitsCollection)[i]->GetDetName();
254 detID[hitsCounter] = (*hitsCollection)[i]->GetDetID();
262 for (G4int j=0;j<hitsCounter;j++) {
263 if( (*hitsCollection)[i]->GetDetName() == name[j] &&
264 (*hitsCollection)[i]->GetDetID() == detID[j] ){
273 name[hitsCounter] = (*hitsCollection)[i]->GetDetName();
274 detID[hitsCounter] = (*hitsCollection)[i]->GetDetID();
290 for (G4int i=0;i<NbCrystalsWithHit;i++)
305 delete [] detIDWithSomeEnergy;
306 delete [] nameWithSomeEnergy;
307 delete [] detIDWithHit;
308 delete [] nameWithHit;
311 for (G4int i=0;i<NbCrystalsWithHit;i++)
delete theSciHit[i];
329 else G4cout <<
"ERROR in R3BROOTAnalCal::AddCalCrystalHit()." << G4endl
330 <<
"Unknown Detector Name: "<< gHit->
GetDetName() << G4endl << G4endl;
G4double GetParticleCharge()
void SetTheRunID(G4int id)
ActarSimROOTAnalSci()
Constructor.
G4THitsCollection< ActarSimSciGeantHit > ActarSimSciGeantHitsCollection
void SetEnergy(Double_t ed)
~ActarSimROOTAnalSci()
Destructor. Makes nothing.
void EndOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the beginning of the run.
void UserSteppingAction(const G4Step *)
Actions to perform in the scintillator detector analysis after each step.
void SetParticleID(UInt_t pdgID)
void BeginOfRunAction(const G4Run *)
Actions to perform in the scintillator anal at the begining of the run.
TBranch * sciHitsBranch
Local branch for scintillators.
void BeginOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the begining of the event.
void FillingHits(const G4Event *anEvent)
Defining the ActarSimSciHits from the ActarSimSciGeantHits.
void SetTime(Double_t ti)
void SetParticleCharge(Double_t pdgCharge)
void SetParticleMass(Double_t pdgMass)
ActarSimROOTAnalysis * gActarSimROOTAnalysis
Global pointer to this soliton.
TClonesArray * sciHitCA
ClonesArray of the hits in the scintillators.
TTree * eventTree
Local pointer to the event tree.
void GeneratePrimaries(const G4Event *)
Actions to perform in the scintillator anal when generating the primaries.
void SetEventID(UInt_t ev)
void SetRunID(UInt_t run)
ActarSimSciHit ** theSciHit
Pointer to the hits in the scintillators.
void AddCalCrystalHit(ActarSimSciHit *, ActarSimSciGeantHit *, G4int)
G4double GetParticleMass()
TFile * simFile
Local pointer to simFile.
void SetTheEventID(G4int id)