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 MAXRPC =20;
30 static const int MAXDTBX=20;
31 static const int MAXCSC =20;
32 static const int TRIG_DT =1;
33 static const int TRIG_RPC=2;
34 static const int TRIG_GCT=4;
35 static const int TRIG_CSC=8;
36 static const int TRIG_RPCF=16;
37 
39 {
40  Online_ = ps.getUntrackedParameter<bool>("online",false);
41  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
42  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
43  debug_ = ps.getUntrackedParameter<int>("debug",0);
44  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
45  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
46  prefixME_.append("/");
47  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","DetDiagTimingMonitor_Hcal");
48  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
49  subdir_.append("/");
50  subdir_=prefixME_+subdir_;
51  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
52  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
53  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
54  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
55 
56  GCTTriggerBit1_= ps.getUntrackedParameter<int>("GCTTriggerBit1", 15);
57  GCTTriggerBit2_= ps.getUntrackedParameter<int>("GCTTriggerBit2", 16);
58  GCTTriggerBit3_= ps.getUntrackedParameter<int>("GCTTriggerBit3", 17);
59  GCTTriggerBit4_= ps.getUntrackedParameter<int>("GCTTriggerBit4", 18);
60  GCTTriggerBit5_= ps.getUntrackedParameter<int>("GCTTriggerBit5", 16);
61  CosmicsCorr_ = ps.getUntrackedParameter<bool>("CosmicsCorr", true);
62 
65 
66  // register for data access
67  tok_raw_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<edm::InputTag>("FEDRawDataCollection",edm::InputTag("source","")));
68  tok_l1_ = consumes<L1GlobalTriggerReadoutRecord>(L1ADataLabel_);
69  tok_l1mu_ = consumes<L1MuGMTReadoutCollection>(L1ADataLabel_);
70  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabelDigi_);
71  tok_ho_ = consumes<HODigiCollection>(inputLabelDigi_);
72  tok_hf_ = consumes<HFDigiCollection>(inputLabelDigi_);
73 }
74 
76 
78 
80 {
81  if (debug_>1) std::cout <<"HcalDetDiagTimingMonitor::bookHistograms"<<std::endl;
83 
84  if (tevt_==0) this->setup(ib); // set up histograms if they have not been created before
85  if (mergeRuns_==false)
86  this->reset();
87 
88  return;
89 
90 } // void HcalNDetDiagTimingMonitor::bookHistograms(...)
91 
92 
93 
95 {
96 
98 
99  std::string str;
101  str="Hcal Timing summary"; Summary = ib.book2D(str,str,6,0,6,6,0,6);
102  Summary->setBinLabel(1,"DT",1);
103  Summary->setBinLabel(2,"RPC",1);
104  Summary->setBinLabel(3,"GCT",1);
105  Summary->setBinLabel(4,"CSC",1);
106  Summary->setBinLabel(5,"RPCf",1);
107  Summary->setBinLabel(6,"bit11",1);
108  Summary->setBinLabel(1,"HB",2);
109  Summary->setBinLabel(2,"HO",2);
110  Summary->setBinLabel(3,"HEM",2);
111  Summary->setBinLabel(4,"HEP",2);
112  Summary->setBinLabel(5,"HFM",2);
113  Summary->setBinLabel(6,"HFP",2);
114  for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) Summary->setBinContent(i,j,-1);
115 
116  ib.setCurrentFolder(subdir_+"Timing Plots");
117  str="HB Timing (DT Trigger)"; HBTimeDT = ib.book1D(str,str,100,0,10);
118  str="HO Timing (DT Trigger)"; HOTimeDT = ib.book1D(str,str,100,0,10);
119  str="HB Timing (RPC Trigger)"; HBTimeRPC = ib.book1D(str,str,100,0,10);
120  str="HO Timing (RPC Trigger)"; HOTimeRPC = ib.book1D(str,str,100,0,10);
121  str="HB Timing (HO SelfTrigger tech bit 11)"; HBTimeHO = ib.book1D(str,str,100,0,10);
122  str="HO Timing (HO SelfTrigger tech bit 11)"; HOTimeHO = ib.book1D(str,str,100,0,10);
123 
124  str="HB Timing (GCT Trigger alg bit 15 16 17 18)"; HBTimeGCT =ib.book1D(str,str,100,0,10);
125  str="HO Timing (GCT Trigger alg bit 15 16 17 18)"; HOTimeGCT =ib.book1D(str,str,100,0,10);
126 
127  str="HEP Timing (CSC Trigger)"; HETimeCSCp =ib.book1D(str,str,100,0,10);
128  str="HEM Timing (CSC Trigger)"; HETimeCSCm =ib.book1D(str,str,100,0,10);
129  str="HEP Timing (RPCf Trigger)"; HETimeRPCp =ib.book1D(str,str,100,0,10);
130  str="HEM Timing (RPCf Trigger)"; HETimeRPCm =ib.book1D(str,str,100,0,10);
131  str="HFP Timing (CSC Trigger)"; HFTimeCSCp =ib.book1D(str,str,100,0,10);
132  str="HFM Timing (CSC Trigger)"; HFTimeCSCm =ib.book1D(str,str,100,0,10);
133  str="HBHE Shape"; HBHEShape =ib.book1D(str,str,10,-0.5,9.5);
134  str="HO Shape"; HOShape =ib.book1D(str,str,10,-0.5,9.5);
135 
136 }
137 
139 {
140  HcalBaseDQMonitor::analyze(iEvent, iSetup);
141  if (!IsAllowedCalibType()) return;
142  if (LumiInOrder(iEvent.luminosityBlock())==false) return;
143 // HcalBaseDQMonitor::analyze(iEvent, iSetup);
144 
145  int eta,phi,depth,nTS,BXinEVENT=1,TRIGGER=0;
146 
147  // We do not want to look at Abort Gap events
149  iEvent.getByToken(tok_raw_,rawdata);
150  //checking FEDs for calibration information
151  if(!rawdata.isValid()) return;
154  {
156  continue;
157 
158  const FEDRawData& fedData = rawdata->FEDData(i) ;
159  if ( fedData.size() < 24 ) continue ;
160  if(((const HcalDCCHeader*)(fedData.data()))->getCalibType()!=hc_Null) return;
161  }
164  bool GCTTrigger1=false,GCTTrigger2=false,GCTTrigger3=false,GCTTrigger4=false,GCTTrigger5=false,HOselfTrigger=false;
165  // Check GCT trigger bits
167  iEvent.getByToken(tok_l1_, gtRecord);
168  if(gtRecord.isValid()){
169 
170  const TechnicalTriggerWord tWord = gtRecord->technicalTriggerWord();
171  const DecisionWord dWord = gtRecord->decisionWord();
172  //bool HFselfTrigger = tWord.at(9);
173  if (!tWord.empty()) HOselfTrigger = tWord.at(11);
174 
175  if (!dWord.empty())
176  {
177  GCTTrigger1 = dWord.at(GCTTriggerBit1_);
178  GCTTrigger2 = dWord.at(GCTTriggerBit2_);
179  GCTTrigger3 = dWord.at(GCTTriggerBit3_);
180  GCTTrigger4 = dWord.at(GCTTriggerBit4_);
181  GCTTrigger5 = dWord.at(GCTTriggerBit5_);
182  }
183 
184  // define trigger trigger source (example from GMT group)
186  iEvent.getByToken(tok_l1mu_,gmtrc_handle);
187  if(!gmtrc_handle.isValid()) return;
188  L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
189 
190  int idt =0;
191  int icsc =0;
192  int irpcb =0;
193  int irpcf =0;
194  int ndt[5] = {0,0,0,0,0};
195  int ncsc[5] = {0,0,0,0,0};
196  int nrpcb[5] = {0,0,0,0,0};
197  int nrpcf[5] = {0,0,0,0,0};
198  int N;
199  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
200  std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
201  N=0;
202  int NN=0;
203  for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
204  if(igmtrr->getBxInEvent()==0) BXinEVENT=NN;
205  NN++;
206  std::vector<L1MuRegionalCand>::const_iterator iter1;
207  std::vector<L1MuRegionalCand> rmc;
208  // DTBX Trigger
209  rmc = igmtrr->getDTBXCands();
210  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
211  if ( idt < MAXDTBX && !(*iter1).empty() ) {
212  idt++;
213  if(N<5) ndt[N]++;
214 
215  }
216  }
217  // CSC Trigger
218  rmc = igmtrr->getCSCCands();
219  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
220  if ( icsc < MAXCSC && !(*iter1).empty() ) {
221  icsc++;
222  if(N<5) ncsc[N]++;
223  }
224  }
225  // RPCb Trigger
226  rmc = igmtrr->getBrlRPCCands();
227  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
228  if ( irpcb < MAXRPC && !(*iter1).empty() ) {
229  irpcb++;
230  if(N<5) nrpcb[N]++;
231 
232  }
233  }
234  // RPCfwd Trigger
235  rmc = igmtrr->getFwdRPCCands();
236  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
237  if ( irpcf < MAXRPC && !(*iter1).empty() ) {
238  irpcf++;
239  if(N<5) nrpcf[N]++;
240 
241  }
242  }
243 
244  N++;
245  }
246  if(ncsc[BXinEVENT]>0 ) { TRIGGER=+TRIG_CSC; }
247  if(ndt[BXinEVENT]>0 ) { TRIGGER=+TRIG_DT; }
248  if(nrpcb[BXinEVENT]>0) { TRIGGER=+TRIG_RPC; }
249  if(nrpcf[BXinEVENT]>0) { TRIGGER=+TRIG_RPCF; }
250  if(GCTTrigger1 || GCTTrigger2 || GCTTrigger3 || GCTTrigger4 || GCTTrigger5) { TRIGGER=+TRIG_GCT; }
251  }
254  if(ievt_<100){
256  iEvent.getByToken(tok_hbhe_,hbhe);
257  if(hbhe.isValid()){
258  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
259  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
260  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()]);
261  }
262  }
264  iEvent.getByToken(tok_ho_,ho);
265  if(ho.isValid()){
266  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
267  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
268  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()]);
269  }
270  }
272  iEvent.getByToken(tok_hf_,hf);
273  if(hf.isValid()){
274  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
275  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
276  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()]);
277  }
278  }
279  return;
280  }
283  double data[20];
285  iEvent.getByToken(tok_hbhe_,hbhe);
286  if(hbhe.isValid()){
287  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
288  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
289  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hbhe(eta,phi,depth,digi->sample(i).capid());
290 
291  double energy=0;
292  for(int i=0;i<nTS;i++) energy+=data[i];
293  if(energy>20) for(int i=0;i<nTS;i++) HBHEShape->Fill(i,data[i]);
294 
295  if(!isSignal(data,nTS)) continue;
296 
297  occHBHE[eta+50][phi][depth]+=1.0; occSum+=1.0;
298  if((occHBHE[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
299 
300  double Time=GetTime(data,nTS);
301  if(digi->id().subdet()==HcalBarrel){
302  if(TRIGGER==TRIG_GCT) HBTimeGCT->Fill(Time);
303  if(CosmicsCorr_) Time+=(7.5*sin((phi*5.0)/180.0*3.14159))/25.0;
304  if(TRIGGER==TRIG_DT) HBTimeDT->Fill(Time);
305  if(HOselfTrigger) HBTimeHO->Fill(Time);
306  if(TRIGGER==TRIG_RPC) HBTimeRPC->Fill(Time);
307  }
308  if(digi->id().subdet()==HcalEndcap){
309  if(CosmicsCorr_) Time+=(3.5*sin((phi*5.0)/180.0*3.14159))/25.0;
310  if(TRIGGER==TRIG_CSC && eta>0) HETimeCSCp->Fill(Time);
311  if(TRIGGER==TRIG_CSC && eta<0) HETimeCSCm->Fill(Time);
312  if(TRIGGER==TRIG_RPCF && eta>0) HETimeRPCp->Fill(Time);
313  if(TRIGGER==TRIG_RPCF && eta<0) HETimeRPCm->Fill(Time);
314  }
315 
316  }
317  }
319  iEvent.getByToken(tok_ho_,ho);
320  if(ho.isValid()){
321  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
322  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
323  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_ho(eta,phi,depth,digi->sample(i).capid());
324 
325  double energy=0;
326  for(int i=0;i<nTS;i++) energy+=data[i];
327  if(energy>100) for(int i=0;i<nTS;i++) HOShape->Fill(i,data[i]);
328  if(energy<100) continue;
329 
330  occHO[eta+50][phi][depth]+=1.0;
331  occSum+=1.0;
332  if((occHO[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
333 
334  double Time=GetTime(data,nTS);
335  if(CosmicsCorr_) Time+=(12.0*sin((phi*5.0)/180.0*3.14159))/25.0;
336  if(TRIGGER==TRIG_DT) HOTimeDT ->Fill(Time);
337  if(HOselfTrigger) HOTimeHO ->Fill(Time);
338  if(TRIGGER==TRIG_RPC) HOTimeRPC->Fill(Time);
339  if(TRIGGER==TRIG_GCT) HOTimeGCT->Fill(Time);
340  }
341  }
343  iEvent.getByToken(tok_hf_,hf);
344  if(hf.isValid()){
345  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
346  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
347  double energy=0;
348  for(int i=0;i<nTS;i++){
349  data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hf(eta,phi,depth,digi->sample(i).capid());
350  energy+=data[i];
351  }
352 
353  if(energy<25.0) continue;
354  occHF[eta+50][phi][depth]+=1.0;
355  occSum+=1.0;
356 
357  double Time=GetTime(data,nTS);
358  if((occHF[eta+50][phi][depth]/(double)(ievt_))>0.01) continue;
359 
360  if(TRIGGER==TRIG_CSC && eta>0) HFTimeCSCp->Fill(Time);
361  if(TRIGGER==TRIG_CSC && eta<0) HFTimeCSCm->Fill(Time);
362  }
363  }
364  if((ievt_%500)==0){
365  CheckTiming();
366  //printf("Run: %i, Evants processed: %i\n",iEvent.run(),ievt_);
367  }
368 }
369 
371  if(HBTimeDT->getEntries()>10){
372  Summary->setBinContent(1,1,1);
373  }
374  if(HBTimeRPC->getEntries()>10){
375  Summary->setBinContent(2,1,1);
376  }
377  if(HBTimeGCT->getEntries()>10){
378  Summary->setBinContent(3,1,1);
379  }
380  if(HBTimeHO->getEntries()>10){
381  Summary->setBinContent(6,1,1);
382  }
383  if(HOTimeDT->getEntries()>10){
384  Summary->setBinContent(1,2,1);
385  }
386  if(HOTimeRPC->getEntries()>10){
387  Summary->setBinContent(2,2,1);
388  }
389  if(HOTimeGCT->getEntries()>10){
390  Summary->setBinContent(3,2,1);
391  }
392  if(HOTimeHO->getEntries()>10){
393  Summary->setBinContent(6,2,1);
394  }
395  if(HETimeCSCp->getEntries()>10){
396  Summary->setBinContent(4,4,1);
397  }
398  if(HETimeCSCm->getEntries()>10){
399  Summary->setBinContent(4,3,1);
400  }
401  if(HETimeRPCp->getEntries()>10){
402  Summary->setBinContent(5,4,1);
403  }
404  if(HETimeRPCm->getEntries()>10){
405  Summary->setBinContent(5,3,1);
406  }
407  if(HFTimeCSCp->getEntries()>10){
408  Summary->setBinContent(4,6,1);
409  }
410  if(HFTimeCSCm->getEntries()>10){
411  Summary->setBinContent(4,4,1);
412  }
413 }
414 
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)
int ib
Definition: cuy.py:660
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
void set_hf(int eta, int phi, int depth, int cap, float val)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
std::vector< HBHEDataFrame >::const_iterator const_iterator
void setup(DQMStore::IBooker &)
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:62
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
static const int MAXRPC
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
double getEntries(void) const
get # of entries
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:230
void bookHistograms(DQMStore::IBooker &ib, const edm::Run &run, const edm::EventSetup &c)
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
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
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:75
void set_ho(int eta, int phi, int depth, int cap, float val)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
#define N
Definition: blowfish.cc:9
static const int TRIG_RPCF
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
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)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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
tuple cout
Definition: gather_cfg.py:145
dictionary rawdata
Definition: lumiPlot.py:393
double GetTime(double *data, int n)
virtual void setup(DQMStore::IBooker &)
edm::EDGetTokenT< HODigiCollection > tok_ho_
Definition: Run.h:43
static const int TRIG_DT