Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:22

0001 #include "SimMuon/RPCDigitizer/src/IRPCDigitizer.h"
0002 #include "SimMuon/RPCDigitizer/src/RPCSimFactory.h"
0003 #include "SimMuon/RPCDigitizer/src/RPCSim.h"
0004 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0005 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "SimMuon/RPCDigitizer/src/RPCSimSetUp.h"
0009 
0010 // default constructor allocates default wire and strip digitizers
0011 
0012 IRPCDigitizer::IRPCDigitizer(const edm::ParameterSet& config)
0013     : theRPCSim{RPCSimFactory::get()->create(config.getParameter<std::string>("digiIRPCModel"),
0014                                              config.getParameter<edm::ParameterSet>("digiIRPCModelConfig"))} {
0015   theNoise = config.getParameter<bool>("doBkgNoise");
0016 }
0017 
0018 IRPCDigitizer::~IRPCDigitizer() = default;
0019 
0020 void IRPCDigitizer::doAction(MixCollection<PSimHit>& simHits,
0021                              RPCDigiCollection& rpcDigis,
0022                              RPCDigiSimLinks& rpcDigiSimLink,
0023                              CLHEP::HepRandomEngine* engine) {
0024   theRPCSim->setRPCSimSetUp(theSimSetUp);
0025 
0026   // arrange the hits by roll
0027   std::map<int, edm::PSimHitContainer> hitMap;
0028   for (MixCollection<PSimHit>::MixItr hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr) {
0029     hitMap[hitItr->detUnitId()].push_back(*hitItr);
0030   }
0031 
0032   if (!theGeometry) {
0033     throw cms::Exception("Configuration")
0034         << "IRPCDigitizer requires the RPCGeometry \n which is not present in the configuration file.  You must add "
0035            "the service\n in the configuration file or remove the modules that require it.";
0036   }
0037 
0038   const std::vector<const RPCRoll*>& rpcRolls = theGeometry->rolls();
0039   for (auto r = rpcRolls.begin(); r != rpcRolls.end(); r++) {
0040     RPCDetId id = (*r)->id();
0041     const edm::PSimHitContainer& rollSimHits = hitMap[id];
0042 
0043     if ((*r)->isIRPC()) {
0044       theRPCSim->simulate(*r, rollSimHits, engine);
0045 
0046       if (theNoise) {
0047         theRPCSim->simulateNoise(*r, engine);
0048       }
0049     }
0050 
0051     theRPCSim->fillDigis((*r)->id(), rpcDigis);
0052     rpcDigiSimLink.insert(theRPCSim->rpcDigiSimLinks());
0053   }
0054 }
0055 
0056 const RPCRoll* IRPCDigitizer::findDet(int detId) const {
0057   assert(theGeometry != nullptr);
0058   const GeomDetUnit* detUnit = theGeometry->idToDetUnit(RPCDetId(detId));
0059   return dynamic_cast<const RPCRoll*>(detUnit);
0060 }