Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:23

0001 #include "SimG4Core/Geometry/interface/DDG4SensitiveConverter.h"
0002 #include "SimG4Core/Geometry/interface/SensitiveDetectorCatalog.h"
0003 
0004 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 
0009 #include "G4LogicalVolume.hh"
0010 
0011 DDG4SensitiveConverter::DDG4SensitiveConverter() {}
0012 
0013 DDG4SensitiveConverter::~DDG4SensitiveConverter() {}
0014 
0015 void DDG4SensitiveConverter::upDate(const DDG4DispContainer &ddg4s, SensitiveDetectorCatalog &catalog) {
0016   edm::LogVerbatim("SimG4CoreGeometry") << " DDG4SensitiveConverter::upDate() starts";
0017 
0018   for (auto ddg4 : ddg4s) {
0019     const DDLogicalPart *part = (ddg4->getDDLogicalPart());
0020     G4LogicalVolume *result = (ddg4->getG4LogicalVolume());
0021 
0022     std::string sClassName = getString("SensitiveDetector", part);
0023     std::string sROUName = getString("ReadOutName", part);
0024     std::string fff = result->GetName();
0025     if (sClassName != "NotFound") {
0026       edm::LogVerbatim("SimG4CoreGeometry")
0027           << " DDG4SensitiveConverter: Sensitive " << fff << " Class Name " << sClassName << " ROU Name " << sROUName;
0028       fff = result->GetName();
0029       catalog.insert(sClassName, sROUName, fff);
0030     }
0031   }
0032 }
0033 
0034 std::string DDG4SensitiveConverter::getString(const std::string &ss, const DDLogicalPart *part) {
0035   std::vector<std::string> temp;
0036   DDValue val(ss);
0037   std::vector<const DDsvalues_type *> result = part->specifics();
0038   bool foundIt = false;
0039   for (auto stype : result) {
0040     foundIt = DDfetch(stype, val);
0041     if (foundIt)
0042       break;
0043   }
0044   if (foundIt) {
0045     temp = val.strings();
0046     if (temp.size() != 1) {
0047       edm::LogError("SimG4CoreGeometry") << "DDG4SensitiveConverter - ERROR: I need 1 " << ss << " tags";
0048       throw cms::Exception("SimG4CoreGeometry",
0049                            " DDG4SensitiveConverter::getString Problem with "
0050                            "Region tags - one and only one allowed: " +
0051                                ss);
0052     }
0053     return temp[0];
0054   }
0055   return "NotFound";
0056 }