DataCheck_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 /// \brief Commissioning files to look at the quality of our data
3 /// \author lein@physics.umn.edu, zirnstein@umn.edu
4 ///////////////////////////////////////////////////////////////////////
5 #include <cmath>
6 #include <string>
7 #include <time.h>
8 #include <vector>
9 #include <iostream>
10 #include <ostream>
11 #include <fstream>
12 #include <sstream>
13 
14 // ROOT includes
15 #include "TH1F.h"
16 #include "TH2F.h"
17 #include "TH3F.h"
18 #include "TF1.h"
19 
20 // Framework includes
27 
28 // NOvA includes
31 #include "Geometry/Geometry.h"
33 #include "NovaDatabase/Table.h"
34 #include "RawData/RawDigit.h"
35 #include "RawData/RawTrigger.h"
36 #include "RecoBase/CellHit.h"
37 #include "RecoBase/Cluster.h"
38 #include "TrackFit/RLFit.h"
39 #include "RunHistory/RunHistory.h" //....tx
40 
41 namespace comi {
42 
43  class DataCheck : public art::EDAnalyzer {
44  public:
45  explicit DataCheck(fhicl::ParameterSet const& pset);
46  virtual ~DataCheck();
47 
48  void beginJob();
49  virtual void beginSubRun(art::SubRun const& sr);
50  void analyze(art::Event const& evt);
51  void reconfigure(const fhicl::ParameterSet& p);
52  void endJob();
53  virtual void endSubRun(art::SubRun const& sr);
54 
55  private:
56 
57  TH1F* fNSlices;
60  TH1F* fSliceLength;
62  TH2F* fPlaneVCell;
64  TH2F* fChannelMap;
65  TH3F* fBlocDcmFeb;
66  TH1F* fOccupancy;
67  TH1F* fEmptyEvents;
68  TH1F* fNoiseEvents;
69  TH1F* fNEvents;
70 
71  TH2F* fDCM_temp;
72  std::vector<TH2F*> vDCMs;
73 
74  int fRun;
75  int fSubRun;
76  unsigned int fNevents;
77  unsigned int fNempty;
78  unsigned int fNoise;
79  unsigned int fTriggerType;
80  unsigned int fNGoodChannels;
81  unsigned int fNRawChannels;
82 
83  int fDCM_FEB[4][3][64];
84  int fDCM_nFEB[4][3];
85 
90 
93  std::vector<float> fNHits;
94  unsigned int fNDCM;
95 
96  private:
97  std::string fSlicerModule; ///< Label of the slicer module in the fcl file used
98  std::string fCalHitModule; ///< Label of the calhit module in the fcl file used
99  std::string fRawDigitModule; ///< Label of the raw digit module; set to default
103  }; // end of class DataCheck
104 
105  // NOvA uses a 64 Mhz clock
106  //static const double kUSEC_PER_TDC = (1.0E6/64.0E6);
107  //static const int kTDC_PER_USEC = 64;
108 
109  //......................................................................
110 
112  EDAnalyzer(p),
113  fRun(-999),
114  fSubRun(-999),
115  fNevents(0),
116  fNempty(0),
117  fNoise(0),
118  fTriggerType(-999),
119  fNGoodChannels(0),
120  fNRawChannels(0),
125  fNHits(0),
126  fNDCM(0)
127 
128  {
129  this->reconfigure(p);
130  }
131 
132  //......................................................................
133 
135  {
138  // const unsigned int maxCell = std::max(geom->Plane(0)->Ncells(), geom->Plane(1)->Ncells());
139  Int_t NPlanes = 910;// geom->NPlanes();
140  Int_t NCells = 394;//std::max(geom->Plane(0)->Ncells(), geom->Plane(1)->Ncells());
141 
142 
143  // Some event-level histograms
144 
145  fNSlices = f->make<TH1F>("fNSlices",";NSlices;Events",100,0.0,100.0);
146  fNHitsPerSlice = f->make<TH1F>("fNHitsPerSlice",";NHits;Slices",100,0.0,100.0);
147  fNHitsPerSliceNoNoise = f->make<TH1F>("fNHitsPerSliceNoNoise",";NHits;Slices",100,0.0,100.0);
148  fSliceLength = f->make<TH1F>("fSliceLength",";Slice Duration; NSlices", 550,0.0, 5500);
149 
150  fNHitsPerEvent = f->make<TH1F>("fNHitsPerEvent",";NHits/NGoodChannels;Events",100,0.0,0.5);
151  fPlaneVCell = f->make<TH2F>("fPlaneVCell",";Plane Number;Cell Number", NPlanes,-0.5,NPlanes-0.5, NCells,-0.5,NCells -0.5);
152  fPlaneVCellRaw = f->make<TH2F>("fPlaneVCellRaw",";Plane Number;Cell Number",NPlanes,-0.5,NPlanes-0.5, NCells,-0.5,NCells -0.5);
153  fChannelMap = f->make<TH2F>("fChannelMap","Channel Map;Plane Number;Cell Number",NPlanes,-0.5,NPlanes-0.5, NCells,-0.5,NCells -0.5);
154 
155  fBlocDcmFeb = f->make<TH3F>("fBlockDcmFeb","Channel Map;Diblock; DCM;FEB",14,-0.5, 13.5, 12,-0.5,11.5 ,64,-0.5,63.5);
156 
157  fOccupancy = f->make<TH1F>("fOccupancy",";log of Occupancy;Channels",200,-3.0,0.0);
158  fEmptyEvents = f->make<TH1F>("fEmptyEvents",";;Number of empty events",2,0,2);
159  fNoiseEvents = f->make<TH1F>("fNoiseEvents",";;Number of events with noise only slice",2,0,2);
160  fNEvents = f->make<TH1F>("fNEvents",";;Number of events",2,0,2);
161 
162 
163  for(int ndiblock=0;ndiblock<4;ndiblock++){
164  for(int ndcm=0;ndcm<3;ndcm++){
165  for(int nfeb=0;nfeb<64;nfeb++){
166  fDCM_FEB[ndiblock][ndcm][nfeb]=0;
167  }
168  fDCM_nFEB[ndiblock][ndcm]=0;
169 
170  }
171  }
172  } //End of beginJob
173 
174  //......................................................................
176  {
177  delete fDCM_temp;
178  vDCMs.clear();
179  }
180 
181  //............................begin SubRun..............................
183  {
186 
187  novadaq::cnv::DetId detectorid = geom->DetId();
188  if(fRun < 0) fRun = sr.run();
189  nova::dbi::RunHistory rh(fRun, detectorid);
190  rh.LoadDAQRunHistory();
191 
192  unsigned int nDB = rh.NDiBlocks();
193  const nova::dbi::RunHistory::DiBlock tempDiBlock = rh.GetDiBlock(0);
194  float nFEB = (float)tempDiBlock.dcm[0].feb.size();
195 
196  int ic=0;
197  for (unsigned int i=0; i<nDB; ++i) {
199  for( unsigned int j=0;j<db.dcm.size(); j++, ++ic ){
200  std::string dcmName = db.dcm[j].appname;
201  char histname[30];
202  strcpy(histname, dcmName.c_str());
203  vDCMs.push_back(fDCM_temp);
204  vDCMs.at(ic) = f->make<TH2F>(histname,";Event;FEB",100,0.0,38000.0,nFEB,0,nFEB);
205  }
206  }
207  }
208 
210  {
211  }
212  //........................................................................
214  {
215 
217 
219  double detid = geom->DetId();
220 
221  art::Timestamp ts = evt.time();
222 
223  time_t uevt_sec = ts.timeHigh(); //utval >> 32 & 0xFFFFFFFFF;
224 
226  evt.getByLabel(fRawDataLabel, trigv);
227  const rawdata::RawTrigger& trig = (*trigv)[0];
229 
230 
231  if(fRun < 0) fRun = evt.run();
232  if(fSubRun < 0) fSubRun = evt.subRun();
233 
234  if( fFirstEventTimeStamp == 0 ) {
235  fFirstEventTimeStamp=uevt_sec;
236  }
237  if (fNevents > 0 ) {
238  fLastEventTimeStamp=uevt_sec;
239  }
240 
241 
242  ++fNevents; //Updating counter of number of events
243 
244  fNEvents->Fill(1);
245 
246  //-------------------------------------------------------------------------------------------------
247 
248  //Looking at Slices
249 
250  //Load the slicer list from the event
252  evt.getByLabel(fSlicerModule,slicecol);
253 
254  // put in a mf::LogWarning why this statement returns if true
255  if(slicecol->empty()){
256  mf::LogWarning ("No Slices")<<"No Slices in the input file";
257  return;
258  }
259 
260  //Fill histogram with number of slices
261  fNSlices->Fill(slicecol->size());
262 
263  //Loop over slices
264  for(unsigned int iSlice = 0; iSlice < slicecol->size(); ++iSlice){
265  const rb::Cluster &slice = slicecol->at(iSlice);
266 
267  fNHitsPerSlice->Fill(slice.NCell()); //Hits per slice (with Noise Slice)
268 
269  //branching for noise slice
270  if(slice.IsNoise()){
271  continue;
272  }
273 
274  // Initialize the beginning and ending times to first hit times.
275  if(slice.NCell() != 0){
276  fSliceLength->Fill(slice.ExtentTNS()); //Fill histogram with slice length
277  }
278 
279  fNHitsPerSliceNoNoise->Fill(slice.NCell()); //Hits per slice (without Noise Slice)
280 
281  }
282 
283  //-------------------------------------------------------------------------------------------------
284 
285  //Looking at CellHits
286 
287 
288  // Load hit list (CellHits)
290  evt.getByLabel(fCalHitModule, hitcol);
291 
292  //Make it an art::PtrVector
294  for(unsigned int i = 0; i < hitcol->size(); ++i){
295  art::Ptr<rb::CellHit> hit(hitcol,i);
296  hitlist.push_back(hit);
297  }
298 
299  //Loop over CellHits
300  int cell, plane;
301  for(unsigned int iHit = 0; iHit < hitlist.size(); iHit++){
302 
303  cell = hitlist[iHit]->Cell();
304  plane = hitlist[iHit]->Plane();
305 
306  fPlaneVCell->Fill(plane,cell);
307 
308  } //End of loop over CellHits
309 
310  //-------------------------------------------------------------------------------------------------
311 
312  //Looking at RawDigits
313 
314  // Load hit list (RawDigits)
316  evt.getByLabel(fRawDigitModule, rawhitcol);
317 
318  //Make it an art::PtrVector
320  for(unsigned int i = 0; i < rawhitcol->size(); ++i){
321  art::Ptr<rawdata::RawDigit> rawhit(rawhitcol,i);
322  rawhitlist.push_back(rawhit);
323  }
324 
325 
326  //Loop over RawDigits
327 
328  uint32_t daq_channel = 0;
329  uint32_t feb = 0;
330  uint32_t dcm = 0;
331  uint32_t diblock = 0;
332  uint32_t rawplane = 0;
333  uint32_t rawcell = 0;
334 
335  for(unsigned int iRawHit = 0; iRawHit < rawhitlist.size(); iRawHit++){
336 
337  daq_channel = rawhitlist[iRawHit]->DaqChannel();
338 
339  feb = cmap->Map()->getFEB(daq_channel);
340  dcm = cmap->Map()->getDCM(daq_channel);
341  diblock = cmap->Map()->getDiBlock(daq_channel);
342  rawplane = cmap->Map()->getPlane(daq_channel);
343  rawcell = cmap->Map()->getCell(daq_channel);
344 
345  fPlaneVCellRaw->Fill(rawplane,rawcell);
346  fBlocDcmFeb->Fill(diblock,dcm, feb);
347  if( detid==1 ){
348  vDCMs.at(diblock*12+dcm-13)->Fill(fNevents,feb);
349  }
350  else if( detid==2 ){
351  vDCMs.at(diblock*12+dcm-13)->Fill(fNevents,feb);
352  }
353  else if( detid==3 ){
354  vDCMs.at(diblock*3+dcm-4)->Fill(fNevents,feb);
355  }
356  else{
357  std::cout << "no such detector!!!!!!!!!!!!!" << std::endl;
358  }
359 
360 
361  if(diblock<2 && dcm <12) fDCM_FEB[diblock-1][dcm-1][feb]++;
362 
363  } //End of loop over RawDigits
364 
365  //Timestamps of non-empty events; Counters for empty events and noise only events
366 
367  if( (fFirstNonEmptyEventTimeStamp == 0) && (rawhitlist.size() !=0) ) {
369  }
370 
371  if ( (fNevents > 0) && (rawhitlist.size() !=0) ) {
373  }
374 
375  if(hitlist.size()==0) {
376  ++fNempty;
377  fEmptyEvents->Fill(1);
378  }
379  else if (slicecol->size()==1) {
380  ++fNoise;
381  fNoiseEvents->Fill(1);
382  }
383 
384  fNHits.push_back(hitlist.size());
385 
386  } //End of DataCheck::analyze
387 
388  //......................................................................
389 
391  {
392  //Rescaling fPlaneVCell by dividing by number of events
394 
395  fPlaneVCell->Scale(1.0/(float)fNevents);
396  fPlaneVCellRaw->Scale(1.0/(float)fNevents);
397 
398  //Occupancy Plots
399 
400  for (int xbin = 1; xbin <= fPlaneVCell->GetNbinsX(); xbin++) {
401  for (int ybin = 1; ybin <= fPlaneVCell->GetNbinsY(); ybin++) {
402 
403  double cellcontent = fPlaneVCell->GetBinContent(xbin,ybin);
404  double logcontent = -6;
405 
406  if (cellcontent > 0.0) {
407  logcontent = log10(cellcontent);
408  fNGoodChannels++;
409  //fNGoodChannels->Fill(1);
410  fChannelMap->SetBinContent(xbin,ybin,1);
411  }// End of assigning log to cell content
412 
413  fOccupancy->Fill(logcontent);
414 
415  }// End of loop over y cells
416  }// End of loop over x cells
417 
418  // Count number of active raw channels
419 
420  for (int xbin = 1; xbin <= fPlaneVCellRaw->GetNbinsX(); xbin++) {
421  for (int ybin = 1; ybin <= fPlaneVCellRaw->GetNbinsY(); ybin++) {
422 
423  double cellcontent = fPlaneVCellRaw->GetBinContent(xbin,ybin);
424 
425  if (cellcontent > 0.0) {
426  fNRawChannels++;
427  }
428 
429  }// End of loop over y cells
430  }// End of loop over x cells
431 
432  // occupancy fit
433  TF1 *f1=new TF1("f1","landau");
434  fOccupancy->Fit("f1");
435 
436 
437  //rescale fNHits by the number of good channels
438  for(unsigned int i = 0; i < fNHits.size(); i++){
439  fNHitsPerEvent->Fill(fNHits[i]/(float)fNGoodChannels);
440  }
441 
442 
443 
444 
445  std::cout<< fBlocDcmFeb->GetXaxis()->GetNbins()<<std::endl;
446  for(int nx=1;nx<=14;nx++){
447  for(int ny=1;ny<=12;ny++){
448  for(int nz=1;nz<=64;nz++){
449 
450  if( fBlocDcmFeb->GetBinContent(nx,ny,nz)) fNDCM++;
451 
452  }}}
453 
454 
455 
456 
457  //Get software release
458  fSoftwareRelease = getenv("SRT_BASE_RELEASE");
459 
460  //Figure out "Good Run Status" Standard cuts are below 100% empty events, less than 10% noise only events, hits per event between 0.00 and 0.06
461  unsigned int stat = 0;
462  float femptyp = fNempty/(1.0*fNevents);
463  float fnoisep = 0.0;
464  if (fNempty == fNevents) fnoisep = fNoise/(1.0*(fNevents-fNempty));
465  float fhits = fNHitsPerEvent->GetMean(1);
466 
467  if(fRun>=11570 && fRun<12978){
468  if(femptyp < 1.0 && fnoisep < 0.1 && fhits < 0.06 && fhits > 0.0) stat=1;
469  else stat=0;
470  }
471  if(fRun>12978){
472  if(femptyp < 1.0 && fnoisep < 0.25 && fhits < 0.06 && fhits > 0.0) stat=1;
473  else stat=0;
474  }
475 
476  std::cout<<"detector=" <<"NDOS"<<std::endl;
477  std::cout<<"run=" <<fRun<<std::endl;
478  std::cout<<"subrun=" <<fSubRun<<std::endl;
479  std::cout<<"triggertype=" <<fTriggerType<<std::endl;
480  std::cout<<"nevents=" <<fNevents<<std::endl;
481  std::cout<<"nemptyevents=" <<fNempty<<std::endl;
482  std::cout<<"nnoiseevents=" <<fNoise<<std::endl;
483  std::cout<<"nactivechannels=" <<fNGoodChannels<<std::endl;
484  std::cout<<"nrawactivechannels=" <<fNRawChannels<<std::endl;
485  std::cout<<"nslices=" <<fNSlices->GetMean(1)<<std::endl;
486  std::cout<<"sliceduration=" <<fSliceLength->GetMean(1)<<std::endl;
487  std::cout<<"hitsperslice=" <<fNHitsPerSlice->GetMean(1)<<std::endl;
488  std::cout<<"hitsperslicenonoise=" <<fNHitsPerSliceNoNoise->GetMean(1)<<std::endl;
489  std::cout<<"hitsperevent=" <<fNHitsPerEvent->GetMean(1)<<std::endl;
490  std::cout<<"occupancympv=" <<f1->GetParameter(1)<<std::endl;
491  std::cout<<"occupancysigma=" <<f1->GetParameter(2)<<std::endl;
492  std::cout<<"software release=" <<fSoftwareRelease<<std::endl;
493  std::cout<<"Good Run Status= " <<stat<<std::endl;
494  std::cout<<"Number of active DCMs= " <<fNDCM<<std::endl;
495  for(int ndiblock=0;ndiblock<4;ndiblock++){
496  for(int ndcm=0;ndcm<3;ndcm++){
497  std::cout<<"nfebfor DCM"<<ndiblock+1<<"-"<<ndcm+1<<"="<<fDCM_nFEB[ndiblock][ndcm]<<std::endl;
498  }
499  }
500 
501  char fFirstEventTimeStampStr[256];
502  char fFirstNonEmptyEventTimeStampStr[256];
503  char fLastNonEmptyEventTimeStampStr[256];
504  char fLastEventTimeStampStr[256];
505 
506  struct tm * fFirstEventTimeStampinfo;
507  struct tm * fFirstNonEmptyEventTimeStampinfo;
508  struct tm * fLastNonEmptyEventTimeStampinfo;
509  struct tm * fLastEventTimeStampinfo;
510 
511  fFirstEventTimeStampinfo = localtime(&fFirstEventTimeStamp);
512  strftime(fFirstEventTimeStampStr,256,"%Y-%m-%d %H:%M:%S", fFirstEventTimeStampinfo);
513 
514  std::cout<<"Time of First Event= " <<fFirstEventTimeStampStr<<std::endl;
515 
516  fFirstNonEmptyEventTimeStampinfo = localtime(&fFirstNonEmptyEventTimeStamp);
517  strftime(fFirstNonEmptyEventTimeStampStr,256,"%Y-%m-%d %H:%M:%S", fFirstNonEmptyEventTimeStampinfo);
518 
519  std::cout<<"Time of First Non Empty Event= " <<fFirstNonEmptyEventTimeStampStr<<std::endl;
520 
521  fLastNonEmptyEventTimeStampinfo = localtime(&fLastNonEmptyEventTimeStamp);
522  strftime(fLastNonEmptyEventTimeStampStr,256,"%Y-%m-%d %H:%M:%S", fLastNonEmptyEventTimeStampinfo);
523 
524  std::cout<<"Time of Last Non Empty Event= " <<fLastNonEmptyEventTimeStampStr<<std::endl;
525 
526  fLastEventTimeStampinfo = localtime(&fLastEventTimeStamp);
527  strftime(fLastEventTimeStampStr,256,"%Y-%m-%d %H:%M:%S", fLastEventTimeStampinfo);
528 
529  std::cout<<"Time of Last Event= " <<fLastEventTimeStampStr<<std::endl;
530 
531 
532 
533  if (fWriteToDB && !fIsNearline){
534 
535  nova::database::Table* t = new nova::database::Table(std::string("/Commissioning/tables/DataCheck.xml"));
536 
537 
538  t->SetDetector(geom->DetId());
539  t->SetValidityRange("detector", novadaq::cnv::DetInfo::GetName(geom->DetId()));
540  t->SetValidityRange("run",fRun);
541  t->SetValidityRange("subrun",fSubRun);
542  t->SetValidityRange("triggertype",fTriggerType);
543  t->SetValidityRange("softwarerelease",fSoftwareRelease);
544  t->LoadFromDB();
545  if ( t->NRow() ){
546  std::cerr<< " Subrun metrics is already in the database "<<std::endl;
547  }
548  else{
549  std::cout<< " Writting subrun metrics to the database "<<std::endl;
550 
551  nova::database::Row* r = t->NewRow();
552  r->Set("detector", novadaq::cnv::DetInfo::GetName(geom->DetId()));
553  r->Set("run", fRun);
554  r->Set("subrun", fSubRun);
555  r->Set("triggertype", fTriggerType);
556  r->Set("nevents", fNevents);
557  r->Set("nemptyevents", fNempty);
558  r->Set("nnoiseevents", fNoise);
559  r->Set("nactivechannels", fNGoodChannels);
560  r->Set("nrawactivechannels", fNRawChannels);
561  r->Set("firsteventtime", fFirstEventTimeStampStr);
562  r->Set("firstnonemptyeventtime", fFirstNonEmptyEventTimeStampStr);
563  r->Set("lastnonemptyeventtime", fLastNonEmptyEventTimeStampStr);
564  r->Set("lasteventtime", fLastEventTimeStampStr);
565  r->Set("nslices", fNSlices->GetMean(1));
566  r->Set("sliceduration", fSliceLength->GetMean(1));
567  r->Set("hitsperslice", fNHitsPerSlice->GetMean(1));
568  r->Set("hitsperslicenonoise", fNHitsPerSliceNoNoise->GetMean(1));
569  r->Set("hitsperevent", fNHitsPerEvent->GetMean(1));
570  r->Set("occupancympv" , f1->GetParameter(1));
571  r->Set("occupancysigma" , f1->GetParameter(2));
572  r->Set("softwarerelease", fSoftwareRelease);
573  r->Set("status", stat);
574  r->Set("nDCMs", fNDCM);
575  r->Set("DCM11", fDCM_nFEB[1-1][1-1]);
576  r->Set("DCM12", fDCM_nFEB[1-1][2-1]);
577  r->Set("DCM13", fDCM_nFEB[1-1][3-1]);
578  r->Set("DCM21", fDCM_nFEB[2-1][1-1]);
579  r->Set("DCM22", fDCM_nFEB[2-1][2-1]);
580  r->Set("DCM23", fDCM_nFEB[2-1][3-1]);
581  r->Set("DCM31", fDCM_nFEB[3-1][1-1]);
582  r->Set("DCM32", fDCM_nFEB[3-1][2-1]);
583  r->Set("DCM33", fDCM_nFEB[3-1][3-1]);
584  r->Set("DCM41", fDCM_nFEB[4-1][1-1]);
585  r->Set("DCM42", fDCM_nFEB[4-1][2-1]);
586 
587  t->AddRow(r);
588  delete r;
589  t->WriteToDB();
590  }
591 
592  }
593 
594  if (fWriteToDB && fIsNearline){
595 
596  nova::database::Table* t = new nova::database::Table(std::string("/Commissioning/tables/NearlineTable.xml"));
597 
598  t->SetDetector(geom->DetId());
599  t->SetValidityRange("detector", novadaq::cnv::DetInfo::GetName(geom->DetId()));
600  t->SetValidityRange("run",fRun);
601  t->SetValidityRange("subrun",fSubRun);
602  t->SetValidityRange("triggertype",fTriggerType);
603  t->SetValidityRange("softwarerelease",fSoftwareRelease);
604  t->LoadFromDB();
605  if ( t->NRow() ){
606  std::cerr<< " Subrun metrics is already in the database "<<std::endl;
607  }
608  else{
609  std::cout<< " Writting subrun metrics to the database "<<std::endl;
610 
611  nova::database::Row* r = t->NewRow();
612  r->Set("detector", novadaq::cnv::DetInfo::GetName(geom->DetId()));
613  r->Set("run", fRun);
614  r->Set("subrun", fSubRun);
615  r->Set("triggertype", fTriggerType);
616  r->Set("nevents", fNevents);
617  r->Set("nemptyevents", fNempty);
618  r->Set("nnoiseevents", fNoise);
619  r->Set("nactivechannels", fNGoodChannels);
620  r->Set("nrawactivechannels", fNRawChannels);
621  r->Set("firsteventtime", fFirstEventTimeStampStr);
622  r->Set("firstnonemptyeventtime", fFirstNonEmptyEventTimeStampStr);
623  r->Set("lastnonemptyeventtime", fLastNonEmptyEventTimeStampStr);
624  r->Set("lasteventtime", fLastEventTimeStampStr);
625  r->Set("nslices", fNSlices->GetMean(1));
626  r->Set("sliceduration", fSliceLength->GetMean(1));
627  r->Set("hitsperslice", fNHitsPerSlice->GetMean(1));
628  r->Set("hitsperslicenonoise", fNHitsPerSliceNoNoise->GetMean(1));
629  r->Set("hitsperevent", fNHitsPerEvent->GetMean(1));
630  r->Set("occupancympv" , f1->GetParameter(1));
631  r->Set("occupancysigma" , f1->GetParameter(2));
632  r->Set("softwarerelease", fSoftwareRelease);
633  r->Set("status", stat);
634  r->Set("nDCMs", fNDCM);
635  r->Set("DCM11", fDCM_nFEB[1-1][1-1]);
636  r->Set("DCM12", fDCM_nFEB[1-1][2-1]);
637  r->Set("DCM13", fDCM_nFEB[1-1][3-1]);
638  r->Set("DCM21", fDCM_nFEB[2-1][1-1]);
639  r->Set("DCM22", fDCM_nFEB[2-1][2-1]);
640  r->Set("DCM23", fDCM_nFEB[2-1][3-1]);
641  r->Set("DCM31", fDCM_nFEB[3-1][1-1]);
642  r->Set("DCM32", fDCM_nFEB[3-1][2-1]);
643  r->Set("DCM33", fDCM_nFEB[3-1][3-1]);
644  r->Set("DCM41", fDCM_nFEB[4-1][1-1]);
645  r->Set("DCM42", fDCM_nFEB[4-1][2-1]);
646 
647  t->AddRow(r);
648  delete r;
649  t->WriteToDB();
650  }
651 
652  }
653 
654  //.........................................................
655  novadaq::cnv::DetId detectorid = geom->DetId();
656  nova::dbi::RunHistory rh(fRun, detectorid);
657  rh.LoadDAQRunHistory();
658 
659  std::ostringstream oss;
660  oss << fReportDir << "feb_shutoff_r" << fRun << "_s" << fSubRun << ".txt";
661 // std::cout << "run: " << fRun << " subrun: " << fSubRun << std::endl;
662  std::string fname(oss.str());
663  std::ofstream fout(fname.c_str(),std::ios::app);
664 
665  int nbinx = vDCMs.at(1)->GetNbinsX(); // number of events
666  int nbiny = vDCMs.at(1)->GetNbinsY(); // number of febs
667  double width = vDCMs.at(1)->GetBinWidth(1); //number of events per bin
668  nbinx = (int)(fNevents/width);
669  // 2013-10-19 JMP: not sure if this is what is desired... orig. author(s)
670  // should check this!
671  int nDiBlocks = rh.NDiBlocks();
672  int ic=0;
673  for ( int i=0; i<nDiBlocks; ++i) {
675  for (unsigned int idcm=0; idcm<db.dcm.size(); ++idcm, ++ic) {
676  std::string dcmname = db.dcm[idcm].appname;
677  for( int j=0;j<nbiny;j++ ){
678  bool biscool = db.dcm[idcm].feb[j].isCooled; //feb name is from 0-63, the list starts from 0
679  // double APDv = tempDCM.feb[j].apdV;
680  std::string strcool = "hello";
681  if( biscool ) strcool = "is cool";
682  else strcool = "is not cool";
683  int prev = 999;
684  int curr = 999;
685  for( int k=0;k<nbinx;k++ ){
686  if( ( (vDCMs.at(ic))->GetBinContent(k+1,j+1))!=0.0 ) curr = 1;
687  else curr = 0;
688  if( (k!=0) & (prev>curr) ){
689  if(fout){
690  fout << "FEB" << j << " in " << dcmname << " shutoff in subrun" << fSubRun << ". This feb is " << strcool << std::endl;
691  }
692  }
693  else if( (k!=0) & (prev<curr) ){
694  if(fout){
695  fout << "FEB" << j << " in " << dcmname << " came back in subrun" << fSubRun << ". This feb is " << strcool << std::endl;
696  }
697  }
698  prev = curr;
699  }
700  } //loop over events
701  } //loop over febs
702  } //loop over DCMs
703 
704  fout.close();
705 
706  } //End of DataCheck::endJob
707 
708  //......................................................................
709 
711  {
712  fSlicerModule = p.get<std::string>("SlicerModule");
713  fCalHitModule = p.get<std::string>("CalHitModule");
714  fRawDigitModule = p.get<std::string>("RawDigitModule", "daq");
715  fRawDataLabel = p.get<std::string>("RawDataLabel", "daq");
716  fWriteToDB = p.get<int>("WriteToDB");
717  fIsNearline = p.get<int>("Nearline");
718  fReportDir = p.get<std::string>("ReportDir");
719  }
720 
721 } // end namespace comi
722 
static std::string GetName(int id)
bool Set(std::string cname, T value)
Definition: Row.h:30
SubRunNumber_t subRun() const
Definition: Event.h:72
int NDiBlocks()
gives number of active diblocks only, may be less than 14
Definition: RunHistory.h:394
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
TH2 * rh
Definition: drawXsec.C:5
std::string fRawDigitModule
Label of the raw digit module; set to default.
unsigned int fTriggerType
void reconfigure(const fhicl::ParameterSet &p)
std::string fSlicerModule
Label of the slicer module in the fcl file used.
std::string fReportDir
const char * p
Definition: xmltok.h:285
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:35
DiBlock GetDiBlock(int i, bool loadAll=true)
get ith diblock is RH list (which only includes diblocks with activity), starting with i=0...
unsigned int fNoise
A collection of associated CellHits.
Definition: Cluster.h:47
OStream cerr
Definition: OStream.cxx:7
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
std::string fCalHitModule
Label of the calhit module in the fcl file used.
DEFINE_ART_MODULE(TestTMapFile)
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
time_t fLastNonEmptyEventTimeStamp
DataCheck(fhicl::ParameterSet const &pset)
unsigned int fNRawChannels
std::string fSoftwareRelease
bool SetValidityRange(std::string cname, T start, T end)
Definition: Table.h:206
uint8_t fTriggerMask_TriggerType
Definition: RawTrigger.h:43
void analyze(art::Event const &evt)
unsigned int fNevents
bool WriteToDB(bool commit=true)
use commit=false if just testing
Definition: Table.cpp:1810
void prev()
Definition: show_event.C:91
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
Make a linear fit to a collection of raw hits.
unsigned int fNGoodChannels
std::string fRawDataLabel
std::string getenv(std::string const &name)
Commissioning files to look at the quality of our data.
Definition: Cana_module.cc:39
T get(std::string const &key) const
Definition: ParameterSet.h:231
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
int fDCM_FEB[4][3][64]
Float_t f1
virtual void endSubRun(art::SubRun const &sr)
const double j
Definition: BetheBloch.cxx:29
unsigned int fNempty
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
TH1F * fNHitsPerSliceNoNoise
void AddRow(const Row *row)
Definition: Table.cpp:727
std::vector< float > fNHits
size_type size() const
Definition: PtrVector.h:308
bool SetDetector(std::string det)
Definition: Table.cpp:513
OStream cout
Definition: OStream.cxx:6
virtual void beginSubRun(art::SubRun const &sr)
std::vector< DCM > dcm
Definition: RunHistory.h:311
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
time_t fFirstNonEmptyEventTimeStamp
T * make(ARGS...args) const
unsigned int fNDCM
T log10(T number)
Definition: d0nt_math.hpp:120
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
struct Table Table
Definition: TexBuilder.h:2
Definition: event.h:1
app
Definition: demo.py:189
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void geom(int which=0)
Definition: geom.C:163
std::vector< TH2F * > vDCMs
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
TRandom3 r(0)
Timestamp time() const
Definition: Event.h:61
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
RunNumber_t run() const
Definition: Event.h:77
double ExtentTNS() const
Definition: Cluster.h:252
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
Encapsulate the geometry of one entire detector (near, far, ndos)
RunNumber_t run() const
Definition: SubRun.h:49
static constexpr Double_t sr
Definition: Munits.h:164
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.