19 #include "G4RunManager.hh" 20 #include "G4SDManager.hh" 24 #include "G4ClassificationOfNewTrack.hh" 25 #include "G4TrackStatus.hh" 42 #include "TClonesArray.h" 80 sprintf(newDirName,
"%s%i",
"Histos",aRun->GetRunID());
85 sprintf(
dirName,
"%s",
"sciRing");
114 G4int hitsCollectionID =
115 G4SDManager::GetSDMpointer()->GetCollectionID(
"SciRingCollection");
117 G4HCofThisEvent* HCofEvent = anEvent->GetHCofThisEvent();
123 G4int NbHits = hitsCollection->entries();
124 G4int NbHitsWithSomeEnergy = NbHits;
129 for (G4int i=0;i<NbHits;i++)
130 if((*hitsCollection)[i]->GetEdep()==0.)
131 NbHitsWithSomeEnergy--;
134 G4int NbCrystalsWithHit=NbHitsWithSomeEnergy;
135 G4String* nameWithSomeEnergy;
136 G4int* detIDWithSomeEnergy;
137 detIDWithSomeEnergy =
new G4int[NbHitsWithSomeEnergy];
138 nameWithSomeEnergy =
new G4String[NbHitsWithSomeEnergy];
141 G4int hitsWithEnergyCounter=0;
142 for (G4int i=0;i<NbHits;i++) {
143 if((*hitsCollection)[i]->GetEdep()>0.){
144 nameWithSomeEnergy[hitsWithEnergyCounter] = (*hitsCollection)[i]->GetDetName();
145 detIDWithSomeEnergy[hitsWithEnergyCounter] = (*hitsCollection)[i]->GetDetID();
148 hitsWithEnergyCounter++;
159 for (G4int i=0;i<NbHitsWithSomeEnergy;i++) {
160 for(G4int j=0;j<i;j++){
161 if(nameWithSomeEnergy[i] == nameWithSomeEnergy[j] && detIDWithSomeEnergy[i] == detIDWithSomeEnergy[j]){
169 G4String* nameWithHit;
171 detIDWithHit =
new G4int[NbCrystalsWithHit];
172 nameWithHit =
new G4String[NbCrystalsWithHit];
173 hitsWithEnergyCounter=0;
177 for (G4int i=0;i<NbHits;i++) {
178 if ((*hitsCollection)[i]->GetEdep()>0.) {
180 nameWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetName();
181 detIDWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetID();
187 for (G4int j=0;j<hitsCounter;j++) {
188 if ( (*hitsCollection)[i]->GetDetName() == nameWithHit[j] &&
189 (*hitsCollection)[i]->GetDetID() == detIDWithHit[j] ) {
192 if(j==hitsCounter-1){
193 nameWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetName();
194 detIDWithHit[hitsCounter] = (*hitsCollection)[i]->GetDetID();
213 for (G4int i=0;i<NbCrystalsWithHit;i++)
229 detID =
new G4int[NbCrystalsWithHit];
230 name =
new G4String[NbCrystalsWithHit];
232 G4bool shouldThisBeStored = 0;
234 for (G4int i=0;i<NbHits;i++) {
237 shouldThisBeStored=0;
241 for (G4int j=0;j<NbCrystalsWithHit;j++) {
242 if( (*hitsCollection)[i]->GetDetName() == nameWithHit[j] &&
243 (*hitsCollection)[i]->GetDetID() == detIDWithHit[j] ) {
244 shouldThisBeStored=1;
248 if(!shouldThisBeStored)
continue;
250 name[hitsCounter] = (*hitsCollection)[i]->GetDetName();
251 detID[hitsCounter] = (*hitsCollection)[i]->GetDetID();
259 for (G4int j=0;j<hitsCounter;j++) {
260 if( (*hitsCollection)[i]->GetDetName() == name[j] &&
261 (*hitsCollection)[i]->GetDetID() == detID[j] ){
270 name[hitsCounter] = (*hitsCollection)[i]->GetDetName();
271 detID[hitsCounter] = (*hitsCollection)[i]->GetDetID();
287 for (G4int i=0;i<NbCrystalsWithHit;i++)
302 delete [] detIDWithSomeEnergy;
303 delete [] nameWithSomeEnergy;
304 delete [] detIDWithHit;
305 delete [] nameWithHit;
308 for (G4int i=0;i<NbCrystalsWithHit;i++)
delete theSciRingHit[i];
326 else G4cout <<
"ERROR in R3BROOTAnalCal::AddCalCrystalHit()." << G4endl
327 <<
"Unknown Detector Name: "<< gHit->
GetDetName() << G4endl << G4endl;
void BeginOfRunAction(const G4Run *)
Actions to perform in the SciRingntillator anal at the begining of the run.
void UserSteppingAction(const G4Step *)
Actions to perform in the scintillator detector analysis after each step.
void SetTheRunID(G4int id)
void GeneratePrimaries(const G4Event *)
Actions to perform in the SciRingntillator anal when generating the primaries.
void FillingHits(const G4Event *anEvent)
Defining the ActarSimSciHits from the ActarSimSciGeantHits.
ActarSimROOTAnalSciRing()
Constructor.
void SetParticleID(UInt_t pdgID)
void SetTheEventID(G4int id)
G4THitsCollection< ActarSimSciRingGeantHit > ActarSimSciRingGeantHitsCollection
void SetParticleMass(Double_t pdgMass)
void SetEventID(UInt_t ev)
TFile * simFile
Local pointer to simFile.
TBranch * sciRingHitsBranch
Local branch for the scintillator ring hits.
TClonesArray * sciRingHitCA
ClonesArray of the hits in the scintillator ring.
void SetTrackID(UInt_t track)
ActarSimROOTAnalysis * gActarSimROOTAnalysis
Global pointer to this soliton.
void SetParticleCharge(Double_t pdgCharge)
void SetTime(Double_t ti)
void SetEnergy(Double_t ed)
void SetRunID(UInt_t run)
G4double GetParticleMass()
ActarSimSciRingHit ** theSciRingHit
Pointer to the hits in the scintillator ring.
void BeginOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the begining of the event.
void AddCalCrystalHit(ActarSimSciRingHit *, ActarSimSciRingGeantHit *, G4int)
TTree * eventTree
Local pointer to the event tree.
G4double GetParticleCharge()
void EndOfEventAction(const G4Event *)
Actions to perform in the scintillator anal at the beginning of the run.
~ActarSimROOTAnalSciRing()
Destructor. Makes nothing.