125 G4GDMLParser
parser(&reader);
127 cet::search_path sp{
"FW_SEARCH_PATH"};
128 std::string fullGDMLFileName;
132 parser.Read(fullGDMLFileName,
false);
133 G4VPhysicalVolume* World =
parser.GetWorldVolume();
135 std::stringstream ss;
136 ss << World->GetTranslation() <<
"\n\n";
137 ss <<
"Found World: " << World->GetName() <<
"\n";
138 ss <<
"World LV: " << World->GetLogicalVolume()->GetName() <<
"\n";
139 G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
140 ss <<
"Found " << pLVStore->size() <<
" logical volumes." 142 G4PhysicalVolumeStore* pPVStore = G4PhysicalVolumeStore::GetInstance();
143 ss <<
"Found " << pPVStore->size() <<
" physical volumes." 145 G4SDManager* SDman = G4SDManager::GetSDMpointer();
146 const G4GDMLAuxMapType* auxmap =
parser.GetAuxMap();
147 ss <<
"Found " << auxmap->size() <<
" volume(s) with auxiliary information." 149 ss <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
150 mf::LogInfo(
"LArG4DetectorService::doBuildLVs") << ss.str();
152 for (
auto const& [volume, auxes] : *auxmap) {
153 G4cout <<
"Volume " << volume->GetName()
154 <<
" has the following list of auxiliary information: \n";
155 for (
auto const& aux : auxes) {
156 G4cout <<
"--> Type: " << aux.type <<
" Value: " << aux.value <<
"\n";
158 G4double
value = atof(aux.value);
159 G4double val_unit = 1;
160 G4String provided_category =
"NONE";
161 if ((aux.unit) && (aux.unit !=
"")) {
162 val_unit = G4UnitDefinition::GetValueOf(aux.unit);
163 provided_category = G4UnitDefinition::GetCategory(aux.unit);
164 mf::LogInfo(
"AuxUnit") <<
" Unit parsed = " << aux.unit
165 <<
" from unit category: " << provided_category.c_str();
170 if (aux.type ==
"StepLimit") {
171 G4UserLimits* fStepLimit =
new G4UserLimits();
172 G4AutoDelete::Register(fStepLimit);
175 G4String steplimit_category =
"Length";
176 if (provided_category == steplimit_category) {
177 mf::LogInfo(
"AuxUnit") <<
"Valid StepLimit unit category obtained: " 178 << provided_category.c_str();
180 value = (value / CLHEP::mm) * CLHEP::mm;
181 fStepLimit->SetMaxAllowedStep(value);
183 <<
"fStepLimit: " << value <<
" " << value / CLHEP::cm <<
" cm\n";
185 else if (provided_category ==
187 MF_LOG_WARNING(
"StepLimitUnit") <<
"StepLimit in geometry file does not have a unit!" 188 <<
" Defaulting to mm...";
190 fStepLimit->SetMaxAllowedStep(value);
192 <<
"fStepLimit: " << value <<
" " << value / CLHEP::cm <<
" cm\n";
196 <<
"StepLimit does not have a valid length unit!\n" 197 <<
" Category of unit provided = " << provided_category <<
".\n";
200 volume->SetUserLimits(fStepLimit);
203 <<
"Set stepLimit for volume: " << volume->GetName() <<
" from the GDML file.";
204 setGDMLVolumes_.insert(std::make_pair(volume->GetName(), (float)(value / CLHEP::mm)));
206 if (aux.type ==
"ExcitationEnergy") {
207 G4String ExcitationEnergy_category =
"Energy";
208 if (provided_category == ExcitationEnergy_category) {
209 G4cout <<
"Valid ExcitationEnergy unit category obtained: " << provided_category.c_str()
211 G4cout <<
" unit Value:" << val_unit <<
" Value: " << value << G4endl;
212 G4cout <<
" unit Value:" << val_unit <<
" Value: " << value / CLHEP::eV <<
" eV" 214 volume->GetMaterial()->GetIonisation()->SetMeanExcitationEnergy(value);
215 G4cout <<
" Mean Ionization energy: " 216 << volume->GetMaterial()->GetIonisation()->GetMeanExcitationEnergy() << G4endl;
220 if (aux.type ==
"SensDet") {
221 if (aux.value ==
"DRCalorimeter") {
222 G4String name = volume->GetName() +
"_DRCalorimeter";
223 artg4tk::DRCalorimeterSD* aDRCalorimeterSD =
new artg4tk::DRCalorimeterSD(name);
224 SDman->AddNewDetector(aDRCalorimeterSD);
225 volume->SetSensitiveDetector(aDRCalorimeterSD);
226 std::cout <<
"Attaching sensitive Detector: " << aux.value
227 <<
" to Volume: " << volume->GetName() <<
"\n";
228 detectors_.emplace_back(volume->GetName(), aux.value);
230 else if (aux.value ==
"Calorimeter") {
231 G4String name = volume->GetName() +
"_Calorimeter";
232 artg4tk::CalorimeterSD* aCalorimeterSD =
new artg4tk::CalorimeterSD(name);
233 SDman->AddNewDetector(aCalorimeterSD);
234 volume->SetSensitiveDetector(aCalorimeterSD);
235 std::cout <<
"Attaching sensitive Detector: " << aux.value
236 <<
" to Volume: " << volume->GetName() <<
"\n";
237 detectors_.emplace_back(volume->GetName(), aux.value);
239 else if (aux.value ==
"PhotonDetector") {
240 G4String name = volume->GetName() +
"_PhotonDetector";
241 artg4tk::PhotonSD* aPhotonSD =
new artg4tk::PhotonSD(name);
242 SDman->AddNewDetector(aPhotonSD);
243 volume->SetSensitiveDetector(aPhotonSD);
244 std::cout <<
"Attaching sensitive Detector: " << aux.value
245 <<
" to Volume: " << volume->GetName() <<
"\n";
246 detectors_.emplace_back(volume->GetName(), aux.value);
248 else if (aux.value ==
"Tracker") {
249 G4String name = volume->GetName() +
"_Tracker";
250 artg4tk::TrackerSD* aTrackerSD =
new artg4tk::TrackerSD(name);
251 SDman->AddNewDetector(aTrackerSD);
252 volume->SetSensitiveDetector(aTrackerSD);
253 std::cout <<
"Attaching sensitive Detector: " << aux.value
254 <<
" to Volume: " << volume->GetName() <<
"\n";
255 detectors_.push_back(std::make_pair(volume->GetName(), aux.value));
257 else if (aux.value ==
"SimEnergyDeposit") {
258 G4String name = volume->GetName() +
"_SimEnergyDeposit";
259 SimEnergyDepositSD* aSimEnergyDepositSD =
new SimEnergyDepositSD(name);
260 SDman->AddNewDetector(aSimEnergyDepositSD);
261 volume->SetSensitiveDetector(aSimEnergyDepositSD);
262 std::cout <<
"Attaching sensitive Detector: " << aux.value
263 <<
" to Volume: " << volume->GetName() <<
"\n";
264 detectors_.emplace_back(volume->GetName(), aux.value);
266 else if (aux.value ==
"AuxDet") {
267 G4String name = volume->GetName() +
"_AuxDet";
268 AuxDetSD* aAuxDetSD =
new AuxDetSD(name);
269 SDman->AddNewDetector(aAuxDetSD);
270 volume->SetSensitiveDetector(aAuxDetSD);
271 std::cout <<
"Attaching sensitive Detector: " << aux.value
272 <<
" to Volume: " << volume->GetName() <<
"\n";
273 detectors_.emplace_back(volume->GetName(), aux.value);
275 else if (aux.value ==
"HadInteraction") {
276 G4String name = volume->GetName() +
"_HadInteraction";
277 artg4tk::HadInteractionSD* aHadInteractionSD =
new artg4tk::HadInteractionSD(name);
280 volume->SetSensitiveDetector(aHadInteractionSD);
281 std::cout <<
"Attaching sensitive Detector: " << aux.value
282 <<
" to Volume: " << volume->GetName() <<
"\n";
283 detectors_.emplace_back(volume->GetName(), aux.value);
285 else if (aux.value ==
"HadIntAndEdepTrk") {
286 G4String name = volume->GetName() +
"_HadIntAndEdepTrk";
287 artg4tk::HadIntAndEdepTrkSD* aHadIntAndEdepTrkSD =
new artg4tk::HadIntAndEdepTrkSD(name);
290 volume->SetSensitiveDetector(aHadIntAndEdepTrkSD);
291 std::cout <<
"Attaching sensitive Detector: " << aux.value
292 <<
" to Volume: " << volume->GetName() <<
"\n";
293 detectors_.emplace_back(volume->GetName(), aux.value);
298 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
300 if (
dumpMP_) { G4cout << *(G4Material::GetMaterialTable()) << G4endl; }
302 std::cout <<
"List SD Tree: \n";
304 std::cout <<
" Collection Capacity: " << SDman->GetCollectionCapacity() <<
"\n";
305 G4HCtable* hctable = SDman->GetHCtable();
306 for (G4int j = 0; j < SDman->GetCollectionCapacity(); ++j) {
307 std::cout <<
"HC Name: " << hctable->GetHCname(j) <<
" SD Name: " << hctable->GetSDname(j)
310 std::cout <<
"==================================================\n";
312 std::vector<G4LogicalVolume*> myLVvec;
313 myLVvec.push_back(pLVStore->at(0));
314 std::cout <<
"nr of LV ======================: " << myLVvec.size() <<
"\n";
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< std::pair< std::string, std::string > > detectors_
std::string gdmlFileName_
CommandLineParser * parser(0)
#define MF_LOG_WARNING(category)
std::unordered_map< std::string, float > setGDMLVolumes_
cet::coded_exception< error, detail::translate > exception