CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TimingTask.cc
Go to the documentation of this file.
1 #include "../interface/TimingTask.h"
2 
4 
6 
8 
9 namespace ecaldqm
10 {
12  DQWorkerTask(),
13  chi2ThresholdEB_(0.),
14  chi2ThresholdEE_(0.),
15  energyThresholdEB_(0.),
16  energyThresholdEE_(0.),
17  meTimeMapByLS(0)
18  {
19  }
20 
21  void
23  {
24  chi2ThresholdEB_ = _params.getUntrackedParameter<double>("chi2ThresholdEB");
25  chi2ThresholdEE_ = _params.getUntrackedParameter<double>("chi2ThresholdEE");
26  energyThresholdEB_ = _params.getUntrackedParameter<double>("energyThresholdEB");
27  energyThresholdEE_ = _params.getUntrackedParameter<double>("energyThresholdEE");
28  }
29 
30  bool
31  TimingTask::filterRunType(short const* _runType)
32  {
33  for(int iFED(0); iFED < nDCC; iFED++){
34  if(_runType[iFED] == EcalDCCHeaderBlock::COSMIC ||
35  _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
36  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
37  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
38  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
39  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL) return true;
40  }
41 
42  return false;
43  }
44 
45  void
47  {
48  // Fill separate MEs with only 10 LSs worth of stats
49  // Used to correctly fill Presample Trend plots:
50  // 1 pt:10 LS in Trend plots
51  meTimeMapByLS = &MEs_.at("TimeMapByLS");
52  if ( timestamp_.iLumi % 10 == 0 )
54  }
55 
56  void
58  {
59  MESet& meTimeAmp(MEs_.at("TimeAmp"));
60  MESet& meTimeAmpAll(MEs_.at("TimeAmpAll"));
61  MESet& meTimeAll(MEs_.at("TimeAll"));
62  MESet& meTimeAllMap(MEs_.at("TimeAllMap"));
63  MESet& meTimeMap(MEs_.at("TimeMap")); // contains cumulative run stats => not suitable for Trend plots
64  MESet& meTime1D(MEs_.at("Time1D"));
65  MESet& meChi2(MEs_.at("Chi2"));
66 
67  uint32_t mask(~((0x1 << EcalRecHit::kGood) | (0x1 << EcalRecHit::kOutOfTime)));
68  float threshold(_collection == kEBRecHit ? energyThresholdEB_ : energyThresholdEE_);
69  int signedSubdet;
70 
71  std::for_each(_hits.begin(), _hits.end(), [&](EcalRecHitCollection::value_type const& hit){
72  if(hit.checkFlagMask(mask)) return;
73 
74  DetId id(hit.id());
75 
76  float time(hit.time());
77  float energy(hit.energy());
78 
79  // Apply cut on chi2 of pulse shape fit
80  float chi2Threshold = ( id.subdetId() == EcalBarrel ) ? chi2ThresholdEB_ : chi2ThresholdEE_;
81  if ( id.subdetId() == EcalBarrel )
82  signedSubdet = EcalBarrel;
83  else {
84  EEDetId eeId( hit.id() );
85  if ( eeId.zside() < 0 )
86  signedSubdet = -EcalEndcap;
87  else
88  signedSubdet = EcalEndcap;
89  }
90  if ( energy > threshold )
91  meChi2.fill(signedSubdet, hit.chi2());
92  if ( hit.chi2() > chi2Threshold ) return;
93 
94  meTimeAmp.fill(id, energy, time);
95  meTimeAmpAll.fill(id, energy, time);
96 
97  if(energy > threshold){
98  meTimeAll.fill(id, time);
99  meTimeMap.fill(id, time);
100  meTimeMapByLS->fill(id, time);
101  meTime1D.fill(id, time);
102  meTimeAllMap.fill(id, time);
103  }
104  });
105  }
106 
107  // For In-time vs Out-of-Time amplitude correlation MEs:
108  // Only UncalibRecHits carry information about OOT amplitude
109  // But still need to make sure we apply similar cuts as on RecHits
111  {
112  MESet& meTimeAmpBXm( MEs_.at("TimeAmpBXm") );
113  MESet& meTimeAmpBXp( MEs_.at("TimeAmpBXp") );
114 
115  for( EcalUncalibratedRecHitCollection::const_iterator uhitItr(_uhits.begin()); uhitItr != _uhits.end(); ++uhitItr ) {
116 
117  // Apply reconstruction quality cuts
118  if( !uhitItr->checkFlag(EcalUncalibratedRecHit::kGood) ) continue;
119  DetId id( uhitItr->id() );
120  float chi2Threshold = ( id.subdetId() == EcalBarrel ) ? chi2ThresholdEB_ : chi2ThresholdEE_;
121  if( uhitItr->chi2() > chi2Threshold ) continue;
122 
123  // Apply amplitude cut based on approx rechit energy
124  float amp( uhitItr->amplitude() );
125  float ampThreshold( id.subdetId() == EcalBarrel ? energyThresholdEB_*20. : energyThresholdEE_*5. ); // 1 GeV ~ ( EB:20, EE:5 ) ADC
126  if( amp < ampThreshold ) continue;
127 
128  // Apply jitter timing cut based on approx rechit timing
129  float timeOff( id.subdetId() == EcalBarrel ? 0.4 : 1.8 );
130  float hitTime( uhitItr->jitter()*25. + timeOff ); // 1 jitter ~ 25 ns
131  if( abs(hitTime) >= 5. ) continue;
132 
133  // Fill MEs
134  meTimeAmpBXm.fill( id,amp,uhitItr->outOfTimeAmplitude(4) ); // BX-1
135  meTimeAmpBXp.fill( id,amp,uhitItr->outOfTimeAmplitude(6) ); // BX+1
136 
137  }
138  }
139 
141 }
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
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: TimingTask.cc:46
void setParams(edm::ParameterSet const &) override
Definition: TimingTask.cc:22
void runOnRecHits(EcalRecHitCollection const &, Collections)
Definition: TimingTask.cc:57
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:110
float energyThresholdEE_
Definition: TimingTask.h:29
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:31
float energyThresholdEB_
Definition: TimingTask.h:28
bool filterRunType(short const *) override
Definition: TimingTask.cc:31
const_iterator begin() const