Changeset 268 in Idarraga
- Timestamp:
- Mar 8, 2012, 3:10:30 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
allpix/src/AllPixTrackerSD.cc
r87 r268 75 75 76 76 /* 77 * Second constructor for sensitive devices w ich are77 * Second constructor for sensitive devices which are 78 78 * not actual pixel detectors 79 79 */ 80 AllPixTrackerSD::AllPixTrackerSD(G4String name, 81 G4ThreeVector absPos, 82 G4RotationMatrix * rot) 80 AllPixTrackerSD::AllPixTrackerSD(G4String name, G4ThreeVector absPos, G4RotationMatrix * rot) 83 81 :G4VSensitiveDetector(name) 84 82 { … … 103 101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 104 102 103 /** 104 * Runs once per event. The hitsCollections pointers are retrieved 105 * I have a set of pointers to control that I get them right 106 */ 105 107 void AllPixTrackerSD::Initialize(G4HCofThisEvent* HCE) 106 108 { 107 109 110 // Create the hit collection 108 111 hitsCollection = new AllPixTrackerHitsCollection 109 112 (SensitiveDetectorName, collectionName[0]); 110 113 111 //G4cout << "TrackerSD : " << SensitiveDetectorName << " " << collectionName[0] << G4endl;112 113 114 static G4int HCID = -1; 114 115 HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); 115 116 117 // Add to hits collection of this event 116 118 HCE->AddHitsCollection( HCID, hitsCollection ); 117 119 120 // Insert the pointer in a set to check its existence later 121 // Normally there is only one instance of AllPixTrackerSD per sensitive volume 122 m_hitsCollectionSet.insert(hitsCollection); 123 118 124 } 119 125 … … 124 130 { 125 131 132 // Check first if we are working in a valid HitCollection 133 try { 134 if( m_hitsCollectionSet.find(hitsCollection) == m_hitsCollectionSet.end()) // not found ! 135 throw hitsCollection; 136 } catch (AllPixTrackerHitsCollection * h) { 137 G4cout << "[WARNING] The following pointer to hitsCollection is invalid : " << h << G4endl; 138 G4cout << " The available set contains " << m_hitsCollectionSet.size() << " collections." << G4endl; 139 G4cout << " Trying to recover by ignoring this hit where this hitCollection" << G4endl; 140 G4cout << " has been given. AllPixTrackerSD::ProcessHits returns false." << G4endl; 141 return false; 142 } 143 144 // Work with the Hit 126 145 G4double edep = aStep->GetTotalEnergyDeposit(); 127 146 if(edep==0.) return false; … … 139 158 G4ThreeVector correctedPos(0,0,0); 140 159 141 if (m_thisIsAPixelDetector){160 if (m_thisIsAPixelDetector) { 142 161 // This positions are global, I will bring them to pixel-centered frame 143 162 // I can use the physical volumes for that … … 174 193 copyIDx_pre = touchablepre->GetCopyNumber(1); 175 194 } 195 176 196 // Look at the touchablepost only if in the same volume, i.e. in the sensitive Si Box 177 197 // If the hit is in a different pixel, it is still the same phys volume … … 222 242 newHit->SetParentVolumeName(aTrack->GetLogicalVolumeAtVertex()->GetName()); 223 243 244 //G4cout << "hitsCollection : " << hitsCollection << G4endl; 245 //G4cout << " entries --> " << hitsCollection->entries() << G4endl; 224 246 hitsCollection->insert(newHit); 225 226 247 //newHit->Print(); 227 248 //newHit->Draw(); … … 238 259 if(NbHits > 0) 239 260 G4cout << "--------> Hits Collection : " << collectionName[0] << " has " << NbHits << " hits " << G4endl; 261 262 // clear the Set of pointers to hitCollection used for verification 263 m_hitsCollectionSet.clear(); 240 264 241 265 }
Note: See TracChangeset
for help on using the changeset viewer.