CMS 3D CMS Logo

PPSPixelDigiProducer.cc
Go to the documentation of this file.
1 #ifndef SimPPS_PPSPixelDigiProducer_PPSPixelDigiProducer_h
2 #define SimPPS_PPSPixelDigiProducer_PPSPixelDigiProducer_h
3 
4 // -*- C++ -*-
5 //
6 // Package: PPSPixelDigiProducer
7 // Class: CTPPSPixelDigiProducer
8 //
16 //
17 // Original Author: F.Ferro
18 //
19 
20 // system include files
21 #include <memory>
22 #include <vector>
23 #include <map>
24 #include <string>
25 
26 // user include files
29 
33 
37 
38 // **** CTPPS
41 
44 
46 
47 // DB
54 
57 // user include files
62 #include <cstdlib> // I need it for random numbers
63 //needed for the geometry:
66 
68 
69 //Random Number
73 #include "CLHEP/Random/RandomEngine.h"
74 
75 namespace CLHEP {
76  class HepRandomEngine;
77 }
78 
80 public:
82  ~CTPPSPixelDigiProducer() override;
83  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
84 
85 private:
86  void produce(edm::Event&, const edm::EventSetup&) override;
87 
88  // ----------member data ---------------------------
89  std::vector<std::string> RPix_hit_containers_;
90  typedef std::map<unsigned int, std::vector<PSimHit>> simhit_map;
91  typedef simhit_map::iterator simhit_map_iterator;
92 
94 
95  std::map<uint32_t, std::unique_ptr<RPixDetDigitizer>> theAlgoMap; //DetId = uint32_t
96 
97  CLHEP::HepRandomEngine* rndEngine_ = nullptr;
99 
103 };
104 
106  : conf_(conf), gainCalibESToken_(esConsumes()), thePixelTopologyToken_(esConsumes()) {
107  produces<edm::DetSetVector<CTPPSPixelDigi>>();
108 
109  // register data to consume
110  tokenCrossingFramePPSPixel = consumes<CrossingFrame<PSimHit>>(edm::InputTag("mix", "g4SimHitsCTPPSPixelHits"));
111 
112  RPix_hit_containers_.clear();
113  RPix_hit_containers_ = conf.getParameter<std::vector<std::string>>("ROUList");
114  verbosity_ = conf.getParameter<int>("RPixVerbosity");
115 }
116 
118 
121  // all distances in [mm]
122  // RPDigiProducer
123  desc.add<std::vector<std::string>>("ROUList", {"CTPPSPixelHits"});
124  desc.add<int>("RPixVerbosity", 0);
125  desc.add<bool>("CTPPSPixelDigiSimHitRelationsPersistence",
126  false); // save links betweend digi, clusters and OSCAR/Geant4 hits
127 
128  // RPDetDigitizer
129  desc.add<double>("RPixEquivalentNoiseCharge", 1000.0);
130  desc.add<bool>("RPixNoNoise", false);
131 
132  // RPDisplacementGenerator
133  desc.add<double>("RPixGeVPerElectron", 3.61e-09);
134  desc.add<std::vector<double>>("RPixInterSmearing", {0.011});
135  desc.add<bool>("RPixLandauFluctuations", true);
136  desc.add<int>("RPixChargeDivisions", 20);
137  desc.add<double>("RPixDeltaProductionCut", 0.120425); // [MeV]
138 
139  // RPixChargeShare
140  desc.add<std::string>("ChargeMapFile2E", "SimPPS/PPSPixelDigiProducer/data/PixelChargeMap.txt");
141  desc.add<std::string>("ChargeMapFile2E_2X", "SimPPS/PPSPixelDigiProducer/data/PixelChargeMap_2X.txt");
142  desc.add<std::string>("ChargeMapFile2E_2Y", "SimPPS/PPSPixelDigiProducer/data/PixelChargeMap_2Y.txt");
143  desc.add<std::string>("ChargeMapFile2E_2X2Y", "SimPPS/PPSPixelDigiProducer/data/PixelChargeMap_2X2Y.txt");
144  desc.add<double>(
145  "RPixCoupling",
146  0.250); // fraction of the remaining charge going to the closer neighbour pixel. Value = 0.135, Value = 0.0 bypass the charge map and the charge sharing approach
147 
148  // RPixDummyROCSimulator
149  desc.add<double>("RPixDummyROCThreshold", 1900.0);
150  desc.add<double>("RPixDummyROCElectronPerADC", 135.0); // 210.0 to be verified
151  desc.add<int>("VCaltoElectronGain", 50); // same values as in RPixDetClusterizer
152  desc.add<int>("VCaltoElectronOffset", -411); //
153  desc.add<bool>("doSingleCalibration", false); //
154  desc.add<double>("RPixDeadPixelProbability", 0.001);
155  desc.add<bool>("RPixDeadPixelSimulationOn", true);
156 
157  desc.add<std::string>("mixLabel", "mix");
158  desc.add<std::string>("InputCollection", "g4SimHitsCTPPSPixelHits");
159  descriptions.add("RPixDetDigitizer", desc);
160 }
161 
162 // member functions
163 //
164 
165 // ------------ method called to produce the data ------------
167  if (!rndEngine_) {
169  if (!rng.isAvailable()) {
170  throw cms::Exception("Configuration")
171  << "This class requires the RandomNumberGeneratorService\n"
172  "which is not present in the configuration file. You must add the service\n"
173  "in the configuration file or remove the modules that require it.";
174  }
175  rndEngine_ = &(rng->getEngine(iEvent.streamID()));
176  }
177 
178  // get calibration DB
179  const auto& gainCalibration = iSetup.getData(gainCalibESToken_);
180  const auto& thePixelTopology = iSetup.getData(thePixelTopologyToken_);
181 
182  // Step A: Get Inputs
184 
185  iEvent.getByToken(tokenCrossingFramePPSPixel, cf);
186 
187  if (verbosity_) {
188  edm::LogInfo("PPS") << "PixelDigiProducer \n\n=================== Starting SimHit access"
189  << " ===================";
190 
191  MixCollection<PSimHit> col{cf.product(), std::pair(-0, 0)};
193  int count = 0;
194  for (cfi = col.begin(); cfi != col.end(); cfi++) {
195  edm::LogInfo("PPS") << "PixelDigiProducer"
196  << " Hit " << count << " has tof " << cfi->timeOfFlight() << " trackid " << cfi->trackId()
197  << " bunchcr " << cfi.bunch() << " trigger " << cfi.getTrigger()
198  << ", from EncodedEventId: " << cfi->eventId().bunchCrossing() << " "
199  << cfi->eventId().event() << " bcr from MixCol " << cfi.bunch();
200  edm::LogInfo("PPS") << " PixelDigiProducer Hit: " << (*cfi) << " " << cfi->exitPoint();
201  count++;
202  }
203  }
204 
205  MixCollection<PSimHit> allRPixHits{cf.product(), std::pair(0, 0)};
206 
207  if (verbosity_)
208  edm::LogInfo("PPS") << "PixelDigiProducer Input MixCollection size = " << allRPixHits.size();
209 
210  //Loop on PSimHit
211  simhit_map SimHitMap;
212  SimHitMap.clear();
213 
215  for (isim = allRPixHits.begin(); isim != allRPixHits.end(); ++isim) {
216  SimHitMap[(*isim).detUnitId()].push_back((*isim));
217  }
218 
219  // Step B: LOOP on hits in event
220  std::vector<edm::DetSet<CTPPSPixelDigi>> theDigiVector;
221  theDigiVector.reserve(400);
222  theDigiVector.clear();
223 
224  for (simhit_map_iterator it = SimHitMap.begin(); it != SimHitMap.end(); ++it) {
225  edm::DetSet<CTPPSPixelDigi> digi_collector(it->first);
226 
227  if (theAlgoMap.find(it->first) == theAlgoMap.end()) {
228  theAlgoMap[it->first] = std::make_unique<RPixDetDigitizer>(
229  conf_, *rndEngine_, it->first, thePixelTopology); //a digitizer for any detector
230  }
231 
232  std::vector<int> input_links;
233  std::vector<std::vector<std::pair<int, double>>> output_digi_links; // links to simhits
234 
235  theAlgoMap.at(it->first)->run(
236  SimHitMap[it->first], input_links, digi_collector.data, output_digi_links, &gainCalibration, &thePixelTopology);
237 
238  if (!digi_collector.data.empty()) {
239  theDigiVector.push_back(digi_collector);
240  }
241  }
242 
243  std::unique_ptr<edm::DetSetVector<CTPPSPixelDigi>> digi_output(new edm::DetSetVector<CTPPSPixelDigi>(theDigiVector));
244 
245  if (verbosity_) {
246  edm::LogInfo("PPS") << "PixelDigiProducer digi_output->size()=" << digi_output->size();
247  }
248 
249  iEvent.put(std::move(digi_output));
250 }
251 
253 
254 #endif
ConfigurationDescriptions.h
CTPPSPixelDigiProducer::tokenCrossingFramePPSPixel
edm::EDGetTokenT< CrossingFrame< PSimHit > > tokenCrossingFramePPSPixel
Definition: PPSPixelDigiProducer.cc:100
edm::DetSetVector
Definition: DetSetVector.h:61
PPSPixelTopology.h
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
CTPPSPixelAnalysisMaskRcd.h
CTPPSPixelDAQMappingRcd.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
edm::DetSet
Definition: DetSet.h:23
edm::EDGetTokenT
Definition: EDGetToken.h:33
RandomNumberGenerator.h
CrossingFrame.h
cuy.col
col
Definition: cuy.py:1009
PSimHitContainer.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
RPixDetDigitizer.h
CTPPSPixelDigiProducer::thePixelTopologyToken_
edm::ESGetToken< PPSPixelTopology, PPSPixelTopologyRcd > thePixelTopologyToken_
Definition: PPSPixelDigiProducer.cc:102
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
MixCollection::MixItr
Definition: MixCollection.h:61
CTPPSPixelGainCalibrations.h
MakerMacros.h
MixCollection::MixItr::bunch
int bunch() const
Definition: MixCollection.h:90
PSimHit.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
CTPPSPixelDigiProducer::CTPPSPixelDigiProducer
CTPPSPixelDigiProducer(const edm::ParameterSet &)
Definition: PPSPixelDigiProducer.cc:105
MixCollection.h
MixCollection
Definition: MixCollection.h:10
Service.h
CTPPSPixelDigiProducer::verbosity_
int verbosity_
Definition: PPSPixelDigiProducer.cc:98
MixCollection::MixItr::getTrigger
bool getTrigger() const
Definition: MixCollection.h:97
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
ParameterSetDescription.h
CTPPSPixelDigiProducer::theAlgoMap
std::map< uint32_t, std::unique_ptr< RPixDetDigitizer > > theAlgoMap
Definition: PPSPixelDigiProducer.cc:95
CTPPSPixelDigiProducer::simhit_map
std::map< unsigned int, std::vector< PSimHit > > simhit_map
Definition: PPSPixelDigiProducer.cc:90
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
CLHEP
Definition: CocoaGlobals.h:27
CTPPSPixelAnalysisMask.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CTPPSPixelDigiProducer::gainCalibESToken_
edm::ESGetToken< CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd > gainCalibESToken_
Definition: PPSPixelDigiProducer.cc:101
CTPPSPixelDigiProducer
Definition: PPSPixelDigiProducer.cc:79
edm::Service< edm::RandomNumberGenerator >
iEvent
int iEvent
Definition: GenABIO.cc:224
CTPPSPixelDigiProducer::simhit_map_iterator
simhit_map::iterator simhit_map_iterator
Definition: PPSPixelDigiProducer.cc:91
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
CTPPSPixelDigiProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PPSPixelDigiProducer.cc:119
CTPPSPixelDigiProducer::rndEngine_
CLHEP::HepRandomEngine * rndEngine_
Definition: PPSPixelDigiProducer.cc:97
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd >
CTPPSPixelDigi.h
CTPPSPixelGainCalibrationsRcd.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
CTPPSPixelDigiProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PPSPixelDigiProducer.cc:166
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
CTPPSPixelDAQMapping.h
Frameworkfwd.h
Exception
Definition: hltDiff.cc:245
CTPPSPixelDigiProducer::~CTPPSPixelDigiProducer
~CTPPSPixelDigiProducer() override
Definition: PPSPixelDigiProducer.cc:117
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
CTPPSPixelDigiProducer::conf_
edm::ParameterSet conf_
Definition: PPSPixelDigiProducer.cc:93
DetSet.h
ParameterSet.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
CTPPSPixelDigiCollection.h
PPSPixelTopologyRcd.h
CTPPSPixelDigiProducer::RPix_hit_containers_
std::vector< std::string > RPix_hit_containers_
Definition: PPSPixelDigiProducer.cc:89