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> ampWeights_;
25  const std::vector<double> timeWeights_;
26 
29 };
30 
33 
34  desc.add<std::string>("EBhitCollection", "EcalUncalibRecHitsEB");
35  desc.add<double>("tRise", 0.2);
36  desc.add<double>("tFall", 2.);
37  desc.add<std::vector<double>>("ampWeights",
38  {-0.121016,
39  -0.119899,
40  -0.120923,
41  -0.0848959,
42  0.261041,
43  0.509881,
44  0.373591,
45  0.134899,
46  -0.0233605,
47  -0.0913195,
48  -0.112452,
49  -0.118596,
50  -0.121737,
51  -0.121737,
52  -0.121737,
53  -0.121737});
54  desc.add<std::vector<double>>("timeWeights",
55  {0.429452,
56  0.442762,
57  0.413327,
58  0.858327,
59  4.42324,
60  2.04369,
61  -3.42426,
62  -4.16258,
63  -2.36061,
64  -0.725371,
65  0.0727267,
66  0.326005,
67  0.402035,
68  0.404287,
69  0.434207,
70  0.422775});
71 
72  desc.add<edm::InputTag>("BarrelDigis", edm::InputTag("simEcalUnsuppressedDigis", ""));
73 
74  descriptions.addWithDefaultLabel(desc);
75 }
76 
78  : tRise_(ps.getParameter<double>("tRise")),
79  tFall_(ps.getParameter<double>("tFall")),
80  ampWeights_(ps.getParameter<std::vector<double>>("ampWeights")),
81  timeWeights_(ps.getParameter<std::vector<double>>("timeWeights")),
82  ebDigiCollectionToken_(consumes<EBDigiCollectionPh2>(ps.getParameter<edm::InputTag>("BarrelDigis"))),
83  ebUncalibRecHitCollectionToken_(
84  produces<EBUncalibratedRecHitCollection>(ps.getParameter<std::string>("EBhitCollection"))) {}
85 
87  // retrieve digis
88  const EBDigiCollectionPh2* pdigis = &evt.get(ebDigiCollectionToken_);
89 
90  // prepare output
91  auto ebUncalibRechits = std::make_unique<EBUncalibratedRecHitCollection>();
92 
93  for (auto itdg = pdigis->begin(); itdg != pdigis->end(); ++itdg) {
94  EBDataFrame digi(*itdg);
95  EcalDataFrame_Ph2 dataFrame(*itdg);
96  DetId detId(digi.id());
97 
98  bool g1 = false;
99 
100  std::vector<float> timetrace;
101  std::vector<float> adctrace;
102 
103  int nSamples = digi.size();
104 
105  timetrace.reserve(nSamples);
106  adctrace.reserve(nSamples);
107 
108  float amp = 0;
109  float t0 = 0;
110  float gratio;
111 
112  for (int sample = 0; sample < nSamples; ++sample) {
113  EcalLiteDTUSample thisSample = dataFrame[sample];
114  gratio = ecalPh2::gains[thisSample.gainId()];
115  adctrace.push_back(thisSample.adc() * gratio);
116 
117  amp = amp + adctrace[sample] * ampWeights_[sample];
118 
119  t0 = t0 + adctrace[sample] * timeWeights_[sample];
120 
121  if (thisSample.gainId() == 1)
122  g1 = true;
123 
124  timetrace.push_back(sample);
125 
126  } // loop on samples
127 
128  float amp_e = 1;
129  float t0_e = 0;
130 
131  EcalUncalibratedRecHit rhit(detId, amp, 0., t0, 0., 0); // rhit(detIt, amp, pedestal, t0, chi2, flags)
132  rhit.setAmplitudeError(amp_e);
133  rhit.setJitterError(t0_e);
134  if (g1)
136 
137  ebUncalibRechits->push_back(rhit);
138 
139  } // loop on digis
140 
141  evt.put(ebUncalibRecHitCollectionToken_, std::move(ebUncalibRechits));
142 }
143 
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:347
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static constexpr const float * gains
Definition: EcalConstants.h:33
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