CMS 3D CMS Logo

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

#include <EcalTBWeightUncalibRecHitProducer.h>

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

Public Types

typedef std::vector< double > EcalRecoAmplitudes
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 EcalTBWeightUncalibRecHitProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 ~EcalTBWeightUncalibRecHitProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

EcalUncalibRecHitRecWeightsAlgo< EBDataFrameEBalgo_
 
edm::InputTag EBdigiCollection_
 
std::string EBhitCollection_
 
EcalUncalibRecHitRecWeightsAlgo< EEDataFrameEEalgo_
 
edm::InputTag EEdigiCollection_
 
std::string EEhitCollection_
 
int nbTimeBin_
 
edm::InputTag tdcRecInfoCollection_
 
const EBShape testbeamEBShape
 
const EEShape testbeamEEShape
 
bool use2004OffsetConvention_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

produce ECAL uncalibrated rechits from dataframes

$Alex Zabi$ Modification to detect first sample to switch gain. used for amplitude recontruction at high energy Add TDC convention option (P. Meridiani)

Definition at line 19 of file EcalTBWeightUncalibRecHitProducer.h.

Member Typedef Documentation

◆ EcalRecoAmplitudes

Definition at line 21 of file EcalTBWeightUncalibRecHitProducer.h.

Constructor & Destructor Documentation

◆ EcalTBWeightUncalibRecHitProducer()

EcalTBWeightUncalibRecHitProducer::EcalTBWeightUncalibRecHitProducer ( const edm::ParameterSet ps)
explicit

Definition at line 48 of file EcalTBWeightUncalibRecHitProducer.cc.

50  false)), // Shapes have been updated in 2018 such as to be able to fetch shape from the DB if EBShape(true)//EEShape(true) are used
52  false)) // use false as argument if you would rather prefer to use Phase I hardcoded shapes (18.05.2018 K. Theofilatos)
53 {
54  EBdigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
55  EEdigiCollection_ = ps.getParameter<edm::InputTag>("EEdigiCollection");
56  tdcRecInfoCollection_ = ps.getParameter<edm::InputTag>("tdcRecInfoCollection");
57  EBhitCollection_ = ps.getParameter<std::string>("EBhitCollection");
58  EEhitCollection_ = ps.getParameter<std::string>("EEhitCollection");
59  nbTimeBin_ = ps.getParameter<int>("nbTimeBin");
60  use2004OffsetConvention_ = ps.getUntrackedParameter<bool>("use2004OffsetConvention", false);
61  produces<EBUncalibratedRecHitCollection>(EBhitCollection_);
62  produces<EEUncalibratedRecHitCollection>(EEhitCollection_);
63 }

References EBdigiCollection_, EBhitCollection_, EEdigiCollection_, EEhitCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), nbTimeBin_, AlCaHLTBitMon_QueryRunRegistry::string, tdcRecInfoCollection_, and use2004OffsetConvention_.

◆ ~EcalTBWeightUncalibRecHitProducer()

EcalTBWeightUncalibRecHitProducer::~EcalTBWeightUncalibRecHitProducer ( )
override

Definition at line 65 of file EcalTBWeightUncalibRecHitProducer.cc.

65 {}

Member Function Documentation

◆ produce()

void EcalTBWeightUncalibRecHitProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 67 of file EcalTBWeightUncalibRecHitProducer.cc.

67  {
68  using namespace edm;
69 
70  Handle<EBDigiCollection> pEBDigis;
71  const EBDigiCollection* EBdigis = nullptr;
72  if (!EBdigiCollection_.label().empty() || !EBdigiCollection_.instance().empty()) {
73  // evt.getByLabel( digiProducer_, EBdigiCollection_, pEBDigis);
74  evt.getByLabel(EBdigiCollection_, pEBDigis);
75  if (!pEBDigis.isValid()) {
76  edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product " << EBdigiCollection_;
77  } else {
78  EBdigis = pEBDigis.product(); // get a ptr to the produc
79 #ifdef DEBUG
80  LogDebug("EcalUncalibRecHitInfo") << "total # EBdigis: " << EBdigis->size();
81 #endif
82  }
83  }
84 
85  Handle<EEDigiCollection> pEEDigis;
86  const EEDigiCollection* EEdigis = nullptr;
87 
88  if (!EEdigiCollection_.label().empty() || !EEdigiCollection_.instance().empty()) {
89  // evt.getByLabel( digiProducer_, EEdigiCollection_, pEEDigis);
90  evt.getByLabel(EEdigiCollection_, pEEDigis);
91  if (!pEEDigis.isValid()) {
92  edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product " << EEdigiCollection_;
93  } else {
94  EEdigis = pEEDigis.product(); // get a ptr to the produc
95 #ifdef DEBUG
96  LogDebug("EcalUncalibRecHitInfo") << "total # EEdigis: " << EEdigis->size();
97  // std::cout << "total # EEdigis: " << EEdigis->size() << std::endl;
98 #endif
99  }
100  }
101 
102  if (!EBdigis && !EEdigis)
103  return;
104 
105  Handle<EcalTBTDCRecInfo> pRecTDC;
106  const EcalTBTDCRecInfo* recTDC = nullptr;
107 
108  // evt.getByLabel( digiProducer_, EBdigiCollection_, pEBDigis);
109  evt.getByLabel(tdcRecInfoCollection_, pRecTDC);
110  if (pRecTDC.isValid()) {
111  recTDC = pRecTDC.product(); // get a ptr to the product
112  }
113 
114  // fetch map of groups of xtals
116  es.get<EcalWeightXtalGroupsRcd>().get(pGrp);
117  const EcalWeightXtalGroups* grp = pGrp.product();
118  if (!grp)
119  return;
120 
121  const EcalXtalGroupsMap& grpMap = grp->getMap();
122 
123  // Gain Ratios
125  es.get<EcalGainRatiosRcd>().get(pRatio);
126  const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
127 
128  // fetch TB weights
129 #ifdef DEBUG
130  LogDebug("EcalUncalibRecHitDebug") << "Fetching EcalTBWeights from DB ";
131  // std::cout <<"Fetching EcalTBWeights from DB " ;
132 #endif
134  es.get<EcalTBWeightsRcd>().get(pWgts);
135  const EcalTBWeights* wgts = pWgts.product();
136 
137  if (!wgts)
138  return;
139 
140 #ifdef DEBUG
141  LogDebug("EcalUncalibRecHitDebug") << "EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->getMap().size();
142  // std::cout << "EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->getMap().size() ;
143 #endif
144 
145  // fetch the pedestals from the cond DB via EventSetup
146 #ifdef DEBUG
147  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
148  // std::cout << "fetching pedestals....";
149 #endif
151  es.get<EcalPedestalsRcd>().get(pedHandle);
152  const EcalPedestalsMap& pedMap = pedHandle.product()->getMap(); // map of pedestals
153 #ifdef DEBUG
154  LogDebug("EcalUncalibRecHitDebug") << "done.";
155  // std::cout << "done." ;
156 #endif
157  // collection of reco'ed ampltudes to put in the event
158 
159  auto EBuncalibRechits = std::make_unique<EBUncalibratedRecHitCollection>();
160  auto EEuncalibRechits = std::make_unique<EEUncalibratedRecHitCollection>();
161 
162  EcalPedestalsMapIterator pedIter; // pedestal iterator
163 
164  EcalGainRatioMap::const_iterator gainIter; // gain iterator
165 
166  EcalXtalGroupsMap::const_iterator git; // group iterator
167 
168  EcalTBWeights::EcalTBWeightMap::const_iterator wit; //weights iterator
169  // loop over EB digis
170  //Getting the TDC bin
171  EcalTBWeights::EcalTDCId tdcid(int(nbTimeBin_ / 2) + 1);
172 
173  if (recTDC)
174  if (recTDC->offset() == -999.) {
175  edm::LogError("EcalUncalibRecHitError") << "TDC bin completely out of range. Returning";
176  return;
177  }
178 
179  if (EBdigis) {
180  for (unsigned int idig = 0; idig < EBdigis->size(); ++idig) {
181  EBDataFrame itdg = (*EBdigis)[idig];
182 
183  // counter_++; // verbosity counter
184 
185  // find pedestals for this channel
186 #ifdef DEBUG
187  LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << EBDetId(itdg.id());
188 #endif
189  pedIter = pedMap.find(itdg.id().rawId());
190  if (pedIter == pedMap.end()) {
191  edm::LogError("EcalUncalibRecHitError")
192  << "error!! could not find pedestals for channel: " << EBDetId(itdg.id())
193  << "\n no uncalib rechit will be made for this digi!";
194  continue;
195  }
196  const EcalPedestals::Item& aped = (*pedIter);
197  double pedVec[3];
198  double pedRMSVec[3];
199  pedVec[0] = aped.mean_x12;
200  pedVec[1] = aped.mean_x6;
201  pedVec[2] = aped.mean_x1;
202  pedRMSVec[0] = aped.rms_x12;
203  pedRMSVec[1] = aped.rms_x6;
204  pedRMSVec[2] = aped.rms_x1;
205 
206  // find gain ratios
207 #ifdef DEBUG
208  LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << EBDetId(itdg.id());
209 #endif
210  gainIter = gainMap.find(itdg.id().rawId());
211  if (gainIter == gainMap.end()) {
212  edm::LogError("EcalUncalibRecHitError")
213  << "error!! could not find gain ratios for channel: " << EBDetId(itdg.id())
214  << "\n no uncalib rechit will be made for this digi!";
215  continue;
216  }
217  const EcalMGPAGainRatio& aGain = (*gainIter);
218  double gainRatios[3];
219  gainRatios[0] = 1.;
220  gainRatios[1] = aGain.gain12Over6();
221  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
222 
223  // lookup group ID for this channel
224  git = grpMap.find(itdg.id().rawId());
225  if (git == grpMap.end()) {
226  edm::LogError("EcalUncalibRecHitError")
227  << "No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
228  << "\n no uncalib rechit will be made for digi with id: " << EBDetId(itdg.id());
229  continue;
230  }
231  const EcalXtalGroupId& gid = (*git);
232 
233  //GAIN SWITCHING DETECTION ///////////////////////////////////////////////////////////////////////////////////////////////////
234  double sampleGainRef = 1;
235  int sampleSwitch = 999;
236  for (int sample = 0; sample < itdg.size(); ++sample) {
237  double gainSample = itdg.sample(sample).gainId();
238  if (gainSample != sampleGainRef) {
239  sampleGainRef = gainSample;
240  sampleSwitch = sample;
241  }
242  } //loop sample
244 
245  if (recTDC) {
246  int tdcBin = 0;
247  if (recTDC->offset() <= 0.)
248  tdcBin = 1;
249  else if (recTDC->offset() >= 1.)
250  tdcBin = nbTimeBin_;
251  else
252  tdcBin = int(recTDC->offset() * float(nbTimeBin_)) + 1;
253 
254  if (tdcBin < 1 || tdcBin > nbTimeBin_) {
255  edm::LogError("EcalUncalibRecHitError")
256  << "TDC bin out of range " << tdcBin << " offset " << recTDC->offset();
257  continue;
258  }
259 
260  // In case gain switching happens at the sample 4 (5th sample)
261  // (sample 5 (6th sample) in 2004 TDC convention) an extra
262  // set of weights has to be used. This set of weights is assigned to
263  // TDC values going from 25 and up.
264  if (use2004OffsetConvention_ && sampleSwitch == 5)
265  tdcid = EcalTBWeights::EcalTDCId(tdcBin + 25);
266  else if (!use2004OffsetConvention_ && sampleSwitch == 4)
267  tdcid = EcalTBWeights::EcalTDCId(tdcBin + 25);
268  else
269  tdcid = EcalTBWeights::EcalTDCId(tdcBin);
270  } //check TDC
271 
272  // now lookup the correct weights in the map
273  wit = wgts->getMap().find(std::make_pair(gid, tdcid));
274  if (wit == wgts->getMap().end()) { // no weights found for this group ID
275  edm::LogError("EcalUncalibRecHitError")
276  << "No weights found for EcalGroupId: " << gid.id() << " and EcalTDCId: " << tdcid
277  << "\n skipping digi with id: " << EBDetId(itdg.id());
278  continue;
279  }
280  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
281 
282  // EcalWeightMatrix is vec<vec:double>>
283 
284 #ifdef DEBUG
285  LogDebug("EcalUncalibRecHitDebug") << "accessing matrices of weights...";
286 #endif
289  //const EcalWeightSet::EcalChi2WeightMatrix& mat3 = wset.getChi2WeightsBeforeGainSwitch();
290  //const EcalWeightSet::EcalChi2WeightMatrix& mat4 = wset.getChi2WeightsAfterGainSwitch();
292  weights[0] = &mat1;
293  weights[1] = &mat2;
294  // weights.push_back(clmat1);
295  // weights.push_back(clmat2);
296  // LogDebug("EcalUncalibRecHitDebug") << "weights before switch:\n" << clmat1 ;
297  // LogDebug("EcalUncalibRecHitDebug") << "weights after switch:\n" << clmat2 ;
298 
299  // build CLHEP chi2 matrices
300  //const EcalWeightSet::EcalChi2WeightMatrix* chi2mat[2];
301  // chi2mat[0]=&mat3;
302  // chi2mat[1]=&mat4;
303 
304  EcalUncalibratedRecHit aHit = EBalgo_.makeRecHit(itdg, pedVec, pedRMSVec, gainRatios, weights, testbeamEBShape);
305  //EBalgo_.makeRecHit(itdg, pedVec, gainRatios, weights, chi2mat);
306  EBuncalibRechits->push_back(aHit);
307 #ifdef DEBUG
308  if (aHit.amplitude() > 0.) {
309  LogDebug("EcalUncalibRecHitDebug") << "processed EBDataFrame with id: " << EBDetId(itdg.id()) << "\n"
310  << "uncalib rechit amplitude: " << aHit.amplitude();
311  }
312 #endif
313  }
314  }
315  // put the collection of reconstructed hits in the event
316  evt.put(std::move(EBuncalibRechits), EBhitCollection_);
317 
318  if (EEdigis) {
319  for (unsigned int idig = 0; idig < EEdigis->size(); ++idig) {
320  EEDataFrame itdg = (*EEdigis)[idig];
321 
322  // counter_++; // verbosity counter
323 
324  // find pedestals for this channel
325 #ifdef DEBUG
326  LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << EEDetId(itdg.id());
327  // std::cout << "looking up pedestal for crystal: " << EEDetId(itdg.id()) ;
328 #endif
329  pedIter = pedMap.find(itdg.id().rawId());
330  if (pedIter == pedMap.end()) {
331  edm::LogError("EcalUncalibRecHitError")
332  << "error!! could not find pedestals for channel: " << EEDetId(itdg.id())
333  << "\n no uncalib rechit will be made for this digi!";
334  continue;
335  }
336  const EcalPedestals::Item& aped = (*pedIter);
337  double pedVec[3];
338  double pedRMSVec[3];
339  pedVec[0] = aped.mean_x12;
340  pedVec[1] = aped.mean_x6;
341  pedVec[2] = aped.mean_x1;
342  pedRMSVec[0] = aped.rms_x12;
343  pedRMSVec[1] = aped.rms_x6;
344  pedRMSVec[2] = aped.rms_x1;
345 
346  // find gain ratios
347 #ifdef DEBUG
348  LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << EEDetId(itdg.id());
349  // std::cout << "looking up gainRatios for crystal: " << EEDetId(itdg.id()) ;
350 #endif
351  gainIter = gainMap.find(itdg.id().rawId());
352  if (gainIter == gainMap.end()) {
353  edm::LogError("EcalUncalibRecHitError")
354  << "error!! could not find gain ratios for channel: " << EEDetId(itdg.id())
355  << "\n no uncalib rechit will be made for this digi!";
356  continue;
357  }
358  const EcalMGPAGainRatio& aGain = (*gainIter);
359  double gainRatios[3];
360  gainRatios[0] = 1.;
361  gainRatios[1] = aGain.gain12Over6();
362  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
363 
364  // lookup group ID for this channel
365  git = grpMap.find(itdg.id().rawId());
366  if (git == grpMap.end()) {
367  edm::LogError("EcalUncalibRecHitError")
368  << "No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
369  << "\n no uncalib rechit will be made for digi with id: " << EEDetId(itdg.id());
370  continue;
371  }
372  const EcalXtalGroupId& gid = (*git);
373 
374  //GAIN SWITCHING DETECTION ///////////////////////////////////////////////////////////////////////////////////////////////////
375  double sampleGainRef = 1;
376  int sampleSwitch = 999;
377  for (int sample = 0; sample < itdg.size(); ++sample) {
378  double gainSample = itdg.sample(sample).gainId();
379  if (gainSample != sampleGainRef) {
380  sampleGainRef = gainSample;
381  sampleSwitch = sample;
382  }
383  } //loop sample
385 
386  if (recTDC) {
387  int tdcBin = 0;
388  if (recTDC->offset() <= 0.)
389  tdcBin = 1;
390  else if (recTDC->offset() >= 1.)
391  tdcBin = nbTimeBin_;
392  else
393  tdcBin = int(recTDC->offset() * float(nbTimeBin_)) + 1;
394 
395  if (tdcBin < 1 || tdcBin > nbTimeBin_) {
396  edm::LogError("EcalUncalibRecHitError")
397  << "TDC bin out of range " << tdcBin << " offset " << recTDC->offset();
398  continue;
399  }
400 
401  // In case gain switching happens at the sample 4 (5th sample)
402  // (sample 5 (6th sample) in 2004 TDC convention) an extra
403  // set of weights has to be used. This set of weights is assigned to
404  // TDC values going from 25 and up.
405  if (use2004OffsetConvention_ && sampleSwitch == 5)
406  tdcid = EcalTBWeights::EcalTDCId(tdcBin + 25);
407  else if (!use2004OffsetConvention_ && sampleSwitch == 4)
408  tdcid = EcalTBWeights::EcalTDCId(tdcBin + 25);
409  else
410  tdcid = EcalTBWeights::EcalTDCId(tdcBin);
411  } //check TDC
412 
413  // now lookup the correct weights in the map
414  wit = wgts->getMap().find(std::make_pair(gid, tdcid));
415  if (wit == wgts->getMap().end()) { // no weights found for this group ID
416  edm::LogError("EcalUncalibRecHitError")
417  << "No weights found for EcalGroupId: " << gid.id() << " and EcalTDCId: " << tdcid
418  << "\n skipping digi with id: " << EEDetId(itdg.id());
419  continue;
420  }
421  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
422 
423  // EcalWeightMatrix is vec<vec:double>>
424 
425 #ifdef DEBUG
426  LogDebug("EcalUncalibRecHitDebug") << "accessing matrices of weights...";
427  // std::cout << "accessing matrices of weights...";
428 #endif
431  //const EcalWeightSet::EcalChi2WeightMatrix& mat3 = wset.getChi2WeightsBeforeGainSwitch();
432  //const EcalWeightSet::EcalChi2WeightMatrix& mat4 = wset.getChi2WeightsAfterGainSwitch();
434  weights[0] = &mat1;
435  weights[1] = &mat2;
436  // weights.push_back(clmat1);
437  // weights.push_back(clmat2);
438  // LogDebug("EcalUncalibRecHitDebug") << "weights before switch:\n" << clmat1 ;
439  // LogDebug("EcalUncalibRecHitDebug") << "weights after switch:\n" << clmat2 ;
440 
441  // build CLHEP chi2 matrices
442  //const EcalWeightSet::EcalChi2WeightMatrix* chi2mat[2];
443  //chi2mat[0]=&mat3;
444  //chi2mat[1]=&mat4;
445 
446  EcalUncalibratedRecHit aHit = EEalgo_.makeRecHit(itdg, pedVec, pedRMSVec, gainRatios, weights, testbeamEEShape);
447  //EEalgo_.makeRecHit(itdg, pedVec, gainRatios, weights, chi2mat);
448  EEuncalibRechits->push_back(aHit);
449 #ifdef DEBUG
450  if (aHit.amplitude() > 0.) {
451  LogDebug("EcalUncalibRecHitDebug") << "processed EEDataFrame with id: " << EEDetId(itdg.id()) << "\n"
452  << "uncalib rechit amplitude: " << aHit.amplitude()
453 
454  // std::cout << "processed EEDataFrame with id: "
455  // << EEDetId(itdg.id()) << "\n"
456  // << "uncalib rechit amplitude: " << aHit.amplitude() << std::endl;
457  ;
458  }
459 #endif
460  }
461  }
462  // put the collection of reconstructed hits in the event
463  evt.put(std::move(EEuncalibRechits), EEhitCollection_);
464 }

References EcalUncalibratedRecHit::amplitude(), EBalgo_, EBdigiCollection_, EBhitCollection_, EEalgo_, EEdigiCollection_, EEhitCollection_, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), dqmMemoryStats::float, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), EcalMGPASample::gainId(), edm::EventSetup::get(), get, edm::Event::getByLabel(), EcalTBWeights::getMap(), EcalCondObjectContainer< T >::getMap(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), EcalXtalGroupId::id(), EEDataFrame::id(), EBDataFrame::id(), edm::InputTag::instance(), createfilelist::int, edm::HandleBase::isValid(), edm::InputTag::label(), LogDebug, EcalUncalibRecHitRecWeightsAlgo< C >::makeRecHit(), eostools::move(), nbTimeBin_, EcalTBTDCRecInfo::offset(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), DetId::rawId(), simplePhotonAnalyzer_cfi::sample, EcalDataFrame::sample(), EcalDataFrame::size(), edm::DataFrameContainer::size(), tdcRecInfoCollection_, testbeamEBShape, testbeamEEShape, use2004OffsetConvention_, and HLT_FULL_cff::weights.

Member Data Documentation

◆ EBalgo_

EcalUncalibRecHitRecWeightsAlgo<EBDataFrame> EcalTBWeightUncalibRecHitProducer::EBalgo_
private

Definition at line 34 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

◆ EBdigiCollection_

edm::InputTag EcalTBWeightUncalibRecHitProducer::EBdigiCollection_
private

◆ EBhitCollection_

std::string EcalTBWeightUncalibRecHitProducer::EBhitCollection_
private

◆ EEalgo_

EcalUncalibRecHitRecWeightsAlgo<EEDataFrame> EcalTBWeightUncalibRecHitProducer::EEalgo_
private

Definition at line 35 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

◆ EEdigiCollection_

edm::InputTag EcalTBWeightUncalibRecHitProducer::EEdigiCollection_
private

◆ EEhitCollection_

std::string EcalTBWeightUncalibRecHitProducer::EEhitCollection_
private

◆ nbTimeBin_

int EcalTBWeightUncalibRecHitProducer::nbTimeBin_
private

◆ tdcRecInfoCollection_

edm::InputTag EcalTBWeightUncalibRecHitProducer::tdcRecInfoCollection_
private

◆ testbeamEBShape

const EBShape EcalTBWeightUncalibRecHitProducer::testbeamEBShape
private

Definition at line 38 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

◆ testbeamEEShape

const EEShape EcalTBWeightUncalibRecHitProducer::testbeamEEShape
private

Definition at line 37 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

◆ use2004OffsetConvention_

bool EcalTBWeightUncalibRecHitProducer::use2004OffsetConvention_
private
EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:78
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:74
EcalDataFrame::sample
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
EcalTBWeights::getMap
const EcalTBWeightMap & getMap() const
Definition: EcalTBWeights.h:28
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
EBShape
Definition: EBShape.h:6
EcalUncalibratedRecHit::amplitude
float amplitude() const
Definition: EcalUncalibratedRecHit.h:28
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
EBDataFrame
Definition: EBDataFrame.h:11
EcalTBWeightUncalibRecHitProducer::EEalgo_
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > EEalgo_
Definition: EcalTBWeightUncalibRecHitProducer.h:35
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::Handle< EBDigiCollection >
EcalXtalGroupId
Definition: EcalXtalGroupId.h:11
EBDataFrame::id
key_type id() const
Definition: EBDataFrame.h:28
EcalTBWeightsRcd
Definition: EcalTBWeightsRcd.h:5
EcalTBWeightUncalibRecHitProducer::testbeamEEShape
const EEShape testbeamEEShape
Definition: EcalTBWeightUncalibRecHitProducer.h:37
EcalTBWeightUncalibRecHitProducer::EBalgo_
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > EBalgo_
Definition: EcalTBWeightUncalibRecHitProducer.h:34
EcalWeightSet::EcalWeightMatrix
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
EcalMGPASample::gainId
int gainId() const
get the gainId (2 bits)
Definition: EcalMGPASample.h:33
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
EcalTBTDCRecInfo::offset
float offset() const
Definition: EcalTBTDCRecInfo.h:19
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99166
edm::ESHandle
Definition: DTSurvey.h:22
EEDataFrame::id
key_type id() const
Definition: EEDataFrame.h:24
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:496
EcalWeightSet::getWeightsAfterGainSwitch
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
EEShape
Definition: EEShape.h:6
EcalTBWeightUncalibRecHitProducer::EEdigiCollection_
edm::InputTag EEdigiCollection_
Definition: EcalTBWeightUncalibRecHitProducer.h:28
EcalMGPAGainRatio::gain12Over6
float gain12Over6() const
Definition: EcalMGPAGainRatio.h:19
EEDetId
Definition: EEDetId.h:14
EcalGainRatiosRcd
Definition: EcalGainRatiosRcd.h:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalTBWeightUncalibRecHitProducer::EEhitCollection_
std::string EEhitCollection_
Definition: EcalTBWeightUncalibRecHitProducer.h:32
EcalWeightSet::getWeightsBeforeGainSwitch
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
EcalTBWeightUncalibRecHitProducer::EBhitCollection_
std::string EBhitCollection_
Definition: EcalTBWeightUncalibRecHitProducer.h:31
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
EcalTBWeights::EcalTDCId
int EcalTDCId
Definition: EcalTBWeights.h:17
EcalTBWeightUncalibRecHitProducer::use2004OffsetConvention_
bool use2004OffsetConvention_
Definition: EcalTBWeightUncalibRecHitProducer.h:46
EcalCondObjectContainer::Item
T Item
Definition: EcalCondObjectContainer.h:15
EBDigiCollection
Definition: EcalDigiCollections.h:56
EEDigiCollection
Definition: EcalDigiCollections.h:69
EcalPedestalsMapIterator
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
EcalWeightSet
Definition: EcalWeightSet.h:17
EcalUncalibratedRecHit
Definition: EcalUncalibratedRecHit.h:8
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
EcalMGPAGainRatio::gain6Over1
float gain6Over1() const
Definition: EcalMGPAGainRatio.h:20
EcalTBWeightUncalibRecHitProducer::tdcRecInfoCollection_
edm::InputTag tdcRecInfoCollection_
Definition: EcalTBWeightUncalibRecHitProducer.h:29
EcalUncalibRecHitRecWeightsAlgo::makeRecHit
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
Definition: EcalUncalibRecHitRecWeightsAlgo.h:30
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalDataFrame::size
int size() const
Definition: EcalDataFrame.h:26
EcalTBWeightUncalibRecHitProducer::EBdigiCollection_
edm::InputTag EBdigiCollection_
Definition: EcalTBWeightUncalibRecHitProducer.h:27
EcalXtalGroupId::id
unsigned int id() const
Definition: EcalXtalGroupId.h:22
EcalCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
EcalTBTDCRecInfo
Definition: EcalTBTDCRecInfo.h:12
EcalWeightXtalGroupsRcd
Definition: EcalWeightXtalGroupsRcd.h:5
EcalPedestalsRcd
Definition: EcalPedestalsRcd.h:5
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
EEDataFrame
Definition: EEDataFrame.h:12
EcalTBWeightUncalibRecHitProducer::testbeamEBShape
const EBShape testbeamEBShape
Definition: EcalTBWeightUncalibRecHitProducer.h:38
edm::InputTag
Definition: InputTag.h:15
EcalTBWeightUncalibRecHitProducer::nbTimeBin_
int nbTimeBin_
Definition: EcalTBWeightUncalibRecHitProducer.h:43
EcalTBWeights
Definition: EcalTBWeights.h:15
EcalMGPAGainRatio
Definition: EcalMGPAGainRatio.h:13
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162