CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/SimG4Core/SensitiveDetector/src/AttachSD.cc

Go to the documentation of this file.
00001 //#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorFactoryByName.h"
00002 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h"
00003 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetector.h"
00004 #include "SimG4Core/SensitiveDetector/interface/AttachSD.h"
00005 #include <string>
00006 #include <vector>
00007 
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 
00010 using std::vector;
00011 using std::string;
00012 using std::cout;
00013 using std::endl;
00014 
00015 // #define DEBUG
00016 
00017 AttachSD::AttachSD() {}
00018 
00019 AttachSD::~AttachSD() {}
00020 
00021 std::pair< std::vector<SensitiveTkDetector*>,
00022            std::vector<SensitiveCaloDetector*> > 
00023 AttachSD::create(const DDDWorld & w, 
00024                  const DDCompactView & cpv,
00025                  SensitiveDetectorCatalog & clg,
00026                  edm::ParameterSet const & p,
00027                  const SimTrackManager* m,
00028                  SimActivityRegistry& reg) const
00029 {
00030   std::pair< std::vector<SensitiveTkDetector *>,
00031     std::vector<SensitiveCaloDetector*> > detList;
00032 //#ifdef DEBUG
00033   //cout << " Initializing AttachSD " << endl;
00034   LogDebug("SimG4CoreSensitiveDetector") << " AttachSD: Initializing" ;
00035 //#endif
00036   std::vector<std::string> rouNames = clg.readoutNames();
00037   for (std::vector<std::string>::iterator it = rouNames.begin();
00038        it != rouNames.end(); it++) {
00039     std::string className = clg.className(*it);
00040     //std::cout<<" trying to find something for "<<className<<" " <<*it<<std::endl;
00041     edm::LogInfo("SimG4CoreSensitiveDetector") << " AttachSD: trying to find something for " << className << " "  << *it ;
00042     std::auto_ptr<SensitiveDetectorMakerBase> temp(
00043                                                    SensitiveDetectorPluginFactory::get()->create(className) );
00044     std::auto_ptr<SensitiveTkDetector> tkDet;
00045     std::auto_ptr<SensitiveCaloDetector> caloDet;
00046     temp->make(*it,cpv,clg,p,m,reg,tkDet,caloDet);
00047     if(tkDet.get()){
00048       detList.first.push_back(tkDet.get());
00049       tkDet.release();
00050     }
00051     if(caloDet.get()){
00052       detList.second.push_back(caloDet.get());
00053       caloDet.release();
00054     }
00055 //#ifdef DEBUG
00056     // cout << " AttachSD: created a " << className << " with name " << *it << endl;
00057     LogDebug("SimG4CoreSensitiveDetector") << " AttachSD: created a " << className << " with name " << *it ;
00058     //#endif
00059   }      
00060   return detList;
00061 }
00062