IcebergTpcMonitor_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // Class: IcebergTpcMonitor_module
4 // Module type: analyzer
5 // File: IcebergTpcMonitor_module.cc
6 // Author: Jingbo Wang (jiowang@ucdavis.edu), February 2018. Modifications by Tom Junk
7 //
8 // Modification: Maggie Greenwood July, 2018
9 // Added large summary histograms.
10 ///////////////////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef IcebergTpcMonitor_module
14 #define IcebergTpcMonitor_module
15 
16 // LArSoft includes
20 
21 // Data type includes
22 #include "lardataobj/RawData/raw.h"
25 
26 // Framework includes
31 #include "art_root_io/TFileService.h"
33 #include "canvas/Persistency/Common/FindManyP.h"
35 #include "fhiclcpp/ParameterSet.h"
37 
38 // ROOT includes.
39 #include "TH1.h"
40 #include "TH2.h"
41 #include "TH2F.h"
42 #include "TTree.h"
43 #include "TLorentzVector.h"
44 #include "TVector3.h"
45 #include "TCanvas.h"
46 #include "TPad.h"
47 #include "TFile.h"
48 #include "TProfile.h"
49 #include "TProfile2D.h"
50 
51 // C++ Includes
52 #include <vector>
53 #include <algorithm>
54 #include <fstream>
55 #include <iostream>
56 #include <string>
57 #include <sstream>
58 #include <cmath>
59 
60 #ifdef __MAKECINT__
61 #pragma link C++ class vector<vector<int> >+;
62 #endif
63 
64 namespace tpc_monitor{
65 
67 
68  public:
69 
70  explicit IcebergTpcMonitor(fhicl::ParameterSet const& pset);
71  virtual ~IcebergTpcMonitor();
72 
73  void beginJob();
74  void beginRun(const art::Run& run);
75  void reconfigure(fhicl::ParameterSet const& pset);
76  void analyze(const art::Event& evt);
77  int FEMBchanToHistogramMap(int, int);
78 
79  void endJob();
80 
81  private:
82  // Parameters in .fcl file
86 
87  // Branch variables for tree
88  unsigned int fEvent;
89  unsigned int fRun;
90  unsigned int fSubRun;
91 
92  //int NumberOfRCEs; // unused
93 
94  // TPC
95  unsigned int fNUCh;
96  unsigned int fNVCh;
97  unsigned int fNZ0Ch;
98  unsigned int fNZ1Ch;
99  // find channel boundaries for each view
100  unsigned int fUChanMin;
101  unsigned int fUChanMax;
102  unsigned int fVChanMin;
103  unsigned int fVChanMax;
104  unsigned int fZ0ChanMin;
105  unsigned int fZ0ChanMax;
106  unsigned int fZ1ChanMin;
107  unsigned int fZ1ChanMax;
108  unsigned int fNticks;
109 
110  unsigned int fNofAPA;
111  unsigned int fChansPerAPA;
112 
113  // sampling rate
114  float fSampleRate;
115 
116  // bin width in kHz
117  float fBinWidth;
118 
119  // Mean and RMS distributions by offline channel in each plane -- the vector indexes over APA number
120  std::vector<TH1F*> fChanMeanDistU;
121  std::vector<TH1F*> fChanRMSDistU;
122  std::vector<TH1F*> fChanMeanDistV;
123  std::vector<TH1F*> fChanRMSDistV;
124  std::vector<TH1F*> fChanMeanDistZ;
125  std::vector<TH1F*> fChanRMSDistZ;
126 
127  // stuck code fraction histograms by APA
128  std::vector<TH1F*> fStuckCodeOffFrac;
129  std::vector<TH1F*> fStuckCodeOnFrac;
130 
131  // stuck code fraction histograms by channel and plane
132  std::vector<TProfile*> fChanStuckCodeOffFracU;
133  std::vector<TProfile*> fChanStuckCodeOnFracU;
134  std::vector<TProfile*> fChanStuckCodeOffFracV;
135  std::vector<TProfile*> fChanStuckCodeOnFracV;
136  std::vector<TProfile*> fChanStuckCodeOffFracZ;
137  std::vector<TProfile*> fChanStuckCodeOnFracZ;
138 
139  // FFT by channel in each plane -- the vector indexes over APA number
140  std::vector<TH2F*> fChanFFTU;
141  std::vector<TH2F*> fChanFFTV;
142  std::vector<TH2F*> fChanFFTZ;
143 
144  // profiled Mean/RMS by offline channel
145  std::vector<TProfile*> fChanRMSU_pfx;
146  std::vector<TProfile*> fChanMeanU_pfx;
147  std::vector<TProfile*> fChanRMSV_pfx;
148  std::vector<TProfile*> fChanMeanV_pfx;
149  std::vector<TProfile*> fChanRMSZ_pfx;
150  std::vector<TProfile*> fChanMeanZ_pfx;
151 
152  // Persistent and overlay wavefroms by fiber
153  //std::vector<TH2F*> fPersistentFFT_by_Fiber;
154  // change to only saving these for each APA
155  std::vector<TH2F*> fPersistentFFT_by_APA;
156 
157  // Profiled fft by fiber
158  std::vector<TProfile*> fFFT_by_Fiber_pfx;
159 
160  // Rebin factor
161  int fRebinX;
162  int fRebinY;
163 
164  // define nADC counts for uncompressed vs compressed
165  unsigned int nADC_comp;
166  unsigned int nADC_uncomp;
167  unsigned int nADC_uncompPed;
168 
169  TH1F *fNTicksTPC;
170 
171  // Noise level cut parameters
176 
177  // Histograms to save dead/noisy channels
184 
188 
192 
196 
197  // define functions
198  float rmsADC(std::vector< short > & uncompressed);
199  float meanADC(std::vector< short > & uncompressed);
200  void calculateFFT(TH1D* hist_waveform, TH1D* graph_frequency);
201  void FillChannelHistos(TProfile* h1, double mean, double sigma, int& ndeadchannels, int& nnoisychannels_sigma, int& nnoisychannels_counts);
203 
204  std::vector<unsigned int> fApaLabelNum;
205 
206 
207  }; // IcebergTpcMonitor
208 
209  //-----------------------------------------------------------------------
210 
212  : EDAnalyzer(parameterSet), fRebinX(1), fRebinY(1), fApaLabelNum{1} {
213  this->reconfigure(parameterSet);
214  }
215 
216  //-----------------------------------------------------------------------
217 
218 
220 
221 
222  //-----------------------------------------------------------------------
223 
226  unsigned int UChMin;
227  unsigned int UChMax;
228  unsigned int VChMin;
229  unsigned int VChMax;
230  unsigned int ZChMin;
231  unsigned int ZChMax;
232 
233  // Accquiring geometry data
235  //fNofAPA = 1; // iceberg has just one APA. Should come out of the geometry
237 
238  // loop through channels in the first APA to find the channel boundaries for each view
239  // will adjust for desired APA after
240  fUChanMin = 0;
241  fZ1ChanMax = fChansPerAPA - 1;
242  for ( unsigned int c = fUChanMin + 1; c < fZ1ChanMax; c++ ){
243  if ( fGeom->View(c) == geo::kV && fGeom->View(c-1) == geo::kU ){
244  fVChanMin = c;
245  fUChanMax = c - 1;
246  }
247  if ( fGeom->View(c) == geo::kZ && fGeom->View(c-1) == geo::kV ){
248  fZ0ChanMin = c;
249  fVChanMax = c-1;
250  }
251  if ( fGeom->View(c) == geo::kZ && fGeom->ChannelToWire(c)[0].TPC == fGeom->ChannelToWire(c-1)[0].TPC + 1 ){
252  fZ1ChanMin = c;
253  fZ0ChanMax = c-1;
254  }
255  }
256 
257 
261  fNZ1Ch=fZ1ChanMax-fZ1ChanMin+1;
262 
263  mf::LogVerbatim("IcebergTpcMonitor")
264  <<"U: "<< fNUCh<<" V: "<<fNVCh<<" Z0: "<<fNZ0Ch << " Z1: " <<fNZ1Ch << std::endl;
265 
266  //Mean/RMS by offline channel for each view in each APA
267  for(unsigned int i=0;i<fNofAPA;i++)
268  {
269  UChMin=fUChanMin + i*fChansPerAPA;
270  UChMax=fUChanMax + i*fChansPerAPA;
271  VChMin=fVChanMin + i*fChansPerAPA;
272  VChMax=fVChanMax + i*fChansPerAPA;
273  ZChMin=fZ0ChanMin + i*fChansPerAPA;
274  //ZChMax=fZ0ChanMax + i*fChansPerAPA;
275  ZChMax=fZ1ChanMax + i*fChansPerAPA; //including unused channels
276 
277  //std::cout<<"UCh:"<<UChMin<<" - "<<UChMax<<std::endl;
278  //std::cout<<"VCh:"<<VChMin<<" - "<<VChMax<<std::endl;
279  //std::cout<<"ZCh:"<<ZChMin<<" - "<<ZChMax<<std::endl;
280 
281  // summaries for all views
282 
283  unsigned int j=fApaLabelNum.at(i);
284 
285  fStuckCodeOffFrac.push_back(tfs->make<TH1F>(Form("fStuckCodeOffFrac%d",j),Form("Stuck-Off Code Fraction APA%d",j),100,0,1));
286  fStuckCodeOnFrac.push_back(tfs->make<TH1F>(Form("fStuckCodeOnFrac%d",j),Form("Stuck-On Code Fraction APA%d",j),100,0,1));
287 
288  // U view
289  fChanRMSU_pfx.push_back(tfs->make<TProfile>(Form("fChanRMSU%d_pfx", j),Form("Profiled RMS vs Channel(Plane U, APA%d)", j), UChMax - UChMin + 1, UChMin-0.5, UChMax+0.5, "s"));
290  fChanMeanU_pfx.push_back(tfs->make<TProfile>(Form("fChanMeanU%d_pfx",j),Form("Profiled MEAN vs Channel(Plane U, APA%d)",j), UChMax - UChMin + 1, UChMin-0.5, UChMax+0.5, "s"));
291  fChanFFTU.push_back(tfs->make<TH2F>(Form("fChanFFTU%d", j),Form("fChanFFT (Plane U, APA%d)", j), UChMax - UChMin + 1, UChMin-0.5, UChMax+0.5, fNticks/2,0,fNticks/2*fBinWidth));
292  fChanMeanDistU.push_back(tfs->make<TH1F>(Form("fChanMeanDistU%d",j),Form("Means of Channels in (Plane U, APA%d)",j), 1000, 0, 16383));
293  fChanRMSDistU.push_back(tfs->make<TH1F>(Form("fChanRMSDistU%d",j),Form("RMSs of Channels in (Plane U, APA%d)",j), 100, 0, 50));
294  fChanStuckCodeOffFracU.push_back(tfs->make<TProfile>(Form("fChanStuckCodeOffFracU%d",j),Form("Stuck-Off Code Fraction (Plane U, APA%d)",j), UChMax - UChMin + 1, UChMin-0.5, UChMax+0.5, "s"));
295  fChanStuckCodeOnFracU.push_back(tfs->make<TProfile>(Form("fChanStuckCodeOnFracU%d",j),Form("Stuck-On Code Fraction (Plane U, APA%d)",j), UChMax - UChMin + 1, UChMin-0.5, UChMax+0.5, "s"));
296 
297  // V view
298  fChanRMSV_pfx.push_back(tfs->make<TProfile>(Form("fChanRMSV%d_pfx",j),Form("Profiled RMS vs Channel(Plane V, APA%d)",j), VChMax - VChMin + 1, VChMin-0.5, VChMax+0.5, "s"));
299  fChanMeanV_pfx.push_back(tfs->make<TProfile>(Form("fChanMeanV%d_pfx",j),Form("Profiled Mean vs Channel(Plane V, APA%d)",j), VChMax - VChMin + 1, VChMin-0.5, VChMax+0.5, "s"));
300  fChanFFTV.push_back(tfs->make<TH2F>(Form("fChanFFTV%d", j),Form("fChanFFT (Plane V, APA%d)", j), VChMax - VChMin + 1, VChMin-0.5, VChMax+0.5, fNticks/2,0,fNticks/2*fBinWidth));
301  fChanMeanDistV.push_back(tfs->make<TH1F>(Form("fChanMeanDistV%d",j),Form("Means of Channels in (Plane V, APA%d)",j), 1000, 0, 16383));
302  fChanRMSDistV.push_back(tfs->make<TH1F>(Form("fChanRMSDistV%d",j),Form("RMSs of Channels in (Plane V, APA%d)",j), 100, 0, 50));
303  fChanStuckCodeOffFracV.push_back(tfs->make<TProfile>(Form("fChanStuckCodeOffFracV%d",j),Form("Stuck-Off Code Fraction (Plane V, APA%d)",j), VChMax - VChMin + 1, VChMin-0.5, VChMax+0.5, "s"));
304  fChanStuckCodeOnFracV.push_back(tfs->make<TProfile>(Form("fChanStuckCodeOnFracV%d",j),Form("Stuck-On Code Fraction (Plane V, APA%d)",j), VChMax - VChMin + 1, VChMin-0.5, VChMax+0.5, "s"));
305 
306  // Z view
307  fChanRMSZ_pfx.push_back(tfs->make<TProfile>(Form("fChanRMSZ%d_pfx",j),Form("Profiled RMS vs Channel(Plane Z, APA%d)",j), ZChMax - ZChMin + 1, ZChMin-0.5, ZChMax+0.5, "s"));
308  fChanMeanZ_pfx.push_back(tfs->make<TProfile>(Form("fChanMeanZ%d_pfx",j),Form("Profiled Mean vs Channel(Plane Z, APA%d)",j), ZChMax - ZChMin + 1, ZChMin-0.5, ZChMax+0.5, "s"));
309  fChanFFTZ.push_back(tfs->make<TH2F>(Form("fChanFFTZ%d", j),Form("fChanFFT (Plane Z, APA%d)", j), ZChMax - ZChMin + 1, ZChMin-0.5, ZChMax+0.5, fNticks/2,0,fNticks/2*fBinWidth));
310  fChanMeanDistZ.push_back(tfs->make<TH1F>(Form("fChanMeanDistZ%d",j),Form("Means of Channels in (Plane Z, APA%d)",j), 1000, 0, 16383));
311  fChanRMSDistZ.push_back(tfs->make<TH1F>(Form("fChanRMSDistZ%d",j),Form("RMSs of Channels in (Plane Z, APA%d)",j), 100, 0, 50));
312  fChanStuckCodeOffFracZ.push_back(tfs->make<TProfile>(Form("fChanStuckCodeOffFracZ%d",j),Form("Stuck-Off Code Fraction (Plane Z, APA%d)",j), ZChMax - ZChMin + 1, ZChMin-0.5, ZChMax+0.5, "s"));
313  fChanStuckCodeOnFracZ.push_back(tfs->make<TProfile>(Form("fChanStuckCodeOnFracZ%d",j),Form("Stuck-On Code Fraction (Plane Z, APA%d)",j), ZChMax - ZChMin + 1, ZChMin-0.5, ZChMax+0.5, "s"));
314 
315  // Set titles
316  fChanRMSU_pfx[i]->GetXaxis()->SetTitle("Chan"); fChanRMSU_pfx[i]->GetYaxis()->SetTitle("raw RMS");
317  fChanMeanU_pfx[i]->GetXaxis()->SetTitle("Chan"); fChanMeanU_pfx[i]->GetYaxis()->SetTitle("raw Mean");
318  fChanRMSV_pfx[i]->GetXaxis()->SetTitle("Chan"); fChanRMSV_pfx[i]->GetYaxis()->SetTitle("raw RMS");
319  fChanMeanV_pfx[i]->GetXaxis()->SetTitle("Chan"); fChanMeanV_pfx[i]->GetYaxis()->SetTitle("raw Mean");
320  fChanRMSZ_pfx[i]->GetXaxis()->SetTitle("Chan"); fChanRMSZ_pfx[i]->GetYaxis()->SetTitle("raw RMS");
321  fChanMeanZ_pfx[i]->GetXaxis()->SetTitle("Chan"); fChanMeanZ_pfx[i]->GetYaxis()->SetTitle("raw Mean");
322  fChanFFTU[i]->GetXaxis()->SetTitle("Chan"); fChanFFTU[i]->GetYaxis()->SetTitle("kHz");
323  fChanFFTV[i]->GetXaxis()->SetTitle("Chan"); fChanFFTV[i]->GetYaxis()->SetTitle("kHz");
324  fChanFFTZ[i]->GetXaxis()->SetTitle("Chan"); fChanFFTZ[i]->GetYaxis()->SetTitle("kHz");
325  fChanStuckCodeOffFracU[i]->GetXaxis()->SetTitle("Chan"); fChanStuckCodeOffFracZ[i]->GetYaxis()->SetTitle("Fraction");
326  fChanStuckCodeOnFracU[i]->GetXaxis()->SetTitle("Chan"); fChanStuckCodeOnFracZ[i]->GetYaxis()->SetTitle("Fraction");
327  fChanStuckCodeOffFracV[i]->GetXaxis()->SetTitle("Chan"); fChanStuckCodeOffFracZ[i]->GetYaxis()->SetTitle("Fraction");
328  fChanStuckCodeOnFracV[i]->GetXaxis()->SetTitle("Chan"); fChanStuckCodeOnFracZ[i]->GetYaxis()->SetTitle("Fraction");
329  fChanStuckCodeOffFracZ[i]->GetXaxis()->SetTitle("Chan"); fChanStuckCodeOffFracZ[i]->GetYaxis()->SetTitle("Fraction");
330  fChanStuckCodeOnFracZ[i]->GetXaxis()->SetTitle("Chan"); fChanStuckCodeOnFracZ[i]->GetYaxis()->SetTitle("Fraction");
331 
332  fChanMeanDistU[i]->GetXaxis()->SetTitle("Mean (ADC counts)");
333  fChanRMSDistU[i]->GetXaxis()->SetTitle("RMS (ADC counts)");
334  fChanMeanDistV[i]->GetXaxis()->SetTitle("Mean (ADC counts)");
335  fChanRMSDistV[i]->GetXaxis()->SetTitle("RMS (ADC counts)");
336  fChanMeanDistZ[i]->GetXaxis()->SetTitle("Mean (ADC counts)");
337  fChanRMSDistZ[i]->GetXaxis()->SetTitle("RMS (ADC counts)");
338 
339  // Rebin histograms
340  //std::cout<<"RebinX = "<<fRebinX<<" RebinY = "<<fRebinY<<std::endl;
341  fChanFFTU[i]->Rebin2D(fRebinX, fRebinY);
342  fChanFFTV[i]->Rebin2D(fRebinX, fRebinY);
343  fChanFFTZ[i]->Rebin2D(fRebinX, fRebinY);
344  }
345 
346  // protodune, but the first 10 are Iceberg labels
347 
348  // unsigned int fembmap_by_fiberID[120] =
349  // {
350  // 703,727,715,723,721,706,726,716,704,709,
351  // 308,303,317,312,307,302,316,311,306,301,505,510,515,520,504,509,514,519,503,508,513,518,502,507,512,517,501,506,511,516,220,215,210,205,219,
352  // 214,209,204,218,213,208,203,217,212,207,202,216,211,206,201,605,610,615,620,604,609,614,619,603,608,613,618,602,607,612,617,601,606,611,616,120,115,110,105,119,114,109,104,118,113,
353  // 108,103,117,112,107,102,116,111,106,101,405,410,415,420,404,409,414,419,403,408,413,418,402,407,412,417,401,406,411,416
354  // };
355  // latest Run 2 FEMB placement
356  std::pair<std::string, std::string> fembmapstr_by_fiberID[10] =
357  {
358  {"727", "WIB1-FEMB1"}, {"726", "WIB3-FEMB1"},{"716","WIB2-FEMB1"},{"723","WIB1-FEMB2"},{"703","WIB3-FEMB3"},
359  {"FM015", "WIB1-FEMB4"},{"FM012","WIB2-FEMB4"},{"FM140","WIB3-FEMB4"},{"721","WIB1-FEMB3"},{"706","WIB2-FEMB3"}
360  };
361 
362 
363  // FFT's by fiber
364  for(int i=0;i<10;i++) {
365  // re-order by Z - plane channels
366  unsigned int z_i = (i > 4) ? 14 - i : i;
367  // unsigned int imb = fembmap_by_fiberID[i];
368  std::pair<std::string, std::string> fembstr = fembmapstr_by_fiberID[i];
369  //fPersistentFFT_by_Fiber.push_back(tfs->make<TH2F>(Form("Persistent_FFT_FEMB_%d", imb), Form("FFT FEMB%d WIB%d", imb, ( (i/4) % 5)+1), fNticks/2, 0, fNticks/2*fBinWidth, 150, -100, 50));
370  //fPersistentFFT_by_Fiber[i]->GetXaxis()->SetTitle("Frequency [kHz]"); fPersistentFFT_by_Fiber[i]->GetYaxis()->SetTitle("Amplitude [dB]");
371  // still keep the profiled FFT's by FEMB
372  // fFFT_by_Fiber_pfx.push_back(tfs->make<TProfile>(Form("Profiled_FFT_FEMB_%02d", imb), Form("Profiled FFT FEMB_%d WIB%d", imb, ( (i/4) %5)+1), fNticks/2, 0, fNticks/2*fBinWidth, -100, 50));
373  fFFT_by_Fiber_pfx.push_back(tfs->make<TProfile>(Form("Profiled_FFT_FEMB_%02d", z_i+1), Form("Profiled FFT FEMB_%s %s", fembstr.first.c_str(), fembstr.second.c_str()), fNticks/2, 0, fNticks/2*fBinWidth, -100, 50));
374  fFFT_by_Fiber_pfx[i]->GetXaxis()->SetTitle("Frequency [kHz]"); fFFT_by_Fiber_pfx[i]->GetYaxis()->SetTitle("Amplitude [dB]");
375  }
376  // persistent FFT now by APA
377  for (unsigned int i=0;i<fNofAPA;++i)
378  {
379  fPersistentFFT_by_APA.push_back(tfs->make<TH2F>(Form("Persistent_FFT_APA_%d", fApaLabelNum[i]), Form("FFT APA%d ", fApaLabelNum[i]), fNticks/2, 0, fNticks/2*fBinWidth, 150, -100, 50));
380  fPersistentFFT_by_APA[i]->GetXaxis()->SetTitle("Frequency [kHz]");
381  fPersistentFFT_by_APA[i]->GetYaxis()->SetTitle("Amplitude [dB]");
382  }
383 
384  fNTicksTPC = tfs->make<TH1F>("NTicksTPC","NTicks in TPC Channels",100,0,20000);
385 
386  // Dead/noisy channels
387  fNDeadChannelsHisto = tfs->make<TH1F>("fNDeadChannelsHisto","Number of dead channels",fNofAPA+1,0,fNofAPA+1);
388  fNDeadChannelsHisto->GetYaxis()->SetTitle("Number of dead channels");
389  fNNoisyChannelsHistoFromNSigma = tfs->make<TH1F>("fNNoisyChannelsHistoFromNSigma","Number of noisy channels",fNofAPA+1,0,fNofAPA+1);
390  fNNoisyChannelsHistoFromNSigma->GetYaxis()->SetTitle("Number of noisy channels");
391  fNNoisyChannelsHistoFromNCounts = tfs->make<TH1F>("fNNoisyChannelsHistoFromNCounts",Form("Number of noisy channels above counts %i-%i-%i (U-V-Z)", fNoiseLevelMinNCountsU, fNoiseLevelMinNCountsV, fNoiseLevelMinNCountsZ), fNofAPA+1,0,fNofAPA+1);
392  fNNoisyChannelsHistoFromNCounts->GetYaxis()->SetTitle("Number of noisy channels");
393 
394  fNDeadChannelsHistoU = tfs->make<TH1F>("fNDeadChannelsHistoU","Number of dead channels (Plane U)",fNofAPA+1,0,fNofAPA+1);
395  fNDeadChannelsHistoU->GetYaxis()->SetTitle("Number of dead channels (Plane U)");
396  fNNoisyChannelsHistoFromNSigmaU = tfs->make<TH1F>("fNNoisyChannelsHistoFromNSigmaU","Number of noisy channels (Plane U)",fNofAPA+1,0,fNofAPA+1);
397  fNNoisyChannelsHistoFromNSigmaU->GetYaxis()->SetTitle("Number of noisy channels (Plane U)");
398  fNNoisyChannelsHistoFromNCountsU = tfs->make<TH1F>("fNNoisyChannelsHistoFromNCountsU",Form("Number of noisy channels above %i counts (Plane U)", fNoiseLevelMinNCountsU), fNofAPA+1,0,fNofAPA+1);
399  fNNoisyChannelsHistoFromNCountsU->GetYaxis()->SetTitle("Number of noisy channels (Plane U)");
400 
401  fNDeadChannelsHistoV = tfs->make<TH1F>("fNDeadChannelsHistoV","Number of dead channels (Plane V)",fNofAPA+1,0,fNofAPA+1);
402  fNDeadChannelsHistoV->GetYaxis()->SetTitle("Number of dead channels (Plane V)");
403  fNNoisyChannelsHistoFromNSigmaV = tfs->make<TH1F>("fNNoisyChannelsHistoFromNSigmaV","Number of noisy channels (Plane V)",fNofAPA+1,0,fNofAPA+1);
404  fNNoisyChannelsHistoFromNSigmaV->GetYaxis()->SetTitle("Number of noisy channels (Plane V)");
405  fNNoisyChannelsHistoFromNCountsV = tfs->make<TH1F>("fNNoisyChannelsHistoFromNCountsV",Form("Number of noisy channels above %i counts (Plane V)", fNoiseLevelMinNCountsV), fNofAPA+1,0,fNofAPA+1);
406  fNNoisyChannelsHistoFromNCountsV->GetYaxis()->SetTitle("Number of noisy channels (Plane V)");
407 
408  fNDeadChannelsHistoZ = tfs->make<TH1F>("fNDeadChannelsHistoZ","Number of dead channels (Plane Z)",fNofAPA+1,0,fNofAPA+1);
409  fNDeadChannelsHistoZ->GetYaxis()->SetTitle("Number of dead channels (Plane Z)");
410  fNNoisyChannelsHistoFromNSigmaZ = tfs->make<TH1F>("fNNoisyChannelsHistoFromNSigmaZ","Number of noisy channels (Plane Z)",fNofAPA+1,0,fNofAPA+1);
411  fNNoisyChannelsHistoFromNSigmaZ->GetYaxis()->SetTitle("Number of noisy channels (Plane Z)");
412  fNNoisyChannelsHistoFromNCountsZ = tfs->make<TH1F>("fNNoisyChannelsHistoFromNCountsZ",Form("Number of noisy channels above %i counts (Plane Z)", fNoiseLevelMinNCountsZ), fNofAPA+1,0,fNofAPA+1);
413  fNNoisyChannelsHistoFromNCountsZ->GetYaxis()->SetTitle("Number of noisy channels (Plane Z)");
414 
415  fNDeadChannelsList = tfs->make<TH1F>("fNDeadChannelsList","List of dead channels",fGeom->Nchannels()+1,fUChanMin,fGeom->Nchannels()+1);
416  fNDeadChannelsList->GetXaxis()->SetTitle("Channel ID");
417  fNNoisyChannelsListFromNSigma = tfs->make<TH1F>("fNNoisyChannelsListFromNSigma","List of noisy channels",fGeom->Nchannels()+1,fUChanMin,fGeom->Nchannels()+1);
418  fNNoisyChannelsListFromNSigma->GetXaxis()->SetTitle("Channel ID");
419  fNNoisyChannelsListFromNCounts = tfs->make<TH1F>("fNNoisyChannelsListFromNCounts",Form("Number of noisy channels above counts %i-%i-%i (U-V-Z)", fNoiseLevelMinNCountsU, fNoiseLevelMinNCountsV, fNoiseLevelMinNCountsZ),fGeom->Nchannels()+1,fUChanMin,fGeom->Nchannels()+1);
420  fNNoisyChannelsListFromNCounts->GetXaxis()->SetTitle("Channel ID");
421 
422  for(unsigned int i=0;i<fNofAPA;i++){
423  unsigned int j=fApaLabelNum.at(i);
424  TString apastring = Form("APA %i", j);
425  fNDeadChannelsHisto->GetXaxis()->SetBinLabel(j+1, apastring.Data());
426  fNNoisyChannelsHistoFromNSigma->GetXaxis()->SetBinLabel(j+1, apastring.Data());
427  fNNoisyChannelsHistoFromNCounts->GetXaxis()->SetBinLabel(j+1, apastring.Data());
428 
429  fNDeadChannelsHistoU->GetXaxis()->SetBinLabel(j+1, apastring.Data());
430  fNNoisyChannelsHistoFromNSigmaU->GetXaxis()->SetBinLabel(j+1, apastring.Data());
431  fNNoisyChannelsHistoFromNCountsU->GetXaxis()->SetBinLabel(j+1, apastring.Data());
432  fNDeadChannelsHistoV->GetXaxis()->SetBinLabel(j+1, apastring.Data());
433  fNNoisyChannelsHistoFromNSigmaV->GetXaxis()->SetBinLabel(j+1, apastring.Data());
434  fNNoisyChannelsHistoFromNCountsV->GetXaxis()->SetBinLabel(j+1, apastring.Data());
435  fNDeadChannelsHistoZ->GetXaxis()->SetBinLabel(j+1, apastring.Data());
436  fNNoisyChannelsHistoFromNSigmaZ->GetXaxis()->SetBinLabel(j+1, apastring.Data());
437  fNNoisyChannelsHistoFromNCountsZ->GetXaxis()->SetBinLabel(j+1, apastring.Data());
438  }
439  }
440 
441  //-----------------------------------------------------------------------
443  // place to read databases or run independent info
444  }
445  //-----------------------------------------------------------------------
446 
448 
449  // reconfigure without recompiling
450  // read in the parameters from the .fcl file
451  // allows for interactive changes of the parameter values
452 
453  fTPCInput = p.get< std::string >("TPCInputModule");
454  fTPCInstance = p.get< std::string >("TPCInstanceName");
455  fRebinX = p.get<int>("RebinFactorX");
456  fRebinY = p.get<int>("RebinFactorY");
457  fNoiseLevelMinNCountsU = p.get<int>("NoiseLevelMinNCountsU");
458  fNoiseLevelMinNCountsV = p.get<int>("NoiseLevelMinNCountsV");
459  fNoiseLevelMinNCountsZ = p.get<int>("NoiseLevelMinNCountsZ");
460  fNoiseLevelNSigma = p.get<double>("NoiseLevelNSigma");
461  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
462  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
463  fNticks = detProp.NumberTimeSamples();
464 
465  std::cout<< "Number of Ticks = "<< fNticks <<std::endl;
466  //get sampling rate
467  fSampleRate = sampling_rate(clockData);
468  std::cout<<"Sampling rate = "<<fSampleRate<<std::endl;
469  // width of frequencyBin in kHz
470  fBinWidth = 1.0/(fNticks*fSampleRate*1.0e-6);
471  std::cout<<"Bin Width (kHz) = "<<fBinWidth<<std::endl;
472  return;
473  }
474 
475  //-----------------------------------------------------------------------
476 
478  // Get channel map
480  // TODO Use MF_LOG_DEBUG
481  MF_LOG_INFO("IcebergTpcMonitor")
482  << "-------------------- TPC IcebergTpcMonitor -------------------";
483 
484  // called once per event
485 
486  fEvent = event.id().event();
487  fRun = event.run();
488  fSubRun = event.subRun();
489  std::cout << "EventNumber = " << fEvent << std::endl;
490 
491  // Get the objects holding raw information: RawDigit for TPC data
493  auto RawTPC = event.getHandle< std::vector<raw::RawDigit> >(itag1);
494 
495  // Get RDStatus handle
496 
497  auto RDStatusHandle = event.getHandle< std::vector<raw::RDStatus> >(itag1);
498 
499  // Fill pointer vectors - more useful form for the raw data
500  // a more usable form
501  std::vector< art::Ptr<raw::RawDigit> > RawDigits;
502  art::fill_ptr_vector(RawDigits, RawTPC);
503 
504  // example of retrieving RDStatus word and flags
505 
506  for ( auto const& rdstatus : (*RDStatusHandle) )
507  {
508  if (rdstatus.GetCorruptDataDroppedFlag())
509  {
510  MF_LOG_INFO("IcebergTpcMonitor_module: ") << "Corrupt Data Dropped Flag set in RDStatus";
511  }
512  //std::cout << "RDStatus: Corrupt Data dropped " << rdstatus.GetCorruptDataDroppedFlag() << std::endl;
513  //std::cout << "RDStatus: Corrupt Data kept " << rdstatus.GetCorruptDataKeptFlag() << std::endl;
514  //std::cout << "RDStatus: Status Word " << rdstatus.GetStatWord() << std::endl;
515  }
516 
517  // Loop over all RawRCEDigits (entire channels)
518  for(auto const & dptr : RawDigits) {
519  const raw::RawDigit & digit = *dptr;
520 
521  // Get the channel number for this digit
522  uint32_t chan = digit.Channel();
523  // number of samples in uncompressed ADC
524  int nSamples = digit.Samples();
525  fNTicksTPC->Fill(nSamples);
526  unsigned int apa = std::floor( chan/fChansPerAPA );
527  //int pedestal = (int)digit.GetPedestal();
528  int pedestal = 0;
529 
530  std::vector<short> uncompressed(nSamples);
531  // with pedestal
532  raw::Uncompress(digit.ADCs(), uncompressed, pedestal, digit.Compression());
533 
534  // number of compressed ADCs
535  nADC_comp=digit.NADC();
536  // number of ADC uncompressed
537  nADC_uncomp=uncompressed.size();
538  // subtract pedestals
539  std::vector<short> uncompPed(nSamples);
540 
541  int nstuckoff=0;
542  int nstuckon=0;
543  for (int i=0; i<nSamples; i++)
544  {
545  auto adc=uncompressed.at(i);
546  auto adcl6b = adc & 0x3F;
547  if (adcl6b == 0) ++nstuckoff;
548  if (adcl6b == 0x3F) ++nstuckon;
549  uncompPed.at(i) = adc - pedestal;
550  }
551  float fracstuckoff = ((float) nstuckoff)/((float) nSamples);
552  float fracstuckon = ((float) nstuckon)/((float) nSamples);
553 
554  // number of ADC uncompressed without pedestal
555  nADC_uncompPed=uncompPed.size();
556 
557  // wavefrom histogram
558  int FiberID = channelMap->FiberIdFromOfflineChannel(chan);
559  TH1D* histwav=new TH1D(Form("wav%d",(int)chan),Form("wav%d",(int)chan),nSamples,0,nSamples);
560 
561  for(int k=0;k<(int)nADC_uncompPed;k++) {
562  histwav->SetBinContent(k+1, uncompPed.at(k));
563  // Fill Persistent waveform by fiber -- skip as it takes too much RAM
564  //fPersistentWav_by_Fiber.at(FiberID)->Fill(k+1, uncompPed.at(k));
565  }
566 
567  // Do FFT for single waveforms
568  TH1D* histfft=new TH1D(Form("fft%d",(int)chan),Form("fft%d",(int)chan),nSamples,0,nSamples*fBinWidth);
569  calculateFFT(histwav, histfft);
570  // Fill persistent/overlay FFT for each fiber/FEMB
571  for(int k=0;k<(int)nADC_uncompPed/2;k++) {
572  fPersistentFFT_by_APA.at(apa)->Fill((k+0.5)*fBinWidth, histfft->GetBinContent(k+1)); // offline apa number. Plot labels are online
573  fFFT_by_Fiber_pfx.at(FiberID % 120)->Fill((k+0.5)*fBinWidth, histfft->GetBinContent(k+1));
574  }
575 
576  // summary stuck code fraction distributions by APA -- here the APA is the offline APA number. The plot labels contain the mapping
577 
578  fStuckCodeOffFrac[apa]->Fill(fracstuckoff);
579  fStuckCodeOnFrac[apa]->Fill(fracstuckon);
580 
581  // Mean and RMS
582  float mean = meanADC(uncompPed);
583  float rms = rmsADC(uncompPed);
584 
585  // U View, induction Plane
586  if( fGeom->View(chan) == geo::kU){
587  fChanMeanU_pfx[apa]->Fill(chan, mean, 1);
588  fChanRMSU_pfx[apa]->Fill(chan, rms, 1);
589  fChanMeanDistU[apa]->Fill(mean);
590  fChanRMSDistU[apa]->Fill(rms);
591  fChanStuckCodeOffFracU[apa]->Fill(chan,fracstuckoff,1);
592  fChanStuckCodeOnFracU[apa]->Fill(chan,fracstuckon,1);
593 
594  //fft
595  for(int l=0;l<nSamples/2;l++) {
596  //for the 2D histos
597  fChanFFTU[apa]->Fill(chan, (l+0.5)*fBinWidth, histfft->GetBinContent(l+1));
598  }
599 
600  }// end of U View
601 
602  // V View, induction Plane
603  if( fGeom->View(chan) == geo::kV){
604  fChanRMSV_pfx[apa]->Fill(chan, rms, 1);
605  fChanMeanV_pfx[apa]->Fill(chan, mean, 1);
606  fChanMeanDistV[apa]->Fill(mean);
607  fChanRMSDistV[apa]->Fill(rms);
608  fChanStuckCodeOffFracV[apa]->Fill(chan,fracstuckoff,1);
609  fChanStuckCodeOnFracV[apa]->Fill(chan,fracstuckon,1);
610 
611  //fft
612  for(int l=0;l<nSamples/2;l++) {
613  //for the 2D histos
614  fChanFFTV[apa]->Fill(chan, (l+0.5)*fBinWidth, histfft->GetBinContent(l+1));
615  }
616 
617  }// end of V View
618 
619  // Z View, collection Plane
620  if( fGeom->View(chan) == geo::kZ){
621  fChanMeanZ_pfx[apa]->Fill(chan, mean, 1);
622  fChanRMSZ_pfx[apa]->Fill(chan, rms, 1);
623  fChanMeanDistZ[apa]->Fill(mean);
624  fChanRMSDistZ[apa]->Fill(rms);
625  fChanStuckCodeOffFracZ[apa]->Fill(chan,fracstuckoff,1);
626  fChanStuckCodeOnFracZ[apa]->Fill(chan,fracstuckon,1);
627 
628  //fft
629  for(int l=0;l<nSamples/2;l++) {
630  //for the 2D histos
631  fChanFFTZ[apa]->Fill(chan, (l+0.5)*fBinWidth, histfft->GetBinContent(l+1));
632  }
633 
634  }// end of Z View
635 
636  histwav->Delete();
637  histfft->Delete();
638 
639  } // RawDigits
640 
641  return;
642  }
643 
644  //-----------------------------------------------------------------------
645  // define RMS
646  float IcebergTpcMonitor::rmsADC(std::vector< short > &uncomp)
647  {
648  int n = uncomp.size();
649  float sum = 0.;
650  for(int i = 0; i < n; i++){
651  if(uncomp[i]!=0) sum += uncomp[i];
652  }
653  float mean = sum / n;
654  sum = 0;
655  for(int i = 0; i < n; i++)
656  {
657  if (uncomp[i]!=0) sum += (uncomp[i]-mean)*(uncomp[i]-mean);
658  }
659  return sqrt(sum / n);
660  }
661 
662  //-----------------------------------------------------------------------
663  //define Mean
664  float IcebergTpcMonitor::meanADC(std::vector< short > &uncomp)
665  {
666  int n = uncomp.size();
667  float sum = 0.;
668  for(int i = 0; i < n; i++)
669  {
670  if (uncomp[i]!=0) sum += abs(uncomp[i]);
671  }
672  return sum / n;
673  }
674 
675  //-----------------------------------------------------------------------
676  //calculate FFT
677  void IcebergTpcMonitor::calculateFFT(TH1D* hist_waveform, TH1D* hist_frequency) {
678 
679  int n_bins = hist_waveform->GetNbinsX();
680  TH1* hist_transform = 0;
681 
682  // Create hist_transform from the input hist_waveform
683  hist_transform = hist_waveform->FFT(hist_transform, "MAG");
684  hist_transform -> Scale (1.0 / float(n_bins));
685  int nFFT=hist_transform->GetNbinsX();
686 
687  double frequency;
688  double amplitude;
689  double amplitudeLog;
690 
691  // Loop on the hist_transform to fill the hist_transform_frequency
692  for (int k = 0; k < nFFT/2; k++){
693 
694  frequency = (k+0.5)*fBinWidth; // kHz
695  amplitude = hist_transform->GetBinContent(k+1);
696  amplitudeLog = 20*log10(amplitude); // dB
697  hist_frequency->Fill(frequency, amplitudeLog);
698  }
699 
700  hist_transform->Delete();
701 
702  }
703 
704  //-----------------------------------------------------------------------
705  // Fill dead/noisy channels tree
706  void IcebergTpcMonitor::FillChannelHistos(TProfile* h1, double mean, double sigma, int& ndeadchannels, int& nnoisychannels_sigma, int& nnoisychannels_counts){
707 
708  double rms_threshold = mean + fNoiseLevelNSigma*sigma;
709  TString htitle = h1->GetTitle();
710 
711  for(Int_t j=1; j <= h1->GetNbinsX(); j++){
712 
713  int fChannelID = h1->GetBinCenter(j);
714  double fChannelValue = h1->GetBinContent(j);
715 
716  if(fChannelValue == 0){ // dead channel
717  ndeadchannels++;
718  fNDeadChannelsList->SetBinContent(fChannelID, 1.0);
719  }
720  else{
721  if(fChannelValue > rms_threshold){ // noisy channel far away from mean
722  nnoisychannels_sigma++;
723  fNNoisyChannelsListFromNSigma->SetBinContent(fChannelID, 1.0);
724  }
725  if(htitle.Contains("Plane U"))
726  {
727  if (fChannelValue > fNoiseLevelMinNCountsU)
728  { // noisy U channel above count threshold
729  nnoisychannels_counts++;
730  fNNoisyChannelsListFromNCounts->SetBinContent(fChannelID, 1.0);
731  }
732  }
733  else if(htitle.Contains("Plane V"))
734  {
735  if (fChannelValue > fNoiseLevelMinNCountsV)
736  { // noisy V channel above count threshold
737  nnoisychannels_counts++;
738  fNNoisyChannelsListFromNCounts->SetBinContent(fChannelID, 1.0);
739  }
740  }
741  else if(htitle.Contains("Plane Z"))
742  {
743  if (fChannelValue > fNoiseLevelMinNCountsZ)
744  { // noisy Z channel above count threshold
745  nnoisychannels_counts++;
746  fNNoisyChannelsListFromNCounts->SetBinContent(fChannelID, 1.0);
747  }
748  }
749  else{
750  mf::LogVerbatim("IcebergTpcMonitor::FillChannelHistos")
751  << " Unknown histogram title: " << htitle.Data() << std::endl;
752  }
753  }
754  }
755 
756  return;
757  }
758 
759  //----------------------------------------------------------------------
760  //define the mapping of FEMBchans to the histogram.
762  //to see the reason for this channel mapping, check DocDB 4064 Table 5
763  //for one FEMB, this dictates the coordinates on the histogram as a 4X32 block.
764  int FEMBchanToHistogram[128][2] = { {0,0},{0,1},{0,2},{0,3},{0,4},//for U
765  {0,10},{0,11},{0,12},{0,13},{0,14},//for V
766  {0,20},{0,21},{0,22},{0,23},{0,24},{0,25},//for Z
767  {0,5},{0,6},{0,7},{0,8},{0,9},//for U
768  {0,15},{0,16},{0,17},{0,18},{0,19},//for V
769  {0,26},{0,27},{0,28},{0,29},{0,30},{0,31},//for Z
770  {1,20},{1,21},{1,22},{1,23},{1,24},{1,25},//for Z
771  {1,10},{1,11},{1,12},{1,13},{1,14},//for V
772  {1,0},{1,1},{1,2},{1,3},{1,4},//for U
773  {1,26},{1,27},{1,28},{1,29},{1,30},{1,31},//for Z
774  {1,15},{1,16},{1,17},{1,18},{1,19},//for V
775  {1,5},{1,6},{1,7},{1,8},{1,9},//for U
776  {2,0},{2,1},{2,2},{2,3},{2,4},//for U
777  {2,10},{2,11},{2,12},{2,13},{2,14},//for V
778  {2,20},{2,21},{2,22},{2,23},{2,24},{2,25},//for Z
779  {2,5},{2,6},{2,7},{2,8},{2,9},//for U
780  {2,15},{2,16},{2,17},{2,18},{2,19},//for V
781  {2,26},{2,27},{2,28},{2,29},{2,30},{2,31},//for Z
782  {3,20},{3,21},{3,22},{3,23},{3,24},{3,25},//for Z
783  {3,10},{3,11},{3,12},{3,13},{3,14},//for V
784  {3,0},{3,1},{3,2},{3,3},{3,4},//for U
785  {3,26},{3,27},{3,28},{3,29},{3,30},{3,31},//for Z
786  {3,15},{3,16},{3,17},{3,18},{3,19},//for V
787  {3,5},{3,6},{3,7},{3,8},{3,9} };//for U
788  return FEMBchanToHistogram[FEMBchan][coord];
789  }
790 
791  //-----------------------------------------------------------------------
793 
794  // Find dead/noisy channels. Do this separately for each APA and for each view.
795  std::vector<double> fURMS_mean; std::vector<double> fURMS_sigma;
796  std::vector<double> fVRMS_mean; std::vector<double> fVRMS_sigma;
797  std::vector<double> fZRMS_mean; std::vector<double> fZRMS_sigma;
798  for(unsigned int i = 0; i < fNofAPA; i++){
799  // U plane
800  TH1F* h1 = (TH1F*)fChanRMSDistU.at(i);
801  fURMS_mean.push_back(h1->GetMean());
802  fURMS_sigma.push_back(h1->GetRMS());
803  // V plane
804  TH1F* h2 = (TH1F*)fChanRMSDistV.at(i);
805  fVRMS_mean.push_back(h2->GetMean());
806  fVRMS_sigma.push_back(h2->GetRMS());
807  // Z plane
808  TH1F* h3 = (TH1F*)fChanRMSDistZ.at(i);
809  fZRMS_mean.push_back(h3->GetMean());
810  fZRMS_sigma.push_back(h3->GetRMS());
811  }
812 
813  std::vector<int> fUdch_vec; std::vector<int> fUnch_vec; std::vector<int> fUcch_vec;
814  std::vector<int> fVdch_vec; std::vector<int> fVnch_vec; std::vector<int> fVcch_vec;
815  std::vector<int> fZdch_vec; std::vector<int> fZnch_vec; std::vector<int> fZcch_vec;
816 
817  for(unsigned int i = 0; i < fNofAPA; i++){
818  int ndeadchannels = 0; int nnoisychannels = 0; int nnoisychannels_counts = 0;
819 
820  // U plane
821  TProfile* h1 = (TProfile*)fChanRMSU_pfx.at(i);
822  FillChannelHistos(h1, fURMS_mean.at(i), fURMS_sigma.at(i), ndeadchannels, nnoisychannels, nnoisychannels_counts);
823  fUdch_vec.push_back(ndeadchannels);
824  fUnch_vec.push_back(nnoisychannels);
825  fUcch_vec.push_back(nnoisychannels_counts);
826 
827  // V plane
828  ndeadchannels = 0; nnoisychannels = 0; nnoisychannels_counts = 0;
829  TProfile* h2 = (TProfile*)fChanRMSV_pfx.at(i);
830  FillChannelHistos(h2, fVRMS_mean.at(i), fVRMS_sigma.at(i), ndeadchannels, nnoisychannels, nnoisychannels_counts);
831  fVdch_vec.push_back(ndeadchannels);
832  fVnch_vec.push_back(nnoisychannels);
833  fVcch_vec.push_back(nnoisychannels_counts);
834 
835  // Z plane
836  ndeadchannels = 0; nnoisychannels = 0; nnoisychannels_counts = 0;
837  TProfile* h3 = (TProfile*)fChanRMSZ_pfx.at(i);
838  FillChannelHistos(h3, fZRMS_mean.at(i), fZRMS_sigma.at(i), ndeadchannels, nnoisychannels, nnoisychannels_counts);
839  fZdch_vec.push_back(ndeadchannels);
840  fZnch_vec.push_back(nnoisychannels);
841  fZcch_vec.push_back(nnoisychannels_counts);
842  }
843 
844  // Fill summary histograms
845  for(unsigned int i = 0; i < fNofAPA; i++){
846  unsigned int j=fApaLabelNum.at(i);
847  int nch = fUdch_vec.at(i) + fVdch_vec.at(i) + fZdch_vec.at(i);
848  fNDeadChannelsHisto->SetBinContent(j+1, nch);
849  nch = fUnch_vec.at(i) + fVnch_vec.at(i) + fZnch_vec.at(i);
850  fNNoisyChannelsHistoFromNSigma->SetBinContent(j+1, nch);
851  nch = fUcch_vec.at(i) + fVcch_vec.at(i) + fZcch_vec.at(i);
852  fNNoisyChannelsHistoFromNCounts->SetBinContent(j+1, nch);
853 
854  fNDeadChannelsHistoU->SetBinContent(j+1, fUdch_vec.at(i));
855  fNDeadChannelsHistoV->SetBinContent(j+1, fVdch_vec.at(i));
856  fNDeadChannelsHistoZ->SetBinContent(j+1, fZdch_vec.at(i));
857 
858  fNNoisyChannelsHistoFromNSigmaU->SetBinContent(j+1, fUnch_vec.at(i));
859  fNNoisyChannelsHistoFromNSigmaV->SetBinContent(j+1, fVnch_vec.at(i));
860  fNNoisyChannelsHistoFromNSigmaZ->SetBinContent(j+1, fZnch_vec.at(i));
861 
862  fNNoisyChannelsHistoFromNCountsU->SetBinContent(j+1, fUcch_vec.at(i));
863  fNNoisyChannelsHistoFromNCountsV->SetBinContent(j+1, fVcch_vec.at(i));
864  fNNoisyChannelsHistoFromNCountsZ->SetBinContent(j+1, fZcch_vec.at(i));
865  }
866 
867  // myfileU.close();
868  // myfileV.close();
869  // myfileZ.close();
870  return;
871  }
872 
873 }
874 
876 
877 
878 
879 #endif // IcebergTpcMonitore_module
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Definition: RawDigit.h:210
std::vector< TProfile * > fFFT_by_Fiber_pfx
void calculateFFT(TH1D *hist_waveform, TH1D *graph_frequency)
float rmsADC(std::vector< short > &uncompressed)
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Definition: RawDigit.h:213
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
std::string string
Definition: nybbler.cc:12
Planes which measure V.
Definition: geo_types.h:130
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
std::vector< TProfile * > fChanStuckCodeOnFracV
std::vector< TProfile * > fChanRMSZ_pfx
IcebergTpcMonitor(fhicl::ParameterSet const &pset)
void reconfigure(fhicl::ParameterSet const &pset)
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
std::vector< raw::RawDigit > RawDigits
Definition: HDF5Utils.h:23
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
int16_t adc
Definition: CRTFragment.hh:202
Planes which measure Z direction.
Definition: geo_types.h:132
Scale(size_t pos, T factor) -> Scale< T >
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
static QStrList * l
Definition: config.cpp:1044
unsigned int FiberIdFromOfflineChannel(unsigned int offlineChannel) const
Returns global fiber ID.
std::vector< TProfile * > fChanRMSU_pfx
void FillChannelHistos(TProfile *h1, double mean, double sigma, int &ndeadchannels, int &nnoisychannels_sigma, int &nnoisychannels_counts)
art framework interface to geometry description
Definition: Run.h:17
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
T abs(T value)
Planes which measure U.
Definition: geo_types.h:129
std::vector< unsigned int > fApaLabelNum
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::vector< TProfile * > fChanMeanU_pfx
std::void_t< T > n
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::vector< TProfile * > fChanStuckCodeOnFracU
size_t NADC() const
Number of elements in the compressed ADC sample vector.
Definition: RawDigit.h:207
p
Definition: test.py:223
Description of geometry of one entire detector.
#define MF_LOG_INFO(category)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Definition of data types for geometry description.
void analyze(const art::Event &evt)
float meanADC(std::vector< short > &uncompressed)
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
Definition: RawDigit.h:216
std::vector< TProfile * > fChanStuckCodeOnFracZ
std::vector< TProfile * > fChanRMSV_pfx
std::vector< TProfile * > fChanStuckCodeOffFracZ
std::vector< TProfile * > fChanStuckCodeOffFracU
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
std::vector< TProfile * > fChanMeanV_pfx
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
std::vector< TProfile * > fChanStuckCodeOffFracV
std::vector< TProfile * > fChanMeanZ_pfx
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:16
QTextStream & endl(QTextStream &s)
Event finding and building.