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  if(dbe_){
81  dbe_ = 0;
82  }
83 }
85 
87 {
88  if (debug_>1) std::cout <<"HcalDetDiagTimingMonitor::beginRun"<<std::endl;
90 
91  if (tevt_==0) this->setup(); // set up histograms if they have not been created before
92  if (mergeRuns_==false)
93  this->reset();
94 
95  return;
96 
97 } // void HcalNDetDiagTimingMonitor::beginRun(...)
98 
99 
100 
102 {
103 
105 
106  std::string str;
107  if(dbe_!=NULL){
109  str="Hcal Timing summary"; Summary = dbe_->book2D(str,str,6,0,6,6,0,6);
110  Summary->setBinLabel(1,"DT",1);
111  Summary->setBinLabel(2,"RPC",1);
112  Summary->setBinLabel(3,"GCT",1);
113  Summary->setBinLabel(4,"CSC",1);
114  Summary->setBinLabel(5,"RPCf",1);
115  Summary->setBinLabel(6,"bit11",1);
116  Summary->setBinLabel(1,"HB",2);
117  Summary->setBinLabel(2,"HO",2);
118  Summary->setBinLabel(3,"HEM",2);
119  Summary->setBinLabel(4,"HEP",2);
120  Summary->setBinLabel(5,"HFM",2);
121  Summary->setBinLabel(6,"HFP",2);
122  for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) Summary->setBinContent(i,j,-1);
123 
124  dbe_->setCurrentFolder(subdir_+"Timing Plots");
125  str="HB Timing (DT Trigger)"; HBTimeDT = dbe_->book1D(str,str,100,0,10);
126  str="HO Timing (DT Trigger)"; HOTimeDT = dbe_->book1D(str,str,100,0,10);
127  str="HB Timing (RPC Trigger)"; HBTimeRPC = dbe_->book1D(str,str,100,0,10);
128  str="HO Timing (RPC Trigger)"; HOTimeRPC = dbe_->book1D(str,str,100,0,10);
129  str="HB Timing (HO SelfTrigger tech bit 11)"; HBTimeHO = dbe_->book1D(str,str,100,0,10);
130  str="HO Timing (HO SelfTrigger tech bit 11)"; HOTimeHO = dbe_->book1D(str,str,100,0,10);
131 
132  str="HB Timing (GCT Trigger alg bit 15 16 17 18)"; HBTimeGCT =dbe_->book1D(str,str,100,0,10);
133  str="HO Timing (GCT Trigger alg bit 15 16 17 18)"; HOTimeGCT =dbe_->book1D(str,str,100,0,10);
134 
135  str="HEP Timing (CSC Trigger)"; HETimeCSCp =dbe_->book1D(str,str,100,0,10);
136  str="HEM Timing (CSC Trigger)"; HETimeCSCm =dbe_->book1D(str,str,100,0,10);
137  str="HEP Timing (RPCf Trigger)"; HETimeRPCp =dbe_->book1D(str,str,100,0,10);
138  str="HEM Timing (RPCf Trigger)"; HETimeRPCm =dbe_->book1D(str,str,100,0,10);
139  str="HFP Timing (CSC Trigger)"; HFTimeCSCp =dbe_->book1D(str,str,100,0,10);
140  str="HFM Timing (CSC Trigger)"; HFTimeCSCm =dbe_->book1D(str,str,100,0,10);
141  }
142 }
143 
145 {
146  if (!IsAllowedCalibType()) return;
147  if (LumiInOrder(iEvent.luminosityBlock())==false) return;
148  HcalBaseDQMonitor::analyze(iEvent, iSetup);
149 
150  int eta,phi,depth,nTS,BXinEVENT=1,TRIGGER=0;
151 
152  if(!dbe_) return;
153  // We do not want to look at Abort Gap events
155  iEvent.getByToken(tok_raw_,rawdata);
156  //checking FEDs for calibration information
157  if(!rawdata.isValid()) return;
159  const FEDRawData& fedData = rawdata->FEDData(i) ;
160  if ( fedData.size() < 24 ) continue ;
161  if(((const HcalDCCHeader*)(fedData.data()))->getCalibType()!=hc_Null) return;
162  }
165  bool GCTTrigger1=false,GCTTrigger2=false,GCTTrigger3=false,GCTTrigger4=false,GCTTrigger5=false,HOselfTrigger=false;
166  // Check GCT trigger bits
168  iEvent.getByToken(tok_l1_, gtRecord);
169  if(gtRecord.isValid()){
170 
171  const TechnicalTriggerWord tWord = gtRecord->technicalTriggerWord();
172  const DecisionWord dWord = gtRecord->decisionWord();
173  //bool HFselfTrigger = tWord.at(9);
174  if (!tWord.empty()) HOselfTrigger = tWord.at(11);
175 
176  if (!dWord.empty())
177  {
178  GCTTrigger1 = dWord.at(GCTTriggerBit1_);
179  GCTTrigger2 = dWord.at(GCTTriggerBit2_);
180  GCTTrigger3 = dWord.at(GCTTriggerBit3_);
181  GCTTrigger4 = dWord.at(GCTTriggerBit4_);
182  GCTTrigger5 = dWord.at(GCTTriggerBit5_);
183  }
184 
185  // define trigger trigger source (example from GMT group)
187  iEvent.getByToken(tok_l1mu_,gmtrc_handle);
188  if(!gmtrc_handle.isValid()) return;
189  L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
190 
191  int idt =0;
192  int icsc =0;
193  int irpcb =0;
194  int irpcf =0;
195  int ndt[5] = {0,0,0,0,0};
196  int ncsc[5] = {0,0,0,0,0};
197  int nrpcb[5] = {0,0,0,0,0};
198  int nrpcf[5] = {0,0,0,0,0};
199  int N;
200  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
201  std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
202  N=0;
203  int NN=0;
204  for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
205  if(igmtrr->getBxInEvent()==0) BXinEVENT=NN;
206  NN++;
207  std::vector<L1MuRegionalCand>::const_iterator iter1;
208  std::vector<L1MuRegionalCand> rmc;
209  // DTBX Trigger
210  rmc = igmtrr->getDTBXCands();
211  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
212  if ( idt < MAXDTBX && !(*iter1).empty() ) {
213  idt++;
214  if(N<5) ndt[N]++;
215 
216  }
217  }
218  // CSC Trigger
219  rmc = igmtrr->getCSCCands();
220  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
221  if ( icsc < MAXCSC && !(*iter1).empty() ) {
222  icsc++;
223  if(N<5) ncsc[N]++;
224  }
225  }
226  // RPCb Trigger
227  rmc = igmtrr->getBrlRPCCands();
228  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
229  if ( irpcb < MAXRPC && !(*iter1).empty() ) {
230  irpcb++;
231  if(N<5) nrpcb[N]++;
232 
233  }
234  }
235  // RPCfwd Trigger
236  rmc = igmtrr->getFwdRPCCands();
237  for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
238  if ( irpcf < MAXRPC && !(*iter1).empty() ) {
239  irpcf++;
240  if(N<5) nrpcf[N]++;
241 
242  }
243  }
244 
245  N++;
246  }
247  if(ncsc[BXinEVENT]>0 ) { TRIGGER=+TRIG_CSC; }
248  if(ndt[BXinEVENT]>0 ) { TRIGGER=+TRIG_DT; }
249  if(nrpcb[BXinEVENT]>0) { TRIGGER=+TRIG_RPC; }
250  if(nrpcf[BXinEVENT]>0) { TRIGGER=+TRIG_RPCF; }
251  if(GCTTrigger1 || GCTTrigger2 || GCTTrigger3 || GCTTrigger4 || GCTTrigger5) { TRIGGER=+TRIG_GCT; }
252  }
255  if(ievt_<100){
257  iEvent.getByToken(tok_hbhe_,hbhe);
258  if(hbhe.isValid()){
259  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
260  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
261  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()]);
262  }
263  }
265  iEvent.getByToken(tok_ho_,ho);
266  if(ho.isValid()){
267  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
268  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
269  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()]);
270  }
271  }
273  iEvent.getByToken(tok_hf_,hf);
274  if(hf.isValid()){
275  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
276  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
277  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()]);
278  }
279  }
280  return;
281  }
284  double data[20];
286  iEvent.getByToken(tok_hbhe_,hbhe);
287  if(hbhe.isValid()){
288  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
289  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
290  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hbhe(eta,phi,depth,digi->sample(i).capid());
291  if(!isSignal(data,nTS)) continue;
292 
293  occHBHE[eta+50][phi][depth]+=1.0; occSum+=1.0;
294  if((occHBHE[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
295 
296  double Time=GetTime(data,nTS);
297  if(digi->id().subdet()==HcalBarrel){
298  if(TRIGGER==TRIG_GCT) HBTimeGCT->Fill(Time);
299  if(CosmicsCorr_) Time+=(7.5*sin((phi*5.0)/180.0*3.14159))/25.0;
300  if(TRIGGER==TRIG_DT) HBTimeDT->Fill(Time);
301  if(HOselfTrigger) HBTimeHO->Fill(Time);
302  if(TRIGGER==TRIG_RPC) HBTimeRPC->Fill(Time);
303  }
304  if(digi->id().subdet()==HcalEndcap){
305  if(CosmicsCorr_) Time+=(3.5*sin((phi*5.0)/180.0*3.14159))/25.0;
306  if(TRIGGER==TRIG_CSC && eta>0) HETimeCSCp->Fill(Time);
307  if(TRIGGER==TRIG_CSC && eta<0) HETimeCSCm->Fill(Time);
308  if(TRIGGER==TRIG_RPCF && eta>0) HETimeRPCp->Fill(Time);
309  if(TRIGGER==TRIG_RPCF && eta<0) HETimeRPCm->Fill(Time);
310  }
311 
312  }
313  }
315  iEvent.getByToken(tok_ho_,ho);
316  if(ho.isValid()){
317  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
318  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
319  for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()]-get_ped_ho(eta,phi,depth,digi->sample(i).capid());
320  if(!isSignal(data,nTS)) continue;
321  occHO[eta+50][phi][depth]+=1.0;
322  occSum+=1.0;
323  if((occHO[eta+50][phi][depth]/(double)(ievt_))>0.001) continue;
324 
325  double Time=GetTime(data,nTS);
326  if(CosmicsCorr_) Time+=(12.0*sin((phi*5.0)/180.0*3.14159))/25.0;
327  if(TRIGGER==TRIG_DT) HOTimeDT ->Fill(Time);
328  if(HOselfTrigger) HOTimeHO ->Fill(Time);
329  if(TRIGGER==TRIG_RPC) HOTimeRPC->Fill(Time);
330  if(TRIGGER==TRIG_GCT) HOTimeGCT->Fill(Time);
331  }
332  }
334  iEvent.getByToken(tok_hf_,hf);
335  if(hf.isValid()){
336  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
337  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
338  double energy=0;
339  for(int i=0;i<nTS;i++){
340  data[i]=adc2fC[digi->sample(i).adc()]-get_ped_hf(eta,phi,depth,digi->sample(i).capid());
341  energy+=data[i];
342  }
343 
344  if(energy<25.0) continue;
345  occHF[eta+50][phi][depth]+=1.0;
346  occSum+=1.0;
347 
348  double Time=GetTime(data,nTS);
349  if((occHF[eta+50][phi][depth]/(double)(ievt_))>0.01) continue;
350 
351  if(TRIGGER==TRIG_CSC && eta>0) HFTimeCSCp->Fill(Time);
352  if(TRIGGER==TRIG_CSC && eta<0) HFTimeCSCm->Fill(Time);
353  }
354  }
355  if((ievt_%500)==0){
356  CheckTiming();
357  //printf("Run: %i, Evants processed: %i\n",iEvent.run(),ievt_);
358  }
359 }
360 
362  if(HBTimeDT->getEntries()>10){
363  Summary->setBinContent(1,1,1);
364  }
365  if(HBTimeRPC->getEntries()>10){
366  Summary->setBinContent(2,1,1);
367  }
368  if(HBTimeGCT->getEntries()>10){
369  Summary->setBinContent(3,1,1);
370  }
371  if(HBTimeHO->getEntries()>10){
372  Summary->setBinContent(6,1,1);
373  }
374  if(HOTimeDT->getEntries()>10){
375  Summary->setBinContent(1,2,1);
376  }
377  if(HOTimeRPC->getEntries()>10){
378  Summary->setBinContent(2,2,1);
379  }
380  if(HOTimeGCT->getEntries()>10){
381  Summary->setBinContent(3,2,1);
382  }
383  if(HOTimeHO->getEntries()>10){
384  Summary->setBinContent(6,2,1);
385  }
386  if(HETimeCSCp->getEntries()>10){
387  Summary->setBinContent(4,4,1);
388  }
389  if(HETimeCSCm->getEntries()>10){
390  Summary->setBinContent(4,3,1);
391  }
392  if(HETimeRPCp->getEntries()>10){
393  Summary->setBinContent(5,4,1);
394  }
395  if(HETimeRPCm->getEntries()>10){
396  Summary->setBinContent(5,3,1);
397  }
398  if(HFTimeCSCp->getEntries()>10){
399  Summary->setBinContent(4,6,1);
400  }
401  if(HFTimeCSCm->getEntries()>10){
402  Summary->setBinContent(4,4,1);
403  }
404 }
405 
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:954
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 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
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:3135
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
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:1082
virtual void setup(void)
double GetTime(double *data, int n)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
edm::EDGetTokenT< HODigiCollection > tok_ho_
Definition: Run.h:41
static const int TRIG_DT
Definition: DDAxes.h:10