DataQualityMonitor.cxx
1 #include "DataQualityMonitor.h"
2 
3 DataQualityMonitor::DataQualityMonitor(){
4 
5  Double_t defaultThresholds[NUM_POL][NUM_SEAVEYS] = {
6  {109, 104, 139, 102, 173, 104, 116, 107, 85, 186, 224, 157, 245, 118, 137, 108,
7  95, 117, 108, 111, 109, 111, 103, 103, 97, 199, 208, 200, 184, 205, 175, 109,
8  106, 147, 117, 115, 117, 116, 114, 106, 95, 179, 208, 189, 184, 198, 110, 99},
9  {186, 205, 235, 269, 180, 239, 247, 175, 197, 310, 288, 327, 291, 270, 374, 232,
10  247, 257, 264, 249, 218, 283, 216, 250, 220, 360, 293, 347, 375, 423, 373, 247,
11  114, 177, 201, 266, 207, 239, 206, 184, 190, 327, 326, 271, 397, 415, 247, 255}};
12 
13  fillThresholds(defaultThresholds);
14 }
15 
16 
17 DataQualityMonitor::~DataQualityMonitor(){
18 
19 }
20 
21 
22 Int_t DataQualityMonitor::ProcessEvent(RawAnitaEvent* rawEvent){
23 
24  UsefulAnitaEvent* pedEvent = new UsefulAnitaEvent(rawEvent, WaveCalType::kAddPeds);
25  pedEvent->setAlfaFilterFlag(false); // Turn off the ALFA filtering
26 
27  fillMaxAbsSecondDerivArray(pedEvent);
28 
29  Int_t numBadChannels = 0;
30 
31  for(Int_t pol=0; pol<NUM_POL; pol++){
32  for(Int_t ant=0; ant<NUM_SEAVEYS; ant++){
33 
34  if(lastMaxAbsSecondDeriv[pol][ant] > threshMaxAbsSecondDeriv[pol][ant]){
35  numBadChannels++;
36  }
37  }
38  }
39 
40  delete pedEvent;
41 
42  return numBadChannels;
43 }
44 
45 
46 void DataQualityMonitor::fillMaxAbsSecondDerivArray(UsefulAnitaEvent* pedEvent){
47 
48  for(Int_t pol=0; pol<NUM_POL; pol++){
49  for(Int_t ant=0; ant<NUM_SEAVEYS; ant++){
50  lastMaxAbsSecondDeriv[pol][ant] = -9999;
51 
52  TGraph* gr = pedEvent->getGraph(ant, (AnitaPol::AnitaPol_t) pol);
53 
54  for(int samp = 0; samp < gr->GetN(); samp++){
55 
56  Double_t V = gr->GetY()[samp];
57 
58  if(samp < gr->GetN() - 2){
59  Double_t V2 = gr->GetY()[samp+1];
60  Double_t V3 = gr->GetY()[samp+2];
61  double thisAbsSecondDeriv = TMath::Abs(2*V2 - V3 - V);
62  if(thisAbsSecondDeriv > lastMaxAbsSecondDeriv[pol][ant]){
63  lastMaxAbsSecondDeriv[pol][ant] = thisAbsSecondDeriv;
64  }
65  }
66 
67  }
68 
69  delete gr;
70 
71  }
72  }
73 }
74 
75 
76 void DataQualityMonitor::fillThresholds(Double_t vals[NUM_POL][NUM_SEAVEYS]){
77 
78  for(Int_t pol=0; pol<NUM_POL; pol++){
79  for(Int_t ant=0; ant<NUM_SEAVEYS; ant++){
80  threshMaxAbsSecondDeriv[pol][ant] = vals[pol][ant];
81  }
82  }
83 
84 }