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 Attributes
DigiSimLinkProducer Class Reference

#include <DigiSimLinkProducer.h>

Inheritance diagram for DigiSimLinkProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DigiSimLinkProducer (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~DigiSimLinkProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::map< unsigned int,
std::vector< std::pair< const
PSimHit *, int > >, std::less
< unsigned int > > 
simhit_map
 
typedef simhit_map::iterator simhit_map_iterator
 
typedef std::vector< std::string > vstring
 

Private Attributes

std::string alias
 
edm::ParameterSet conf_
 
std::string geometryType
 
int numStrips
 
simhit_map SimHitMap
 
SimHitSelectorFromDB SimHitSelectorFromDB_
 
std::map< uint32_t,
std::vector< int > > 
theDetIdList
 
DigiSimLinkAlgorithmtheDigiAlgo
 
std::vector< edm::DetSet
< StripDigiSimLink > > 
theDigiLinkVector
 
std::vector< edm::DetSet
< SiStripDigi > > 
theDigiVector
 
std::vector< edm::DetSet
< SiStripRawDigi > > 
theRawDigiVector
 
SiStripFedZeroSuppressiontheSiFEDZeroSuppress
 
vstring trackerContainers
 
bool useConfFromDB
 
bool zeroSuppression
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

DigiSimLinkProducer to convert hits to digis

Definition at line 30 of file DigiSimLinkProducer.h.

Member Typedef Documentation

typedef std::map<unsigned int, std::vector<std::pair<const PSimHit*, int> >,std::less<unsigned int> > DigiSimLinkProducer::simhit_map
private

Definition at line 42 of file DigiSimLinkProducer.h.

typedef simhit_map::iterator DigiSimLinkProducer::simhit_map_iterator
private

Definition at line 43 of file DigiSimLinkProducer.h.

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

Definition at line 41 of file DigiSimLinkProducer.h.

Constructor & Destructor Documentation

DigiSimLinkProducer::DigiSimLinkProducer ( const edm::ParameterSet conf)
explicit

Definition at line 66 of file DigiSimLinkProducer.cc.

References alias, conf_, edm::hlt::Exception, geometryType, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theDigiAlgo, trackerContainers, useConfFromDB, and zeroSuppression.

66  :
67  conf_(conf)
68 {
69  alias = conf.getParameter<std::string>("@module_label");
70  edm::ParameterSet ParamSet=conf_.getParameter<edm::ParameterSet>("DigiModeList");
71 
72  produces<edm::DetSetVector<StripDigiSimLink> >().setBranchAlias ( alias + "siStripDigiSimLink");
73  trackerContainers.clear();
74  trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
75  geometryType = conf.getParameter<std::string>("GeometryType");
76  useConfFromDB = conf.getParameter<bool>("TrackerConfigurationFromDB");
78  if ( ! rng.isAvailable()) {
79  throw cms::Exception("Configuration")
80  << "DigiSimLinkProducer requires the RandomNumberGeneratorService\n"
81  "which is not present in the configuration file. You must add the service\n"
82  "in the configuration file or remove the modules that require it.";
83  }
84 
85  zeroSuppression = conf_.getParameter<bool>("ZeroSuppression");
87 
88 }
T getParameter(std::string const &) const
edm::ParameterSet conf_
DigiSimLinkAlgorithm * theDigiAlgo
DigiSimLinkProducer::~DigiSimLinkProducer ( )
virtual

Definition at line 91 of file DigiSimLinkProducer.cc.

References theDigiAlgo.

91  {
92  delete theDigiAlgo;
93 }
DigiSimLinkAlgorithm * theDigiAlgo

Member Function Documentation

void DigiSimLinkProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 96 of file DigiSimLinkProducer.cc.

References conf_, compareJSON::const, geometryType, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventSetup::getData(), edm::RandomNumberGenerator::getEngine(), edm::ParameterSet::getParameter(), SimHitSelectorFromDB::getSimHit(), i, edm::ESHandleBase::isValid(), DigiSimLinkAlgorithm::make_link(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), DigiSimLinkAlgorithm::run(), DigiSimLinkAlgorithm::setParticleDataTable(), SimHitMap, SimHitSelectorFromDB_, edm::Event::streamID(), AlCaHLTBitMon_QueryRunRegistry::string, theDetIdList, theDigiAlgo, theDigiLinkVector, theDigiVector, theRawDigiVector, trackerContainers, useConfFromDB, and zeroSuppression.

97 {
99  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
100 
101  // Step A: Get Inputs
103  iSetup.getData( pdt );
104 
105  if(useConfFromDB){
107  iSetup.get<SiStripDetCablingRcd>().get( detCabling );
108  detCabling->addConnected(theDetIdList);
109  }
110 
112  std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
113  for(uint32_t i = 0; i< trackerContainers.size();i++){
114  iEvent.getByLabel("mix",trackerContainers[i],cf_simhit);
115  cf_simhitvec.push_back(cf_simhit.product());
116  }
117 
118  std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
119 
120  //Loop on PSimHit
121  SimHitMap.clear();
122 
123  //inside SimHitSelectorFromDb add the counter information from the original allhits collection
124  std::vector<std::pair<const PSimHit*,int> > trackerHits(SimHitSelectorFromDB_.getSimHit(allTrackerHits,theDetIdList));
125  std::vector<std::pair<const PSimHit*,int> >::iterator isim;
126  for (isim=trackerHits.begin() ; isim!= trackerHits.end();isim++) {
127  //make a pair = <*isim, counter> and save also position in the vector for DigiSimLink
128  SimHitMap[((*isim).first)->detUnitId()].push_back(*isim);
129  }
130 
132  iSetup.get<TrackerDigiGeometryRecord>().get(geometryType,pDD);
133 
135  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
136 
137  //get gain noise pedestal lorentzAngle from ES handle
138  edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
139  edm::ESHandle<SiStripGain> gainHandle;
140  edm::ESHandle<SiStripNoises> noiseHandle;
141  edm::ESHandle<SiStripThreshold> thresholdHandle;
142  edm::ESHandle<SiStripPedestals> pedestalHandle;
143  edm::ESHandle<SiStripBadStrip> deadChannelHandle;
144  std::string LAname = conf_.getParameter<std::string>("LorentzAngle");
145  iSetup.get<SiStripLorentzAngleSimRcd>().get(LAname,lorentzAngleHandle);
146  std::string gainLabel = conf_.getParameter<std::string>("Gain");
147  iSetup.get<SiStripGainSimRcd>().get(gainLabel,gainHandle);
148  iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
149  iSetup.get<SiStripThresholdRcd>().get(thresholdHandle);
150  iSetup.get<SiStripPedestalsRcd>().get(pedestalHandle);
151  iSetup.get<SiStripBadChannelRcd>().get(deadChannelHandle);
152 
153  //Retrieve tracker topology from geometry
155  iSetup.get<IdealGeometryRecord>().get(tTopoHand);
156  const TrackerTopology *tTopo=tTopoHand.product();
157 
159 
160  // Step B: LOOP on StripGeomDetUnit
161  theDigiVector.reserve(10000);
162  theDigiVector.clear();
163  theDigiLinkVector.reserve(10000);
164  theDigiLinkVector.clear();
165 
166  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){
167  if(useConfFromDB){
168  //apply the cable map _before_ digitization: consider only the detis that are connected
169  if(theDetIdList.find((*iu)->geographicalId().rawId())==theDetIdList.end())
170  continue;
171  }
172  GlobalVector bfield=pSetup->inTesla((*iu)->surface().position());
173  auto sgd = dynamic_cast<StripGeomDetUnit const*>((*iu));
174  if (sgd != 0){
175  edm::DetSet<SiStripDigi> collectorZS((*iu)->geographicalId().rawId());
176  edm::DetSet<SiStripRawDigi> collectorRaw((*iu)->geographicalId().rawId());
177  edm::DetSet<StripDigiSimLink> linkcollector((*iu)->geographicalId().rawId());
178  float langle = (lorentzAngleHandle.isValid()) ? lorentzAngleHandle->getLorentzAngle((*iu)->geographicalId().rawId()) : 0.;
179  theDigiAlgo->run(collectorZS,collectorRaw,SimHitMap[(*iu)->geographicalId().rawId()],sgd,bfield,langle,
180  gainHandle,thresholdHandle,noiseHandle,pedestalHandle, deadChannelHandle, tTopo, engine);
181  if(zeroSuppression){
182  if(collectorZS.data.size()>0){
183  theDigiVector.push_back(collectorZS);
184  if(SimHitMap[(*iu)->geographicalId().rawId()].size()>0){
185  linkcollector.data = theDigiAlgo->make_link();
186  if(linkcollector.data.size()>0)
187  theDigiLinkVector.push_back(linkcollector);
188  }
189  }
190  }else{
191  if(collectorRaw.data.size()>0){
192  theRawDigiVector.push_back(collectorRaw);
193  if(SimHitMap[(*iu)->geographicalId().rawId()].size()>0){
194  linkcollector.data = theDigiAlgo->make_link();
195  if(linkcollector.data.size()>0)
196  theDigiLinkVector.push_back(linkcollector);
197  }
198  }
199  }
200  }
201  }
202 
203  // Step C: create output collection
204  std::auto_ptr<edm::DetSetVector<StripDigiSimLink> > outputlink(new edm::DetSetVector<StripDigiSimLink>(theDigiLinkVector));
205  // Step D: write output to file
206  iEvent.put(outputlink);
207 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< edm::DetSet< StripDigiSimLink > > theDigiLinkVector
std::vector< StripDigiSimLink > make_link()
edm::ParameterSet conf_
void setParticleDataTable(const ParticleDataTable *pardt)
std::vector< std::pair< const PSimHit *, int > > getSimHit(std::auto_ptr< MixCollection< PSimHit > > &, std::map< uint32_t, std::vector< int > > &)
int iEvent
Definition: GenABIO.cc:230
void run(edm::DetSet< SiStripDigi > &, edm::DetSet< SiStripRawDigi > &, const std::vector< std::pair< const PSimHit *, int > > &, StripGeomDetUnit const *, GlobalVector, float, edm::ESHandle< SiStripGain > &, edm::ESHandle< SiStripThreshold > &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripPedestals > &, edm::ESHandle< SiStripBadStrip > &, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
std::map< uint32_t, std::vector< int > > theDetIdList
DigiSimLinkAlgorithm * theDigiAlgo
T const * product() const
Definition: Handle.h:81
T const * product() const
Definition: ESHandle.h:86
string const
Definition: compareJSON.py:14
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
SimHitSelectorFromDB SimHitSelectorFromDB_
std::vector< edm::DetSet< SiStripDigi > > theDigiVector
std::vector< edm::DetSet< SiStripRawDigi > > theRawDigiVector
bool isValid() const
Definition: ESHandle.h:47

Member Data Documentation

std::string DigiSimLinkProducer::alias
private

Definition at line 57 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer().

edm::ParameterSet DigiSimLinkProducer::conf_
private

Definition at line 52 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

std::string DigiSimLinkProducer::geometryType
private

Definition at line 56 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

int DigiSimLinkProducer::numStrips
private

Definition at line 55 of file DigiSimLinkProducer.h.

simhit_map DigiSimLinkProducer::SimHitMap
private

Definition at line 54 of file DigiSimLinkProducer.h.

Referenced by produce().

SimHitSelectorFromDB DigiSimLinkProducer::SimHitSelectorFromDB_
private

Definition at line 48 of file DigiSimLinkProducer.h.

Referenced by produce().

std::map<uint32_t, std::vector<int> > DigiSimLinkProducer::theDetIdList
private

Definition at line 47 of file DigiSimLinkProducer.h.

Referenced by produce().

DigiSimLinkAlgorithm* DigiSimLinkProducer::theDigiAlgo
private

Definition at line 45 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), produce(), and ~DigiSimLinkProducer().

std::vector<edm::DetSet<StripDigiSimLink> > DigiSimLinkProducer::theDigiLinkVector
private

Definition at line 51 of file DigiSimLinkProducer.h.

Referenced by produce().

std::vector<edm::DetSet<SiStripDigi> > DigiSimLinkProducer::theDigiVector
private

Definition at line 49 of file DigiSimLinkProducer.h.

Referenced by produce().

std::vector<edm::DetSet<SiStripRawDigi> > DigiSimLinkProducer::theRawDigiVector
private

Definition at line 50 of file DigiSimLinkProducer.h.

Referenced by produce().

SiStripFedZeroSuppression* DigiSimLinkProducer::theSiFEDZeroSuppress
private

Definition at line 46 of file DigiSimLinkProducer.h.

vstring DigiSimLinkProducer::trackerContainers
private

Definition at line 53 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

bool DigiSimLinkProducer::useConfFromDB
private

Definition at line 59 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

bool DigiSimLinkProducer::zeroSuppression
private

Definition at line 58 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().