CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelDigitizer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelDigitizer
4 // Class: SiPixelDigitizer
5 //
13 //
14 // Original Author: Michele Pioppi-INFN perugia
15 // Modifications: Freya Blekman - Cornell University
16 // Created: Mon Sep 26 11:08:32 CEST 2005
17 // $Id: SiPixelDigitizer.cc,v 1.6 2009/11/13 14:14:22 fambrogl Exp $
18 //
19 //
20 
21 
22 // system include files
23 #include <memory>
24 // user include files
27 
39 
41 
44 
46 // user include files
49 
52 
54 
57 
63 
64 //Random Number
68 #include "CLHEP/Random/RandomEngine.h"
69 
70 //
71 // constants, enums and typedefs
72 //
73 
74 //
75 // static data member definitions
76 //
77 
78 //
79 // constructors and destructor
80 //
81 //using namespace std;
82 
83 
84 namespace cms
85 {
87  conf_(iConfig),first(true)
88  {
89  edm::LogInfo ("PixelDigitizer ") <<"Enter the Pixel Digitizer";
90 
91  std::string alias ( iConfig.getParameter<std::string>("@module_label") );
92 
93  produces<edm::DetSetVector<PixelDigi> >().setBranchAlias( alias );
94  produces<edm::DetSetVector<PixelDigiSimLink> >().setBranchAlias ( alias + "siPixelDigiSimLink");
95  trackerContainers.clear();
96  trackerContainers = iConfig.getParameter<std::vector<std::string> >("ROUList");
97  geometryType = iConfig.getParameter<std::string>("GeometryType");
99  if ( ! rng.isAvailable()) {
100  throw cms::Exception("Configuration")
101  << "SiPixelDigitizer requires the RandomNumberGeneratorService\n"
102  "which is not present in the configuration file. You must add the service\n"
103  "in the configuration file or remove the modules that require it.";
104  }
105 
106  rndEngine = &(rng->getEngine());
108 
109  }
110 
112  edm::LogInfo ("PixelDigitizer ") <<"Destruct the Pixel Digitizer";
113  delete _pixeldigialgo;
114  }
115 
116 
117  //
118  // member functions
119  //
120 
121  // ------------ method called to produce the data ------------
122  void
124  {
125 
126  if(first){
127  _pixeldigialgo->init(iSetup);
128  first = false;
129  }
130 
131  // Step A: Get Inputs
133  std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
134  for(uint32_t i = 0; i< trackerContainers.size();i++){
135  iEvent.getByLabel("mix",trackerContainers[i],cf_simhit);
136  cf_simhitvec.push_back(cf_simhit.product());
137  }
138 
139  std::auto_ptr<MixCollection<PSimHit> > allPixelTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
140 
142 
143  iSetup.get<TrackerDigiGeometryRecord> ().get(geometryType,pDD);
144 
146  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
147 
148  //Loop on PSimHit
149  SimHitMap.clear();
150 
152  for (isim=allPixelTrackerHits->begin(); isim!= allPixelTrackerHits->end();isim++) {
153  DetId detid=DetId((*isim).detUnitId());
154  unsigned int subid=detid.subdetId();
156  SimHitMap[(*isim).detUnitId()].push_back((*isim));
157  }
158  }
159 
160  // Step B: LOOP on PixelGeomDetUnit //
161  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){
162  DetId idet=DetId((*iu)->geographicalId().rawId());
163  unsigned int isub=idet.subdetId();
164 
165 
167 
168 
169  //access to magnetic field in global coordinates
170  GlobalVector bfield=pSetup->inTesla((*iu)->surface().position());
171  LogDebug ("PixelDigitizer ") << "B-field(T) at "<<(*iu)->surface().position()<<"(cm): "
172  << pSetup->inTesla((*iu)->surface().position());
173  //
174 
175  edm::DetSet<PixelDigi> collector((*iu)->geographicalId().rawId());
176  edm::DetSet<PixelDigiSimLink> linkcollector((*iu)->geographicalId().rawId());
177 
178 
179  collector.data=
180  _pixeldigialgo->run(SimHitMap[(*iu)->geographicalId().rawId()],
181  dynamic_cast<PixelGeomDetUnit*>((*iu)),
182  bfield);
183  if (collector.data.size()>0){
184  theDigiVector.push_back(collector);
185 
186  //digisimlink
187  if(SimHitMap[(*iu)->geographicalId().rawId()].size()>0){
188  linkcollector.data=_pixeldigialgo->make_link();
189  if (linkcollector.data.size()>0) theDigiLinkVector.push_back(linkcollector);
190  }
191 
192  }
193  }
194 
195  }
196 
197  // Step C: create collection with the cache vector of DetSet
198  std::auto_ptr<edm::DetSetVector<PixelDigi> >
200  std::auto_ptr<edm::DetSetVector<PixelDigiSimLink> >
202 
203  // Step D: write output to file
204  iEvent.put(output);
205  iEvent.put(outputlink);
206  }
207 
208 
209 
210 
211 }// end namespace cms::
212 
#define LogDebug(id)
void init(const edm::EventSetup &es)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< PixelDigiSimLink > make_link()
CLHEP::HepRandomEngine * rndEngine
iterator end()
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< edm::DetSet< PixelDigiSimLink > > theDigiLinkVector
edm::DetSet< PixelDigi >::collection_type run(const std::vector< PSimHit > &input, PixelGeomDetUnit *pixdet, GlobalVector)
bool first
Definition: L1TdeRCT.cc:94
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
SiPixelDigitizerAlgorithm * _pixeldigialgo
Definition: DetId.h:20
iterator begin()
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
collection_type data
Definition: DetSet.h:79
virtual void produce(edm::Event &e, const edm::EventSetup &c)
SiPixelDigitizer(const edm::ParameterSet &conf)
std::vector< edm::DetSet< PixelDigi > > theDigiVector