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
 
std::unique_ptr< 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 
106 
107  for(auto const& trackerContainer : trackerContainers) {
108  edm::InputTag tag(hitsProducer, trackerContainer);
109  iC.consumes<std::vector<PSimHit> >(edm::InputTag(hitsProducer, trackerContainer));
110  }
112  if ( ! rng.isAvailable()) {
113  throw cms::Exception("Configuration")
114  << "SiPixelDigitizer requires the RandomNumberGeneratorService\n"
115  "which is not present in the configuration file. You must add the service\n"
116  "in the configuration file or remove the modules that require it.";
117  }
118 
119  _pixeldigialgo.reset(new SiPixelDigitizerAlgorithm(iConfig));
120  if (_pixeldigialgo->killBadFEDChannels()){
122  }
123  }
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 125 of file SiPixelDigitizer.cc.

125  {
126  edm::LogInfo ("PixelDigitizer ") <<"Destruct the Pixel Digitizer";
127  }

Member Function Documentation

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

Implements DigiAccumulatorMixMod.

Definition at line 210 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.

210  {
211  // Step A: Get Inputs
212  for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
215 
216  iEvent.getByLabel(tag, simHits);
217  unsigned int tofBin = PixelDigiSimLink::LowTof;
218  if ((*i).find(std::string("HighTof")) != std::string::npos) tofBin = PixelDigiSimLink::HighTof;
219  accumulatePixelHits(simHits, crossingSimHitIndexOffset_[tag.encode()], tofBin, iSetup);
220  // Now that the hits have been processed, I'll add the amount of hits in this crossing on to
221  // the global counter. Next time accumulateStripHits() is called it will count the sim hits
222  // as though they were on the end of this collection.
223  // Note that this is only used for creating digi-sim links (if configured to do so).
224 // std::cout << "index offset, current hit count = " << crossingSimHitIndexOffset_[tag.encode()] << ", " << simHits->size() << std::endl;
225  if( simHits.isValid() ) crossingSimHitIndexOffset_[tag.encode()]+=simHits->size();
226  }
227  }
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 230 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.

230  {
231  // Step A: Get Inputs
232  for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
235 
236  iEvent.getByLabel(tag, simHits);
237  unsigned int tofBin = PixelDigiSimLink::LowTof;
238  if ((*i).find(std::string("HighTof")) != std::string::npos) tofBin = PixelDigiSimLink::HighTof;
239  accumulatePixelHits(simHits, crossingSimHitIndexOffset_[tag.encode()], tofBin, iSetup);
240  // Now that the hits have been processed, I'll add the amount of hits in this crossing on to
241  // the global counter. Next time accumulateStripHits() is called it will count the sim hits
242  // as though they were on the end of this collection.
243  // Note that this is only used for creating digi-sim links (if configured to do so).
244 // std::cout << "index offset, current hit count = " << crossingSimHitIndexOffset_[tag.encode()] << ", " << simHits->size() << std::endl;
245  if( simHits.isValid() ) crossingSimHitIndexOffset_[tag.encode()]+=simHits->size();
246  }
247  }
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 135 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().

138  {
139  if(hSimHits.isValid()) {
140  std::set<unsigned int> detIds;
141  std::vector<PSimHit> const& simHits = *hSimHits.product();
143  iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
144  const TrackerTopology *tTopo=tTopoHand.product();
145  for(std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it, ++globalSimHitIndex) {
146  unsigned int detId = (*it).detUnitId();
147  if(detIds.insert(detId).second) {
148  // The insert succeeded, so this detector element has not yet been processed.
149  assert(detectorUnits[detId]);
150  if(detectorUnits[detId] && detectorUnits[detId]->type().isTrackerPixel()) { // this test could be avoided and changed into a check of pixdet!=0
151  std::map<unsigned int, PixelGeomDetUnit const *>::iterator itDet = detectorUnits.find(detId);
152  if (itDet == detectorUnits.end()) continue;
153  auto pixdet = itDet->second;
154  assert(pixdet !=nullptr);
155  //access to magnetic field in global coordinates
156  GlobalVector bfield = pSetup->inTesla(pixdet->surface().position());
157  LogDebug ("PixelDigitizer ") << "B-field(T) at " << pixdet->surface().position() << "(cm): "
158  << pSetup->inTesla(pixdet->surface().position());
159  _pixeldigialgo->accumulateSimHits(it, itEnd, globalSimHitIndex, tofBin, pixdet, bfield, tTopo, randomEngine_);
160  }
161  }
162  }
163  }
164  }
#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:84
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 251 of file SiPixelDigitizer.cc.

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

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

Reimplemented from DigiAccumulatorMixMod.

Definition at line 68 of file SiPixelDigitizer.h.

68 { return PileupInfo_.get(); }
std::unique_ptr< PileupMixingContent > PileupInfo_
void SiPixelDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 167 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().

167  {
169  _pixeldigialgo->init(iSetup);
170  firstInitializeEvent_ = false;
171  }
172 
173  // Make sure that the first crossing processed starts indexing the sim hits from zero.
174  // This variable is used so that the sim hits from all crossing frames have sequential
175  // indices used to create the digi-sim link (if configured to do so) rather than starting
176  // from zero for each crossing.
178 
179  // Cache random number engine
181  randomEngine_ = &rng->getEngine(e.streamID());
182 
183  _pixeldigialgo->initializeEvent();
184  iSetup.get<TrackerDigiGeometryRecord>().get(geometryType, pDD);
185  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
187  iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
188  const TrackerTopology *tTopo=tTopoHand.product();
189 
190  // FIX THIS! We only need to clear and (re)fill this map when the geometry type IOV changes. Use ESWatcher to determine this.
191  if(true) { // Replace with ESWatcher
192  detectorUnits.clear();
193  for( const auto& iu : pDD->detUnits()) {
194  unsigned int detId = iu->geographicalId().rawId();
195  if(iu->type().isTrackerPixel()) {
196  auto pixdet = dynamic_cast<const PixelGeomDetUnit*>(iu);
197  assert(pixdet != nullptr);
198  if (iu->subDetector()==GeomDetEnumerators::SubDetector::PixelEndcap) { // true ONLY for the phase 0 pixel deetctor
199  unsigned int disk = tTopo->layer(detId); // using the generic layer method
200  //if using pilot blades, then allowing it for current detector only
201  if ((disk == 3)&&((!pilotBlades)&&(NumberOfEndcapDisks == 2))) continue;
202  }
203  detectorUnits.insert(std::make_pair(detId, pixdet));
204  }
205  }
206  }
207  }
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:84
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.

References genPUProtons_cfi::bunchCrossingList.

64  {
65  PileupInfo_ = std::make_unique<PileupMixingContent>(numInteractionList, bunchCrossingList, TrueInteractionList, eventInfoList, bunchSpacing);
66  }
std::unique_ptr< 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().

std::unique_ptr<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().