CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/SimMuon/GEMDigitizer/src/GEMDigitizer.cc

Go to the documentation of this file.
00001 #include "SimMuon/GEMDigitizer/src/GEMDigitizer.h"
00002 #include "SimMuon/GEMDigitizer/src/GEMSimFactory.h"
00003 #include "SimMuon/GEMDigitizer/src/GEMSim.h"
00004 #include "SimMuon/GEMDigitizer/src/GEMSimSetUp.h"
00005 
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
00009 
00010 
00011 GEMDigitizer::GEMDigitizer(const edm::ParameterSet& config, CLHEP::HepRandomEngine& eng)
00012 {
00013   modelName_ = config.getParameter<std::string>("digiModel");
00014   gemSim_ = GEMSimFactory::get()->create(modelName_, config.getParameter<edm::ParameterSet>("digiModelConfig"));
00015   gemSim_->setRandomEngine(eng);
00016 }
00017 
00018 
00019 GEMDigitizer::~GEMDigitizer()
00020 {
00021   if(gemSim_) delete gemSim_;
00022 }
00023 
00024 
00025 void GEMDigitizer::digitize(MixCollection<PSimHit> & simHits, 
00026                             GEMDigiCollection & digis,
00027                             StripDigiSimLinks & digiSimLinks)
00028 {
00029   gemSim_->setGEMSimSetUp(simSetUp_);
00030   
00031   // arrange the hits by roll
00032   std::map<int, edm::PSimHitContainer> hitMap;
00033   for(auto &hit: simHits)
00034   {
00035     hitMap[hit.detUnitId()].push_back(hit);
00036   }
00037 
00038   if ( ! geometry_)
00039   {
00040     throw cms::Exception("Configuration")
00041       << "GEMDigitizer::digitize() - No GEMGeometry present in the configuration file."
00042       << "Add the service in the configuration file or remove the modules that require it.";
00043   }
00044 
00045   auto etaPartitions = geometry_->etaPartitions() ;
00046   for(auto &p: etaPartitions)
00047   {
00048     const auto & partSimHits = hitMap[p->id()];
00049 
00050     //LogDebug("GEMDigitizer") << "GEMDigitizer: found " << partSimHits.size() <<" hit(s) in the eta partition";
00051     
00052     gemSim_->simulate(p, partSimHits);
00053     gemSim_->simulateNoise(p);
00054     gemSim_->fillDigis(p->id(), digis);
00055     digiSimLinks.insert(gemSim_->stripDigiSimLinks());
00056   }
00057 }
00058 
00059 
00060 const GEMEtaPartition * GEMDigitizer::findDet(int detId) const
00061 {
00062   assert(geometry_ != 0);
00063   return dynamic_cast<const GEMEtaPartition *>(geometry_->idToDetUnit(GEMDetId(detId)));
00064 }
00065