CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/SimG4Core/Geometry/src/DDG4SensitiveConverter.cc

Go to the documentation of this file.
00001 #include "SimG4Core/Geometry/interface/DDG4SensitiveConverter.h"
00002 #include "SimG4Core/Notification/interface/SimG4Exception.h"
00003 
00004 #include "SimG4Core/Notification/interface/SimG4Exception.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include "G4LogicalVolume.hh"
00008 
00009 using std::string;
00010 using std::vector;
00011 using std::cout;
00012 using std::endl;
00013 
00014 DDG4SensitiveConverter::DDG4SensitiveConverter() {}
00015 
00016 DDG4SensitiveConverter::~DDG4SensitiveConverter() {}
00017 
00018 SensitiveDetectorCatalog DDG4SensitiveConverter::upDate(const DDG4DispContainer & ddg4s) {
00019 
00020   LogDebug("SimG4CoreGeometry") <<" DDG4SensitiveConverter::upDate() starts" ;
00021   SensitiveDetectorCatalog catalog;
00022 
00023   for (unsigned int i=0; i<ddg4s.size(); i++)  {
00024     DDG4Dispatchable * ddg4 = ddg4s[i];
00025     const DDLogicalPart * part   = (ddg4->getDDLogicalPart());
00026     G4LogicalVolume *     result = (ddg4->getG4LogicalVolume());
00027   
00028     std::string sClassName = getString("SensitiveDetector",part);
00029     std::string sROUName   = getString("ReadOutName",part);
00030     std::string fff        = result->GetName();
00031     if (sClassName != "NotFound") {
00032       LogDebug("SimG4CoreGeometry") << " DDG4SensitiveConverter: Sensitive " << fff
00033                                     << " Class Name " << sClassName << " ROU Name " << sROUName ;           
00034       fff = result->GetName();
00035       catalog.insert(sClassName,sROUName,fff);
00036     }
00037   }
00038   return catalog;
00039 }
00040 
00041 std::string DDG4SensitiveConverter::getString(const std::string & s, 
00042                                               const DDLogicalPart * part) {
00043   std::vector<std::string> temp;
00044   DDValue val(s);
00045   std::vector<const DDsvalues_type *> result = part->specifics();
00046   std::vector<const DDsvalues_type *>::iterator it = result.begin();
00047   bool foundIt = false;
00048   for (; it != result.end(); ++it) {
00049     foundIt = DDfetch(*it,val);
00050     if (foundIt) break;
00051   }    
00052   if (foundIt) { 
00053     temp = val.strings(); 
00054     if (temp.size() != 1) {
00055       edm::LogError("SimG4CoreGeometry") << "DDG4SensitiveConverter - ERROR: I need 1 " << s << " tags" ;
00056       throw SimG4Exception("DDG4SensitiveConverter: Problem with Region tags: one and only one is allowed");
00057     }
00058     return temp[0]; 
00059   }
00060   return "NotFound";
00061 }
00062