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 Member Functions | Private Attributes
HGCDigitizer Class Reference

#include <HGCDigitizer.h>

Public Member Functions

void accumulate (edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
 handle SimHit accumulation More...
 
void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
 
void accumulate (edm::Handle< edm::PCaloHitContainer > const &hits, int bxCrossing, const edm::ESHandle< HGCalGeometry > &geom, CLHEP::HepRandomEngine *)
 
void beginRun (const edm::EventSetup &es)
 actions at the start/end of run More...
 
std::string digiCollection ()
 
void endRun ()
 
void finalizeEvent (edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
 
 HGCDigitizer (const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
 
void initializeEvent (edm::Event const &e, edm::EventSetup const &c)
 actions at the start/end of event More...
 
bool producesEEDigis ()
 
bool producesHEbackDigis ()
 
bool producesHEfrontDigis ()
 
 ~HGCDigitizer ()
 

Private Member Functions

void resetSimHitDataAccumulator ()
 

Private Attributes

int bxTime_
 
bool checkValidDetIds_
 
std::string digiCollection_
 
int digitizationType_
 
std::string hitCollection_
 
int maxSimHitsAccTime_
 
ForwardSubdetector mySubDet_
 
float refSpeed_
 
std::unique_ptr
< HGCSimHitDataAccumulator
simHitAccumulator_
 
std::unique_ptr< HGCEEDigitizertheHGCEEDigitizer_
 
std::unique_ptr
< HGCHEbackDigitizer
theHGCHEbackDigitizer_
 
std::unique_ptr
< HGCHEfrontDigitizer
theHGCHEfrontDigitizer_
 
float tofDelay_
 
bool useAllChannels_
 
int verbosity_
 

Detailed Description

Definition at line 34 of file HGCDigitizer.h.

Constructor & Destructor Documentation

HGCDigitizer::HGCDigitizer ( const edm::ParameterSet ps,
edm::ConsumesCollector iC 
)
explicit

Definition at line 20 of file HGCDigitizer.cc.

References bxTime_, edm::ConsumesCollector::consumes(), digiCollection_, digitizationType_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HGCEE, HGCHEB, HGCHEF, hitCollection_, HLT_25ns14e33_v1_cff::InputTag, maxSimHitsAccTime_, mySubDet_, AlCaHLTBitMon_QueryRunRegistry::string, theHGCEEDigitizer_, theHGCHEbackDigitizer_, theHGCHEfrontDigitizer_, tofDelay_, useAllChannels_, and verbosity_.

20  :
21  checkValidDetIds_(true),
24  refSpeed_(0.1*CLHEP::c_light) { //[CLHEP::c_light]=mm/ns convert to cm/ns
25 
26  //configure from cfg
27  hitCollection_ = ps.getParameter< std::string >("hitCollection");
28  digiCollection_ = ps.getParameter< std::string >("digiCollection");
29  maxSimHitsAccTime_ = ps.getParameter< uint32_t >("maxSimHitsAccTime");
30  bxTime_ = ps.getParameter< int32_t >("bxTime");
31  digitizationType_ = ps.getParameter< uint32_t >("digitizationType");
32  useAllChannels_ = ps.getParameter< bool >("useAllChannels");
33  verbosity_ = ps.getUntrackedParameter< int32_t >("verbosity",0);
34  tofDelay_ = ps.getParameter< double >("tofDelay");
35 
36  iC.consumes<std::vector<PCaloHit> >(edm::InputTag("g4SimHits",hitCollection_));
37 
38  if(hitCollection_.find("HitsEE")!=std::string::npos) {
40  theHGCEEDigitizer_=std::unique_ptr<HGCEEDigitizer>(new HGCEEDigitizer(ps) );
41  }
42  if(hitCollection_.find("HitsHEfront")!=std::string::npos) {
44  theHGCHEfrontDigitizer_=std::unique_ptr<HGCHEfrontDigitizer>(new HGCHEfrontDigitizer(ps) );
45  }
46  if(hitCollection_.find("HitsHEback")!=std::string::npos) {
48  theHGCHEbackDigitizer_=std::unique_ptr<HGCHEbackDigitizer>(new HGCHEbackDigitizer(ps) );
49  }
50 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:90
int digitizationType_
Definition: HGCDigitizer.h:76
std::string hitCollection_
Definition: HGCDigitizer.h:73
bool useAllChannels_
Definition: HGCDigitizer.h:93
bool checkValidDetIds_
Definition: HGCDigitizer.h:70
std::string digiCollection_
Definition: HGCDigitizer.h:73
float refSpeed_
Definition: HGCDigitizer.h:97
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:86
int maxSimHitsAccTime_
Definition: HGCDigitizer.h:79
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:87
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:85
std::unordered_map< uint32_t, HGCSimHitData > HGCSimHitDataAccumulator
std::unique_ptr< HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:81
HGCDigitizer::~HGCDigitizer ( )
inline

Definition at line 39 of file HGCDigitizer.h.

39 { }

Member Function Documentation

void HGCDigitizer::accumulate ( edm::Event const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  engine 
)

handle SimHit accumulation

Definition at line 80 of file HGCDigitizer.cc.

References relativeConstraints::geom, edm::EventSetup::get(), edm::Event::getByLabel(), hitCollection_, edm::HandleBase::isValid(), producesEEDigis(), producesHEbackDigis(), and producesHEfrontDigis().

Referenced by accumulate().

80  {
81 
82  //get inputs
84  e.getByLabel(edm::InputTag("g4SimHits",hitCollection_),hits);
85  if( !hits.isValid() ){
86  edm::LogError("HGCDigitizer") << " @ accumulate : can't find " << hitCollection_ << " collection of g4SimHits";
87  return;
88  }
89 
90  //get geometry
92  if( producesEEDigis() ) eventSetup.get<IdealGeometryRecord>().get("HGCalEESensitive" , geom);
93  if( producesHEfrontDigis() ) eventSetup.get<IdealGeometryRecord>().get("HGCalHESiliconSensitive" , geom);
94  if( producesHEbackDigis() ) eventSetup.get<IdealGeometryRecord>().get("HGCalHEScintillatorSensitive", geom);
95 
96  //accumulate in-time the main event
97  accumulate(hits, 0, geom, engine);
98 }
std::string hitCollection_
Definition: HGCDigitizer.h:73
bool producesEEDigis()
Definition: HGCDigitizer.h:56
bool isValid() const
Definition: HandleBase.h:75
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:57
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
handle SimHit accumulation
Definition: HGCDigitizer.cc:80
bool producesHEbackDigis()
Definition: HGCDigitizer.h:58
void HGCDigitizer::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 101 of file HGCDigitizer.cc.

References accumulate(), PileUpEventPrincipal::bunchCrossing(), relativeConstraints::geom, edm::EventSetup::get(), PileUpEventPrincipal::getByLabel(), hitCollection_, edm::HandleBase::isValid(), producesEEDigis(), producesHEbackDigis(), and producesHEfrontDigis().

101  {
102 
103  //get inputs
105  e.getByLabel(edm::InputTag("g4SimHits",hitCollection_),hits);
106  if( !hits.isValid() ){
107  edm::LogError("HGCDigitizer") << " @ accumulate : can't find " << hitCollection_ << " collection of g4SimHits";
108  return;
109  }
110 
111  //get geometry
113  if( producesEEDigis() ) eventSetup.get<IdealGeometryRecord>().get("HGCalEESensitive" , geom);
114  if( producesHEfrontDigis() ) eventSetup.get<IdealGeometryRecord>().get("HGCalHESiliconSensitive" , geom);
115  if( producesHEbackDigis() ) eventSetup.get<IdealGeometryRecord>().get("HGCalHEScintillatorSensitive", geom);
116 
117  //accumulate for the simulated bunch crossing
118  accumulate(hits, e.bunchCrossing(), geom, engine);
119 }
std::string hitCollection_
Definition: HGCDigitizer.h:73
bool producesEEDigis()
Definition: HGCDigitizer.h:56
bool isValid() const
Definition: HandleBase.h:75
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:57
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
handle SimHit accumulation
Definition: HGCDigitizer.cc:80
bool producesHEbackDigis()
Definition: HGCDigitizer.h:58
void HGCDigitizer::accumulate ( edm::Handle< edm::PCaloHitContainer > const &  hits,
int  bxCrossing,
const edm::ESHandle< HGCalGeometry > &  geom,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 122 of file HGCDigitizer.cc.

References bxTime_, checkValidDetIds_, gather_cfg::cout, HGCalTopology::dddConstants(), HGCalTopology::detectorType(), hitCollection_, edm::ESHandleBase::isValid(), mySubDet_, producesEEDigis(), refSpeed_, simHitAccumulator_, HGCalDDDConstants::simToReco(), tofDelay_, useAllChannels_, and verbosity_.

122  {
123  if(!geom.isValid()) return;
124  const HGCalTopology &topo=geom->topology();
125  const HGCalDDDConstants &dddConst=topo.dddConstants();
126 
127  for(edm::PCaloHitContainer::const_iterator hit_it = hits->begin(); hit_it != hits->end(); ++hit_it) {
128  HGCalDetId simId( hit_it->id() );
129 
130  //skip this hit if after ganging it is not valid
131  int layer(simId.layer()), cell(simId.cell());
132  std::pair<int,int> recoLayerCell=dddConst.simToReco(cell,layer,topo.detectorType());
133  cell = recoLayerCell.first;
134  layer = recoLayerCell.second;
135  if(layer<0 || cell<0) continue;
136 
137  //assign the RECO DetId
138  DetId id( producesEEDigis() ?
139  (uint32_t)HGCEEDetId(mySubDet_,simId.zside(),layer,simId.sector(),simId.subsector(),cell):
140  (uint32_t)HGCHEDetId(mySubDet_,simId.zside(),layer,simId.sector(),simId.subsector(),cell) );
141 
142  if (verbosity_>0) {
143  if (producesEEDigis())
144  std::cout << "HGCDigitizer: i/p " << simId << " o/p " << HGCEEDetId(id) << std::endl;
145  else
146  std::cout << "HGCDigitizer: i/p " << simId << " o/p " << HGCHEDetId(id) << std::endl;
147  }
148 
149  //distance to the center of the detector
150  float dist2center( geom->getPosition(id).mag() );
151 
152  //hit time: [time()]=ns [centerDist]=cm [refSpeed_]=cm/ns + delay by 1ns
153  //accumulate in 6 buckets of 25ns (4 pre-samples, 1 in-time, 1 post-sample)
154  float tof(hit_it->time()-dist2center/refSpeed_+tofDelay_);
155  int itime=floor( tof/bxTime_ ) ;
156 
157  //no need to add bx crossing - tof comes already corrected from the mixing module
158  //itime += bxCrossing;
159  itime += 4;
160 
161  if(itime<0 || itime>5) continue;
162 
163  //energy deposited
164  HGCSimEn_t ien( hit_it->energy() );
165 
166  //check if already existing (perhaps could remove this in the future - 2nd event should have all defined)
167  HGCSimHitDataAccumulator::iterator simHitIt=simHitAccumulator_->find(id);
168  if(simHitIt==simHitAccumulator_->end()) {
169  HGCSimHitData baseData;
170  baseData.fill(0.);
171  simHitAccumulator_->insert( std::make_pair(id,baseData) );
172  simHitIt=simHitAccumulator_->find(id);
173  }
174 
175  //check if time index is ok and store energy
176  if(itime >= (int)simHitIt->second.size() ) continue;
177  (simHitIt->second)[itime] += ien;
178  }
179 
180  //add base data for noise simulation
181  if(!checkValidDetIds_) return;
182  if(!geom.isValid()) return;
183  HGCSimHitData baseData;
184  baseData.fill(0.);
185  const std::vector<DetId> &validIds=geom->getValidDetIds();
186  int nadded(0);
187  if (useAllChannels_) {
188  for(std::vector<DetId>::const_iterator it=validIds.begin(); it!=validIds.end(); it++) {
189  uint32_t id(it->rawId());
190  if(simHitAccumulator_->find(id)!=simHitAccumulator_->end()) continue;
191  simHitAccumulator_->insert( std::make_pair(id,baseData) );
192  nadded++;
193  }
194  }
195  if (verbosity_ > 0)
196  std::cout << "HGCDigitizer:Added " << nadded << ":" << validIds.size()
197  << " detIds without " << hitCollection_
198  << " in first event processed" << std::endl;
199  checkValidDetIds_=false;
200 }
ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:90
std::string hitCollection_
Definition: HGCDigitizer.h:73
bool useAllChannels_
Definition: HGCDigitizer.h:93
bool checkValidDetIds_
Definition: HGCDigitizer.h:70
bool detectorType() const
int zside(DetId const &)
std::array< HGCSimEn_t, 6 > HGCSimHitData
bool producesEEDigis()
Definition: HGCDigitizer.h:56
float refSpeed_
Definition: HGCDigitizer.h:97
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
std::pair< int, int > simToReco(int cell, int layer, bool half) const
Definition: DetId.h:18
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:97
std::unique_ptr< HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:81
float HGCSimEn_t
tuple cout
Definition: gather_cfg.py:121
bool isValid() const
Definition: ESHandle.h:47
void HGCDigitizer::beginRun ( const edm::EventSetup es)

actions at the start/end of run

Definition at line 203 of file HGCDigitizer.cc.

203 { }
std::string HGCDigitizer::digiCollection ( )
inline

Definition at line 59 of file HGCDigitizer.h.

References digiCollection_.

Referenced by finalizeEvent().

59 { return digiCollection_; }
std::string digiCollection_
Definition: HGCDigitizer.h:73
void HGCDigitizer::endRun ( void  )

Definition at line 206 of file HGCDigitizer.cc.

206 { }
void HGCDigitizer::finalizeEvent ( edm::Event e,
edm::EventSetup const &  c,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 58 of file HGCDigitizer.cc.

References digiCollection(), digitizationType_, producesEEDigis(), producesHEbackDigis(), producesHEfrontDigis(), edm::Event::put(), simHitAccumulator_, theHGCEEDigitizer_, theHGCHEbackDigitizer_, and theHGCHEfrontDigitizer_.

58  {
59  if( producesEEDigis() ) {
60  std::auto_ptr<HGCEEDigiCollection> digiResult(new HGCEEDigiCollection() );
62  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " EE hits";
63  e.put(digiResult,digiCollection());
64  }
65  if( producesHEfrontDigis()) {
66  std::auto_ptr<HGCHEDigiCollection> digiResult(new HGCHEDigiCollection() );
68  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " HE front hits";
69  e.put(digiResult,digiCollection());
70  }
71  if( producesHEbackDigis() ) {
72  std::auto_ptr<HGCHEDigiCollection> digiResult(new HGCHEDigiCollection() );
74  edm::LogInfo("HGCDigitizer") << " @ finalize event - produced " << digiResult->size() << " HE back hits";
75  e.put(digiResult,digiCollection());
76  }
77 }
edm::SortedCollection< HGCEEDataFrame > HGCEEDigiCollection
int digitizationType_
Definition: HGCDigitizer.h:76
bool producesEEDigis()
Definition: HGCDigitizer.h:56
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
bool producesHEfrontDigis()
Definition: HGCDigitizer.h:57
std::unique_ptr< HGCHEbackDigitizer > theHGCHEbackDigitizer_
Definition: HGCDigitizer.h:86
bool producesHEbackDigis()
Definition: HGCDigitizer.h:58
std::unique_ptr< HGCHEfrontDigitizer > theHGCHEfrontDigitizer_
Definition: HGCDigitizer.h:87
std::unique_ptr< HGCEEDigitizer > theHGCEEDigitizer_
Definition: HGCDigitizer.h:85
std::unique_ptr< HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:81
std::string digiCollection()
Definition: HGCDigitizer.h:59
edm::SortedCollection< HGCHEDataFrame > HGCHEDigiCollection
void HGCDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)

actions at the start/end of event

Definition at line 53 of file HGCDigitizer.cc.

References resetSimHitDataAccumulator().

53  {
55 }
void resetSimHitDataAccumulator()
bool HGCDigitizer::producesEEDigis ( )
inline

Definition at line 56 of file HGCDigitizer.h.

References HGCEE, and mySubDet_.

Referenced by accumulate(), and finalizeEvent().

ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:90
bool HGCDigitizer::producesHEbackDigis ( )
inline

Definition at line 58 of file HGCDigitizer.h.

References HGCHEB, and mySubDet_.

Referenced by accumulate(), and finalizeEvent().

ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:90
bool HGCDigitizer::producesHEfrontDigis ( )
inline

Definition at line 57 of file HGCDigitizer.h.

References HGCHEF, and mySubDet_.

Referenced by accumulate(), and finalizeEvent().

ForwardSubdetector mySubDet_
Definition: HGCDigitizer.h:90
void HGCDigitizer::resetSimHitDataAccumulator ( )
private

Definition at line 209 of file HGCDigitizer.cc.

References simHitAccumulator_.

Referenced by initializeEvent().

209  {
210  for( HGCSimHitDataAccumulator::iterator it = simHitAccumulator_->begin(); it!=simHitAccumulator_->end(); it++) it->second.fill(0.);
211 }
std::unique_ptr< HGCSimHitDataAccumulator > simHitAccumulator_
Definition: HGCDigitizer.h:81

Member Data Documentation

int HGCDigitizer::bxTime_
private

Definition at line 80 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

bool HGCDigitizer::checkValidDetIds_
private

Definition at line 70 of file HGCDigitizer.h.

Referenced by accumulate().

std::string HGCDigitizer::digiCollection_
private

Definition at line 73 of file HGCDigitizer.h.

Referenced by digiCollection(), and HGCDigitizer().

int HGCDigitizer::digitizationType_
private

Definition at line 76 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

std::string HGCDigitizer::hitCollection_
private

Definition at line 73 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

int HGCDigitizer::maxSimHitsAccTime_
private

Definition at line 79 of file HGCDigitizer.h.

Referenced by HGCDigitizer().

ForwardSubdetector HGCDigitizer::mySubDet_
private
float HGCDigitizer::refSpeed_
private

Definition at line 97 of file HGCDigitizer.h.

Referenced by accumulate().

std::unique_ptr<HGCSimHitDataAccumulator> HGCDigitizer::simHitAccumulator_
private

Definition at line 81 of file HGCDigitizer.h.

Referenced by accumulate(), finalizeEvent(), and resetSimHitDataAccumulator().

std::unique_ptr<HGCEEDigitizer> HGCDigitizer::theHGCEEDigitizer_
private

Definition at line 85 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

std::unique_ptr<HGCHEbackDigitizer> HGCDigitizer::theHGCHEbackDigitizer_
private

Definition at line 86 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

std::unique_ptr<HGCHEfrontDigitizer> HGCDigitizer::theHGCHEfrontDigitizer_
private

Definition at line 87 of file HGCDigitizer.h.

Referenced by finalizeEvent(), and HGCDigitizer().

float HGCDigitizer::tofDelay_
private

Definition at line 100 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

bool HGCDigitizer::useAllChannels_
private

Definition at line 93 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().

int HGCDigitizer::verbosity_
private

Definition at line 94 of file HGCDigitizer.h.

Referenced by accumulate(), and HGCDigitizer().