CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void accumulate (edm::Event const &e, edm::EventSetup const &c) override
 
virtual void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c) override
 
virtual void beginJob ()
 
virtual void finalizeEvent (edm::Event &e, edm::EventSetup const &c) override
 
virtual void initializeEvent (edm::Event const &e, edm::EventSetup const &c) override
 
 SiPixelDigitizer (const edm::ParameterSet &conf, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
 
virtual ~SiPixelDigitizer ()
 
- 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 > >)
 

Private Attributes

std::unique_ptr
< SiPixelDigitizerAlgorithm
_pixeldigialgo
 
std::map< unsigned int,
PixelGeomDetUnit * > 
detectorUnits
 
bool first
 
const std::string geometryType
 
const std::string hitsProducer
 
edm::ESHandle< TrackerGeometrypDD
 
edm::ESHandle< MagneticFieldpSetup
 
CLHEP::HepRandomEngine * rndEngine
 
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 64 of file SiPixelDigitizer.h.

Constructor & Destructor Documentation

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

Definition at line 89 of file SiPixelDigitizer.cc.

References _pixeldigialgo, edm::ConsumesCollector::consumes(), edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), hitsProducer, edm::Service< T >::isAvailable(), rndEngine, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.

89  :
90  first(true),
92  hitsProducer(iConfig.getParameter<std::string>("hitsProducer")),
93  trackerContainers(iConfig.getParameter<std::vector<std::string> >("ROUList")),
94  geometryType(iConfig.getParameter<std::string>("GeometryType"))
95  {
96  edm::LogInfo ("PixelDigitizer ") <<"Enter the Pixel Digitizer";
97 
98  const std::string alias ("simSiPixelDigis");
99 
100  mixMod.produces<edm::DetSetVector<PixelDigi> >().setBranchAlias(alias);
101  mixMod.produces<edm::DetSetVector<PixelDigiSimLink> >().setBranchAlias(alias + "siPixelDigiSimLink");
102  for(auto const& trackerContainer : trackerContainers) {
103  edm::InputTag tag(hitsProducer, trackerContainer);
104  iC.consumes<std::vector<PSimHit> >(edm::InputTag(hitsProducer, trackerContainer));
105  }
107  if ( ! rng.isAvailable()) {
108  throw cms::Exception("Configuration")
109  << "SiPixelDigitizer requires the RandomNumberGeneratorService\n"
110  "which is not present in the configuration file. You must add the service\n"
111  "in the configuration file or remove the modules that require it.";
112  }
113 
114  rndEngine = &(rng->getEngine());
115  _pixeldigialgo.reset(new SiPixelDigitizerAlgorithm(iConfig,(*rndEngine)));
116 
117  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
CLHEP::HepRandomEngine * rndEngine
const std::string hitsProducer
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
const std::string geometryType
const vstring trackerContainers
SiPixelDigitizer::~SiPixelDigitizer ( )
virtual

Definition at line 119 of file SiPixelDigitizer.cc.

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

Member Function Documentation

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

Implements DigiAccumulatorMixMod.

Definition at line 178 of file SiPixelDigitizer.cc.

References accumulatePixelHits(), edm::Event::getByLabel(), hitsProducer, i, trackerHits::simHits, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.

178  {
179  // Step A: Get Inputs
180  for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
183 
184  iEvent.getByLabel(tag, simHits);
185  accumulatePixelHits(simHits);
186  }
187  }
int i
Definition: DBlmapReader.cc:9
void accumulatePixelHits(edm::Handle< std::vector< PSimHit > >)
const std::string hitsProducer
int iEvent
Definition: GenABIO.cc:243
tuple simHits
Definition: trackerHits.py:16
const vstring trackerContainers
void SiPixelDigitizer::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 190 of file SiPixelDigitizer.cc.

References accumulatePixelHits(), PileUpEventPrincipal::getByLabel(), hitsProducer, i, trackerHits::simHits, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.

190  {
191  // Step A: Get Inputs
192  for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
195 
196  iEvent.getByLabel(tag, simHits);
197  accumulatePixelHits(simHits);
198  }
199  }
int i
Definition: DBlmapReader.cc:9
void accumulatePixelHits(edm::Handle< std::vector< PSimHit > >)
const std::string hitsProducer
int iEvent
Definition: GenABIO.cc:243
tuple simHits
Definition: trackerHits.py:16
const vstring trackerContainers
void SiPixelDigitizer::accumulatePixelHits ( edm::Handle< std::vector< PSimHit > >  hSimHits)
private

Definition at line 129 of file SiPixelDigitizer.cc.

References _pixeldigialgo, detectorUnits, LogDebug, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, GloballyPositioned< T >::position(), pSetup, trackerHits::simHits, DetId::subdetId(), and GeomDet::surface().

Referenced by accumulate().

129  {
130  if(hSimHits.isValid()) {
131  std::set<unsigned int> detIds;
132  std::vector<PSimHit> const& simHits = *hSimHits.product();
133  for(std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it) {
134  unsigned int detId = (*it).detUnitId();
135  if(detIds.insert(detId).second) {
136  // The insert succeeded, so this detector element has not yet been processed.
137  unsigned int isub = DetId(detId).subdetId();
139  PixelGeomDetUnit* pixdet = detectorUnits[detId];
140  //access to magnetic field in global coordinates
141  GlobalVector bfield = pSetup->inTesla(pixdet->surface().position());
142  LogDebug ("PixelDigitizer ") << "B-field(T) at " << pixdet->surface().position() << "(cm): "
143  << pSetup->inTesla(pixdet->surface().position());
144  _pixeldigialgo->accumulateSimHits(it, itEnd, pixdet, bfield);
145  }
146  }
147  }
148  }
149  }
#define LogDebug(id)
edm::ESHandle< MagneticField > pSetup
std::map< unsigned int, PixelGeomDetUnit * > detectorUnits
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
Definition: DetId.h:18
tuple simHits
Definition: trackerHits.py:16
T const * product() const
Definition: Handle.h:81
const PositionType & position() const
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 203 of file SiPixelDigitizer.cc.

References _pixeldigialgo, edm::EventSetup::get(), convertSQLitetoXML_cfg::output, pDD, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, edm::ESHandle< class >::product(), edm::Event::put(), and DetId::subdetId().

203  {
204 
206  iSetup.get<IdealGeometryRecord>().get(tTopoHand);
207  const TrackerTopology *tTopo=tTopoHand.product();
208 
209  std::vector<edm::DetSet<PixelDigi> > theDigiVector;
210  std::vector<edm::DetSet<PixelDigiSimLink> > theDigiLinkVector;
211 
212  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){
213  DetId idet=DetId((*iu)->geographicalId().rawId());
214  unsigned int isub=idet.subdetId();
215 
217 
218  //
219 
220  edm::DetSet<PixelDigi> collector((*iu)->geographicalId().rawId());
221  edm::DetSet<PixelDigiSimLink> linkcollector((*iu)->geographicalId().rawId());
222 
223 
224  _pixeldigialgo->digitize(dynamic_cast<PixelGeomDetUnit*>((*iu)),
225  collector.data,
226  linkcollector.data,
227  tTopo);
228  if(collector.data.size() > 0) {
229  theDigiVector.push_back(std::move(collector));
230  }
231  if(linkcollector.data.size() > 0) {
232  theDigiLinkVector.push_back(std::move(linkcollector));
233  }
234  }
235  }
236 
237  // Step C: create collection with the cache vector of DetSet
238  std::auto_ptr<edm::DetSetVector<PixelDigi> >
239  output(new edm::DetSetVector<PixelDigi>(theDigiVector) );
240  std::auto_ptr<edm::DetSetVector<PixelDigiSimLink> >
241  outputlink(new edm::DetSetVector<PixelDigiSimLink>(theDigiLinkVector) );
242 
243  // Step D: write output to file
244  iEvent.put(output);
245  iEvent.put(outputlink);
246  }
int iEvent
Definition: GenABIO.cc:243
edm::ESHandle< TrackerGeometry > pDD
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
Definition: DetId.h:18
T const * product() const
Definition: ESHandle.h:62
void SiPixelDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 152 of file SiPixelDigitizer.cc.

References _pixeldigialgo, detectorUnits, first, geometryType, edm::EventSetup::get(), pDD, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pSetup, and DetId::subdetId().

152  {
153  if(first){
154  _pixeldigialgo->init(iSetup);
155  first = false;
156  }
157  _pixeldigialgo->initializeEvent();
158  iSetup.get<TrackerDigiGeometryRecord>().get(geometryType, pDD);
159  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
160 
161  // FIX THIS! We only need to clear and (re)fill this map when the geometry type IOV changes. Use ESWatcher to determine this.
162  if(true) { // Replace with ESWatcher
163  detectorUnits.clear();
164  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); ++iu) {
165  unsigned int detId = (*iu)->geographicalId().rawId();
166  DetId idet=DetId(detId);
167  unsigned int isub=idet.subdetId();
169  PixelGeomDetUnit* pixdet = dynamic_cast<PixelGeomDetUnit*>((*iu));
170  assert(pixdet != 0);
171  detectorUnits.insert(std::make_pair(detId, pixdet));
172  }
173  }
174  }
175  }
edm::ESHandle< MagneticField > pSetup
std::map< unsigned int, PixelGeomDetUnit * > detectorUnits
edm::ESHandle< TrackerGeometry > pDD
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::unique_ptr< SiPixelDigitizerAlgorithm > _pixeldigialgo
Definition: DetId.h:18
const std::string geometryType

Member Data Documentation

std::unique_ptr<SiPixelDigitizerAlgorithm> cms::SiPixelDigitizer::_pixeldigialgo
private
std::map<unsigned int, PixelGeomDetUnit*> cms::SiPixelDigitizer::detectorUnits
private

Definition at line 70 of file SiPixelDigitizer.h.

Referenced by accumulatePixelHits(), and initializeEvent().

bool cms::SiPixelDigitizer::first
private

Definition at line 62 of file SiPixelDigitizer.h.

Referenced by initializeEvent().

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

Definition at line 67 of file SiPixelDigitizer.h.

Referenced by initializeEvent().

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

Definition at line 65 of file SiPixelDigitizer.h.

Referenced by accumulate(), and SiPixelDigitizer().

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

Definition at line 68 of file SiPixelDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

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

Definition at line 69 of file SiPixelDigitizer.h.

Referenced by accumulatePixelHits(), and initializeEvent().

CLHEP::HepRandomEngine* cms::SiPixelDigitizer::rndEngine
private

Definition at line 71 of file SiPixelDigitizer.h.

Referenced by SiPixelDigitizer().

const vstring cms::SiPixelDigitizer::trackerContainers
private

Definition at line 66 of file SiPixelDigitizer.h.

Referenced by accumulate(), and SiPixelDigitizer().