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;
153  const FEDRawData& fedData = rawdata->FEDData(i) ;
154  if ( fedData.size() < 24 ) continue ;
155  if(((const HcalDCCHeader*)(fedData.data()))->getCalibType()!=hc_Null) return;
156  }
159  bool GCTTrigger1=false,GCTTrigger2=false,GCTTrigger3=false,GCTTrigger4=false,GCTTrigger5=false,HOselfTrigger=false;
160  // Check GCT trigger bits
162  iEvent.getByToken(tok_l1_, gtRecord);
163  if(gtRecord.isValid()){
164 
165  const TechnicalTriggerWord tWord = gtRecord->technicalTriggerWord();
166  const DecisionWord dWord = gtRecord->decisionWord();
167  //bool HFselfTrigger = tWord.at(9);
168  if (!tWord.empty()) HOselfTrigger = tWord.at(11);
169 
170  if (!dWord.empty())
171  {
172  GCTTrigger1 = dWord.at(GCTTriggerBit1_);
173  GCTTrigger2 = dWord.at(GCTTriggerBit2_);
174  GCTTrigger3 = dWord.at(GCTTriggerBit3_);
175  GCTTrigger4 = dWord.at(GCTTriggerBit4_);
176  GCTTrigger5 = dWord.at(GCTTriggerBit5_);
177  }
178 
179  // define trigger trigger source (example from GMT group)
181  iEvent.getByToken(tok_l1mu_,gmtrc_handle);
182  if(!gmtrc_handle.isValid()) return;
183  L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
184 
185  int idt =0;
186  int icsc =0;
187  int irpcb =0;
188  int irpcf =0;
189  int ndt[5] = {0,0,0,0,0};
190  int ncsc[5] = {0,0,0,0,0};
191  int nrpcb[5] = {0,0,0,0,0};
192  int nrpcf[5] = {0,0,0,0,0};
193  int N;
194  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
195  std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
196  N=0;
197  int NN=0;
198  for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
199  if(igmtrr->getBxInEvent()==0) BXinEVENT=NN;
200  NN++;
201  std::vector<L1MuRegionalCand>::const_iterator iter1;
202  std::vector<L1MuRegionalCand> rmc;
203  // DTBX Trigger
204  rmc = igmtrr->getDTBXCands();
205  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
206  if ( idt < MAXDTBX && !(*iter1).empty() ) {
207  idt++;
208  if(N<5) ndt[N]++;
209 
210  }
211  }
212  // CSC Trigger
213  rmc = igmtrr->getCSCCands();
214  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
215  if ( icsc < MAXCSC && !(*iter1).empty() ) {
216  icsc++;
217  if(N<5) ncsc[N]++;
218  }
219  }
220  // RPCb Trigger
221  rmc = igmtrr->getBrlRPCCands();
222  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
223  if ( irpcb < MAXRPC && !(*iter1).empty() ) {
224  irpcb++;
225  if(N<5) nrpcb[N]++;
226 
227  }
228  }
229  // RPCfwd Trigger
230  rmc = igmtrr->getFwdRPCCands();
231  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
232  if ( irpcf < MAXRPC && !(*iter1).empty() ) {
233  irpcf++;
234  if(N<5) nrpcf[N]++;
235 
236  }
237  }
238 
239  N++;
240  }
241  if(ncsc[BXinEVENT]>0 ) { TRIGGER=+TRIG_CSC; }
242  if(ndt[BXinEVENT]>0 ) { TRIGGER=+TRIG_DT; }
243  if(nrpcb[BXinEVENT]>0) { TRIGGER=+TRIG_RPC; }
244  if(nrpcf[BXinEVENT]>0) { TRIGGER=+TRIG_RPCF; }
245  if(GCTTrigger1 || GCTTrigger2 || GCTTrigger3 || GCTTrigger4 || GCTTrigger5) { TRIGGER=+TRIG_GCT; }
246  }
249  if(ievt_<100){
251  iEvent.getByToken(tok_hbhe_,hbhe);
252  if(hbhe.isValid()){
253  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
254  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
255  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()]);
256  }
257  }
259  iEvent.getByToken(tok_ho_,ho);
260  if(ho.isValid()){
261  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->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_ho(eta,phi,depth,digi->sample(i).capid(),adc2fC[digi->sample(i).adc()]);
264  }
265  }
267  iEvent.getByToken(tok_hf_,hf);
268  if(hf.isValid()){
269  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->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_hf(eta,phi,depth,digi->sample(i).capid(),adc2fC[digi->sample(i).adc()]);
272  }
273  }
274  return;
275  }
278  double data[20];
280  iEvent.getByToken(tok_hbhe_,hbhe);
281  if(hbhe.isValid()){
282  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
283  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
284  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hbhe(eta,phi,depth,digi->sample(i).capid());
285 
286  double energy=0;
287  for(int i=0;i<nTS;i++) energy+=data[i];
288  if(energy>20) for(int i=0;i<nTS;i++) HBHEShape->Fill(i,data[i]);
289 
290  if(!isSignal(data,nTS)) continue;
291 
292  occHBHE[eta+50][phi][depth]+=1.0; occSum+=1.0;
293  if((occHBHE[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
294 
295  double Time=GetTime(data,nTS);
296  if(digi->id().subdet()==HcalBarrel){
297  if(TRIGGER==TRIG_GCT) HBTimeGCT->Fill(Time);
298  if(CosmicsCorr_) Time+=(7.5*sin((phi*5.0)/180.0*3.14159))/25.0;
299  if(TRIGGER==TRIG_DT) HBTimeDT->Fill(Time);
300  if(HOselfTrigger) HBTimeHO->Fill(Time);
301  if(TRIGGER==TRIG_RPC) HBTimeRPC->Fill(Time);
302  }
303  if(digi->id().subdet()==HcalEndcap){
304  if(CosmicsCorr_) Time+=(3.5*sin((phi*5.0)/180.0*3.14159))/25.0;
305  if(TRIGGER==TRIG_CSC && eta>0) HETimeCSCp->Fill(Time);
306  if(TRIGGER==TRIG_CSC && eta<0) HETimeCSCm->Fill(Time);
307  if(TRIGGER==TRIG_RPCF && eta>0) HETimeRPCp->Fill(Time);
308  if(TRIGGER==TRIG_RPCF && eta<0) HETimeRPCm->Fill(Time);
309  }
310 
311  }
312  }
314  iEvent.getByToken(tok_ho_,ho);
315  if(ho.isValid()){
316  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
317  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
318  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_ho(eta,phi,depth,digi->sample(i).capid());
319 
320  double energy=0;
321  for(int i=0;i<nTS;i++) energy+=data[i];
322  if(energy>100) for(int i=0;i<nTS;i++) HOShape->Fill(i,data[i]);
323  if(energy<100) continue;
324 
325  occHO[eta+50][phi][depth]+=1.0;
326  occSum+=1.0;
327  if((occHO[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
328 
329  double Time=GetTime(data,nTS);
330  if(CosmicsCorr_) Time+=(12.0*sin((phi*5.0)/180.0*3.14159))/25.0;
331  if(TRIGGER==TRIG_DT) HOTimeDT ->Fill(Time);
332  if(HOselfTrigger) HOTimeHO ->Fill(Time);
333  if(TRIGGER==TRIG_RPC) HOTimeRPC->Fill(Time);
334  if(TRIGGER==TRIG_GCT) HOTimeGCT->Fill(Time);
335  }
336  }
338  iEvent.getByToken(tok_hf_,hf);
339  if(hf.isValid()){
340  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
341  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
342  double energy=0;
343  for(int i=0;i<nTS;i++){
344  data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hf(eta,phi,depth,digi->sample(i).capid());
345  energy+=data[i];
346  }
347 
348  if(energy<25.0) continue;
349  occHF[eta+50][phi][depth]+=1.0;
350  occSum+=1.0;
351 
352  double Time=GetTime(data,nTS);
353  if((occHF[eta+50][phi][depth]/(double)(ievt_))>0.01) continue;
354 
355  if(TRIGGER==TRIG_CSC && eta>0) HFTimeCSCp->Fill(Time);
356  if(TRIGGER==TRIG_CSC && eta<0) HFTimeCSCm->Fill(Time);
357  }
358  }
359  if((ievt_%500)==0){
360  CheckTiming();
361  //printf("Run: %i, Evants processed: %i\n",iEvent.run(),ievt_);
362  }
363 }
364 
366  if(HBTimeDT->getEntries()>10){
367  Summary->setBinContent(1,1,1);
368  }
369  if(HBTimeRPC->getEntries()>10){
370  Summary->setBinContent(2,1,1);
371  }
372  if(HBTimeGCT->getEntries()>10){
373  Summary->setBinContent(3,1,1);
374  }
375  if(HBTimeHO->getEntries()>10){
376  Summary->setBinContent(6,1,1);
377  }
378  if(HOTimeDT->getEntries()>10){
379  Summary->setBinContent(1,2,1);
380  }
381  if(HOTimeRPC->getEntries()>10){
382  Summary->setBinContent(2,2,1);
383  }
384  if(HOTimeGCT->getEntries()>10){
385  Summary->setBinContent(3,2,1);
386  }
387  if(HOTimeHO->getEntries()>10){
388  Summary->setBinContent(6,2,1);
389  }
390  if(HETimeCSCp->getEntries()>10){
391  Summary->setBinContent(4,4,1);
392  }
393  if(HETimeCSCm->getEntries()>10){
394  Summary->setBinContent(4,3,1);
395  }
396  if(HETimeRPCp->getEntries()>10){
397  Summary->setBinContent(5,4,1);
398  }
399  if(HETimeRPCm->getEntries()>10){
400  Summary->setBinContent(5,3,1);
401  }
402  if(HFTimeCSCp->getEntries()>10){
403  Summary->setBinContent(4,6,1);
404  }
405  if(HFTimeCSCm->getEntries()>10){
406  Summary->setBinContent(4,4,1);
407  }
408 }
409 
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:449
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:63
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
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 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:274
#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:121
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:41
static const int TRIG_DT
Definition: DDAxes.h:10