Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file eventgenerator/HepMC/HepMCEx01/src/E 27 /// \brief Implementation of the ExN04Stacking 28 // 29 // 30 31 #include "ExN04StackingAction.hh" 32 33 #include "ExN04StackingActionMessenger.hh" 34 35 #include "G4Event.hh" 36 #include "G4HCofThisEvent.hh" 37 #include "G4ParticleDefinition.hh" 38 #include "G4ParticleTypes.hh" 39 #include "G4RunManager.hh" 40 #include "G4SDManager.hh" 41 #include "G4SystemOfUnits.hh" 42 #include "G4Track.hh" 43 #include "G4TrackStatus.hh" 44 45 //....oooOO0OOooo........oooOO0OOooo........oo 46 ExN04StackingAction::ExN04StackingAction() 47 : G4UserStackingAction(), fTrkHits(0), fMuon 48 { 49 fAngRoI = 30.0 * deg; 50 fReqMuon = 2; 51 fReqIso = 10; 52 fMessenger = new ExN04StackingActionMessenge 53 } 54 55 //....oooOO0OOooo........oooOO0OOooo........oo 56 ExN04StackingAction::~ExN04StackingAction() 57 { 58 delete fMessenger; 59 } 60 61 //....oooOO0OOooo........oooOO0OOooo........oo 62 G4ClassificationOfNewTrack ExN04StackingAction 63 { 64 G4ClassificationOfNewTrack classification = 65 switch (fStage) { 66 case 0: // Stage 0 : Primary muons only 67 if (aTrack->GetParentID() == 0) { 68 G4ParticleDefinition* particleType = a 69 if ((particleType == G4MuonPlus::MuonP 70 || (particleType == G4MuonMinus::M 71 { 72 classification = fUrgent; 73 } 74 } 75 break; 76 77 case 1: // Stage 1 : Charged primaries on 78 // Suspended tracks wil 79 if (aTrack->GetParentID() != 0) { 80 break; 81 } 82 if (aTrack->GetTrackStatus() == fSuspend 83 break; 84 } 85 if (aTrack->GetDefinition()->GetPDGCharg 86 break; 87 } 88 classification = fUrgent; 89 break; 90 91 default: // Stage 2 : Accept all primarie 92 // Accept all secondar 93 // Kill secondaries ou 94 if (aTrack->GetParentID() == 0) { 95 classification = fUrgent; 96 break; 97 } 98 if ((fAngRoI < 0.) || InsideRoI(aTrack, 99 classification = fUrgent; 100 break; 101 } 102 classification = fKill; 103 } 104 return classification; 105 } 106 107 //....oooOO0OOooo........oooOO0OOooo........oo 108 G4bool ExN04StackingAction::InsideRoI(const G4 109 { 110 if (!fMuonHits) { 111 fMuonHits = (ExN04MuonHitsCollection*)GetC 112 } 113 if (!fMuonHits) { 114 G4cerr << "muonCollection NOT FOUND" << G4 115 return true; 116 } 117 118 G4int nhits = fMuonHits->entries(); 119 120 const G4ThreeVector trPos = aTrack->GetPosit 121 for (G4int i = 0; i < nhits; i++) { 122 G4ThreeVector muHitPos = (*fMuonHits)[i]-> 123 G4double angl = muHitPos.angle(trPos); 124 if (angl < ang) { 125 return true; 126 } 127 } 128 129 return false; 130 } 131 132 //....oooOO0OOooo........oooOO0OOooo........oo 133 G4VHitsCollection* ExN04StackingAction::GetCol 134 { 135 G4SDManager* SDMan = G4SDManager::GetSDMpoin 136 G4RunManager* runMan = G4RunManager::GetRunM 137 int colID = SDMan->GetCollectionID(colName); 138 if (colID >= 0) { 139 const G4Event* currentEvent = runMan->GetC 140 G4HCofThisEvent* HCE = currentEvent->GetHC 141 return HCE->GetHC(colID); 142 } 143 return 0; 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oo 147 void ExN04StackingAction::NewStage() 148 { 149 fStage++; 150 G4int nhits; 151 if (fStage == 1) { 152 // Stage 0->1 : check if at least "fReqMuo 153 // otherwise abort current ev 154 if (!fMuonHits) { 155 fMuonHits = (ExN04MuonHitsCollection*)Ge 156 } 157 if (!fMuonHits) { 158 G4cerr << "muonCollection NOT FOUND" << 159 return; 160 } 161 nhits = fMuonHits->entries(); 162 G4cout << "Stage 0->1 : " << nhits << " hi 163 if (nhits < fReqMuon) { 164 stackManager->clear(); 165 G4cout << "++++++++ event aborted" << G4 166 return; 167 } 168 stackManager->ReClassify(); 169 return; 170 } 171 172 else if (fStage == 2) { 173 // Stage 1->2 : check the isolation of muo 174 // at least "fReqIsoMuon" iso 175 // otherwise abort current ev 176 // Isolation requires "fReqIs 177 // (including own hits) in th 178 // in the tracker layers. 179 nhits = fMuonHits->entries(); 180 if (!fTrkHits) { 181 fTrkHits = (ExN04TrackerHitsCollection*) 182 } 183 if (!fTrkHits) { 184 G4cerr << "trackerCollection NOT FOUND" 185 return; 186 } 187 G4int nTrkhits = fTrkHits->entries(); 188 G4int isoMuon = 0; 189 for (G4int j = 0; j < nhits; j++) { 190 G4ThreeVector hitPos = (*fMuonHits)[j]-> 191 G4int nhitIn = 0; 192 for (G4int jj = 0; (jj < nTrkhits) && (n 193 G4ThreeVector trkhitPos = (*fTrkHits)[ 194 if (trkhitPos.angle(hitPos) < fAngRoI) 195 } 196 if (nhitIn <= fReqIso) isoMuon++; 197 } 198 G4cout << "Stage 1->2 : " << isoMuon << " 199 if (isoMuon < fReqIsoMuon) { 200 stackManager->clear(); 201 G4cout << "++++++++ event aborted" << G4 202 return; 203 } 204 stackManager->ReClassify(); 205 return; 206 } 207 208 else { 209 // Other fStage change : just re-classify 210 stackManager->ReClassify(); 211 } 212 } 213 214 //....oooOO0OOooo........oooOO0OOooo........oo 215 void ExN04StackingAction::PrepareNewEvent() 216 { 217 fStage = 0; 218 fTrkHits = 0; 219 fMuonHits = 0; 220 } 221