CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
DigiSimLinkProducer Class Reference

#include <DigiSimLinkProducer.h>

Inheritance diagram for DigiSimLinkProducer:
edm::stream::EDProducer<>

Public Member Functions

 DigiSimLinkProducer (const edm::ParameterSet &conf)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~DigiSimLinkProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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_, 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 ( )
override

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 
)
override

Definition at line 96 of file DigiSimLinkProducer.cc.

References SiStripDetCabling::addConnected(), conf_, TrackerGeometry::detUnits(), geometryType, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventSetup::getData(), edm::RandomNumberGenerator::getEngine(), SiStripLorentzAngle::getLorentzAngle(), edm::ParameterSet::getParameter(), SimHitSelectorFromDB::getSimHit(), mps_fire::i, MagneticField::inTesla(), edm::ESHandleBase::isValid(), DigiSimLinkAlgorithm::make_link(), eostools::move(), edm::Handle< T >::product(), edm::ESHandle< T >::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::unique_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<TrackerTopologyRcd>().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( const auto& iu : pDD->detUnits()) {
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 != nullptr){
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.empty()){
183  theDigiVector.push_back(collectorZS);
184  if(!SimHitMap[iu->geographicalId().rawId()].empty()){
185  linkcollector.data = theDigiAlgo->make_link();
186  if(!linkcollector.data.empty())
187  theDigiLinkVector.push_back(linkcollector);
188  }
189  }
190  }else{
191  if(!collectorRaw.data.empty()){
192  theRawDigiVector.push_back(collectorRaw);
193  if(!SimHitMap[iu->geographicalId().rawId()].empty()){
194  linkcollector.data = theDigiAlgo->make_link();
195  if(!linkcollector.data.empty())
196  theDigiLinkVector.push_back(linkcollector);
197  }
198  }
199  }
200  }
201  }
202 
203  // Step C: create output collection
204  std::unique_ptr<edm::DetSetVector<StripDigiSimLink> > outputlink(new edm::DetSetVector<StripDigiSimLink>(theDigiLinkVector));
205  // Step D: write output to file
206  iEvent.put(std::move(outputlink));
207 }
T getParameter(std::string const &) const
std::vector< std::pair< const PSimHit *, int > > getSimHit(std::unique_ptr< MixCollection< PSimHit > > &, std::map< uint32_t, std::vector< int > > &)
std::vector< edm::DetSet< StripDigiSimLink > > theDigiLinkVector
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
std::vector< StripDigiSimLink > make_link()
edm::ParameterSet conf_
void setParticleDataTable(const ParticleDataTable *pardt)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int iEvent
Definition: GenABIO.cc:230
float getLorentzAngle(const uint32_t &) const
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
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
T const * product() const
Definition: Handle.h:81
SimHitSelectorFromDB SimHitSelectorFromDB_
std::vector< edm::DetSet< SiStripDigi > > theDigiVector
std::vector< edm::DetSet< SiStripRawDigi > > theRawDigiVector
bool isValid() const
Definition: ESHandle.h:47
T const * product() const
Definition: ESHandle.h:86
void addConnected(std::map< uint32_t, std::vector< int > > &) const
def move(src, dest)
Definition: eostools.py:510

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().