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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

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 20 of file EcalTBWeightUncalibRecHitProducer.h.

Member Typedef Documentation

Definition at line 23 of file EcalTBWeightUncalibRecHitProducer.h.

Constructor & Destructor Documentation

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

Definition at line 48 of file EcalTBWeightUncalibRecHitProducer.cc.

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

48  :
49 testbeamEEShape(EEShape(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
50 testbeamEBShape(EBShape(false)) // use false as argument if you would rather prefer to use Phase I hardcoded shapes (18.05.2018 K. Theofilatos)
51 {
52 
53  EBdigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
54  EEdigiCollection_ = ps.getParameter<edm::InputTag>("EEdigiCollection");
55  tdcRecInfoCollection_ = ps.getParameter<edm::InputTag>("tdcRecInfoCollection");
56  EBhitCollection_ = ps.getParameter<std::string>("EBhitCollection");
57  EEhitCollection_ = ps.getParameter<std::string>("EEhitCollection");
58  nbTimeBin_ = ps.getParameter<int>("nbTimeBin");
59  use2004OffsetConvention_ = ps.getUntrackedParameter< bool >("use2004OffsetConvention",false);
60  produces< EBUncalibratedRecHitCollection >(EBhitCollection_);
61  produces< EEUncalibratedRecHitCollection >(EEhitCollection_);
62 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Definition: EBShape.h:6
Definition: EEShape.h:6
EcalTBWeightUncalibRecHitProducer::~EcalTBWeightUncalibRecHitProducer ( )
override

Definition at line 64 of file EcalTBWeightUncalibRecHitProducer.cc.

64  {
65 }

Member Function Documentation

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

Definition at line 68 of file EcalTBWeightUncalibRecHitProducer.cc.

References EcalUncalibratedRecHit::amplitude(), EBalgo_, EBdigiCollection_, EBhitCollection_, EEalgo_, EEdigiCollection_, EEhitCollection_, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), objects.autophobj::float, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), EcalMGPASample::gainId(), edm::EventSetup::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(), EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, eostools::move(), nbTimeBin_, EcalTBTDCRecInfo::offset(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), DetId::rawId(), EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, simplePhotonAnalyzer_cfi::sample, EcalDataFrame::sample(), EcalDataFrame::size(), edm::DataFrameContainer::size(), tdcRecInfoCollection_, testbeamEBShape, testbeamEEShape, use2004OffsetConvention_, and HGCalRecHit_cfi::weights.

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

Member Data Documentation

EcalUncalibRecHitRecWeightsAlgo<EBDataFrame> EcalTBWeightUncalibRecHitProducer::EBalgo_
private

Definition at line 37 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

edm::InputTag EcalTBWeightUncalibRecHitProducer::EBdigiCollection_
private
std::string EcalTBWeightUncalibRecHitProducer::EBhitCollection_
private
EcalUncalibRecHitRecWeightsAlgo<EEDataFrame> EcalTBWeightUncalibRecHitProducer::EEalgo_
private

Definition at line 38 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

edm::InputTag EcalTBWeightUncalibRecHitProducer::EEdigiCollection_
private
std::string EcalTBWeightUncalibRecHitProducer::EEhitCollection_
private
int EcalTBWeightUncalibRecHitProducer::nbTimeBin_
private
edm::InputTag EcalTBWeightUncalibRecHitProducer::tdcRecInfoCollection_
private
const EBShape EcalTBWeightUncalibRecHitProducer::testbeamEBShape
private

Definition at line 41 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

const EEShape EcalTBWeightUncalibRecHitProducer::testbeamEEShape
private

Definition at line 40 of file EcalTBWeightUncalibRecHitProducer.h.

Referenced by produce().

bool EcalTBWeightUncalibRecHitProducer::use2004OffsetConvention_
private