CMS 3D CMS Logo

GEMDigiProducer.cc
Go to the documentation of this file.
1 #ifndef SimMuon_GEMDigitizer_GEMDigiProducer_h
2 #define SimMuon_GEMDigitizer_GEMDigiProducer_h
3 
5 
26 
29 
30 #include <sstream>
31 #include <string>
32 #include <map>
33 #include <vector>
34 
35 namespace CLHEP {
36  class HepRandomEngine;
37 }
38 
40 public:
42 
44 
45  explicit GEMDigiProducer(const edm::ParameterSet& ps);
46 
47  ~GEMDigiProducer() override;
48 
49  void beginRun(const edm::Run&, const edm::EventSetup&) override;
50 
51  void produce(edm::Event&, const edm::EventSetup&) override;
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
56  //Name of Collection used for create the XF
59 
61 
62  std::unique_ptr<GEMDigiModule> gemDigiModule_;
63 };
64 
65 GEMDigiProducer::GEMDigiProducer(const edm::ParameterSet& ps) : gemDigiModule_(std::make_unique<GEMDigiModule>(ps)) {
66  produces<GEMDigiCollection>();
67  produces<StripDigiSimLinks>("GEM");
68  produces<GEMDigiSimLinks>("GEM");
69 
71  if (!rng.isAvailable()) {
72  throw cms::Exception("Configuration")
73  << "GEMDigiProducer::GEMDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
74  << "Add the service in the configuration file or remove the modules that require it.";
75  }
76 
77  std::string mix_(ps.getParameter<std::string>("mixLabel"));
78  std::string collection_(ps.getParameter<std::string>("inputCollection"));
79 
80  cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_));
81  geom_token_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
82 }
83 
85 
88  desc.add<std::string>("inputCollection", "g4SimHitsMuonGEMHits");
89  desc.add<std::string>("mixLabel", "mix");
90 
91  desc.add<double>("signalPropagationSpeed", 0.66);
92  desc.add<double>("timeResolution", 5.);
93  desc.add<double>("timeJitter", 1.0);
94  desc.add<double>("averageShapingTime", 50.0);
95  desc.add<double>("averageEfficiency", 0.98);
96  desc.add<double>("averageNoiseRate", 0.001);
97  // intrinsic noise rate (Hz/cm^2)
98 
99  // in terms of 25 ns
100  desc.add<int>("minBunch", -5);
101  desc.add<int>("maxBunch", 3);
102 
103  desc.add<bool>("fixedRollRadius", true);
104  // Uses fixed radius in the center of the roll
105  desc.add<bool>("digitizeOnlyMuons", false);
106  desc.add<bool>("simulateBkgNoise", false);
107  // false == No background simulation
108  desc.add<bool>("simulateNoiseCLS", true);
109  desc.add<bool>("simulateElectronBkg", true);
110  // flase == simulate only neutral bkg
111  desc.add<bool>("simulateIntrinsicNoise", false);
112 
113  desc.add<double>("instLumi", 7.5);
114  // in units of 1E34 cm^-2 s^-1. Internally the background is parmetrized from FLUKA+GEANT result at 5E+34 (PU 140). We are adding a 1.5 factor for PU 200
115  desc.add<double>("rateFact", 1.0);
116  // We are adding also a safety factor of 2 to tak into account the new beam pipe effect (not yet known). Hits can be thrown away later at re-digi step. Parameters are kept in sync with the ones used in the GEM digitizer
117  desc.add<double>("bxWidth", 25E-9);
118  desc.add<double>("referenceInstLumi", 5.);
119  // referecne inst. luminosity 5E+34 cm^-2s^-1
120  desc.add<double>("resolutionX", 0.03);
121 
122  // The follwing parameters are needed to model the background contribution
123  // The parameters have been obtained after the fit of th perdicted by FLUKA
124  // By default the backgroundmodeling with these parameters should be disabled with
125  // the 9_2_X release setting simulateBkgNoise = false
126  desc.add<double>("GE11ModNeuBkgParam0", 5710.23);
127  desc.add<double>("GE11ModNeuBkgParam1", -43.3928);
128  desc.add<double>("GE11ModNeuBkgParam2", 0.0863681);
129  desc.add<double>("GE21ModNeuBkgParam0", 1440.44);
130  desc.add<double>("GE21ModNeuBkgParam1", -7.48607);
131  desc.add<double>("GE21ModNeuBkgParam2", 0.0103078);
132  desc.add<double>("GE11ElecBkgParam0", 406.249);
133  desc.add<double>("GE11ElecBkgParam1", -2.90939);
134  desc.add<double>("GE11ElecBkgParam2", 0.00548191);
135  desc.add<double>("GE21ElecBkgParam0", 97.0505);
136  desc.add<double>("GE21ElecBkgParam1", -43.3928);
137  desc.add<double>("GE21ElecBkgParam2", 00.000550599);
138 
139  descriptions.add("simMuonGEMDigisDef", desc);
140 }
141 
142 void GEMDigiProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup) {
144  gemDigiModule_->setGeometry(&*hGeom);
145  geometry_ = &*hGeom;
146 }
147 
150  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
151 
153  e.getByToken(cf_token, cf);
154 
156 
157  // Create empty output
158  auto digis = std::make_unique<GEMDigiCollection>();
159  auto stripDigiSimLinks = std::make_unique<StripDigiSimLinks>();
160  auto gemDigiSimLinks = std::make_unique<GEMDigiSimLinks>();
161 
162  // arrange the hits by eta partition
163  std::map<uint32_t, edm::PSimHitContainer> hitMap;
164  for (const auto& hit : hits) {
165  hitMap[GEMDetId(hit.detUnitId()).rawId()].emplace_back(hit);
166  }
167 
168  // simulate signal and noise for each eta partition
169  const auto& etaPartitions(geometry_->etaPartitions());
170 
171  for (const auto& roll : etaPartitions) {
172  const GEMDetId detId(roll->id());
173  const uint32_t rawId(detId.rawId());
174  const auto& simHits(hitMap[rawId]);
175 
176  LogDebug("GEMDigiProducer") << "GEMDigiProducer: found " << simHits.size() << " hit(s) in eta partition" << rawId;
177 
178  gemDigiModule_->simulate(roll, simHits, engine);
179  gemDigiModule_->fillDigis(rawId, *digis);
180  (*stripDigiSimLinks).insert(gemDigiModule_->stripDigiSimLinks());
181  (*gemDigiSimLinks).insert(gemDigiModule_->gemDigiSimLinks());
182  }
183 
184  // store them in the event
185  e.put(std::move(digis));
186  e.put(std::move(stripDigiSimLinks), "GEM");
187  e.put(std::move(gemDigiSimLinks), "GEM");
188 }
189 
191 #endif
GEMDigiProducer::~GEMDigiProducer
~GEMDigiProducer() override
edm::DetSetVector
Definition: DetSetVector.h:61
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
GEMDigiProducer::geom_token_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geom_token_
Definition: GEMDigiProducer.cc:58
Handle.h
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
GEMDigiProducer::GEMDigiSimLinks
edm::DetSetVector< GEMDigiSimLink > GEMDigiSimLinks
Definition: GEMDigiProducer.cc:43
GEMDigiProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GEMDigiProducer.cc:148
EDProducer.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
edm::Run
Definition: Run.h:45
GEMDigiProducer::gemDigiModule_
std::unique_ptr< GEMDigiModule > gemDigiModule_
Definition: GEMDigiProducer.cc:62
edm::EDGetTokenT
Definition: EDGetToken.h:33
GEMDigiProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMDigiProducer.cc:86
RandomNumberGenerator.h
GEMDigiProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: GEMDigiProducer.cc:142
CrossingFrame.h
GEMDigiModule.h
PSimHitContainer.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
ESGetToken.h
GEMDigiProducer::geometry_
const GEMGeometry * geometry_
Definition: GEMDigiProducer.cc:60
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
MixCollection.h
MixCollection
Definition: MixCollection.h:11
Service.h
edm::ESHandle< GEMGeometry >
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
CLHEP
Definition: CocoaGlobals.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEMDigiProducer
Definition: GEMDigiProducer.cc:39
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
GEMDetId
Definition: GEMDetId.h:18
edm::Service< edm::RandomNumberGenerator >
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::stream::EDProducer
Definition: EDProducer.h:38
GEMDigiProducer::GEMDigiProducer
GEMDigiProducer(const edm::ParameterSet &ps)
Definition: GEMDigiProducer.cc:65
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
GEMDigiProducer::StripDigiSimLinks
edm::DetSetVector< StripDigiSimLink > StripDigiSimLinks
Definition: GEMDigiProducer.cc:41
GEMDigiModule
Definition: GEMDigiModule.h:35
edm::ESGetToken< GEMGeometry, MuonGeometryRecord >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GEMGeometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:246
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
GEMGeometry::etaPartitions
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40
GEMDigiProducer::cf_token
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
Definition: GEMDigiProducer.cc:57
GEMGeometry
Definition: GEMGeometry.h:24
ConsumesCollector.h
ParameterSet.h
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37