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  }
37 
38  bool TimingTask::filterRunType(short const* _runType) {
39  for (int iFED(0); iFED < nDCC; iFED++) {
40  if (_runType[iFED] == EcalDCCHeaderBlock::COSMIC || _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
41  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
42  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL || _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
43  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL)
44  return true;
45  }
46 
47  return false;
48  }
49 
51  // Fill separate MEs with only 10 LSs worth of stats
52  // Used to correctly fill Presample Trend plots:
53  // 1 pt:10 LS in Trend plots
54  meTimeMapByLS = &MEs_.at("TimeMapByLS");
55  if (timestamp_.iLumi % 10 == 0)
57  }
58 
59  void TimingTask::beginEvent(edm::Event const& _evt, edm::EventSetup const& _es) {
60  using namespace std;
61  std::vector<int>::iterator pBin = std::upper_bound(bxBinEdges_.begin(), bxBinEdges_.end(), _evt.bunchCrossing());
62  bxBin_ = static_cast<int>(pBin - bxBinEdges_.begin()) - 0.5;
63  }
64 
65  void TimingTask::runOnRecHits(EcalRecHitCollection const& _hits, Collections _collection) {
66  MESet& meTimeAmp(MEs_.at("TimeAmp"));
67  MESet& meTimeAmpAll(MEs_.at("TimeAmpAll"));
68  MESet& meTimingVsBX(onlineMode_ ? MEs_.at("BarrelTimingVsBX") : MEs_.at("BarrelTimingVsBXFineBinned"));
69  MESet& meTimeAll(MEs_.at("TimeAll"));
70  MESet& meTimeAllMap(MEs_.at("TimeAllMap"));
71  MESet& meTimeMap(MEs_.at("TimeMap")); // contains cumulative run stats => not suitable for Trend plots
72  MESet& meTime1D(MEs_.at("Time1D"));
73  MESet& meChi2(MEs_.at("Chi2"));
74 
75  uint32_t mask(~((0x1 << EcalRecHit::kGood) | (0x1 << EcalRecHit::kOutOfTime)));
76  int signedSubdet;
77 
78  std::for_each(_hits.begin(), _hits.end(), [&](EcalRecHitCollection::value_type const& hit) {
79  if (hit.checkFlagMask(mask))
80  return;
81 
82  DetId id(hit.id());
83 
84  float time(hit.time());
85  float energy(hit.energy());
86 
88  if (id.subdetId() == EcalBarrel) {
91  } else {
94  }
95 
96  if (id.subdetId() == EcalBarrel)
97  signedSubdet = EcalBarrel;
98  else {
99  EEDetId eeId(hit.id());
100  if (eeId.zside() < 0)
101  signedSubdet = -EcalEndcap;
102  else
103  signedSubdet = EcalEndcap;
104  }
105 
106  if (energy > energyThreshold)
107  meChi2.fill(signedSubdet, hit.chi2());
108 
109  // Apply cut on chi2 of pulse shape fit
110  if (hit.chi2() > chi2Threshold)
111  return;
112 
113  // Apply cut based on timing error of rechit
114  if (hit.timeError() > timeErrorThreshold_)
115  return;
116 
117  meTimeAmp.fill(id, energy, time);
118  meTimeAmpAll.fill(id, energy, time);
119 
120  if (energy > timingVsBXThreshold_ && signedSubdet == EcalBarrel)
121  meTimingVsBX.fill(bxBin_, time);
122 
123  if (energy > energyThreshold) {
124  meTimeAll.fill(id, time);
125  meTimeMap.fill(id, time);
126  meTimeMapByLS->fill(id, time);
127  meTime1D.fill(id, time);
128  meTimeAllMap.fill(id, time);
129  }
130  });
131  }
132 
133  // For In-time vs Out-of-Time amplitude correlation MEs:
134  // Only UncalibRecHits carry information about OOT amplitude
135  // But still need to make sure we apply similar cuts as on RecHits
137  MESet& meTimeAmpBXm(MEs_.at("TimeAmpBXm"));
138  MESet& meTimeAmpBXp(MEs_.at("TimeAmpBXp"));
139 
140  for (EcalUncalibratedRecHitCollection::const_iterator uhitItr(_uhits.begin()); uhitItr != _uhits.end(); ++uhitItr) {
141  // Apply reconstruction quality cuts
142  if (!uhitItr->checkFlag(EcalUncalibratedRecHit::kGood))
143  continue;
144  DetId id(uhitItr->id());
145  float chi2Threshold = 0.;
146  float ampThreshold = 0.;
147  if (id.subdetId() == EcalBarrel) {
149  ampThreshold = 20. * energyThresholdEB_; // 1 GeV ~ 20 ADC in EB
150  } else {
152  ampThreshold = 5. * ((isForward(id)) ? energyThresholdEEFwd_ : energyThresholdEE_); // 1 GeV ~ 5 ADC in EE
153  }
154 
155  if (uhitItr->chi2() > chi2Threshold)
156  continue;
157 
158  // Apply amplitude cut based on approx rechit energy
159  float amp(uhitItr->amplitude());
160  if (amp < ampThreshold)
161  continue;
162 
163  // Apply jitter timing cut based on approx rechit timing
164  float timeOff(id.subdetId() == EcalBarrel ? 0.4 : 1.8);
165  float hitTime(uhitItr->jitter() * 25. + timeOff); // 1 jitter ~ 25 ns
166  if (std::abs(hitTime) >= 5.)
167  continue;
168 
169  // Fill MEs
170  meTimeAmpBXm.fill(id, amp, uhitItr->outOfTimeAmplitude(4)); // BX-1
171  meTimeAmpBXp.fill(id, amp, uhitItr->outOfTimeAmplitude(6)); // BX+1
172  }
173  }
174 
176 } // namespace ecaldqm
EcalDCCHeaderBlock::COSMICS_LOCAL
Definition: EcalDCCHeaderBlock.h:49
EcalRecHit
Definition: EcalRecHit.h:15
ecaldqm::TimingTask::runOnRecHits
void runOnRecHits(EcalRecHitCollection const &, Collections)
Definition: TimingTask.cc:65
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
ecaldqm::TimingTask::beginEvent
void beginEvent(edm::Event const &, edm::EventSetup const &) override
Definition: TimingTask.cc:59
ecaldqm::TimingTask::TimingTask
TimingTask()
Definition: TimingTask.cc:13
edm::EventBase::bunchCrossing
int bunchCrossing() const
Definition: EventBase.h:64
ecaldqm
Definition: DQWorker.h:24
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
ecaldqm::TimingTask::energyThresholdEB_
float energyThresholdEB_
Definition: TimingTask.h:32
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
l1extraParticles_cfi._params
_params
Definition: l1extraParticles_cfi.py:29
edm::SortedCollection< EcalRecHit >
dtSegmentAnalysisTest_cfi.chi2Threshold
chi2Threshold
Definition: dtSegmentAnalysisTest_cfi.py:12
EcalUncalibratedRecHit::kGood
Definition: EcalUncalibratedRecHit.h:13
TimingTask.h
ecaldqm::TimingTask::filterRunType
bool filterRunType(short const *) override
Definition: TimingTask.cc:38
ecaldqm::isForward
bool isForward(DetId const &)
Definition: EcalDQMCommonUtils.cc:243
EcalBarrel
Definition: EcalSubdetector.h:10
ecaldqm::TimingTask::timingVsBXThreshold_
float timingVsBXThreshold_
Definition: TimingTask.h:35
ecaldqm::MESet::fill
virtual void fill(DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:46
DetId
Definition: DetId.h:17
EcalDCCHeaderBlock::PHYSICS_GLOBAL
Definition: EcalDCCHeaderBlock.h:37
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
ecaldqm::TimingTask::energyThresholdEE_
float energyThresholdEE_
Definition: TimingTask.h:33
ecaldqm::DQWorkerTask
Definition: DQWorkerTask.h:71
ecaldqm::TimingTask::timeErrorThreshold_
float timeErrorThreshold_
Definition: TimingTask.h:36
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
ecaldqm::TimingTask::chi2ThresholdEB_
float chi2ThresholdEB_
Definition: TimingTask.h:30
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
EcalRecHit::kGood
Definition: EcalRecHit.h:21
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:78
EEDetId
Definition: EEDetId.h:14
muonRecoAnalyzer_cfi.pBin
pBin
Definition: muonRecoAnalyzer_cfi.py:37
EcalEndcap
Definition: EcalSubdetector.h:10
ecaldqm::DQWorker::onlineMode_
bool onlineMode_
Definition: DQWorker.h:85
EcalRecHit::kOutOfTime
Definition: EcalRecHit.h:23
ecaldqm::TimingTask::energyThresholdEEFwd_
float energyThresholdEEFwd_
Definition: TimingTask.h:34
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ecaldqm::TimingTask::setParams
void setParams(edm::ParameterSet const &) override
Definition: TimingTask.cc:26
EcalDCCHeaderBlock::PHYSICS_LOCAL
Definition: EcalDCCHeaderBlock.h:48
ecaldqm::Collections
Collections
Definition: Collections.h:8
ecaldqm::MESet::reset
virtual void reset(double=0., double=0., double=0.)
Definition: MESet.cc:98
EcalDCCHeaderBlock.h
edm::EventSetup
Definition: EventSetup.h:57
ecaldqm::TimingTask::meTimeMapByLS
MESet * meTimeMapByLS
Definition: TimingTask.h:38
ecaldqm::TimingTask::runOnUncalibRecHits
void runOnUncalibRecHits(EcalUncalibratedRecHitCollection const &)
Definition: TimingTask.cc:136
ecaldqm::DQWorker::Timestamp::iLumi
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
EcalDCCHeaderBlock::COSMICS_GLOBAL
Definition: EcalDCCHeaderBlock.h:38
std
Definition: JetResolutionObject.h:76
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ecaldqm::TimingTask::bxBinEdges_
std::vector< int > bxBinEdges_
Definition: TimingTask.h:27
EcalDCCHeaderBlock::MTCC
Definition: EcalDCCHeaderBlock.h:25
ecaldqm::TimingTask
Definition: TimingTask.h:10
ecaldqm::DQWorker::timestamp_
Timestamp timestamp_
Definition: DQWorker.h:81
EventSetup.h
EcalDCCHeaderBlock::COSMIC
Definition: EcalDCCHeaderBlock.h:22
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:92
ecaldqm::TimingTask::chi2ThresholdEE_
float chi2ThresholdEE_
Definition: TimingTask.h:31
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:112
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
ClusterTask_cfi.energyThreshold
energyThreshold
Definition: ClusterTask_cfi.py:3
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::Event
Definition: Event.h:73
ecaldqm::TimingTask::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: TimingTask.cc:50
hit
Definition: SiStripHitEffFromCalibTree.cc:88
ecaldqm::TimingTask::bxBin_
double bxBin_
Definition: TimingTask.h:28
EcalDQMCommonUtils.h
ecaldqm::MESet
Definition: MESet.h:27