FEBRateAnalysis.cxx
Go to the documentation of this file.
1 ///
2 /// \file FEBRateAnalysis.cxx
3 /// \brief Summarize FEB rates produced by the online monitoring
4 ///
5 
6 #include "DAQChannelMap/DAQChannelMap.h"
7 #include "DAQChannelMap/HardwareDisplay.h"
8 #include "NovaDAQConventions/DAQConventions.h"
11 #include <iostream>
12 #include "TFile.h"
13 #include "TH1.h"
14 #include "TH2F.h"
15 #include "TTree.h"
16 
17 using namespace om;
18 
19 
21  fHardwareMapping(new daqchannelmap::HardwareDisplay)
22 {
23  if(det == "fd" || det == "FD" || det == "FarDet" || det == "far")
25  if(det == "nd" || det == "ND" || det == "NearDet" || det == "near")
27  if(det == "ndos" || det == "NDOS")
29  if(det == "tb" || det == "TB" || det == "TestBeam" || det == "test")
31 }
32 
33 //......................................................................
34 
35 void FEBRateAnalysis::AnaFile(const TFile& f, int run, int subrun)
36 {
37  std::cout << "FEBRateAnalysis BY PIXEL "
38  << run << ":"
39  << subrun << " "
40  << f.GetName() << std::endl;
41 
42  // Open output file for this subrun
43  char filename[100];
45  sprintf(filename, "FarDet-Summary-onmon_ana-subrun-%.2u-%.2u.root", run, subrun);
47  sprintf(filename, "NearDet-Summary-onmon_ana-subrun-%.2u-%.2u.root", run, subrun);
49  sprintf(filename, "NDOS-Summary-onmon_ana-subrun-%.2u-%.2u.root", run, subrun);
51  sprintf(filename, "TestBeam-Summary-onmon_ana-subrun-%.2u-%.2u.root", run, subrun);
52  TFile* out_file = new TFile(filename, "RECREATE");
53 
54 
55  // Summary tree
56  fNt = new RateSummaryNt;
57 
58  fRatesTree = new TTree("OnMonSummary","OnMon Summary Tree");
59  fRatesTree->Branch("fRateSummaryNt", "om::RateSummaryNt", &fNt, 1600, 99);
60 
61  // Copy the histos of interest into these temp ones
62  TH2F* fcPixelHitRateMap = (TH2F*)f.FindObjectAny("PixelHitRateMap");
63  TH2F* fcPixelHitRateMapLowADC = (TH2F*)f.FindObjectAny("PixelHitRateMapLowADC");
64  TH2F* fcPixelHitRateMapMipADC = (TH2F*)f.FindObjectAny("PixelHitRateMapMipADC");
65  TH2F* fcPixelHitRateMapHighADC = (TH2F*)f.FindObjectAny("PixelHitRateMapHighADC");
66  TH2F* fcFEBShutOff = (TH2F*)f.FindObjectAny("FEBShutOff");
67 
68  unsigned int i=1;
69  unsigned int j=1;
70  this->StoreContent(fcPixelHitRateMap, fcPixelHitRateMapHighADC, fcPixelHitRateMapLowADC,
71  fcPixelHitRateMapMipADC, fcFEBShutOff, run, subrun, (int)i, (int)j);
72 
73  fRatesTree->Write();
74  out_file->Close();
75 }
76 //......................................................................
77 void FEBRateAnalysis::StoreContent(TH2F*& histPix, TH2F*& histPixHigh, TH2F*& histPixLow,
78  TH2F*& histPixMip, TH2F*& histFEBoff, int run, int subrun, int db, int dcm)
79 {
80  // Stores histo content in summary tree
81  bool existsL=0, existsH=0, existsM=0;
82  if (histPixHigh!=0 ) existsH=1;
83  if (histPixLow!=0 ) existsL=1;
84  if (histPixMip!=0 ) existsM=1;
85 
86  int NbinsX = histPix->GetNbinsX();
87  int NbinsY = histPix->GetNbinsY();
88 
89  for (int i=1; i<NbinsX+1; i++) {
90  for (int j=1; j<NbinsY+1; j++) {
91  // Get bin (i,j) content from each plot
92  double content = histPix->GetBinContent(i,j);
93  double contentH=0, contentL=0, contentM=0;
94  if(existsH) contentH = histPixHigh->GetBinContent(i,j);
95  if(existsL) contentL = histPixLow->GetBinContent(i,j);
96  if(existsM) contentM = histPixMip->GetBinContent(i,j);
97 
98 
99  // Match bin i,j to DB DCM FEB Pix location
100  double x = histPix->GetXaxis()->GetBinCenter(i);
101  double y = histPix->GetYaxis()->GetBinCenter(j);
102  unsigned int thisDB, thisDCM, thisFEB, thisPIX;
103  fHardwareMapping->XYDiblock(&thisDB, (unsigned int)x);
104  fHardwareMapping->XYDCM(&thisDCM, (unsigned int)y);
105  fHardwareMapping->XYFEB(&thisFEB, (unsigned int)x, (unsigned int)y);
106  fHardwareMapping->XYPix(&thisPIX, (unsigned int)x, (unsigned int)y);
107 
108  // and to Pln Blk Mod location
109  unsigned int thisBLK, thisPINB, thisVIEW, thisMOD, thisCELL;
110  fHardwareMapping->DAQToPlaneInBlockModCell(&thisBLK,&thisPINB,&thisVIEW,&thisMOD,&thisCELL,
111  thisDB, thisDCM, thisFEB, thisPIX);
112 
113  // Get dropout info from FEB level plots
114  // FEB level bins Pixel level bins
115  // _______________ _______________
116  // | | | | : : : | : : : |
117  // | | | |.:.:.:.|.:.:.:.|
118  // | | | | : : : | : : : |
119  // |_______|_______| |_:_:_:_|_:_:_:_|
120  // 0 4 8 0 1 2 3 4....
121 
122  int i_forFEB = histFEBoff->GetXaxis()->FindFixBin(x);
123  int j_forFEB = histFEBoff->GetYaxis()->FindFixBin(y);
124  double offCount = histFEBoff->GetBinContent(i_forFEB,j_forFEB);
125 
126 
127  fNt->run = run;
128  fNt->subrun = subrun;
129  fNt->db = (int)thisDB;
130  fNt->dcm = (int)thisDCM;
131  fNt->feb = (int)thisFEB;
132  fNt->pix = (int)thisPIX;
133  fNt->hwx = (int)x;
134  fNt->hwy = (int)y;
135  fNt->blk = (int)thisBLK;
136  fNt->pinb = (int)thisPINB;
137  fNt->view = (int)thisVIEW;
138  fNt->mod = (int)thisMOD;
139  fNt->cell = (int)thisCELL;
140  fNt->dropoutCount = (int)offCount;
141  fNt->rate = content;
142  fNt->rateHigh = contentH;
143  fNt->rateLow = contentL;
144  fNt->rateMip = contentM;
145  fRatesTree->Fill();
146 
147  }//j
148  }//i
149 
150 }
151 
152 ////////////////////////////////////////////////////////////////////////
void XYPix(unsigned int *pix, unsigned int ix, unsigned int iy)
RateSummaryNt * fNt
void DAQToPlaneInBlockModCell(unsigned int *block, unsigned int *pinb, unsigned int *view, unsigned int *module, unsigned int *cell, unsigned int db, unsigned int dcm, unsigned int feb, unsigned int pix)
Summarize FEB rates produced by the online monitoring.
void XYDCM(unsigned int *dcm, unsigned int iy)
void XYFEB(unsigned int *feb, unsigned int ix, unsigned int iy)
string filename
Definition: shutoffs.py:106
unsigned int fDetId
DAQ detector ID.
virtual void StoreContent(TH2F *&histPix, TH2F *&histPixHigh, TH2F *&histPixLow, TH2F *&histPixMip, TH2F *&histFEBoff, int run, int subrun, int db, int dcm)
out_file
Append EOF lines.
Definition: modifyFHiCL.py:113
Far Detector at Ash River, MN.
Prototype Near Detector on the surface at FNAL.
Near Detector in the NuMI cavern.
const double j
Definition: BetheBloch.cxx:29
void AnaFile(const TFile &f, int run, int subrun)
daqchannelmap::HardwareDisplay * fHardwareMapping
Map pixel address to hardware space.
Definition: run.py:1
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
FEBRateAnalysis(std::string det)
void XYDiblock(unsigned int *db, unsigned int ix)
Online Monitoring package header.