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 ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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
 
CLHEP::HepRandomEngine * rndEngine
 
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
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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 34 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 46 of file DigiSimLinkProducer.h.

typedef simhit_map::iterator DigiSimLinkProducer::simhit_map_iterator
private

Definition at line 47 of file DigiSimLinkProducer.h.

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

Definition at line 45 of file DigiSimLinkProducer.h.

Constructor & Destructor Documentation

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

Definition at line 63 of file DigiSimLinkProducer.cc.

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

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

Definition at line 89 of file DigiSimLinkProducer.cc.

References theDigiAlgo.

89  {
90  delete theDigiAlgo;
91 }
DigiSimLinkAlgorithm * theDigiAlgo

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 94 of file DigiSimLinkProducer.cc.

References conf_, geometryType, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventSetup::getData(), 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_, AlCaHLTBitMon_QueryRunRegistry::string, theDetIdList, theDigiAlgo, theDigiLinkVector, theDigiVector, theRawDigiVector, trackerContainers, useConfFromDB, and zeroSuppression.

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

Member Data Documentation

std::string DigiSimLinkProducer::alias
private

Definition at line 62 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer().

edm::ParameterSet DigiSimLinkProducer::conf_
private

Definition at line 56 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

std::string DigiSimLinkProducer::geometryType
private

Definition at line 61 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

int DigiSimLinkProducer::numStrips
private

Definition at line 59 of file DigiSimLinkProducer.h.

CLHEP::HepRandomEngine* DigiSimLinkProducer::rndEngine
private

Definition at line 60 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer().

simhit_map DigiSimLinkProducer::SimHitMap
private

Definition at line 58 of file DigiSimLinkProducer.h.

Referenced by produce().

SimHitSelectorFromDB DigiSimLinkProducer::SimHitSelectorFromDB_
private

Definition at line 52 of file DigiSimLinkProducer.h.

Referenced by produce().

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

Definition at line 51 of file DigiSimLinkProducer.h.

Referenced by produce().

DigiSimLinkAlgorithm* DigiSimLinkProducer::theDigiAlgo
private

Definition at line 49 of file DigiSimLinkProducer.h.

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

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

Definition at line 55 of file DigiSimLinkProducer.h.

Referenced by produce().

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

Definition at line 53 of file DigiSimLinkProducer.h.

Referenced by produce().

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

Definition at line 54 of file DigiSimLinkProducer.h.

Referenced by produce().

SiStripFedZeroSuppression* DigiSimLinkProducer::theSiFEDZeroSuppress
private

Definition at line 50 of file DigiSimLinkProducer.h.

vstring DigiSimLinkProducer::trackerContainers
private

Definition at line 57 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

bool DigiSimLinkProducer::useConfFromDB
private

Definition at line 64 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().

bool DigiSimLinkProducer::zeroSuppression
private

Definition at line 63 of file DigiSimLinkProducer.h.

Referenced by DigiSimLinkProducer(), and produce().