CMS 3D CMS Logo

TimingTask.cc
Go to the documentation of this file.
2 
5 
7 
9 
11 
12 namespace ecaldqm {
14  : DQWorkerTask(),
15  bxBinEdges_(),
16  bxBin_(0.),
17  chi2ThresholdEB_(0.),
18  chi2ThresholdEE_(0.),
19  energyThresholdEB_(0.),
20  energyThresholdEE_(0.),
21  energyThresholdEEFwd_(0.),
22  timingVsBXThreshold_(0.),
23  timeErrorThreshold_(0.),
24  meTimeMapByLS(nullptr) {}
25 
27  bxBinEdges_ = onlineMode_ ? _params.getUntrackedParameter<std::vector<int> >("bxBins")
28  : _params.getUntrackedParameter<std::vector<int> >("bxBinsFine");
29  chi2ThresholdEB_ = _params.getUntrackedParameter<double>("chi2ThresholdEB");
30  chi2ThresholdEE_ = _params.getUntrackedParameter<double>("chi2ThresholdEE");
31  energyThresholdEB_ = _params.getUntrackedParameter<double>("energyThresholdEB");
32  energyThresholdEE_ = _params.getUntrackedParameter<double>("energyThresholdEE");
33  energyThresholdEEFwd_ = _params.getUntrackedParameter<double>("energyThresholdEEFwd");
34  timingVsBXThreshold_ = _params.getUntrackedParameter<double>("timingVsBXThreshold");
35  timeErrorThreshold_ = _params.getUntrackedParameter<double>("timeErrorThreshold");
36  splashSwitch_ = _params.getUntrackedParameter<bool>("splashSwitch", false);
37  }
38 
39  bool TimingTask::filterRunType(short const* _runType) {
40  for (int iFED(0); iFED < nDCC; iFED++) {
41  if (_runType[iFED] == EcalDCCHeaderBlock::COSMIC || _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
42  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
43  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL || _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
44  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL)
45  return true;
46  }
47 
48  return false;
49  }
50 
51  void TimingTask::beginEvent(edm::Event const& _evt, edm::EventSetup const& _es, bool const& ByLumiResetSwitch, bool&) {
52  using namespace std;
53  std::vector<int>::iterator pBin = std::upper_bound(bxBinEdges_.begin(), bxBinEdges_.end(), _evt.bunchCrossing());
54  bxBin_ = static_cast<int>(pBin - bxBinEdges_.begin()) - 0.5;
55  if (ByLumiResetSwitch) {
56  meTimeMapByLS = &MEs_.at("TimeMapByLS");
57  if (timestamp_.iLumi % 10 == 0)
59  }
60  }
61 
62  void TimingTask::runOnRecHits(EcalRecHitCollection const& _hits, Collections _collection) {
63  MESet& meTimeAmp(MEs_.at("TimeAmp"));
64  MESet& meTimeAmpAll(MEs_.at("TimeAmpAll"));
65  MESet& meTimingVsBX(onlineMode_ ? MEs_.at("BarrelTimingVsBX") : MEs_.at("BarrelTimingVsBXFineBinned"));
66  MESet& meTimeAll(MEs_.at("TimeAll"));
67  MESet& meTimeAllMap(MEs_.at("TimeAllMap"));
68  MESet& meTimeMap(MEs_.at("TimeMap")); // contains cumulative run stats => not suitable for Trend plots
69  MESet& meTime1D(MEs_.at("Time1D"));
70  MESet& meChi2(MEs_.at("Chi2"));
71 
72  uint32_t mask(~((0x1 << EcalRecHit::kGood) | (0x1 << EcalRecHit::kOutOfTime)));
73  int signedSubdet;
74 
75  std::for_each(_hits.begin(), _hits.end(), [&](EcalRecHitCollection::value_type const& hit) {
76  if (hit.checkFlagMask(mask))
77  return;
78 
79  DetId id(hit.id());
80 
81  float time(hit.time());
82  float energy(hit.energy());
83 
84  float energyThreshold;
85  if (id.subdetId() == EcalBarrel) {
87  signedSubdet = EcalBarrel;
88  } else {
90  EEDetId eeId(hit.id());
91  if (eeId.zside() < 0)
92  signedSubdet = -EcalEndcap;
93  else
94  signedSubdet = EcalEndcap;
95  }
96 
97  if (energy > energyThreshold)
98  meChi2.fill(getEcalDQMSetupObjects(), signedSubdet, hit.chi2());
99 
100  if (!splashSwitch_) { //Not applied for splash events
101  float chi2Threshold;
102  if (id.subdetId() == EcalBarrel)
104  else
106 
107  //Apply cut on chi2 of pulse shape fit
108  if (hit.chi2() > chi2Threshold)
109  return;
110  }
111  // Apply cut based on timing error of rechit
112  if (hit.timeError() > timeErrorThreshold_)
113  return;
114 
115  meTimeAmp.fill(getEcalDQMSetupObjects(), id, energy, time);
116  meTimeAmpAll.fill(getEcalDQMSetupObjects(), id, energy, time);
117 
118  if (energy > timingVsBXThreshold_ && signedSubdet == EcalBarrel)
119  meTimingVsBX.fill(getEcalDQMSetupObjects(), bxBin_, time);
120 
121  if (energy > energyThreshold) {
122  meTimeAll.fill(getEcalDQMSetupObjects(), id, time);
123  meTimeMap.fill(getEcalDQMSetupObjects(), id, time);
125  meTime1D.fill(getEcalDQMSetupObjects(), id, time);
126  meTimeAllMap.fill(getEcalDQMSetupObjects(), id, time);
127  }
128  });
129  }
130 
131  // For In-time vs Out-of-Time amplitude correlation MEs:
132  // Only UncalibRecHits carry information about OOT amplitude
133  // But still need to make sure we apply similar cuts as on RecHits
135  MESet& meTimeAmpBXm(MEs_.at("TimeAmpBXm"));
136  MESet& meTimeAmpBXp(MEs_.at("TimeAmpBXp"));
137 
138  for (EcalUncalibratedRecHitCollection::const_iterator uhitItr(_uhits.begin()); uhitItr != _uhits.end(); ++uhitItr) {
139  // Apply reconstruction quality cuts
140  if (!uhitItr->checkFlag(EcalUncalibratedRecHit::kGood))
141  continue;
142  DetId id(uhitItr->id());
143  float chi2Threshold = 0.;
144  float ampThreshold = 0.;
145  if (id.subdetId() == EcalBarrel) {
147  ampThreshold = 20. * energyThresholdEB_; // 1 GeV ~ 20 ADC in EB
148  } else {
150  ampThreshold = 5. * ((isForward(id)) ? energyThresholdEEFwd_ : energyThresholdEE_); // 1 GeV ~ 5 ADC in EE
151  }
152 
153  if (uhitItr->chi2() > chi2Threshold)
154  continue;
155 
156  // Apply amplitude cut based on approx rechit energy
157  float amp(uhitItr->amplitude());
158  if (amp < ampThreshold)
159  continue;
160 
161  // Apply jitter timing cut based on approx rechit timing
162  float timeOff(id.subdetId() == EcalBarrel ? 0.4 : 1.8);
163  float hitTime(uhitItr->jitter() * 25. + timeOff); // 1 jitter ~ 25 ns
164  if (std::abs(hitTime) >= 5.)
165  continue;
166 
167  // Fill MEs
168  meTimeAmpBXm.fill(getEcalDQMSetupObjects(), id, amp, uhitItr->outOfTimeAmplitude(4)); // BX-1
169  meTimeAmpBXp.fill(getEcalDQMSetupObjects(), id, amp, uhitItr->outOfTimeAmplitude(6)); // BX+1
170  }
171  }
172 
174 } // namespace ecaldqm
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:48
MESet & at(const std::string &key)
Definition: MESet.h:399
std::vector< T >::const_iterator const_iterator
bool isForward(DetId const &)
constexpr uint32_t mask
Definition: gpuClustering.h:24
void setParams(edm::ParameterSet const &) override
Definition: TimingTask.cc:26
float timingVsBXThreshold_
Definition: TimingTask.h:34
void runOnRecHits(EcalRecHitCollection const &, Collections)
Definition: TimingTask.cc:62
float energyThresholdEEFwd_
Definition: TimingTask.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:74
void runOnUncalibRecHits(EcalUncalibratedRecHitCollection const &)
Definition: TimingTask.cc:134
const_iterator begin() const
float energyThresholdEE_
Definition: TimingTask.h:32
unsigned int id
const_iterator end() const
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
Timestamp timestamp_
Definition: DQWorker.h:134
int bunchCrossing() const
Definition: EventBase.h:64
MESetCollection MEs_
Definition: DQWorker.h:131
MESet * meTimeMapByLS
Definition: TimingTask.h:38
float energyThresholdEB_
Definition: TimingTask.h:31
void beginEvent(edm::Event const &, edm::EventSetup const &, bool const &, bool &) override
Definition: TimingTask.cc:51
std::vector< int > bxBinEdges_
Definition: TimingTask.h:26
bool filterRunType(short const *) override
Definition: TimingTask.cc:39
virtual void reset(EcalElectronicsMapping const *, double=0., double=0., double=0.)
Definition: MESet.cc:98
float timeErrorThreshold_
Definition: TimingTask.h:35