CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalNZSMonitor.cc
Go to the documentation of this file.
2 
7 
9 #include <math.h>
10 
12 {
13  Online_ = ps.getUntrackedParameter<bool>("online",false);
14  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
15  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
16  debug_ = ps.getUntrackedParameter<int>("debug",0);
17  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
18  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
19  prefixME_.append("/");
20  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","NZSMonitor_Hcal");
21  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
22  subdir_.append("/");
23  subdir_=prefixME_+subdir_;
24  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
25  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
26  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
27  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
28 
29  triggers_=ps.getUntrackedParameter<std::vector<std::string> >("nzsHLTnames"); //["HLT_HcalPhiSym","HLT_HcalNZS_8E29]
30  period_=ps.getUntrackedParameter<int>("NZSeventPeriod",4096); //4096
32  hltresultsLabel_ = ps.getUntrackedParameter<edm::InputTag>("HLTResultsLabel");
33 
34  // register for data access
35  tok_raw_ = consumes<FEDRawDataCollection>(rawdataLabel_);
36  tok_res_ = consumes<edm::TriggerResults>(hltresultsLabel_);
37 
38 }
39 
41 
43 {
48  meIsUS_->Reset();
50  meTrigFrac_->Reset();
52 } // void HcalNZSMonitor::reset()
53 
54 
56 {
57  if (debug_>1) std::cout <<"HcalNZSMonitor::bookHistograms"<<std::endl;
59 
60  if (tevt_==0) this->setup(ib); // set up histograms if they have not been created before
61  if (mergeRuns_==false)
62  this->reset();
63 
64  return;
65 
66 } // void HcalNZSMonitor::bookHistograms(...)
67 
68 
70 {
72 
73  if(debug_>1) std::cout << "<HcalNZSMonitor::setup> About to pushback fedUnpackList_" << std::endl;
74 
75  selFEDs_.clear();
76  for (int i=FEDNumbering::MINHCALFEDID;
78  {
80  continue;
81 
82  selFEDs_.push_back(i);
83  }
84 
85  nAcc.clear();
86  for (unsigned int i=0; i<triggers_.size(); i++) nAcc.push_back(0);
87 
88  nAndAcc=0;
89  nAcc_Total=0;
90 
91  if (debug_>1) std::cout <<"<HcalNZSMonitor::setup> Creating histograms"<<std::endl;
93 
94  meFEDsizesNZS_=ib.bookProfile("FED sizes","FED sizes",32,699.5,731.5,100,-1000.0,12000.0,"");
95  meFEDsizesNZS_->setAxisTitle("FED number",1);
96  meFEDsizesNZS_->setAxisTitle("average size (KB)",2);
97  meFEDsizesNZS_->getTProfile()->SetMarkerStyle(22);
98 
99  meUTCAFEDsizesNZS_ = ib.bookProfile("uTCA FED sizes",
100  "uTCA FED sizes", 5, 1117.5, 1122.5,100, -1000., 12000., "");
101  meUTCAFEDsizesNZS_->setAxisTitle("FED number",1);
102  meUTCAFEDsizesNZS_->setAxisTitle("average size (KB)",2);
103  meUTCAFEDsizesNZS_->getTProfile()->SetMarkerStyle(22);
104 
105  meFEDsizeVsLumi_=ib.bookProfile("FED_size_Vs_lumi_block_number",
106  "FED size Vs lumi block number;lumiblock number;average HCAL FED size (kB)",
107  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000,"");
108  meFEDsizeVsLumi_->getTProfile()->SetMarkerStyle(22);
109 
110  meL1evtNumber_=ib.book1D("Is_L1_event_number_multiple_of_NZS_period",
111  "Is L1 event number multiple of NZS period",2,0,2);
112  meL1evtNumber_->setBinLabel(1, "NO", 1);
113  meL1evtNumber_->setBinLabel(2, "YES", 1);
114 
115  meIsUS_=ib.book1D("IsUnsuppressed_bit","IsUnsuppressed bit",2,0,2);
116  meIsUS_->setBinLabel(1,"NO",1);
117  meIsUS_->setBinLabel(2,"YES",1);
118 
119  meBXtriggered_=ib.book1D("Triggered_BX_number","Triggered BX number",3850,0,3850);
120  meBXtriggered_->setAxisTitle("BX number",1);
121 
122  meTrigFrac_=ib.book1D("HLT_accept_fractions","HLT accept fractions",triggers_.size()+1,0,triggers_.size()+1);
123  for (unsigned int k=0; k<triggers_.size(); k++) meTrigFrac_->setBinLabel(k+1,triggers_[k].c_str(),1);
124  meTrigFrac_->setBinLabel(triggers_.size()+1,"AND",1);
125 
126  meFullCMSdataSize_=ib.bookProfile("full_CMS_datasize",
127  "full CMS data size;lumiblock number;average FEDRawDataCollection size (kB)",
128  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000,"");
129  meFullCMSdataSize_->getTProfile()->SetMarkerStyle(22);
130 
131  return;
132 } // void HcalNZSMonitor::setup()
133 
134 
136 {
138  if (!IsAllowedCalibType()) return;
139  if (LumiInOrder(e.luminosityBlock())==false) return;
140 
142 
143  if (!(e.getByToken(tok_raw_,rawraw)))
144  {
145  edm::LogWarning("HcalNZSMonitor")<<" raw data with label "<<rawdataLabel_<<" not available";
146  return;
147  }
148 
150  if (!(e.getByToken(tok_res_,hltRes)))
151  {
152  if (debug_>0) edm::LogWarning("HcalNZSMonitor")<<" Could not get HLT results with tag "<<hltresultsLabel_<<std::endl;
153  return;
154  }
155 
156  const edm::TriggerNames & triggerNames = e.triggerNames(*hltRes);
157  // Collections were found; increment counters
158 // HcalBaseDQMonitor::analyze(e,s);
159 
160  processEvent(*rawraw, *hltRes, e.bunchCrossing(), triggerNames);
161 
162 } // void HcalNZSMonitor::analyze(...)
163 
164 
166  const edm::TriggerResults& trigRes,
167  int bxNum,
168  const edm::TriggerNames& triggerNames)
169 {
170 
171  const unsigned int nTrig(triggerNames.size());
172 
173  std::vector<bool> trigAcc;
174  for (unsigned int i=0; i<triggers_.size(); i++) trigAcc.push_back(false);
175 
176  for (unsigned int k=0; k<nTrig; k++)
177  {
178  for (unsigned int i=0; i<triggers_.size(); i++)
179  {
180  if (triggerNames.triggerName(k) == triggers_[i] && trigRes.accept(k)) trigAcc[i]=true;
181  }
182  }
183  bool andAcc=true;
184  bool orAcc=false;
185  for (unsigned int p=0; p<triggers_.size(); p++)
186  {
187  if (!trigAcc[p]) andAcc=false;
188  if (trigAcc[p])
189  {
190  orAcc=true;
191  nAcc[p]++;
192  }
193  }
194 
195  if (orAcc)
196  {
197  nAcc_Total++;
198  for (unsigned int l=0; l<triggers_.size(); l++)
199  {
201  }
202  }
203 
204  if (andAcc)
205  {
206  nAndAcc++;
208  }
209 
210  bool processevent=false;
211  if (orAcc) processevent=true;
212 
213  if (!processevent) return;
214 
215  meBXtriggered_->Fill(bxNum+0.001,1);
216 
217  //calculate full HCAL data size:
218  size_t hcalSize=0;
219  bool hcalIsZS = false;
220  for (unsigned int k=0; k<selFEDs_.size(); k++)
221  {
222  const FEDRawData & fedData = rawraw.FEDData(selFEDs_[k]);
223 
224  // not to include empty FEDs
225  if (fedData.size()<12)
226  continue;
227 
228  hcalSize+=fedData.size();
230  meFEDsizesNZS_->Fill(selFEDs_[k]+0.001,fedData.size()/1024);
231  else
232  meUTCAFEDsizesNZS_->Fill(selFEDs_[k]+0.001,fedData.size()/1024);
233 
234  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fedData.data());
235  if (dccHeader==0) continue; // protection against bad data -- saw this happen in file /store/streamer/Data/A/000/131/540/Data.00131540.0200.A.storageManager.00.0000.dat; not yet sure why -- Jeff, 22 March 2010; this was due to empty (masked?) HO FEDs 724 and 727 -- Grigory, 25/03/2010
236 
237  HcalHTRData htr;
238  int nspigot =0;
239  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++)
240  {
241  nspigot++;
242  if (!dccHeader->getSpigotPresent(spigot)) continue;
243  // Load the given decoder with the pointer and length from this spigot.
244  dccHeader->getSpigotData(spigot,htr, fedData.size());
245  if(k != 20 && nspigot !=14 )
246  {
247  if ( !htr.isUnsuppressed() ) hcalIsZS = true;
248  }
249  }
250  }
251 
252  if (hcalIsZS) meIsUS_->Fill(0,1);
253  else meIsUS_->Fill(1,1);
254 
255  meFEDsizeVsLumi_->Fill(currentLS+0.001, hcalSize/1024);
256 
257  size_t fullSize=0;
258  for (int j=0; j<=FEDNumbering::MAXFEDID; ++j )
259  {
260  const FEDRawData & fedData = rawraw.FEDData(j);
261  fullSize+=fedData.size();
262  }
263 
264  meFullCMSdataSize_->Fill(currentLS+0.001,fullSize/1024);
265 
266  // get Trigger FED-Id
267  const FEDRawData& fedData = rawraw.FEDData(FEDNumbering::MINTriggerGTPFEDID) ;
268  FEDHeader header(fedData.data()) ;
269 
271  if (header.lvl1ID()%period_==0) meL1evtNumber_->Fill(1,1);
272  else meL1evtNumber_->Fill(0,1);
273  return;
274 
275 } //void HcalNZSMonitor::processEvent(...)
276 
void bookHistograms(DQMStore::IBooker &ib, const edm::Run &run, const edm::EventSetup &c)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:215
void setBinContent(int binx, double content)
set content of bin (1-D)
std::vector< std::string > triggers_
std::vector< int > nAcc
int ib
Definition: cuy.py:660
MonitorElement * meIsUS_
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
edm::InputTag rawdataLabel_
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< int > AllowedCalibTypes_
bool accept() const
Has at least one path accepted the event?
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
int bunchCrossing() const
Definition: EventBase.h:65
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
MonitorElement * meUTCAFEDsizesNZS_
Strings::size_type size() const
Definition: TriggerNames.cc:39
void processEvent(const FEDRawDataCollection &rawraw, const edm::TriggerResults &, int bxNum, const edm::TriggerNames &triggerNames)
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
edm::InputTag hltresultsLabel_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
std::vector< int > selFEDs_
void Fill(long long x)
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:353
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
MonitorElement * meFullCMSdataSize_
MonitorElement * meTrigFrac_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
void setup(DQMStore::IBooker &)
HcalNZSMonitor(const edm::ParameterSet &ps)
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
MonitorElement * meL1evtNumber_
TProfile * getTProfile(void) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void analyze(edm::Event const &e, edm::EventSetup const &s)
edm::EDGetTokenT< edm::TriggerResults > tok_res_
tuple cout
Definition: gather_cfg.py:145
MonitorElement * meFEDsizesNZS_
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
virtual void setup(DQMStore::IBooker &)
MonitorElement * meBXtriggered_
Definition: Run.h:43
MonitorElement * meFEDsizeVsLumi_