CMS 3D CMS Logo

EcalUncalibRecHitPhase2WeightsProducer.cc
Go to the documentation of this file.
5 
9 
11 
14 
16 public:
18  void produce(edm::Event& evt, const edm::EventSetup& es) override;
19  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20 
21 private:
22  const float tRise_;
23  const float tFall_;
24  const std::vector<double> weights_;
25 
28 };
29 
32 
33  desc.add<std::string>("EBhitCollection", "EcalUncalibRecHitsEB");
34  desc.add<double>("tRise", 0.2);
35  desc.add<double>("tFall", 2.);
36  desc.add<std::vector<double>>("weights",
37  {-0.121016,
38  -0.119899,
39  -0.120923,
40  -0.0848959,
41  0.261041,
42  0.509881,
43  0.373591,
44  0.134899,
45  -0.0233605,
46  -0.0913195,
47  -0.112452,
48  -0.118596,
49  -0.121737,
50  -0.121737,
51  -0.121737,
52  -0.121737});
53 
54  desc.add<edm::InputTag>("BarrelDigis", edm::InputTag("simEcalUnsuppressedDigis", ""));
55 
56  descriptions.addWithDefaultLabel(desc);
57 }
58 
60  : tRise_(ps.getParameter<double>("tRise")),
61  tFall_(ps.getParameter<double>("tFall")),
62  weights_(ps.getParameter<std::vector<double>>("weights")),
63  ebDigiCollectionToken_(consumes<EBDigiCollectionPh2>(ps.getParameter<edm::InputTag>("BarrelDigis"))),
64  ebUncalibRecHitCollectionToken_(
65  produces<EBUncalibratedRecHitCollection>(ps.getParameter<std::string>("EBhitCollection"))) {}
66 
68  // retrieve digis
69  const EBDigiCollectionPh2* pdigis = &evt.get(ebDigiCollectionToken_);
70 
71  // prepare output
72  auto ebUncalibRechits = std::make_unique<EBUncalibratedRecHitCollection>();
73 
74  for (auto itdg = pdigis->begin(); itdg != pdigis->end(); ++itdg) {
75  EBDataFrame digi(*itdg);
76  EcalDataFrame_Ph2 dataFrame(*itdg);
77  DetId detId(digi.id());
78 
79  bool g1 = false;
80 
81  std::vector<float> timetrace;
82  std::vector<float> adctrace;
83 
84  int nSamples = digi.size();
85 
86  timetrace.reserve(nSamples);
87  adctrace.reserve(nSamples);
88 
89  float amp = 0;
90  float gratio;
91 
92  for (int sample = 0; sample < nSamples; ++sample) {
93  EcalLiteDTUSample thisSample = dataFrame[sample];
94  gratio = ecalPh2::gains[thisSample.gainId()];
95  adctrace.push_back(thisSample.adc() * gratio);
96 
97  amp = amp + adctrace[sample] * weights_[sample];
98 
99  if (thisSample.gainId() == 1)
100  g1 = true;
101 
102  timetrace.push_back(sample);
103 
104  } // loop on samples
105 
106  float amp_e = 1;
107  float t0_e = 0;
108 
109  EcalUncalibratedRecHit rhit(detId, amp, 0., 0., 0., 0); // rhit(detIt, amp, pedestal, t0, chi2, flags)
110  rhit.setAmplitudeError(amp_e);
111  rhit.setJitterError(t0_e);
112  if (g1)
114 
115  ebUncalibRechits->push_back(rhit);
116 
117  } // loop on digis
118 
119  evt.put(ebUncalibRecHitCollectionToken_, std::move(ebUncalibRechits));
120 }
121 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
key_type id() const
Definition: EBDataFrame.h:28
int adc() const
get the ADC sample (12 bits)
void setJitterError(float jitterErr)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< EBDigiCollectionPh2 > ebDigiCollectionToken_
int size() const
Definition: EcalDataFrame.h:26
static constexpr const float * gains
Definition: EcalConstants.h:24
void setAmplitudeError(float amplitudeerror)
const_iterator end() const
int gainId() const
get the gainId (2 bits)
Definition: DetId.h:17
const_iterator begin() const
The iterator returned can not safely be used across threads.
HLT enums.
const edm::EDPutTokenT< EBUncalibratedRecHitCollection > ebUncalibRecHitCollectionToken_
void produce(edm::Event &evt, const edm::EventSetup &es) override
def move(src, dest)
Definition: eostools.py:511