CMS 3D CMS Logo

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