CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
cms::SiPixelDigitizer Class Reference

#include <SiPixelDigitizer.h>

Inheritance diagram for cms::SiPixelDigitizer:
DigiAccumulatorMixMod

Public Member Functions

void accumulate (edm::Event const &e, edm::EventSetup const &c) override
 
void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c, edm::StreamID const &) override
 
virtual void beginJob ()
 
void finalizeEvent (edm::Event &e, edm::EventSetup const &c) override
 
PileupMixingContentgetEventPileupInfo () override
 
void initializeEvent (edm::Event const &e, edm::EventSetup const &c) override
 
 SiPixelDigitizer (const edm::ParameterSet &conf, edm::ProducerBase &mixMod, edm::ConsumesCollector &iC)
 
void StorePileupInformation (std::vector< int > &numInteractionList, std::vector< int > &bunchCrossingList, std::vector< float > &TrueInteractionList, std::vector< edm::EventID > &eventInfoList, int bunchSpacing) override
 
 ~SiPixelDigitizer () override
 
- Public Member Functions inherited from DigiAccumulatorMixMod
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void beginRun (edm::Run const &run, edm::EventSetup const &setup)
 
 DigiAccumulatorMixMod ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void endRun (edm::Run const &run, edm::EventSetup const &setup)
 
virtual void finalizeBunchCrossing (edm::Event &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual void initializeBunchCrossing (edm::Event const &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual ~DigiAccumulatorMixMod ()
 

Private Types

typedef std::vector< std::string > vstring
 

Private Member Functions

void accumulatePixelHits (edm::Handle< std::vector< PSimHit > >, size_t globalSimHitIndex, const unsigned int tofBin, edm::EventSetup const &c)
 

Private Attributes

std::unique_ptr< SiPixelDigitizerAlgorithm_pixeldigialgo
 
std::map< std::string, size_t > crossingSimHitIndexOffset_
 Offset to add to the index of each sim hit to account for which crossing it's in. More...
 
std::map< unsigned int, PixelGeomDetUnit const * > detectorUnits
 
bool firstFinalizeEvent_
 
bool firstInitializeEvent_
 
const std::string geometryType
 
const std::string hitsProducer
 
const int NumberOfEndcapDisks
 
edm::ESHandle< TrackerGeometrypDD
 
PileupMixingContentPileupInfo_
 
const bool pilotBlades
 
edm::ESHandle< MagneticFieldpSetup
 
CLHEP::HepRandomEngine * randomEngine_ = nullptr
 
const vstring trackerContainers
 

Detailed Description

Definition at line 47 of file SiPixelDigitizer.h.

Member Typedef Documentation

typedef std::vector<std::string> cms::SiPixelDigitizer::vstring
private

Definition at line 89 of file SiPixelDigitizer.h.

Constructor & Destructor Documentation

SiPixelDigitizer::SiPixelDigitizer ( const edm::ParameterSet conf,
edm::ProducerBase mixMod,
edm::ConsumesCollector iC 
)
explicit

Definition at line 89 of file SiPixelDigitizer.cc.

References _pixeldigialgo, egammaCTFFinalFitWithMaterial_cff::alias, edm::ConsumesCollector::consumes(), Exception, hitsProducer, edm::ProductRegistryHelper::produces(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.

89  :
91  firstFinalizeEvent_(true),
93  hitsProducer(iConfig.getParameter<std::string>("hitsProducer")),
94  trackerContainers(iConfig.getParameter<std::vector<std::string> >("RoutList")),
95  geometryType(iConfig.getParameter<std::string>("PixGeometryType")),
96  pilotBlades(iConfig.exists("enablePilotBlades")?iConfig.getParameter<bool>("enablePilotBlades"):false),
97  NumberOfEndcapDisks(iConfig.exists("NumPixelEndcap")?iConfig.getParameter<int>("NumPixelEndcap"):2)
98  {
99  edm::LogInfo ("PixelDigitizer ") <<"Enter the Pixel Digitizer";
100 
101  const std::string alias ("simSiPixelDigis");
102 
103  mixMod.produces<edm::DetSetVector<PixelDigi> >().setBranchAlias(alias);
104  mixMod.produces<edm::DetSetVector<PixelDigiSimLink> >().setBranchAlias(alias + "siPixelDigiSimLink");
105  for(auto const& trackerContainer : trackerContainers) {
106  edm::InputTag tag(hitsProducer, trackerContainer);
107  iC.consumes<std::vector<PSimHit> >(edm::InputTag(hitsProducer, trackerContainer));
108  }
110  if ( ! rng.isAvailable()) {
111  throw cms::Exception("Configuration")
112  << "SiPixelDigitizer requires the RandomNumberGeneratorService\n"
113  "which is not present in the configuration file. You must add the service\n"
114  "in the configuration file or remove the modules that require it.";
115  }
116 
117  _pixeldigialgo.reset(new SiPixelDigitizerAlgorithm(iConfig));
118  }
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const std::string hitsProducer
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
const std::string geometryType
const vstring trackerContainers
SiPixelDigitizer::~SiPixelDigitizer ( )
override

Definition at line 120 of file SiPixelDigitizer.cc.

120  {
121  edm::LogInfo ("PixelDigitizer ") <<"Destruct the Pixel Digitizer";
122  }

Member Function Documentation

void SiPixelDigitizer::accumulate ( edm::Event const &  e,
edm::EventSetup const &  c 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 205 of file SiPixelDigitizer.cc.

References accumulatePixelHits(), crossingSimHitIndexOffset_, edm::InputTag::encode(), edm::Event::getByLabel(), PixelDigiSimLink::HighTof, hitsProducer, mps_fire::i, edm::HandleBase::isValid(), PixelDigiSimLink::LowTof, trackerHits::simHits, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.

205  {
206  // Step A: Get Inputs
207  for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
210 
211  iEvent.getByLabel(tag, simHits);
212  unsigned int tofBin = PixelDigiSimLink::LowTof;
213  if ((*i).find(std::string("HighTof")) != std::string::npos) tofBin = PixelDigiSimLink::HighTof;
214  accumulatePixelHits(simHits, crossingSimHitIndexOffset_[tag.encode()], tofBin, iSetup);
215  // Now that the hits have been processed, I'll add the amount of hits in this crossing on to
216  // the global counter. Next time accumulateStripHits() is called it will count the sim hits
217  // as though they were on the end of this collection.
218  // Note that this is only used for creating digi-sim links (if configured to do so).
219 // std::cout << "index offset, current hit count = " << crossingSimHitIndexOffset_[tag.encode()] << ", " << simHits->size() << std::endl;
220  if( simHits.isValid() ) crossingSimHitIndexOffset_[tag.encode()]+=simHits->size();
221  }
222  }
const std::string hitsProducer
int iEvent
Definition: GenABIO.cc:230
std::map< std::string, size_t > crossingSimHitIndexOffset_
Offset to add to the index of each sim hit to account for which crossing it&#39;s in. ...
void accumulatePixelHits(edm::Handle< std::vector< PSimHit > >, size_t globalSimHitIndex, const unsigned int tofBin, edm::EventSetup const &c)
bool isValid() const
Definition: HandleBase.h:74
const vstring trackerContainers
void SiPixelDigitizer::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c,
edm::StreamID const &  streamID 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 225 of file SiPixelDigitizer.cc.

References accumulatePixelHits(), crossingSimHitIndexOffset_, edm::InputTag::encode(), PileUpEventPrincipal::getByLabel(), PixelDigiSimLink::HighTof, hitsProducer, mps_fire::i, edm::HandleBase::isValid(), PixelDigiSimLink::LowTof, trackerHits::simHits, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.

225  {
226  // Step A: Get Inputs
227  for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
230 
231  iEvent.getByLabel(tag, simHits);
232  unsigned int tofBin = PixelDigiSimLink::LowTof;
233  if ((*i).find(std::string("HighTof")) != std::string::npos) tofBin = PixelDigiSimLink::HighTof;
234  accumulatePixelHits(simHits, crossingSimHitIndexOffset_[tag.encode()], tofBin, iSetup);
235  // Now that the hits have been processed, I'll add the amount of hits in this crossing on to
236  // the global counter. Next time accumulateStripHits() is called it will count the sim hits
237  // as though they were on the end of this collection.
238  // Note that this is only used for creating digi-sim links (if configured to do so).
239 // std::cout << "index offset, current hit count = " << crossingSimHitIndexOffset_[tag.encode()] << ", " << simHits->size() << std::endl;
240  if( simHits.isValid() ) crossingSimHitIndexOffset_[tag.encode()]+=simHits->size();
241  }
242  }
const std::string hitsProducer
int iEvent
Definition: GenABIO.cc:230
std::map< std::string, size_t > crossingSimHitIndexOffset_
Offset to add to the index of each sim hit to account for which crossing it&#39;s in. ...
void accumulatePixelHits(edm::Handle< std::vector< PSimHit > >, size_t globalSimHitIndex, const unsigned int tofBin, edm::EventSetup const &c)
bool isValid() const
Definition: HandleBase.h:74
const vstring trackerContainers
void SiPixelDigitizer::accumulatePixelHits ( edm::Handle< std::vector< PSimHit > >  hSimHits,
size_t  globalSimHitIndex,
const unsigned int  tofBin,
edm::EventSetup const &  c 
)
private

Definition at line 130 of file SiPixelDigitizer.cc.

References _pixeldigialgo, detectorUnits, edm::EventSetup::get(), MagneticField::inTesla(), GeomDetEnumerators::isTrackerPixel(), LogDebug, edm::ESHandle< T >::product(), pSetup, randomEngine_, and trackerHits::simHits.

Referenced by accumulate().

133  {
134  if(hSimHits.isValid()) {
135  std::set<unsigned int> detIds;
136  std::vector<PSimHit> const& simHits = *hSimHits.product();
138  iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
139  const TrackerTopology *tTopo=tTopoHand.product();
140  for(std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it, ++globalSimHitIndex) {
141  unsigned int detId = (*it).detUnitId();
142  if(detIds.insert(detId).second) {
143  // The insert succeeded, so this detector element has not yet been processed.
144  assert(detectorUnits[detId]);
145  if(detectorUnits[detId] && detectorUnits[detId]->type().isTrackerPixel()) { // this test could be avoided and changed into a check of pixdet!=0
146  std::map<unsigned int, PixelGeomDetUnit const *>::iterator itDet = detectorUnits.find(detId);
147  if (itDet == detectorUnits.end()) continue;
148  auto pixdet = itDet->second;
149  assert(pixdet !=nullptr);
150  //access to magnetic field in global coordinates
151  GlobalVector bfield = pSetup->inTesla(pixdet->surface().position());
152  LogDebug ("PixelDigitizer ") << "B-field(T) at " << pixdet->surface().position() << "(cm): "
153  << pSetup->inTesla(pixdet->surface().position());
154  _pixeldigialgo->accumulateSimHits(it, itEnd, globalSimHitIndex, tofBin, pixdet, bfield, tTopo, randomEngine_);
155  }
156  }
157  }
158  }
159  }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
std::map< unsigned int, PixelGeomDetUnit const * > detectorUnits
edm::ESHandle< MagneticField > pSetup
bool isValid() const
Definition: HandleBase.h:74
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
CLHEP::HepRandomEngine * randomEngine_
T const * product() const
Definition: Handle.h:81
T const * product() const
Definition: ESHandle.h:86
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
virtual void cms::SiPixelDigitizer::beginJob ( void  )
inlinevirtual

Definition at line 59 of file SiPixelDigitizer.h.

59 {}
void SiPixelDigitizer::finalizeEvent ( edm::Event e,
edm::EventSetup const &  c 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 246 of file SiPixelDigitizer.cc.

References _pixeldigialgo, DigiHGCalTB160_cff::bunchspace, TrackerGeometry::detUnits(), firstFinalizeEvent_, edm::EventSetup::get(), getEventPileupInfo(), PileupMixingContent::getMix_bunchSpacing(), eostools::move(), convertSQLitetoXML_cfg::output, pDD, PileupInfo_, edm::ESHandle< T >::product(), edm::Event::put(), and randomEngine_.

246  {
248  iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
249  const TrackerTopology *tTopo=tTopoHand.product();
250 
251  std::vector<edm::DetSet<PixelDigi> > theDigiVector;
252  std::vector<edm::DetSet<PixelDigiSimLink> > theDigiLinkVector;
253 
255  if (firstFinalizeEvent_) {
256  const unsigned int bunchspace = PileupInfo_->getMix_bunchSpacing();
257  _pixeldigialgo->init_DynIneffDB(iSetup, bunchspace);
258  firstFinalizeEvent_ = false;
259  }
260  _pixeldigialgo->calculateInstlumiFactor(PileupInfo_);
261 
262  for( const auto& iu : pDD->detUnits()) {
263 
264  if(iu->type().isTrackerPixel()) {
265 
266  //
267 
268  edm::DetSet<PixelDigi> collector(iu->geographicalId().rawId());
269  edm::DetSet<PixelDigiSimLink> linkcollector(iu->geographicalId().rawId());
270 
271 
272  _pixeldigialgo->digitize(dynamic_cast<const PixelGeomDetUnit*>(iu),
273  collector.data,
274  linkcollector.data,
275  tTopo,
276  randomEngine_);
277  if(!collector.data.empty()) {
278  theDigiVector.push_back(std::move(collector));
279  }
280  if(!linkcollector.data.empty()) {
281  theDigiLinkVector.push_back(std::move(linkcollector));
282  }
283  }
284  }
285 
286  // Step C: create collection with the cache vector of DetSet
287  std::unique_ptr<edm::DetSetVector<PixelDigi> >
288  output(new edm::DetSetVector<PixelDigi>(theDigiVector) );
289  std::unique_ptr<edm::DetSetVector<PixelDigiSimLink> >
290  outputlink(new edm::DetSetVector<PixelDigiSimLink>(theDigiLinkVector) );
291 
292  // Step D: write output to file
293  iEvent.put(std::move(output));
294  iEvent.put(std::move(outputlink));
295 
296  randomEngine_ = nullptr; // to prevent access outside event
297  }
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
int iEvent
Definition: GenABIO.cc:230
bunchspace
in terms of 25 ns
edm::ESHandle< TrackerGeometry > pDD
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
CLHEP::HepRandomEngine * randomEngine_
PileupMixingContent * PileupInfo_
const int & getMix_bunchSpacing() const
PileupMixingContent * getEventPileupInfo() override
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
PileupMixingContent* cms::SiPixelDigitizer::getEventPileupInfo ( )
inlineoverridevirtual

Reimplemented from DigiAccumulatorMixMod.

Definition at line 68 of file SiPixelDigitizer.h.

Referenced by finalizeEvent().

68 { return PileupInfo_; }
PileupMixingContent * PileupInfo_
void SiPixelDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 162 of file SiPixelDigitizer.cc.

References _pixeldigialgo, crossingSimHitIndexOffset_, detectorUnits, TrackerGeometry::detUnits(), firstInitializeEvent_, geometryType, edm::EventSetup::get(), edm::RandomNumberGenerator::getEngine(), TrackerTopology::layer(), NumberOfEndcapDisks, pDD, pilotBlades, GeomDetEnumerators::PixelEndcap, edm::ESHandle< T >::product(), pSetup, randomEngine_, and edm::Event::streamID().

162  {
164  _pixeldigialgo->init(iSetup);
165  firstInitializeEvent_ = false;
166  }
167 
168  // Make sure that the first crossing processed starts indexing the sim hits from zero.
169  // This variable is used so that the sim hits from all crossing frames have sequential
170  // indices used to create the digi-sim link (if configured to do so) rather than starting
171  // from zero for each crossing.
173 
174  // Cache random number engine
176  randomEngine_ = &rng->getEngine(e.streamID());
177 
178  _pixeldigialgo->initializeEvent();
179  iSetup.get<TrackerDigiGeometryRecord>().get(geometryType, pDD);
180  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
182  iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
183  const TrackerTopology *tTopo=tTopoHand.product();
184 
185  // FIX THIS! We only need to clear and (re)fill this map when the geometry type IOV changes. Use ESWatcher to determine this.
186  if(true) { // Replace with ESWatcher
187  detectorUnits.clear();
188  for( const auto& iu : pDD->detUnits()) {
189  unsigned int detId = iu->geographicalId().rawId();
190  if(iu->type().isTrackerPixel()) {
191  auto pixdet = dynamic_cast<const PixelGeomDetUnit*>(iu);
192  assert(pixdet != nullptr);
193  if (iu->subDetector()==GeomDetEnumerators::SubDetector::PixelEndcap) { // true ONLY for the phase 0 pixel deetctor
194  unsigned int disk = tTopo->layer(detId); // using the generic layer method
195  //if using pilot blades, then allowing it for current detector only
196  if ((disk == 3)&&((!pilotBlades)&&(NumberOfEndcapDisks == 2))) continue;
197  }
198  detectorUnits.insert(std::make_pair(detId, pixdet));
199  }
200  }
201  }
202  }
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
std::map< unsigned int, PixelGeomDetUnit const * > detectorUnits
edm::ESHandle< MagneticField > pSetup
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::map< std::string, size_t > crossingSimHitIndexOffset_
Offset to add to the index of each sim hit to account for which crossing it&#39;s in. ...
edm::ESHandle< TrackerGeometry > pDD
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
CLHEP::HepRandomEngine * randomEngine_
const std::string geometryType
unsigned int layer(const DetId &id) const
T const * product() const
Definition: ESHandle.h:86
void cms::SiPixelDigitizer::StorePileupInformation ( std::vector< int > &  numInteractionList,
std::vector< int > &  bunchCrossingList,
std::vector< float > &  TrueInteractionList,
std::vector< edm::EventID > &  eventInfoList,
int  bunchSpacing 
)
inlineoverridevirtual

Reimplemented from DigiAccumulatorMixMod.

Definition at line 61 of file SiPixelDigitizer.h.

64  {
65  PileupInfo_ = new PileupMixingContent(numInteractionList, bunchCrossingList, TrueInteractionList, eventInfoList, bunchSpacing);
66  }
PileupMixingContent * PileupInfo_

Member Data Documentation

std::unique_ptr<SiPixelDigitizerAlgorithm> cms::SiPixelDigitizer::_pixeldigialgo
private
std::map<std::string,size_t> cms::SiPixelDigitizer::crossingSimHitIndexOffset_
private

Offset to add to the index of each sim hit to account for which crossing it's in.

I need to know what each sim hit index will be when the hits from all crossing frames are merged into one collection (assuming the MixingModule is configured to create the crossing frame for all sim hits). To do this I'll record how many hits were in each crossing, and then add that on to the index for a given hit in a given crossing. This assumes that the crossings are processed in the same order here as they are put into the crossing frame, which I'm pretty sure is true.
The key is the name of the sim hit collection.

Definition at line 87 of file SiPixelDigitizer.h.

Referenced by accumulate(), and initializeEvent().

std::map<unsigned int, PixelGeomDetUnit const *> cms::SiPixelDigitizer::detectorUnits
private

Definition at line 95 of file SiPixelDigitizer.h.

Referenced by accumulatePixelHits(), and initializeEvent().

bool cms::SiPixelDigitizer::firstFinalizeEvent_
private

Definition at line 77 of file SiPixelDigitizer.h.

Referenced by finalizeEvent().

bool cms::SiPixelDigitizer::firstInitializeEvent_
private

Definition at line 76 of file SiPixelDigitizer.h.

Referenced by initializeEvent().

const std::string cms::SiPixelDigitizer::geometryType
private

Definition at line 92 of file SiPixelDigitizer.h.

Referenced by initializeEvent().

const std::string cms::SiPixelDigitizer::hitsProducer
private

Definition at line 90 of file SiPixelDigitizer.h.

Referenced by accumulate(), and SiPixelDigitizer().

const int cms::SiPixelDigitizer::NumberOfEndcapDisks
private

Definition at line 101 of file SiPixelDigitizer.h.

Referenced by initializeEvent().

edm::ESHandle<TrackerGeometry> cms::SiPixelDigitizer::pDD
private

Definition at line 93 of file SiPixelDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

PileupMixingContent* cms::SiPixelDigitizer::PileupInfo_
private

Definition at line 98 of file SiPixelDigitizer.h.

Referenced by finalizeEvent().

const bool cms::SiPixelDigitizer::pilotBlades
private

Definition at line 100 of file SiPixelDigitizer.h.

Referenced by initializeEvent().

edm::ESHandle<MagneticField> cms::SiPixelDigitizer::pSetup
private

Definition at line 94 of file SiPixelDigitizer.h.

Referenced by accumulatePixelHits(), and initializeEvent().

CLHEP::HepRandomEngine* cms::SiPixelDigitizer::randomEngine_ = nullptr
private

Definition at line 96 of file SiPixelDigitizer.h.

Referenced by accumulatePixelHits(), finalizeEvent(), and initializeEvent().

const vstring cms::SiPixelDigitizer::trackerContainers
private

Definition at line 91 of file SiPixelDigitizer.h.

Referenced by accumulate(), and SiPixelDigitizer().