CMS 3D CMS Logo

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