CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDetDiagTimingMonitor.cc
Go to the documentation of this file.
2 
7 
8 #include <math.h>
9 
10 // this is to retrieve GT digi's
14 
15 
16 
18 static const float adc2fC[128]={-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5, 10.5,11.5,12.5,
19  13.5,15.,17.,19.,21.,23.,25.,27.,29.5,32.5,35.5,38.5,42.,46.,50.,54.5,59.5,
20  64.5,59.5,64.5,69.5,74.5,79.5,84.5,89.5,94.5,99.5,104.5,109.5,114.5,119.5,
21  124.5,129.5,137.,147.,157.,167.,177.,187.,197.,209.5,224.5,239.5,254.5,272.,
22  292.,312.,334.5,359.5,384.5,359.5,384.5,409.5,434.5,459.5,484.5,509.5,534.5,
23  559.5,584.5,609.5,634.5,659.5,684.5,709.5,747.,797.,847.,897.,947.,997.,
24  1047.,1109.5,1184.5,1259.5,1334.5,1422.,1522.,1622.,1734.5,1859.5,1984.5,
25  1859.5,1984.5,2109.5,2234.5,2359.5,2484.5,2609.5,2734.5,2859.5,2984.5,
26  3109.5,3234.5,3359.5,3484.5,3609.5,3797.,4047.,4297.,4547.,4797.,5047.,
27  5297.,5609.5,5984.5,6359.5,6734.5,7172.,7672.,8172.,8734.5,9359.5,9984.5};
29 static const int MAXGEN =10;
30 static const int MAXRPC =20;
31 static const int MAXDTBX=20;
32 static const int MAXCSC =20;
33 static const int MAXGMT =20;
34 static const int TRIG_DT =1;
35 static const int TRIG_RPC=2;
36 static const int TRIG_GCT=4;
37 static const int TRIG_CSC=8;
38 static const int TRIG_RPCF=16;
39 
41 {
42  Online_ = ps.getUntrackedParameter<bool>("online",false);
43  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
44  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
45  debug_ = ps.getUntrackedParameter<int>("debug",0);
46  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
47  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
48  prefixME_.append("/");
49  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","DetDiagTimingMonitor_Hcal");
50  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
51  subdir_.append("/");
52  subdir_=prefixME_+subdir_;
53  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
54  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
55  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
56  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
57 
58  GCTTriggerBit1_= ps.getUntrackedParameter<int>("GCTTriggerBit1", 15);
59  GCTTriggerBit2_= ps.getUntrackedParameter<int>("GCTTriggerBit2", 16);
60  GCTTriggerBit3_= ps.getUntrackedParameter<int>("GCTTriggerBit3", 17);
61  GCTTriggerBit4_= ps.getUntrackedParameter<int>("GCTTriggerBit4", 18);
62  GCTTriggerBit5_= ps.getUntrackedParameter<int>("GCTTriggerBit5", 16);
63  CosmicsCorr_ = ps.getUntrackedParameter<bool>("CosmicsCorr", true);
64 
67 
68  // register for data access
69  tok_raw_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<edm::InputTag>("FEDRawDataCollection",edm::InputTag("source","")));
70  tok_l1_ = consumes<L1GlobalTriggerReadoutRecord>(L1ADataLabel_);
71  tok_l1mu_ = consumes<L1MuGMTReadoutCollection>(L1ADataLabel_);
72  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabelDigi_);
73  tok_ho_ = consumes<HODigiCollection>(inputLabelDigi_);
74  tok_hf_ = consumes<HFDigiCollection>(inputLabelDigi_);
75 }
76 
78 
80  if(dbe_){
83  dbe_ = 0;
84  }
85 }
87 
89 {
90  if (debug_>1) std::cout <<"HcalDetDiagTimingMonitor::beginRun"<<std::endl;
92 
93  if (tevt_==0) this->setup(); // set up histograms if they have not been created before
94  if (mergeRuns_==false)
95  this->reset();
96 
97  return;
98 
99 } // void HcalNDetDiagTimingMonitor::beginRun(...)
100 
101 
102 
104 {
105 
107 
108  std::string str;
109  if(dbe_!=NULL){
111  str="Hcal Timing summary"; Summary = dbe_->book2D(str,str,6,0,6,6,0,6);
112  Summary->setBinLabel(1,"DT",1);
113  Summary->setBinLabel(2,"RPC",1);
114  Summary->setBinLabel(3,"GCT",1);
115  Summary->setBinLabel(4,"CSC",1);
116  Summary->setBinLabel(5,"RPCf",1);
117  Summary->setBinLabel(6,"bit11",1);
118  Summary->setBinLabel(1,"HB",2);
119  Summary->setBinLabel(2,"HO",2);
120  Summary->setBinLabel(3,"HEM",2);
121  Summary->setBinLabel(4,"HEP",2);
122  Summary->setBinLabel(5,"HFM",2);
123  Summary->setBinLabel(6,"HFP",2);
124  for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) Summary->setBinContent(i,j,-1);
125 
126  dbe_->setCurrentFolder(subdir_+"Timing Plots");
127  str="HB Timing (DT Trigger)"; HBTimeDT = dbe_->book1D(str,str,100,0,10);
128  str="HO Timing (DT Trigger)"; HOTimeDT = dbe_->book1D(str,str,100,0,10);
129  str="HB Timing (RPC Trigger)"; HBTimeRPC = dbe_->book1D(str,str,100,0,10);
130  str="HO Timing (RPC Trigger)"; HOTimeRPC = dbe_->book1D(str,str,100,0,10);
131  str="HB Timing (HO SelfTrigger tech bit 11)"; HBTimeHO = dbe_->book1D(str,str,100,0,10);
132  str="HO Timing (HO SelfTrigger tech bit 11)"; HOTimeHO = dbe_->book1D(str,str,100,0,10);
133 
134  str="HB Timing (GCT Trigger alg bit 15 16 17 18)"; HBTimeGCT =dbe_->book1D(str,str,100,0,10);
135  str="HO Timing (GCT Trigger alg bit 15 16 17 18)"; HOTimeGCT =dbe_->book1D(str,str,100,0,10);
136 
137  str="HEP Timing (CSC Trigger)"; HETimeCSCp =dbe_->book1D(str,str,100,0,10);
138  str="HEM Timing (CSC Trigger)"; HETimeCSCm =dbe_->book1D(str,str,100,0,10);
139  str="HEP Timing (RPCf Trigger)"; HETimeRPCp =dbe_->book1D(str,str,100,0,10);
140  str="HEM Timing (RPCf Trigger)"; HETimeRPCm =dbe_->book1D(str,str,100,0,10);
141  str="HFP Timing (CSC Trigger)"; HFTimeCSCp =dbe_->book1D(str,str,100,0,10);
142  str="HFM Timing (CSC Trigger)"; HFTimeCSCm =dbe_->book1D(str,str,100,0,10);
143  }
144 }
145 
147 {
148  if (!IsAllowedCalibType()) return;
149  if (LumiInOrder(iEvent.luminosityBlock())==false) return;
150  HcalBaseDQMonitor::analyze(iEvent, iSetup);
151 
152  int eta,phi,depth,nTS,BXinEVENT=1,TRIGGER=0;
153 
154  if(!dbe_) return;
155  // We do not want to look at Abort Gap events
157  iEvent.getByToken(tok_raw_,rawdata);
158  //checking FEDs for calibration information
159  if(!rawdata.isValid()) return;
161  const FEDRawData& fedData = rawdata->FEDData(i) ;
162  if ( fedData.size() < 24 ) continue ;
163  if(((const HcalDCCHeader*)(fedData.data()))->getCalibType()!=hc_Null) return;
164  }
167  bool GCTTrigger1=false,GCTTrigger2=false,GCTTrigger3=false,GCTTrigger4=false,GCTTrigger5=false,HOselfTrigger=false;
168  // Check GCT trigger bits
170  iEvent.getByToken(tok_l1_, gtRecord);
171  if(gtRecord.isValid()){
172 
173  const TechnicalTriggerWord tWord = gtRecord->technicalTriggerWord();
174  const DecisionWord dWord = gtRecord->decisionWord();
175  //bool HFselfTrigger = tWord.at(9);
176  if (!tWord.empty()) HOselfTrigger = tWord.at(11);
177 
178  if (!dWord.empty())
179  {
180  GCTTrigger1 = dWord.at(GCTTriggerBit1_);
181  GCTTrigger2 = dWord.at(GCTTriggerBit2_);
182  GCTTrigger3 = dWord.at(GCTTriggerBit3_);
183  GCTTrigger4 = dWord.at(GCTTriggerBit4_);
184  GCTTrigger5 = dWord.at(GCTTriggerBit5_);
185  }
186 
187  // define trigger trigger source (example from GMT group)
189  iEvent.getByToken(tok_l1mu_,gmtrc_handle);
190  if(!gmtrc_handle.isValid()) return;
191  L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
192 
193  int idt =0;
194  int icsc =0;
195  int irpcb =0;
196  int irpcf =0;
197  int ndt[5] = {0,0,0,0,0};
198  int ncsc[5] = {0,0,0,0,0};
199  int nrpcb[5] = {0,0,0,0,0};
200  int nrpcf[5] = {0,0,0,0,0};
201  int N;
202  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
203  std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
204  N=0;
205  int NN=0;
206  for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
207  if(igmtrr->getBxInEvent()==0) BXinEVENT=NN;
208  NN++;
209  std::vector<L1MuRegionalCand>::const_iterator iter1;
210  std::vector<L1MuRegionalCand> rmc;
211  // DTBX Trigger
212  rmc = igmtrr->getDTBXCands();
213  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
214  if ( idt < MAXDTBX && !(*iter1).empty() ) {
215  idt++;
216  if(N<5) ndt[N]++;
217 
218  }
219  }
220  // CSC Trigger
221  rmc = igmtrr->getCSCCands();
222  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
223  if ( icsc < MAXCSC && !(*iter1).empty() ) {
224  icsc++;
225  if(N<5) ncsc[N]++;
226  }
227  }
228  // RPCb Trigger
229  rmc = igmtrr->getBrlRPCCands();
230  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
231  if ( irpcb < MAXRPC && !(*iter1).empty() ) {
232  irpcb++;
233  if(N<5) nrpcb[N]++;
234 
235  }
236  }
237  // RPCfwd Trigger
238  rmc = igmtrr->getFwdRPCCands();
239  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
240  if ( irpcf < MAXRPC && !(*iter1).empty() ) {
241  irpcf++;
242  if(N<5) nrpcf[N]++;
243 
244  }
245  }
246 
247  N++;
248  }
249  if(ncsc[BXinEVENT]>0 ) { TRIGGER=+TRIG_CSC; }
250  if(ndt[BXinEVENT]>0 ) { TRIGGER=+TRIG_DT; }
251  if(nrpcb[BXinEVENT]>0) { TRIGGER=+TRIG_RPC; }
252  if(nrpcf[BXinEVENT]>0) { TRIGGER=+TRIG_RPCF; }
253  if(GCTTrigger1 || GCTTrigger2 || GCTTrigger3 || GCTTrigger4 || GCTTrigger5) { TRIGGER=+TRIG_GCT; }
254  }
257  if(ievt_<100){
259  iEvent.getByToken(tok_hbhe_,hbhe);
260  if(hbhe.isValid()){
261  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
262  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
263  for(int i=0;i<nTS;i++) if(digi->sample(i).adc()<20) set_hbhe(eta,phi,depth,digi->sample(i).capid(),adc2fC[digi->sample(i).adc()]);
264  }
265  }
267  iEvent.getByToken(tok_ho_,ho);
268  if(ho.isValid()){
269  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
270  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
271  for(int i=0;i<nTS;i++) if(digi->sample(i).adc()<20) set_ho(eta,phi,depth,digi->sample(i).capid(),adc2fC[digi->sample(i).adc()]);
272  }
273  }
275  iEvent.getByToken(tok_hf_,hf);
276  if(hf.isValid()){
277  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
278  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
279  for(int i=0;i<nTS;i++) if(digi->sample(i).adc()<20) set_hf(eta,phi,depth,digi->sample(i).capid(),adc2fC[digi->sample(i).adc()]);
280  }
281  }
282  return;
283  }
286  double data[20];
288  iEvent.getByToken(tok_hbhe_,hbhe);
289  if(hbhe.isValid()){
290  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
291  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
292  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hbhe(eta,phi,depth,digi->sample(i).capid());
293  if(!isSignal(data,nTS)) continue;
294 
295  occHBHE[eta+50][phi][depth]+=1.0; occSum+=1.0;
296  if((occHBHE[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
297 
298  double Time=GetTime(data,nTS);
299  if(digi->id().subdet()==HcalBarrel){
300  if(TRIGGER==TRIG_GCT) HBTimeGCT->Fill(Time);
301  if(CosmicsCorr_) Time+=(7.5*sin((phi*5.0)/180.0*3.14159))/25.0;
302  if(TRIGGER==TRIG_DT) HBTimeDT->Fill(Time);
303  if(HOselfTrigger) HBTimeHO->Fill(Time);
304  if(TRIGGER==TRIG_RPC) HBTimeRPC->Fill(Time);
305  }
306  if(digi->id().subdet()==HcalEndcap){
307  if(CosmicsCorr_) Time+=(3.5*sin((phi*5.0)/180.0*3.14159))/25.0;
308  if(TRIGGER==TRIG_CSC && eta>0) HETimeCSCp->Fill(Time);
309  if(TRIGGER==TRIG_CSC && eta<0) HETimeCSCm->Fill(Time);
310  if(TRIGGER==TRIG_RPCF && eta>0) HETimeRPCp->Fill(Time);
311  if(TRIGGER==TRIG_RPCF && eta<0) HETimeRPCm->Fill(Time);
312  }
313 
314  }
315  }
317  iEvent.getByToken(tok_ho_,ho);
318  if(ho.isValid()){
319  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
320  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
321  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_ho(eta,phi,depth,digi->sample(i).capid());
322  if(!isSignal(data,nTS)) continue;
323  occHO[eta+50][phi][depth]+=1.0;
324  occSum+=1.0;
325  if((occHO[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
326 
327  double Time=GetTime(data,nTS);
328  if(CosmicsCorr_) Time+=(12.0*sin((phi*5.0)/180.0*3.14159))/25.0;
329  if(TRIGGER==TRIG_DT) HOTimeDT ->Fill(Time);
330  if(HOselfTrigger) HOTimeHO ->Fill(Time);
331  if(TRIGGER==TRIG_RPC) HOTimeRPC->Fill(Time);
332  if(TRIGGER==TRIG_GCT) HOTimeGCT->Fill(Time);
333  }
334  }
336  iEvent.getByToken(tok_hf_,hf);
337  if(hf.isValid()){
338  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
339  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
340  double energy=0;
341  for(int i=0;i<nTS;i++){
342  data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hf(eta,phi,depth,digi->sample(i).capid());
343  energy+=data[i];
344  }
345 
346  if(energy<25.0) continue;
347  occHF[eta+50][phi][depth]+=1.0;
348  occSum+=1.0;
349 
350  double Time=GetTime(data,nTS);
351  if((occHF[eta+50][phi][depth]/(double)(ievt_))>0.01) continue;
352 
353  if(TRIGGER==TRIG_CSC && eta>0) HFTimeCSCp->Fill(Time);
354  if(TRIGGER==TRIG_CSC && eta<0) HFTimeCSCm->Fill(Time);
355  }
356  }
357  if((ievt_%500)==0){
358  CheckTiming();
359  //printf("Run: %i, Evants processed: %i\n",iEvent.run(),ievt_);
360  }
361 }
362 
364  if(HBTimeDT->getEntries()>10){
365  Summary->setBinContent(1,1,1);
366  }
367  if(HBTimeRPC->getEntries()>10){
368  Summary->setBinContent(2,1,1);
369  }
370  if(HBTimeGCT->getEntries()>10){
371  Summary->setBinContent(3,1,1);
372  }
373  if(HBTimeHO->getEntries()>10){
374  Summary->setBinContent(6,1,1);
375  }
376  if(HOTimeDT->getEntries()>10){
377  Summary->setBinContent(1,2,1);
378  }
379  if(HOTimeRPC->getEntries()>10){
380  Summary->setBinContent(2,2,1);
381  }
382  if(HOTimeGCT->getEntries()>10){
383  Summary->setBinContent(3,2,1);
384  }
385  if(HOTimeHO->getEntries()>10){
386  Summary->setBinContent(6,2,1);
387  }
388  if(HETimeCSCp->getEntries()>10){
389  Summary->setBinContent(4,4,1);
390  }
391  if(HETimeCSCm->getEntries()>10){
392  Summary->setBinContent(4,3,1);
393  }
394  if(HETimeRPCp->getEntries()>10){
395  Summary->setBinContent(5,4,1);
396  }
397  if(HETimeRPCm->getEntries()>10){
398  Summary->setBinContent(5,3,1);
399  }
400  if(HFTimeCSCp->getEntries()>10){
401  Summary->setBinContent(4,6,1);
402  }
403  if(HFTimeCSCm->getEntries()>10){
404  Summary->setBinContent(4,4,1);
405  }
406 }
407 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
static const int MAXCSC
void setBinContent(int binx, double content)
set content of bin (1-D)
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void set_hf(int eta, int phi, int depth, int cap, float val)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
static const int TRIG_CSC
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< int > AllowedCalibTypes_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< HBHEDataFrame >::const_iterator const_iterator
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
#define NULL
Definition: scimark2.h:8
static const int MAXRPC
T eta() const
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
double getEntries(void) const
get # of entries
static const int MAXGEN
static const float adc2fC[128]
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void Fill(long long x)
edm::EDGetTokenT< HFDigiCollection > tok_hf_
static const int TRIG_RPC
int iEvent
Definition: GenABIO.cc:243
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2764
static const int MAXDTBX
bool isSignal(double *data, int n)
double get_ped_ho(int eta, int phi, int depth, int cup)
std::vector< bool > DecisionWord
typedefs
static const int TRIG_GCT
int j
Definition: DBlmapReader.cc:9
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
edm::EDGetTokenT< L1MuGMTReadoutCollection > tok_l1mu_
bool isValid() const
Definition: HandleBase.h:76
void set_ho(int eta, int phi, int depth, int cap, float val)
#define N
Definition: blowfish.cc:9
static const int TRIG_RPCF
HcalDetDiagTimingMonitor(const edm::ParameterSet &ps)
double get_ped_hbhe(int eta, int phi, int depth, int cup)
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > tok_l1_
double get_ped_hf(int eta, int phi, int depth, int cup)
T const * product() const
Definition: Handle.h:81
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void beginRun(const edm::Run &run, const edm::EventSetup &c)
void set_hbhe(int eta, int phi, int depth, int cap, float val)
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
static const int MAXGMT
tuple cout
Definition: gather_cfg.py:121
dictionary rawdata
Definition: lumiPlot.py:393
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
virtual void setup(void)
double GetTime(double *data, int n)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
edm::EDGetTokenT< HODigiCollection > tok_ho_
Definition: Run.h:41
static const int TRIG_DT
Definition: DDAxes.h:10