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 }
35 
37 
39 {
43  meIsUS_->Reset();
45  meTrigFrac_->Reset();
47 } // void HcalNZSMonitor::reset()
48 
50 {
51  if(dbe_)
52  {
55  }
56 }//void HcalNZSMonitor::cleanup()
57 
58 
60 {
61  if (debug_>1) std::cout <<"HcalNZSMonitor::beginRun"<<std::endl;
63 
64  if (tevt_==0) this->setup(); // set up histograms if they have not been created before
65  if (mergeRuns_==false)
66  this->reset();
67 
68  return;
69 
70 } // void HcalNZSMonitor::beginRun(...)
71 
72 
74 {
76 
77  if(debug_>1) std::cout << "<HcalNZSMonitor::setup> About to pushback fedUnpackList_" << std::endl;
78 
79  selFEDs_.clear();
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;
92  if (dbe_)
93  {
95 
96  meFEDsizesNZS_=dbe_->bookProfile("FED sizes","FED sizes",32,699.5,731.5,100,-1000.0,12000.0,"");
97  meFEDsizesNZS_->setAxisTitle("FED number",1);
98  meFEDsizesNZS_->setAxisTitle("average size (KB)",2);
99  meFEDsizesNZS_->getTProfile()->SetMarkerStyle(22);
100 
101  meFEDsizeVsLumi_=dbe_->bookProfile("FED_size_Vs_lumi_block_number",
102  "FED size Vs lumi block number;lumiblock number;average HCAL FED size (kB)",
103  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000,"");
104  meFEDsizeVsLumi_->getTProfile()->SetMarkerStyle(22);
105 
106  meL1evtNumber_=dbe_->book1D("Is_L1_event_number_multiple_of_NZS_period",
107  "Is L1 event number multiple of NZS period",2,0,2);
108  meL1evtNumber_->setBinLabel(1, "NO", 1);
109  meL1evtNumber_->setBinLabel(2, "YES", 1);
110 
111  meIsUS_=dbe_->book1D("IsUnsuppressed_bit","IsUnsuppressed bit",2,0,2);
112  meIsUS_->setBinLabel(1,"NO",1);
113  meIsUS_->setBinLabel(2,"YES",1);
114 
115  meBXtriggered_=dbe_->book1D("Triggered_BX_number","Triggered BX number",3850,0,3850);
116  meBXtriggered_->setAxisTitle("BX number",1);
117 
118  meTrigFrac_=dbe_->book1D("HLT_accept_fractions","HLT accept fractions",triggers_.size()+1,0,triggers_.size()+1);
119  for (unsigned int k=0; k<triggers_.size(); k++) meTrigFrac_->setBinLabel(k+1,triggers_[k].c_str(),1);
120  meTrigFrac_->setBinLabel(triggers_.size()+1,"AND",1);
121 
122  meFullCMSdataSize_=dbe_->bookProfile("full_CMS_datasize",
123  "full CMS data size;lumiblock number;average FEDRawDataCollection size (kB)",
124  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000,"");
125  meFullCMSdataSize_->getTProfile()->SetMarkerStyle(22);
126 
127  } // if (dbe_)
128  return;
129 } // void HcalNZSMonitor::setup()
130 
131 
133 {
134  if (!IsAllowedCalibType()) return;
135  if (LumiInOrder(e.luminosityBlock())==false) return;
136 
138 
139  if (!(e.getByLabel(rawdataLabel_,rawraw)))
140  {
141  edm::LogWarning("HcalNZSMonitor")<<" raw data with label "<<rawdataLabel_<<" not available";
142  return;
143  }
144 
146  if (!(e.getByLabel(hltresultsLabel_,hltRes)))
147  {
148  if (debug_>0) edm::LogWarning("HcalNZSMonitor")<<" Could not get HLT results with tag "<<hltresultsLabel_<<std::endl;
149  return;
150  }
151 
152  const edm::TriggerNames & triggerNames = e.triggerNames(*hltRes);
153  // Collections were found; increment counters
155 
156  processEvent(*rawraw, *hltRes, e.bunchCrossing(), triggerNames);
157 
158 } // void HcalNZSMonitor::analyze(...)
159 
160 
162  edm::TriggerResults trigRes,
163  int bxNum,
164  const edm::TriggerNames& triggerNames)
165 {
166  if(!dbe_)
167  {
168  if (debug_>0) std::cout <<"HcalNZSMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
169  return;
170  }
171 
172  const unsigned int nTrig(triggerNames.size());
173 
174  std::vector<bool> trigAcc;
175  for (unsigned int i=0; i<triggers_.size(); i++) trigAcc.push_back(false);
176 
177  for (unsigned int k=0; k<nTrig; k++)
178  {
179  for (unsigned int i=0; i<triggers_.size(); i++)
180  {
181  if (triggerNames.triggerName(k) == triggers_[i] && trigRes.accept(k)) trigAcc[i]=true;
182  }
183  }
184  bool andAcc=true;
185  bool orAcc=false;
186  for (unsigned int p=0; p<triggers_.size(); p++)
187  {
188  if (!trigAcc[p]) andAcc=false;
189  if (trigAcc[p])
190  {
191  orAcc=true;
192  nAcc[p]++;
193  }
194  }
195 
196  if (orAcc)
197  {
198  nAcc_Total++;
199  for (unsigned int l=0; l<triggers_.size(); l++)
200  {
202  }
203  }
204 
205  if (andAcc)
206  {
207  nAndAcc++;
209  }
210 
211  bool processevent=false;
212  if (orAcc) processevent=true;
213 
214  if (!processevent) return;
215 
216  meBXtriggered_->Fill(bxNum+0.001,1);
217 
218  //calculate full HCAL data size:
219  size_t hcalSize=0;
220  bool hcalIsZS = false;
221  for (unsigned int k=0; k<selFEDs_.size(); k++)
222  {
223  const FEDRawData & fedData = rawraw.FEDData(selFEDs_[k]);
224  hcalSize+=fedData.size();
225  meFEDsizesNZS_->Fill(selFEDs_[k]+0.001,fedData.size()/1024);
226 
227  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fedData.data());
228  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
229 
230  HcalHTRData htr;
231  int nspigot =0;
232  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++)
233  {
234  nspigot++;
235  if (!dccHeader->getSpigotPresent(spigot)) continue;
236  // Load the given decoder with the pointer and length from this spigot.
237  dccHeader->getSpigotData(spigot,htr, fedData.size());
238  if(k != 20 && nspigot !=14 )
239  {
240  if ( !htr.isUnsuppressed() ) hcalIsZS = true;
241  }
242  }
243  }
244 
245  if (hcalIsZS) meIsUS_->Fill(0,1);
246  else meIsUS_->Fill(1,1);
247 
248  meFEDsizeVsLumi_->Fill(currentLS+0.001, hcalSize/1024);
249 
250  size_t fullSize=0;
251  for (int j=0; j<=FEDNumbering::MAXFEDID; ++j )
252  {
253  const FEDRawData & fedData = rawraw.FEDData(j);
254  fullSize+=fedData.size();
255  }
256 
257  meFullCMSdataSize_->Fill(currentLS+0.001,fullSize/1024);
258 
259  // get Trigger FED-Id
260  const FEDRawData& fedData = rawraw.FEDData(FEDNumbering::MINTriggerGTPFEDID) ;
261  FEDHeader header(fedData.data()) ;
262 
264  if (header.lvl1ID()%period_==0) meL1evtNumber_->Fill(1,1);
265  else meL1evtNumber_->Fill(0,1);
266  return;
267 
268 } //void HcalNZSMonitor::processEvent(...)
269 
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:207
void setBinContent(int binx, double content)
set content of bin (1-D)
std::vector< std::string > triggers_
std::vector< int > nAcc
MonitorElement * meIsUS_
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:722
void beginRun(const edm::Run &run, const edm::EventSetup &c)
edm::InputTag rawdataLabel_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< int > AllowedCalibTypes_
bool accept() const
Has at least one path accepted the event?
int bunchCrossing() const
Definition: EventBase.h:62
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
void processEvent(const FEDRawDataCollection &rawraw, edm::TriggerResults, int bxNum, const edm::TriggerNames &triggerNames)
Strings::size_type size() const
Definition: TriggerNames.cc:39
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:49
std::vector< int > selFEDs_
void Fill(long long x)
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:355
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2569
int j
Definition: DBlmapReader.cc:9
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1036
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
MonitorElement * meFullCMSdataSize_
int k[5][pyjets_maxn]
MonitorElement * meTrigFrac_
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
HcalNZSMonitor(const edm::ParameterSet &ps)
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:21
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:29
void analyze(edm::Event const &e, edm::EventSetup const &s)
tuple cout
Definition: gather_cfg.py:121
MonitorElement * meFEDsizesNZS_
virtual void setup(void)
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)
MonitorElement * meBXtriggered_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36
MonitorElement * meFEDsizeVsLumi_