CMS 3D CMS Logo

RPCDigitizer.cc

Go to the documentation of this file.
00001 #include "Utilities/Timing/interface/TimingReport.h" 
00002 #include "SimMuon/RPCDigitizer/src/RPCDigitizer.h"
00003 #include "SimMuon/RPCDigitizer/src/RPCSimFactory.h"
00004 #include "SimMuon/RPCDigitizer/src/RPCSim.h"
00005 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00006 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00009 #include "SimMuon/RPCDigitizer/src/RPCSimSetUp.h"
00010 
00011 // default constructor allocates default wire and strip digitizers
00012 
00013 RPCDigitizer::RPCDigitizer(const edm::ParameterSet& config) {
00014   theName = config.getParameter<std::string>("digiModel");
00015   theRPCSim = RPCSimFactory::get()->create(theName,config.getParameter<edm::ParameterSet>("digiModelConfig"));
00016 }
00017 
00018 RPCDigitizer::~RPCDigitizer() {
00019   if( theRPCSim )
00020     delete theRPCSim;
00021   theRPCSim = 0;
00022 }
00023 
00024 void RPCDigitizer::doAction(MixCollection<PSimHit> & simHits, 
00025                             RPCDigiCollection & rpcDigis,
00026                             RPCDigiSimLinks & rpcDigiSimLink)
00027 {
00028 
00029   theRPCSim->setRPCSimSetUp(theSimSetUp);
00030 
00031   // arrange the hits by roll
00032   std::map<int, edm::PSimHitContainer> hitMap;
00033   for(MixCollection<PSimHit>::MixItr hitItr = simHits.begin();
00034       hitItr != simHits.end(); ++hitItr) 
00035   {
00036     hitMap[hitItr->detUnitId()].push_back(*hitItr);
00037   }
00038 
00039   // now loop over rolls and run the simulation for each one
00040   for(std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin();
00041       hitMapItr != hitMap.end(); ++hitMapItr)
00042   {
00043     int rollDetId = hitMapItr->first;
00044     const RPCRoll* roll = this->findDet(rollDetId);
00045     const edm::PSimHitContainer & rollSimHits = hitMapItr->second;
00046 
00047     LogDebug("RPCDigitizer") << "RPCDigitizer: found " << rollSimHits.size() <<" hit(s) in the rpc roll";
00048     TimeMe t2("RPCSim");
00049 
00050     theRPCSim->simulate(roll,rollSimHits);
00051     theRPCSim->simulateNoise(roll);
00052     theRPCSim->fillDigis(rollDetId,rpcDigis);
00053     rpcDigiSimLink.insert(theRPCSim->rpcDigiSimLinks());
00054 
00055   }
00056 }
00057 
00058 const RPCRoll * RPCDigitizer::findDet(int detId) const {
00059   assert(theGeometry != 0);
00060   const GeomDetUnit* detUnit = theGeometry->idToDetUnit(RPCDetId(detId));
00061   return dynamic_cast<const RPCRoll *>(detUnit);
00062 }
00063 

Generated on Tue Jun 9 17:47:42 2009 for CMSSW by  doxygen 1.5.4