Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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