DataQualityMonitor.cxx
1 #include "DataQualityMonitor.h"
2 
3 Acclaim::DataQualityMonitor::DataQualityMonitor(){
4 
5 }
6 
7 Acclaim::DataQualityMonitor::DataQualityMonitor(TChain* c){
8 
9  for(int polInd=0; polInd < AnitaPol::kNotAPol; polInd++){
10  for(int ant=0; ant < NUM_SEAVEYS; ant++){
11 
12  maxAbsSecondDeriv[polInd][ant] = 0;
13  maxVolts[polInd][ant] = 0;
14  numPoints[polInd][ant] = 0;
15  }
16  }
17  eventNumber = 0;
18 
19  setBranches(c);
20 }
21 
22 
23 void Acclaim::DataQualityMonitor::setBranches(TChain* c){
24  dataQualityChain = c;
25  dataQualityChain->SetBranchAddress("maxAbsSecondDeriv", &maxAbsSecondDeriv[0][0]);
26  dataQualityChain->SetBranchAddress("maxVolts", &maxVolts[0][0]);
27  dataQualityChain->SetBranchAddress("numPoints", &numPoints[0][0]);
28  dataQualityChain->SetBranchAddress("eventNumber", &eventNumber);
29 
30 
31  maxVoltsBlastThresh = 400;
32  saturationVolts = 1500;
33 }
34 
35 Acclaim::DataQualityMonitor::~DataQualityMonitor(){
36 
37 }
38 
39 
40 
41 Int_t Acclaim::DataQualityMonitor::processEntry(Long64_t entry, UInt_t eventNumberCheck){
42 
43  // std::cerr << dataQualityChain->GetEntry(entry) << std::endl;
44  dataQualityChain->GetEntry(entry);
45 
46  if(eventNumberCheck > 0){
47  if(eventNumberCheck != eventNumber){
48  std::cerr << "Warning in " << __PRETTY_FUNCTION__ << " for entry " << entry << ", eventNumber mismatch! eventNumber = "
49  << eventNumber << ", but eventNumberCheck = " << eventNumberCheck << std::endl;
50  return -1;
51  }
52  }
53 
54 
55  numChannelsAboveSurfSaturation = 0;
56  numAboveVoltsBlastThresh = 0;
57  numPhiAboveMaxVoltsBlastThresh = 0;
58  for(int phi=0; phi<NUM_PHI; phi++){
59  phiAboveMaxVoltsThresh[phi] = 0;
60  }
61 
62  for(int polInd=0; polInd < AnitaPol::kNotAPol; polInd++){
63  for(int phi=0; phi<NUM_PHI; phi++){
64  phiAboveMaxVoltsThresh[phi] = 0;
65  }
66 
67  for(int ant=0; ant < NUM_SEAVEYS; ant++){
68  if(maxVolts[polInd][ant] > maxVoltsBlastThresh){
69  numAboveVoltsBlastThresh++;
70  int phi = ant%NUM_PHI;
71  phiAboveMaxVoltsThresh[phi] = 1;
72  }
73 
74  if(maxVolts[polInd][ant] > saturationVolts){
75  numChannelsAboveSurfSaturation++;
76  }
77  }
78  }
79 
80  for(int phi=0; phi<NUM_PHI; phi++){
81  if(phiAboveMaxVoltsThresh[phi] > 0){
82  numPhiAboveMaxVoltsBlastThresh++;
83  }
84  }
85 
86  // hNumChannelsAboveMaxVolts->Fill(numAboveVoltsBlastThresh);
87  // hNumPhiAboveMaxVolts->Fill(numPhiAboveMaxVoltsBlastThresh);
88  // hAnyChannelsAboveSaturation->Fill(numChannelsAboveSurfSaturation);
89  // p++;
90 
91 
92  Int_t dataQualityNum = 0;
93  if(numAboveVoltsBlastThresh >= 15 || numPhiAboveMaxVoltsBlastThresh >= 9){
94  std::cerr << std::endl;
95  std::cerr << "blast ? " << eventNumber << "\t" << numAboveVoltsBlastThresh << "\t" << numPhiAboveMaxVoltsBlastThresh << std::endl;
96  dataQualityNum = 1;
97  }
98  else if(numChannelsAboveSurfSaturation >= 3){
99  std::cerr << std::endl;
100  std::cerr << "three or more saturating channels ? " << eventNumber << "\t" << numChannelsAboveSurfSaturation << std::endl;
101  dataQualityNum = 2;
102  }
103 
104  return dataQualityNum;
105 }
USeful in for loops.