Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 ////////////////////////////////////////////// 23 /////////////////////////////////////////////////////////////////////////////// 27 // File: CCalSensAssign.cc 24 // File: CCalSensAssign.cc 28 // Description: CCalSenAssign creates and assi 25 // Description: CCalSenAssign creates and assigns the sensitive detetctors 29 ////////////////////////////////////////////// 26 /////////////////////////////////////////////////////////////////////////////// 30 #include "CCalSensAssign.hh" 27 #include "CCalSensAssign.hh" >> 28 #include "CCalStackingAction.hh" 31 #include "CCalSensitiveDetectors.hh" 29 #include "CCalSensitiveDetectors.hh" 32 #include "CCaloSD.hh" 30 #include "CCaloSD.hh" 33 31 >> 32 #include "G4RunManager.hh" 34 #include "G4SDManager.hh" 33 #include "G4SDManager.hh" 35 34 36 //#define debug 35 //#define debug 37 36 38 G4ThreadLocal CCalSensAssign* CCalSensAssign:: << 37 CCalSensAssign* CCalSensAssign::theInstance = 0; 39 38 40 39 41 CCalSensAssign* CCalSensAssign::getInstance() 40 CCalSensAssign* CCalSensAssign::getInstance() { 42 if ( theInstance == nullptr ) { << 41 if (!theInstance) theInstance = new CCalSensAssign; 43 static G4ThreadLocalSingleton< CCalSensAss << 42 return theInstance; 44 theInstance = inst.Instance(); << 45 } << 46 return theInstance; << 47 } 43 } 48 44 49 45 50 CCalSensAssign::CCalSensAssign() {} 46 CCalSensAssign::CCalSensAssign() {} 51 47 52 48 53 G4bool CCalSensAssign::assign() { << 49 bool CCalSensAssign::assign() { 54 G4bool result = false; << 50 bool result = false; >> 51 55 CCalSensitiveDetectors* sensDets = CCalSensi 52 CCalSensitiveDetectors* sensDets = CCalSensitiveDetectors::getInstance(); 56 for (std::map<G4String,G4VSensitiveDetector* 53 for (std::map<G4String,G4VSensitiveDetector*>::const_iterator sens_it = sens_.begin(); 57 sens_it!=sens_.end(); ++sens_it) { 54 sens_it!=sens_.end(); ++sens_it) { 58 G4String name = sens_it->first; 55 G4String name = sens_it->first; 59 G4VSensitiveDetector* sens = sens_it->seco 56 G4VSensitiveDetector* sens = sens_it->second; 60 if (sensDets->setSensitive(name, sens)) { 57 if (sensDets->setSensitive(name, sens)) { 61 G4SDManager::GetSDMpointer()->AddNewDete 58 G4SDManager::GetSDMpointer()->AddNewDetector(sens); 62 #ifdef debug 59 #ifdef debug 63 G4cout << "Add " << sens->GetName() << " << 60 G4cout << "Add " << sens->GetName() >> 61 << " to the list of Sensitive detetctors" << G4endl; 64 #endif 62 #endif 65 } 63 } 66 } 64 } >> 65 >> 66 return result; >> 67 } >> 68 >> 69 bool CCalSensAssign::stackingAction() { >> 70 >> 71 bool result = false; >> 72 //Create the stacking manager required by Calorimeter >> 73 if (G4RunManager::GetRunManager()->GetUserStackingAction() == 0) { >> 74 G4cout << "***CCalSensAssign creating a CCalStackingAction ***" << G4endl; >> 75 G4RunManager::GetRunManager()->SetUserAction(new CCalStackingAction); >> 76 result = true; >> 77 } else { >> 78 G4cout << "***CCalSens: a StackingAction already exists. " >> 79 << "Maybe not the one CCaloSD needs?" << G4endl; >> 80 } 67 return result; 81 return result; 68 } 82 } 69 83 70 84 71 G4bool CCalSensAssign::addCaloSD( G4String nam << 85 bool CCalSensAssign::addCaloSD(G4String name, 72 sens_[name] = new CCaloSD(name, numberingSch << 86 CCalVOrganization* numberingScheme) { >> 87 sens_[name] = new CCaloSD(name, numberingScheme); 73 return true; 88 return true; >> 89 74 } 90 } 75 91