NearlineAna_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 // \file NearlineAna_module.cc
3 // \brief Analysis module to make the Nearline Plots
4 // \version $Id: NearlineAna_module.cc,v 1.0 2013-10-09 14:51:38 mbaird42 Exp $
5 // \author $Author: mbaird42 $
6 ////////////////////////////////////////////////////////////////////////
7 
8 // C/C++ includes
9 #include <cmath>
10 #include <iostream>
11 
12 // ROOT includes
13 #include "TH1F.h"
14 #include "TH1D.h"
15 #include "TH2F.h"
16 #include "TTree.h"
17 #include "TTimeStamp.h" // needed for printing the date/time
18 #include "TVector3.h"
19 
20 // Framework includes
30 #include "fhiclcpp/ParameterSet.h"
32 
33 // NOvASoft includes
34 #include "Geometry/Geometry.h"
36 #include "NovaDAQConventions/DAQConventions.h"
37 #include "RecoBase/CellHit.h"
38 #include "RecoBase/Cluster.h"
39 #include "RecoBase/Track.h"
40 #include "SummaryData/SpillData.h" // needed for getting spill data
41 
42 #include "Utilities/AssociationUtil.h"
43 #include "Utilities/func/MathUtil.h"
44 #include "DAQDataFormats/RawEvent.h"
45 #include "DAQDataFormats/RawTrigger.h"
46 #include "RawData/FlatDAQData.h"
47 
48 // needed for DCM sync status plots
50 #include "DAQChannelMap/DAQChannelMap.h"
51 #include "NovaDAQConventions/DAQConventions.h"
52 #include "RunHistory/service/RunHistoryService.h" //Map of Instrumented Detector
53 
54 
55 //static const double ns = 1.0E-9;
56 
57 // NearlineAna header
58 namespace comi {
59  class NearlineAna : public art::EDAnalyzer {
60  public:
61 
62  bool IsContained(double x, double y, double z);
63 
64  explicit NearlineAna(fhicl::ParameterSet const& pset);
65  ~NearlineAna();
66 
67  void analyze(const art::Event& evt);
68  void beginJob();
69  void endJob();
70  void beginRun(const art::Run& run);
71 
72  private:
73 
74  int fMinTrackHits; ///< minimum # of hits from a track within a DCM for the track to count as having passed through that DCM
75  std::string fSlicerLabel; ///< Where to find Clusters
76  std::string fCellHitsListLabel; ///< Where to find CellHits
77 
78  fhicl::ParameterSet fPSetFD, fPSetND, fPSetNDOS, fPSetTB; ///< Parameter sets for each detector
79 
80  std::string fTrackLabel; ///< Where to find Tracks
81  double fMinX; ///< containment cut in X
82  double fMaxX; ///< containment cut in X
83  double fMinY; ///< containment cut in Y
84  double fMaxY; ///< containment cut in Y
85  double fMinZ; ///< containment cut in Z
86  double fMaxZ; ///< containment cut in Z
87  double fP1MaxZ; ///< containment cut in Z for partition 1
88  double fMinT; ///< for cutting in T
89  double fMaxT; ///< for cutting in T
90  int fMinFEBs; ///< NEW Minimum number of FEBs in a DCM for allow diblock instrumented
91 
92  double fMinPOTCut; ///< min POT cut for beam quality
93  double fMinHornICut; ///< min horn current cut for beam quality
94  double fMaxHornICut; ///< max horn current cut for beam quality
95  double fMinPosXCut; ///< min x position cut for beam quality
96  double fMaxPosXCut; ///< max x position cut for beam quality
97  std::vector<double> fMinPosYCutVec; ///< min y position cut for beam quality vector (for change in cuts)
98  std::vector<double> fMaxPosYCutVec; ///< max y position cut for beam quality vector (for change in cuts)
99  double fMinPosYCut; ///< min y position cut for beam quality
100  double fMaxPosYCut; ///< max y position cut for beam quality
101  double fMinWidthXCut; ///< min x width cut for beam quality
102  double fMaxWidthXCut; ///< max x width cut for beam quality
103  double fMinWidthYCut; ///< min y width cut for beam quality
104  double fMaxWidthYCut; ///< max y width cut for beam quality
105  double fMaxDeltaTCut; ///< mqax delta t cut for beam quality
106 
107  // Header TTree variables etc.
108  TTree* fHeader; ///< Header object to be written to disk with the histograms
109  unsigned int fLastRun; ///< Header: last run number analyzed
110  unsigned int fLastSubrun; ///< Header: last subrun number analyzed
111  unsigned int fPartition; ///< Header: partition number from last event analyzed
112  int fFirstEvent; ///< Header: first event processed
113  int fLastEvent; ///< Header: last event processed
114  int fNevents; ///< Header: number of events processed
115  unsigned long long int fStartTime; ///< Header: time of first processed event - initalized to -1 to make it a HUGE positive number
116  unsigned long long int fEndTime; ///< Header: time of last processed event
117  double fLiveTime; ///< Header: total live time in seconds
118  unsigned int fStartYear; ///< Header: year of first processed event (actual year since 0 A.D.)
119  unsigned int fStartMonth; ///< Header: month of first processed event (actual month 1-12)
120  unsigned int fStartDay; ///< Header: day of first processed event (day of the month 1-31)
121  double fStartHour; ///< Header: hour of first processed event (since midnight 0.0 - 23.99999)
122  unsigned int fEndYear; ///< Header: year of last processed event (actual year since 0 A.D.)
123  unsigned int fEndMonth; ///< Header: month of last processed event (actual month 1-12)
124  unsigned int fEndDay; ///< Header: day of last processed event (day of the month 1-31)
125  double fEndHour; ///< Header: hour of last processed event (since midnight 0.0 - 23.99999)
126 
127  //
128  // Histograms
129  //
130 
131  // Beam histos
132  TH1D * fTimeDiffNanoSec; ///< time difference between the spill times recorded as event timestamp and by IFDB
133  TH1D * fPOTSum; ///< sum of POT
134  TH1D * fspillPOT; ///< spill POT
135  TH1D * fHornCurrent; ///< value of horn current
136  TH1D * fIsRHC; ///< reverse horn current boolean
137  TH1D * fXPosition; ///< horizontal position of beam at target
138  TH1D * fYPosition; ///< vertical position of beam at target
139  TH1D * fXWidth; ///< horizontal width of beam at TRTGT
140  TH1D * fYWidth; ///< vertical width of beam at TRTGT
141  TH1D * fGoodBeam; ///< value of goodbeam parameter, ie whether spill passed beam quality cuts
142  TH1I * fBadSpills; ///< failure modes for those spills that don't pass the beam quality cuts
143 
144  // Slice histos
145  TH1D *fNumSlices; ///< number of non-noise slices
146  TH1D *fNumSlicesGoodBeam; ///< number of non-noise slices for good beam
147  TH1D *fNumHits; ///< number of hits per non noise slice
148  TH1D *fNumHitsNoise; ///< number hits in the noise slice
149  TH1D *fNumHitsX; ///< number of X hits in non-noise slices
150  TH1D *fNumHitsXNoise; ///< number of X hits in the noise slice
151  TH1D *fNumHitsY; ///< number of Y hits in non-noise slices
152  TH1D *fNumHitsYNoise; ///< number of Y hits in the noise slice
153 
154  TH1D *fADCAllHits; ///< ADC for all hits
155  TH1D *fADCNoiseHits; ///< ADC for hits in the noise slice
156  TH1D *fADCNonNoiseHits; ///< ADC for hits in non-noise slices
157  TH1D *fPEAllHits; ///< PE for all hits
158  TH1D *fPENoiseHits; ///< PE for hits in the noise slice
159  TH1D *fPENonNoiseHits; ///< PE for hits in non-noise slices
160 
161  TH2D *fPCXave; ///< for each non-noise slice, average plane/cell of hits
162  TH2D *fPCYave; ///< for each non-noise slice, average plane/cell of hits
163  TH2D *fPCXaveCR; ///< for each non-noise slice, average plane/cell of hits (control room view - meaning X is flipped and Z is flipped for both views)
164  TH2D *fPCYaveCR; ///< for each non-noise slice, average plane/cell of hits (control room view)
165  TH1D *fTave; ///< for each non-noise slice, average time of hits
166  TH2D *fPCXdiff; ///< for each non-noise slice, difference btwn highest and lowest plane/cell
167  TH2D *fPCYdiff; ///< for each non-noise slice, difference btwn highest and lowest plane/cell
168  TH1D *fTsd; ///< for each non-noise slice, standard dev. of hit times
169 
170  // Histos comparing slices and tracks
171  TH1D *fDeltaSliceTrack; ///< number of slices minus number of 3D tracks
172  TH1D *fSliceTrackRatio; ///< ratio of number of 3D tracks to number of slices
173  TH1D *fSliceTrackNHitRatio; ///< ratio of number of hits on 3D track to number of hits in the slice (0 means no track or 2D track)
174  TH2D *fSliceTrackNHitRatioVSnhit; ///< ratio of number of hits on 3D track to number of hits in the slice, 2D plot vs nhit in slice (0 means no track or 2D track)
175 
176  // Tracks histos
177  TH1D *fTrackLengthAll2D; ///< length of track [cm] (all 2D tracks)
178  TH1D *fTrackCosZenithAll2D; ///< cosine theta of track with respect to zenith direction (all 2D tracks)
179  TH1D *fTrackCosAzimuthAll2D; ///< cosine theta of track with respect to azimuth direction (all 2D tracks)
180  TH2D *fTrackCosZenAziAll2D; ///< 2D plot of cos zentih and cos azimuth (all 2D tracks)
181  TH1D *fTrackCosNumiAll2D; ///< cosine theta of track with respect to NuMI beam (all 2D tracks)
182  TH1D *fTrackZenithAll2D; ///< track zenith angle (all 2D tracks)
183  TH1D *fTrackAzimuthAll2D; ///< track azimuthal angle (all 2D tracks)
184  TH2D *fTrackZenAziAll2D; ///< 2D plot of zentih and azimuth (all 2D tracks)
185  TH1D *fTrackNumiAll2D; ///< track numi angle (all 2D tracks)
186  TH1D *fNumTracksAll2D; ///< counter for number of tracks (all 2D tracks)
187  TH1D *fTrackFractionAll2D; ///< fraction of total tracks that are 2D
188  TH2D *fStartPointTrackXZAll2D; ///< 2D histogram showing starting point of reco track in XZ view (all 2D tracks)
189  TH2D *fStartPointTrackYZAll2D; ///< 2D histogram showing starting point of reco track in YZ view (all 2D tracks)
190  TH2D *fStopPointTrackXZAll2D; ///< 2D histogram showing stopping point of reco track in XZ view (all 2D tracks)
191  TH2D *fStopPointTrackYZAll2D; ///< 2D histogram showing stopping point of reco track in YZ view (all 2D tracks)
192  TH2D *fStartPointTrackXZCRAll2D; ///< 2D histogram showing starting point of reco track in XZ view (control room view) (all 2D tracks)
193  TH2D *fStartPointTrackYZCRAll2D; ///< 2D histogram showing starting point of reco track in YZ view (control room view) (all 2D tracks)
194  TH2D *fStopPointTrackXZCRAll2D; ///< 2D histogram showing stopping point of reco track in XZ view (control room view) (all 2D tracks)
195  TH2D *fStopPointTrackYZCRAll2D; ///< 2D histogram showing stopping point of reco track in YZ view (control room view) (all 2D tracks)
196  TH1D *fPETrackHitsAll2D; ///< PE for hits on tracks (all 2D tracks)
197  TH1D *fTtrkAll2D; ///< track times (all 2D tracks)
198 
199  TH1D *fTrackLengthAll3D; ///< length of track [cm] (all 3D tracks)
200  TH1D *fTrackCosZenithAll3D; ///< cosine theta of track with respect to zenith direction (all 3D tracks)
201  TH1D *fTrackCosAzimuthAll3D; ///< cosine theta of track with respect to azimuth direction (all 3D tracks)
202  TH2D *fTrackCosZenAziAll3D; ///< 2D plot of cos zentih and cos azimuth (all 3D tracks)
203  TH1D *fTrackCosNumiAll3D; ///< cosine theta of track with respect to NuMI beam (all 3D tracks)
204  TH1D *fTrackZenithAll3D; ///< track zenith angle (all 3D tracks)
205  TH1D *fTrackAzimuthAll3D; ///< track azimuthal angle (all 3D tracks)
206  TH2D *fTrackZenAziAll3D; ///< 2D plot of zentih and azimuth (all 3D tracks)
207  TH1D *fTrackNumiAll3D; ///< track numi angle (all 3D tracks)
208  TH1D *fNumTracksAll3D; ///< counter for number of tracks (all 3D tracks)
209  TH1D *fTrackFractionAll3D; ///< fraction of total tracks that are 3D
210  TH2D *fStartPointTrackXZAll3D; ///< 2D histogram showing starting point of reco track in XZ view (all 3D tracks)
211  TH2D *fStartPointTrackYZAll3D; ///< 2D histogram showing starting point of reco track in YZ view (all 3D tracks)
212  TH2D *fStopPointTrackXZAll3D; ///< 2D histogram showing stopping point of reco track in XZ view (all 3D tracks)
213  TH2D *fStopPointTrackYZAll3D; ///< 2D histogram showing stopping point of reco track in YZ view (all 3D tracks)
214  TH2D *fStartPointTrackXZCRAll3D; ///< 2D histogram showing starting point of reco track in XZ view (control room view) (all 3D tracks)
215  TH2D *fStartPointTrackYZCRAll3D; ///< 2D histogram showing starting point of reco track in YZ view (control room view) (all 3D tracks)
216  TH2D *fStopPointTrackXZCRAll3D; ///< 2D histogram showing stopping point of reco track in XZ view (control room view) (all 3D tracks)
217  TH2D *fStopPointTrackYZCRAll3D; ///< 2D histogram showing stopping point of reco track in YZ view (control room view) (all 3D tracks)
218  TH1D *fPETrackHitsAll3D; ///< PE for hits on tracks (all 3D tracks)
219  TH1D *fTtrkAll3D; ///< track times (all 3D tracks)
220 
221  TH1D *fTrackLengthCont3D; ///< length of track [cm] (all contained 3D tracks)
222  TH1D *fTrackCosZenithCont3D; ///< cosine theta of track with respect to zenith direction (all contained 3D tracks)
223  TH1D *fTrackCosAzimuthCont3D; ///< cosine theta of track with respect to azimuth direction (all contained 3D tracks)
224  TH2D *fTrackCosZenAziCont3D; ///< 2D plot of cos zentih and cos azimuth (all contained 3D tracks)
225  TH1D *fTrackCosNumiCont3D; ///< cosine theta of track with respect to NuMI beam (all contained 3D tracks)
226  TH1D *fTrackZenithCont3D; ///< track zenith angle (all contained 3D tracks)
227  TH1D *fTrackAzimuthCont3D; ///< track azimuthal angle (all contained 3D tracks)
228  TH2D *fTrackZenAziCont3D; ///< 2D plot of zentih and azimuth (all contained 3D tracks)
229  TH1D *fTrackNumiCont3D; ///< track numi angle (all contained 3D tracks)
230  TH1D *fNumTracksCont3D; ///< counter for number of tracks (all contained 3D tracks)
231  TH1D *fTrackFractionCont3D; ///< fraction of total tracks that are contained 3D
232  TH2D *fStartPointTrackXZCont3D; ///< 2D histogram showing starting point of reco track in XZ view (all contained 3D tracks)
233  TH2D *fStartPointTrackYZCont3D; ///< 2D histogram showing starting point of reco track in YZ view (all contained 3D tracks)
234  TH2D *fStopPointTrackXZCont3D; ///< 2D histogram showing stopping point of reco track in XZ view (all contained 3D tracks)
235  TH2D *fStopPointTrackYZCont3D; ///< 2D histogram showing stopping point of reco track in YZ view (all contained 3D tracks)
236  TH2D *fStartPointTrackXZCRCont3D; ///< 2D histogram showing starting point of reco track in XZ view (control room view) (all contained 3D tracks)
237  TH2D *fStartPointTrackYZCRCont3D; ///< 2D histogram showing starting point of reco track in YZ view (control room view) (all contained 3D tracks)
238  TH2D *fStopPointTrackXZCRCont3D; ///< 2D histogram showing stopping point of reco track in XZ view (control room view) (all contained 3D tracks)
239  TH2D *fStopPointTrackYZCRCont3D; ///< 2D histogram showing stopping point of reco track in YZ view (control room view) (all contained 3D tracks)
240  TH1D *fPETrackHitsCont3D; ///< PE for hits on tracks (all contained 3D tracks)
241  TH1D *fTtrkCont3D; ///< track times (all contained 3D tracks)
242 
243  // DCM sync status stuff
244  int counter2D[14][12]; ///< counter array for the number of hits/tracks per dcm
245  int counter3D[14][12]; ///< counter array for the number of hits/tracks per dcm
246  TH2D *f2DHitNum; ///< Number of hits on 2D tracks per DCM
247  TH2D *f3DHitNum; ///< Number of hits on 3D tracks per DCM
248 
249  TH2D *f2DTrackNum; ///< Number of 3D tracks per DCM
250  TH2D *f3DTrackNum; ///< Number of 2D tracks per DCM
251 
252  TH2F *Instr; ///< Map view of the instrumented detector (DCM w/ > 50APDs)
253  TH2F *fullyinstr; ///< Counter of fully instrumented diblocks
254 
255  };
256 }
257 
258 
259 
260 namespace comi
261 {
262  //.......................................................................
264  EDAnalyzer(pset),
265  fMinTrackHits (pset.get< int >("MinTrackHits") ),
266  fSlicerLabel (pset.get< std::string >("SlicerLabel") ),
267  fCellHitsListLabel(pset.get< std::string >("CellHitsListLabel")),
268  fPSetFD (pset.get< fhicl::ParameterSet >("fd") ),
269  fPSetND (pset.get< fhicl::ParameterSet >("nd") ),
270  fPSetNDOS (pset.get< fhicl::ParameterSet >("ndos") ),
271  fPSetTB (pset.get< fhicl::ParameterSet >("tb") ),
272  fTrackLabel("none"),
273  fMinX(0),
274  fMaxX(0),
275  fMinY(0),
276  fMaxY(0),
277  fMinZ(0),
278  fMaxZ(0),
279  fP1MaxZ(0),
280  fMinT(0),
281  fMaxT(0),
282  fMinFEBs(0),
283  fMinPOTCut(0),
284  fMinHornICut(0),
285  fMaxHornICut(0),
286  fMinPosXCut(0),
287  fMaxPosXCut(0),
288  fMinPosYCut(0),
289  fMaxPosYCut(0),
290  fMinWidthXCut(0),
291  fMaxWidthXCut(0),
292  fMinWidthYCut(0),
293  fMaxWidthYCut(0),
294  fMaxDeltaTCut(0),
295  fHeader(0),
296  fLastRun(0),
297  fLastSubrun(0),
298  fPartition(4),
299  fFirstEvent(1e9),
300  fLastEvent(-1),
301  fNevents(0),
302  fStartTime(-1),
303  fEndTime(0),
304  fLiveTime(0.0)
305  { }
306 
307  //......................................................................
309  { }
310 
311  //......................................................................
313  {
314 
316 
317  // make header
318  fHeader = tfs->make<TTree>("Header","Subrun Information");
319 
320  fHeader->Branch("Run",&fLastRun);
321  fHeader->Branch("Subrun",&fLastSubrun);
322  fHeader->Branch("Partition",&fPartition);
323  fHeader->Branch("FirstEvent",&fFirstEvent);
324  fHeader->Branch("LastEvent",&fLastEvent);
325  fHeader->Branch("Nevents",&fNevents);
326  fHeader->Branch("LiveTime",&fLiveTime);
327  fHeader->Branch("StartYear",&fStartYear);
328  fHeader->Branch("StartMonth",&fStartMonth);
329  fHeader->Branch("StartDay",&fStartDay);
330  fHeader->Branch("StartHour",&fStartHour);
331  fHeader->Branch("EndYear",&fEndYear);
332  fHeader->Branch("EndMonth",&fEndMonth);
333  fHeader->Branch("EndDay",&fEndDay);
334  fHeader->Branch("EndHour",&fEndHour);
335  // I would like to add these two variables to the header object but
336  // root complains that an unsigned long long int is an unacceptable type.
337  //
338  // fHeader->Branch("StartTime", &fStartTime);
339  // fHeader->Branch("EndTime", &fEndTime);
340 
341  // book the histograms
342 
343 
344  // Spill-related
345  fTimeDiffNanoSec = tfs->make<TH1D>("fTimeDiffNanoSec",
346  "Time Difference;Time difference (sec);count",
347  500,-0.1,0.6);
348 
349  fPOTSum = tfs->make<TH1D>("fPOTSum",
350  "Sum POT;Sum POT;count",
351  2,0,1);
352 
353  fspillPOT = tfs->make<TH1D>("fspillPOT",
354  "Spill POT;Spill POT;count",
355  200,0,90e12);
356 
357  fHornCurrent = tfs->make<TH1D>("fHornCurrent",
358  "Horn Current (kA);Current(kA);count",
359  100,-203,-197);
360 
361  fIsRHC = tfs->make<TH1D>("fIsRHC",
362  "Is RHC (bool);IsRHC;count",
363  2, -0.5, 1.5);
364 
365  fXPosition = tfs->make<TH1D>("fXPosition",
366  "Horizontal Beam Position (mm);Position (mm);count",
367  240,-2.1,2.1);
368 
369  fYPosition = tfs->make<TH1D>("fYPosition",
370  "Vertical Beam Position (mm);Position (mm);count",
371  400,-5,2);
372 
373  fXWidth = tfs->make<TH1D>("fXWidth",
374  "Horizontal Beam Width;Width (mm);count",
375  250,0.5,3.0);
376 
377  fYWidth = tfs->make<TH1D>("fYWidth",
378  "Vertical Beam Width;Width (mm); count",
379  250,0.5,3.0);
380 
381  fGoodBeam = tfs->make<TH1D>("fGoodBeam",
382  "Good Beam;Good Beam;count",
383  2,0,2);
384 
385  fBadSpills =tfs->make<TH1I>("fBadSpills",
386  "Failure Mode for Bad Spills;;count",
387  8,1,9);
388 
389  fBadSpills->SetStats(kFALSE);
390 
391 
392  TAxis *badspillsxaxis = fBadSpills->GetXaxis();
393  badspillsxaxis->SetBinLabel(1,"delta t");
394  badspillsxaxis->SetBinLabel(2,"POT");
395  badspillsxaxis->SetBinLabel(3,"horn I");
396  badspillsxaxis->SetBinLabel(4,"x position");
397  badspillsxaxis->SetBinLabel(5,"y position");
398  badspillsxaxis->SetBinLabel(6,"x width");
399  badspillsxaxis->SetBinLabel(7,"y width");
400  badspillsxaxis->SetBinLabel(8,"Total Bad Spills");
401 
402 
403  fNumSlices = tfs->make<TH1D>("fNumSlices",
404  "# of non-noise slices;# of non-noise slices;count",
405  501,-0.5,500.5);
406  fNumSlicesGoodBeam = tfs->make<TH1D>("fNumSlicesGoodBeam",
407  "# of non-noise slices Good Beam;# of non-noise slices good beam;count",
408  501,-0.5,500.5);
409  fNumHits = tfs->make<TH1D>("fNumHits",
410  "# of hits per non-noise slice;# of hits;count",
411  1000,0.0,5000.0);
412  fNumHitsNoise = tfs->make<TH1D>("fNumHitsNoise",
413  "# of hits in the noise slice;# of hits;count",
414  8000,0.0,40000.0);
415  fNumHitsX = tfs->make<TH1D>("fNumHitsX",
416  "# of X hits per non-noise slice;# of hits;count",
417  1000,0.0,5000.0);
418  fNumHitsXNoise = tfs->make<TH1D>("fNumHitsXNoise",
419  "# of X hits in the noise slice;# of hits;count",
420  4000,0.0,20000.0);
421  fNumHitsY = tfs->make<TH1D>("fNumYHits",
422  "# of Y hits per non-noise slice;# of hits;count",
423  1000,0.0,5000.0);
424  fNumHitsYNoise = tfs->make<TH1D>("fNumHitsYNoise",
425  "# of Y hits in the noise slice;# of hits;count",
426  4000,0.0,20000.0);
427 
428  fADCAllHits = tfs->make<TH1D>("fADCAllHits",
429  "ADC for All Hits;ADC;count",
430  4096,0,4096);
431  fADCNoiseHits = tfs->make<TH1D>("fADCNoiseHits",
432  "ADC for Hits in the Noise Slice;ADC;count",
433  4096,0,4096);
434  fADCNonNoiseHits = tfs->make<TH1D>("fADCNonNoiseHits",
435  "ADC for Hits in Non-Noise Slices;ADC;count",
436  4096,0,4096);
437  fPEAllHits = tfs->make<TH1D>("fPEAllHits",
438  "PE for All Hits;PE;count",
439  1862,0,4096);
440  fPENoiseHits = tfs->make<TH1D>("fPENoiseHits",
441  "PE for Hits in the Noise Slice;PE;count",
442  1862,0,4096);
443  fPENonNoiseHits = tfs->make<TH1D>("fPENonNoiseHits",
444  "PE for Hits in Non-Noise Slices;PE;count",
445  1862,0,4096);
446 
447  fPCXave = tfs->make<TH2D>("fPCXave",
448  "ave hit plane vs. ave hit X cell;plane;X cell",
449  660,-20.0,1300.0,255,-10.0,500.0);
450  fPCYave = tfs->make<TH2D>("fPCYave",
451  "ave hit plane vs. ave hit Y cell;plane;Y cell",
452  660,-20.0,1300.0,255,-10.0,500.0);
453  fPCXaveCR = tfs->make<TH2D>("fPCXaveCR",
454  "ave hit plane vs. ave hit X cell (control room view);plane;X cell",
455  660,-1300.0,20.0,255,-500.0,10.0);
456  fPCYaveCR = tfs->make<TH2D>("fPCYaveCR",
457  "ave hit plane vs. ave hit Y cell (control room view);plane;Y cell",
458  660,-1300.0,20.0,255,-10.0,500.0);
459 
460  fTave = tfs->make<TH1D>("fTave",
461  "ave hit time per slice; time [ns]; count",
462  1200,-50000.0,550000.0);
463  fPCXdiff = tfs->make<TH2D>("fPCXdiff",
464  "diff btwn hi and lo for plane vs X cell per slice;delta plane;delta X cell",
465  500,0.0,1000.0,250,0.0,500.0);
466  fPCYdiff = tfs->make<TH2D>("fPCYdiff",
467  "diff btwn hi and lo for plane vs Y cell per slice;delta plane;delta Y cell",
468  500,0.0,1000.0,250,0.0,500.0);
469  fTsd = tfs->make<TH1D>("fTsd",
470  "st. dev. of hit time per slice; sigma time [ns]; count",
471  500000,0.0,500000.0);
472 
473 
474  fDeltaSliceTrack = tfs->make<TH1D>("fDeltaSliceTrack",
475  "N-slices minus N-3D-tracks per Trigger;(N-sl) - (N-3D-trk);count",
476  201,-100.5,100.5);
477  fSliceTrackRatio = tfs->make<TH1D>("fSliceTrackRatio",
478  "Ratio of N-3D-tracks to N-slices per Trigger;(N-3D-tracks)/(N-slices);count",
479  2000,0.0,20.0);
480  fSliceTrackNHitRatio = tfs->make<TH1D>("fSliceTrackNHitRatio",
481  "NHit Ratio from 3D-tracks to Slices per Slice;(NHit-3D-tracks)/(NHit-slices);count",
482  101,0.0,1.01);
483  fSliceTrackNHitRatioVSnhit = tfs->make<TH2D>("fSliceTrackNHitRatioVSnhit",
484  "NHit Ratio from 3D-tracks to Slices per Slice VS. NHit-Slices;NHit-Slice;(NHit-3D-tracks)/(NHit-slices)",
485  200,0.0,2000.0,101,0.0,1.01);
486 
487 
488 
489  fTrackLengthAll3D = tfs->make<TH1D>("fTrackLengthAll3D",
490  "Reconstructed Track Length distribution;Track Length[cm]; count",
491  650,0.0,6500.0);
492  fTrackCosZenithAll3D = tfs->make<TH1D>("fTrackCosZenithAll3D",
493  "Cos #theta with respect to zenith; Cos #theta_{Ze};count",
494  202,-1.01,1.01);
495  fTrackCosAzimuthAll3D = tfs->make<TH1D>("fTrackCosAzimuthAll3D",
496  "Cos #theta with respect to azimuth (in detector coordinates); Cos #theta_{Az};count",
497  202,-1.01,1.01);
498  fTrackCosZenAziAll3D = tfs->make<TH2D>("fTrackCosZenAziAll3D",
499  "Cos #theta_{Zenith} vs. Cos #theta_{Azimuth} (in detector coordinates);Cos #theta_{Ze};Cos #theta_{Az}",
500  202,-1.01,1.01,202,-1.01,1.01);
501  fTrackCosNumiAll3D = tfs->make<TH1D>("fTrackCosNumiAll3D",
502  "Cos #theta with respect to NuMI beam; Cos #theta_{NuMI};count",
503  202,-1.01,1.01);
504  fTrackZenithAll3D = tfs->make<TH1D>("fTrackZenithAll3D",
505  "Zenith Angle;#theta_{Ze};count",
506  91,-0.5,180.5);
507  fTrackAzimuthAll3D = tfs->make<TH1D>("fTrackAzimuthAll3D",
508  "Azimuth Angle (in detector coordinates);#theta_{Az};count",
509  181,-0.5,360.5);
510  fTrackZenAziAll3D = tfs->make<TH2D>("fTrackZenAziAll3D",
511  "#theta_{Zenith} vs. #theta_{Azimuth} (in detector coordinates);#theta_{Ze};#theta_{Az}",
512  91,-0.5,180.5,181,-0.5,360.5);
513  fTrackNumiAll3D = tfs->make<TH1D>("fTrackNumiAll3D",
514  "NuMI Angle;#theta_{NuMI};count",
515  91,-0.5,180.5);
516 
517  fNumTracksAll3D = tfs->make<TH1D>("fNumTracksAll3D",
518  ";No. Tracks;Events",
519  301,-0.5,300.5);
520  fTrackFractionAll3D = tfs->make<TH1D>("fTrackFractionAll3D",
521  ";Track Fraction;Events",
522  101,0.0,1.01);
523 
524  fStartPointTrackXZAll3D = tfs->make<TH2D>("fStartPointTrackXZAll3D",
525  "Starting Point of Reco Track in XZ view; Start Z [cm]; Start X [cm]",
526  630,0.,6300,160,-800.,800.);
527  fStartPointTrackYZAll3D = tfs->make<TH2D>("fStartPointTrackYZAll3D",
528  "Starting Point of Reco Track in YZ view; Start Z [cm]; Start Y [cm]",
529  630,0.,6300,160,-800.,800.);
530  fStopPointTrackXZAll3D = tfs->make<TH2D>("fStopPointTrackXZAll3D",
531  "Stopping Point of Reco Track in XZ view; Start Z [cm]; Start X [cm]",
532  630,0.,6300,160,-800.,800.);
533  fStopPointTrackYZAll3D = tfs->make<TH2D>("fStopPointTrackYZAll3D",
534  "Stopping Point of Reco Track in YZ view; Start Z [cm]; Start Y [cm]",
535  630,0.,6300,160,-800.,800.);
536 
537  fStartPointTrackXZCRAll3D = tfs->make<TH2D>("fStartPointTrackXZCRAll3D",
538  "Starting Point of Reco Track in XZ view (control room view); Start Z [cm]; Start X [cm]",
539  630,-6300,0.0,160,-800.,800.);
540  fStartPointTrackYZCRAll3D = tfs->make<TH2D>("fStartPointTrackYZCRAll3D",
541  "Starting Point of Reco Track in YZ view (control room view); Start Z [cm]; Start Y [cm]",
542  630,-6300,0.0,160,-800.,800.);
543  fStopPointTrackXZCRAll3D = tfs->make<TH2D>("fStopPointTrackXZCRAll3D",
544  "Stopping Point of Reco Track in XZ view (control room view); Start Z [cm]; Start X [cm]",
545  630,-6300,0.0,160,-800.,800.);
546  fStopPointTrackYZCRAll3D = tfs->make<TH2D>("fStopPointTrackYZCRAll3D",
547  "Stopping Point of Reco Track in YZ view (control room view); Start Z [cm]; Start Y [cm]",
548  630,-6300,0.0,160,-800.,800.);
549 
550  fPETrackHitsAll3D = tfs->make<TH1D>("fPETrackHitsAll3D",
551  "PE for Hits on Tracks;PE;count",
552  1862,0,4096);
553  fTtrkAll3D = tfs->make<TH1D>("fTtrkAll3D",
554  "ave hit time per track; time [ns]; count",
555  1200,-50000.0,550000.0);
556 
557 
558  fTrackLengthAll2D = tfs->make<TH1D>("fTrackLengthAll2D",
559  "Reconstructed Track Length distribution;Track Length[cm]; count",
560  650,0.0,6500.0);
561  fTrackCosZenithAll2D = tfs->make<TH1D>("fTrackCosZenithAll2D",
562  "Cos #theta with respect to zenith; Cos #theta_{Ze};count",
563  202,-1.01,1.01);
564  fTrackCosAzimuthAll2D = tfs->make<TH1D>("fTrackCosAzimuthAll2D",
565  "Cos #theta with respect to azimuth (in detector coordinates); Cos #theta_{Az};count",
566  202,-1.01,1.01);
567  fTrackCosZenAziAll2D = tfs->make<TH2D>("fTrackCosZenAziAll2D",
568  "Cos #theta_{Zenith} vs. Cos #theta_{Azimuth} (in detector coordinates);Cos #theta_{Ze};Cos #theta_{Az}",
569  202,-1.01,1.01,202,-1.01,1.01);
570  fTrackCosNumiAll2D = tfs->make<TH1D>("fTrackCosNumiAll2D",
571  "Cos #theta with respect to NuMI beam; Cos #theta_{NuMI};count",
572  202,-1.01,1.01);
573  fTrackZenithAll2D = tfs->make<TH1D>("fTrackZenithAll2D",
574  "Zenith Angle;#theta_{Ze};count",
575  91,-0.5,180.5);
576  fTrackAzimuthAll2D = tfs->make<TH1D>("fTrackAzimuthAll2D",
577  "Azimuth Angle (in detector coordinates);#theta_{Az};count",
578  181,-0.5,360.5);
579  fTrackZenAziAll2D = tfs->make<TH2D>("fTrackZenAziAll2D",
580  "#theta_{Zenith} vs. #theta_{Azimuth} (in detector coordinates);#theta_{Ze};#theta_{Az}",
581  91,-0.5,180.5,181,-0.5,360.5);
582  fTrackNumiAll2D = tfs->make<TH1D>("fTrackNumiAll2D",
583  "NuMI Angle;#theta_{NuMI};count",
584  91,-0.5,180.5);
585 
586  fNumTracksAll2D = tfs->make<TH1D>("fNumTracksAll2D",
587  ";No. Tracks;Events",
588  301,-0.5,300.5);
589  fTrackFractionAll2D = tfs->make<TH1D>("fTrackFractionAll2D",
590  ";Track Fraction;Events",
591  101,0.0,1.01);
592 
593  fStartPointTrackXZAll2D = tfs->make<TH2D>("fStartPointTrackXZAll2D",
594  "Starting Point of reco Track in XZ view; Start Z [cm]; Start X [cm]",
595  630,0.,6300,160,-800.,800.);
596  fStartPointTrackYZAll2D = tfs->make<TH2D>("fStartPointTrackYZAll2D",
597  "Starting Point of reco Track in YZ view; Start Z [cm]; Start Y [cm]",
598  630,0.,6300,160,-800.,800.);
599  fStopPointTrackXZAll2D = tfs->make<TH2D>("fStopPointTrackXZAll2D",
600  "Stopping Point of reco Track in XZ view; Start Z [cm]; Start X [cm]",
601  630,0.,6300,160,-800.,800.);
602  fStopPointTrackYZAll2D = tfs->make<TH2D>("fStopPointTrackYZAll2D",
603  "Stopping Point of reco Track in YZ view; Start Z [cm]; Start Y [cm]",
604  630,0.,6300,160,-800.,800.);
605 
606  fStartPointTrackXZCRAll2D = tfs->make<TH2D>("fStartPointTrackXZCRAll2D",
607  "Starting Point of Reco Track in XZ view (control room view); Start Z [cm]; Start X [cm]",
608  630,-6300,0.0,160,-800.,800.);
609  fStartPointTrackYZCRAll2D = tfs->make<TH2D>("fStartPointTrackYZCRAll2D",
610  "Starting Point of Reco Track in YZ view (control room view); Start Z [cm]; Start Y [cm]",
611  630,-6300,0.0,160,-800.,800.);
612  fStopPointTrackXZCRAll2D = tfs->make<TH2D>("fStopPointTrackXZCRAll2D",
613  "Stopping Point of Reco Track in XZ view (control room view); Start Z [cm]; Start X [cm]",
614  630,-6300,0.0,160,-800.,800.);
615  fStopPointTrackYZCRAll2D = tfs->make<TH2D>("fStopPointTrackYZCRAll2D",
616  "Stopping Point of Reco Track in YZ view (control room view); Start Z [cm]; Start Y [cm]",
617  630,-6300,0.0,160,-800.,800.);
618 
619  fPETrackHitsAll2D = tfs->make<TH1D>("fPETrackHitsAll2D",
620  "PE for Hits on Tracks;PE;count",
621  1862,0,4096);
622  fTtrkAll2D = tfs->make<TH1D>("fTtrkAll2D",
623  "ave hit time per track; time [ns]; count",
624  1200,-50000.0,550000.0);
625 
626  fTrackLengthCont3D = tfs->make<TH1D>("fTrackLengthCont3D",
627  "Reconstructed Track Length distribution;Track Length[cm]; count",
628  650,0.0,6500.0);
629  fTrackCosZenithCont3D = tfs->make<TH1D>("fTrackCosZenithCont3D",
630  "Cos #theta with respect to zenith; Cos #theta_{Ze};count",
631  202,-1.01,1.01);
632  fTrackCosAzimuthCont3D = tfs->make<TH1D>("fTrackCosAzimuthCont3D",
633  "Cos #theta with respect to azimuth (in detector coordinates); Cos #theta_{Az};count",
634  202,-1.01,1.01);
635  fTrackCosZenAziCont3D = tfs->make<TH2D>("fTrackCosZenAziCont3D",
636  "Cos #theta_{Zenith} vs. Cos #theta_{Azimuth} (in detector coordinates);Cos #theta_{Ze};Cos #theta_{Az}",
637  202,-1.01,1.01,202,-1.01,1.01);
638  fTrackCosNumiCont3D = tfs->make<TH1D>("fTrackCosNumiCont3D",
639  "Cos #theta with respect to NuMI beam; Cos #theta_{NuMI};count",
640  202,-1.01,1.01);
641  fTrackZenithCont3D = tfs->make<TH1D>("fTrackZenithCont3D",
642  "Zenith Angle;#theta_{Ze};count",
643  91,-0.5,180.5);
644  fTrackAzimuthCont3D = tfs->make<TH1D>("fTrackAzimuthCont3D",
645  "Azimuth Angle (in detector coordinates);#theta_{Az};count",
646  181,-0.5,360.5);
647  fTrackZenAziCont3D = tfs->make<TH2D>("fTrackZenAziCont3D",
648  "#theta_{Zenith} vs. #theta_{Azimuth} (in detector coordinates);#theta_{Ze};#theta_{Az}",
649  91,-0.5,180.5,181,-0.5,360.5);
650  fTrackNumiCont3D = tfs->make<TH1D>("fTrackNumiCont3D",
651  "NuMI Angle;#theta_{NuMI};count",
652  91,-0.5,180.5);
653 
654 
655 
656  fNumTracksCont3D = tfs->make<TH1D>("fNumTracksCont3D",
657  ";No. Tracks;Events",
658  301,-0.5,300.5);
659  fTrackFractionCont3D = tfs->make<TH1D>("fTrackFractionCont3D",
660  ";Track Fraction;Events",
661  101,0.0,1.01);
662 
663  fStartPointTrackXZCont3D = tfs->make<TH2D>("fStartPointTrackXZCont3D",
664  "Starting Point of Reco Track in XZ view; Start Z [cm]; Start X [cm]",
665  630,0.,6300,160,-800.,800.);
666  fStartPointTrackYZCont3D = tfs->make<TH2D>("fStartPointTrackYZCont3D",
667  "Starting Point of Reco Track in YZ view; Start Z [cm]; Start Y [cm]",
668  630,0.,6300,160,-800.,800.);
669  fStopPointTrackXZCont3D = tfs->make<TH2D>("fStopPointTrackXZCont3D",
670  "Stopping Point of Reco Track in XZ view; Start Z [cm]; Start X [cm]",
671  630,0.,6300,160,-800.,800.);
672  fStopPointTrackYZCont3D = tfs->make<TH2D>("fStopPointTrackYZCont3D",
673  "Stopping Point of Reco Track in YZ view; Start Z [cm]; Start Y [cm]",
674  630,0.,6300,160,-800.,800.);
675 
676  fStartPointTrackXZCRCont3D = tfs->make<TH2D>("fStartPointTrackXZCRCont3D",
677  "Starting Point of Reco Track in XZ view (control room view); Start Z [cm]; Start X [cm]",
678  630,-6300,0.0,160,-800.,800.);
679  fStartPointTrackYZCRCont3D = tfs->make<TH2D>("fStartPointTrackYZCRCont3D",
680  "Starting Point of Reco Track in YZ view (control room view); Start Z [cm]; Start Y [cm]",
681  630,-6300,0.0,160,-800.,800.);
682  fStopPointTrackXZCRCont3D = tfs->make<TH2D>("fStopPointTrackXZCRCont3D",
683  "Stopping Point of Reco Track in XZ view (control room view); Start Z [cm]; Start X [cm]",
684  630,-6300,0.0,160,-800.,800.);
685  fStopPointTrackYZCRCont3D = tfs->make<TH2D>("fStopPointTrackYZCRCont3D",
686  "Stopping Point of Reco Track in YZ view (control room view); Start Z [cm]; Start Y [cm]",
687  630,-6300,0.0,160,-800.,800.);
688 
689  fPETrackHitsCont3D = tfs->make<TH1D>("fPETrackHitsCont3D",
690  "PE for Hits on Tracks;PE;count",
691  1862,0,4096);
692  fTtrkCont3D = tfs->make<TH1D>("fTtrkCont3D",
693  "ave hit time per track; time [ns]; count",
694  1200,-50000.0,550000.0);
695  // DCM sync status stuff
696  int minDiBlock=1;
697  int maxDiBlock=14;
698  int nDiBlock = maxDiBlock-minDiBlock+1;
699 
700  //ENTIRE DETECTOR
701  f2DHitNum = tfs->make<TH2D>("H2DHitOnTrack","Number of Hits from 2D Tracks;Diblock;DCM",
702  nDiBlock,(float)minDiBlock-0.5,
703  (float)maxDiBlock+0.5,12,0.5,12.5);
704  f3DHitNum = tfs->make<TH2D>("H3DHitOnTrack","Number of Hits from 3D Tracks;Diblock;DCM",
705  nDiBlock,(float)minDiBlock-0.5,
706  (float)maxDiBlock+0.5,12,0.5,12.5);
707 
708  f2DTrackNum = tfs->make<TH2D>("H2DTrackNum","Number of 2D Tracks;Diblock;DCM",
709  nDiBlock,(float)minDiBlock-0.5,
710  (float)maxDiBlock+0.5,12,0.5,12.5);
711  f3DTrackNum = tfs->make<TH2D>("H3DTrackNum","Number of 3D Tracks;Diblock;DCM",
712  nDiBlock,(float)minDiBlock-0.5,
713  (float)maxDiBlock+0.5,12,0.5,12.5);
714 
715  Instr = tfs->make<TH2F>("instrumented","Map of Instrumented Detector (DCMs with more than fMinFEBs APDs);Diblock;DCM",
716  nDiBlock,(float)minDiBlock-0.5,
717  (float)maxDiBlock+0.5,12,0.5,12.5);
718 
719  fullyinstr = tfs->make<TH2F>("fully_instrumented","Map of Fully Instrumented Detector;Diblock;DCM",
720  nDiBlock,(float)minDiBlock-0.5,
721  (float)maxDiBlock+0.5,12,0.5,12.5);
722  }
723 
724  //......................................................................
726  {
727  //
728  // Compute header info.
729  //
730 
731  //
732  // DISECTING the time from evt.time().value() into "human readable" format to display the date & time
733  // taken from EventDisplay/HeaderDrawer.cxx
734  //
735  unsigned int hour, minute, second;
736  int nano;
737 
738  // get the time stamp. art::Timestamp::value() returns a TimeValue_t which is a typedef to unsigned long long.
739  // The conventional use is for the upper 32 bits to have the seconds since 1970 epoch and the lower 32 bits to be
740  // the number of nanoseconds with the current second.
741 
742  // taking start time apart
743  const unsigned long int mask32 = 0xFFFFFFFFUL;
744 
745  unsigned long int lup = ( fStartTime >> 32 ) & mask32;
746  unsigned long int llo = fStartTime & mask32;
747  TTimeStamp ts1(lup, (int)llo);
748  ts1.GetDate(kTRUE,0,&fStartYear,&fStartMonth,&fStartDay);
749  ts1.GetTime(kTRUE,0,&hour,&minute,&second);
750  nano = ts1.GetNanoSec();
751  double sec = ((double)second + (double)nano/1.0e9);
752  fStartHour = (double)hour + (double)minute/60.0 + sec/3600.0;
753  // taking end time apart
754  lup = ( fEndTime >> 32 ) & mask32;
755  llo = fEndTime & mask32;
756  TTimeStamp ts2(lup, (int)llo);
757  ts2.GetDate(kTRUE,0,&fEndYear,&fEndMonth,&fEndDay);
758  ts2.GetTime(kTRUE,0,&hour,&minute,&second);
759  nano = ts2.GetNanoSec();
760  sec = ((double)second + (double)nano/1.0e9);
761  fEndHour = (double)hour + (double)minute/60.0 + sec/3600.0;
762 
763  fHeader->Fill();
764  }
765 
766  //......................................................................
768  {
770  fhicl::ParameterSet DETpset;
771 
772  switch(geom->DetId()){
773  case novadaq::cnv::kNDOS:
774  DETpset = fPSetNDOS;
775  break;
777  DETpset = fPSetND;
778  break;
780  DETpset = fPSetFD;
781  break;
783  DETpset = fPSetTB;
784  break;
785  default:
786  std::cout << "\nUnknown detector type!\n";
787  assert(0);
788  }
789  fTrackLabel = DETpset.get<std::string>("TrackLabel");
790  fMinX = DETpset.get< double > ("MinX");
791  fMaxX = DETpset.get< double > ("MaxX");
792  fMinY = DETpset.get< double > ("MinY");
793  fMaxY = DETpset.get< double > ("MaxY");
794  fMinZ = DETpset.get< double > ("MinZ");
795  fMaxZ = DETpset.get< double > ("MaxZ");
796  fP1MaxZ = DETpset.get< double > ("P1MaxZ");
797  fMinT = DETpset.get< double > ("MinT");
798  fMaxT = DETpset.get< double > ("MaxT");
799  fMinFEBs = DETpset.get< int > ("MinFEBs"); // NEW
800 
801  fMinPOTCut = DETpset.get< double >("MinPOTCut" );
802  fMinHornICut = DETpset.get< double >("MinHornICut" );
803  fMaxHornICut = DETpset.get< double >("MaxHornICut" );
804  fMinPosXCut = DETpset.get< double >("MinPosXCut" );
805  fMaxPosXCut = DETpset.get< double >("MaxPosXCut" );
806  fMinPosYCutVec = DETpset.get< std::vector<double> >("MinPosYCut" );
807  fMaxPosYCutVec = DETpset.get< std::vector<double> >("MaxPosYCut" );
808  fMinWidthXCut = DETpset.get< double >("MinWidthXCut" );
809  fMaxWidthXCut = DETpset.get< double >("MaxWidthXCut" );
810  fMinWidthYCut = DETpset.get< double >("MinWidthYCut" );
811  fMaxWidthYCut = DETpset.get< double >("MaxWidthYCut" );
812  fMaxDeltaTCut = DETpset.get< double >("MaxDeltaTCut" );
813 
814  ////////////////////////////////////////////////////////////////////////////////////////////////////
815  //INSTRUMENTATION HISTOGRAMS
816  bool RunHistoryConnectedOK = false;
818  try{
819  RunHistoryConnectedOK = fRH->LoadDAQRunHistory(); //TESTING FAILURE TO CONNECT
820  }
821  catch(...){
822  //If RunHistoryConnectedOK is set to false, we'll know it failed anyway
823  }
824  if(DETpset == fPSetFD){
825  if(RunHistoryConnectedOK){ //IF IT CAN REACH THE CONNECTIONS, THEN FILL THE HISTOGRAMS
826  int ndb = fRH->NDiBlocks();
827  for (int idb=1; idb<=ndb; ++idb) {
828 
829  //std::cout<<"NDiBlocks idb: "<< idb <<std::endl; // number of diblocks
830 
831  nova::dbi::RunHistory::DiBlock db = fRH->GetDiBlock(idb-1,false);
832  for (int idcm=1; idcm<=12; ++idcm) {
833 
834  // number of FEBs (and APDs by extension!) in DCM
835  //std::cout<<"No. of instrumentedFEBs ("<<idcm<<") : "<<db.dcm[idcm-1].nInstrumentedFEBs<<std::endl;
836 
837  if ((db.dcm[idcm-1].nInstrumentedFEBs >= fMinFEBs) && // LOOK AT THE # OF APDs IN A DCM PER DIBLOCK
838  (db.dcm[idcm-1].nInstrumentedFEBs > -1) &&
839  (db.dcm[idcm-1].nInstrumentedFEBs <= 64) ){
840  Instr->Fill(db.num,idcm);
841  // change idb to db.num
842  //std::cout<<"FILLING No. of instrumentedFEBs ("<<idcm<<") : "<<db.dcm[idcm-1].nInstrumentedFEBs<<std::endl;
843  }
844 
845  if(fRH->IsDiBlockFullyInstrumented(idb)){
846  fullyinstr->Fill(idb,idcm);
847  }
848 
849  }
850  }
851  }
852  else{ // IF FAILS REACHING CONNECTION, FILL EMPTY HISTOGRAMS AND LET US KNOW
853  LOG_WARNING("NearlineAna") << " LOG_WAR: Error: Failed to LoadDAQRunHistory"
854  << " LOG_WAR: Histograms from Instrumented Detector and DCM Sync plots will be empty! " << std::endl;
855 
856  std::cerr << " STD CERR: Error: Failed to LoadDAQRunHistory" << std::endl;
857 
858  std::cerr << " STD CERR: Histograms from Instrumented Detector and DCM Sync plots will be empty! " << std::endl;
859 
860  }
861 
862  }
863  else if(DETpset == fPSetND){
864 
865  if(RunHistoryConnectedOK){
866  int ndb = fRH->NDiBlocks();
867  for (int idb=1; idb<=ndb; ++idb) {
868 
869  std::cout<<"NDiBlocks idb: "<< idb <<std::endl; // number of diblocks
870 
871  nova::dbi::RunHistory::DiBlock db = fRH->GetDiBlock(idb-1,false);
872  for (int idcm=1; idcm<=4; ++idcm) {
873 
874  // number of FEBs (and APDs by extension!) in DCM
875  std::cout<<"No. of instrumentedFEBs ("<<idcm<<") : "<<db.dcm[idcm-1].nInstrumentedFEBs<<std::endl;
876 
877  if ((db.dcm[idcm-1].nInstrumentedFEBs >= fMinFEBs) && //fMinFEBs // LOOK AT THE # OF APDs IN A DCM PER DIBLOCK
878  (db.dcm[idcm-1].nInstrumentedFEBs > -1) &&
879  (db.dcm[idcm-1].nInstrumentedFEBs <= 64) ){
880  Instr->Fill(db.num,idcm); // change idb to db.num
881  std::cout<<"FILLING No. of instrumentedFEBs ("<<idcm<<") : "<<db.dcm[idcm-1].nInstrumentedFEBs<<std::endl;
882  }
883 
884  // DOES IT MAKE SENSE FOR ND??
885  if(fRH->IsDiBlockFullyInstrumented(idb)){
886  fullyinstr->Fill(idb,idcm);
887  }
888 
889  }
890  }
891  }
892  }
893  else if(DETpset == fPSetTB){
894 
895  if(RunHistoryConnectedOK){
896  int idb=1;
897  nova::dbi::RunHistory::DiBlock db = fRH->GetDiBlock(idb-1,false);
898  for (int idcm=1; idcm<=3; ++idcm) {
899 
900  // number of FEBs (and APDs by extension!) in DCM
901  std::cout<<"No. of instrumentedFEBs ("<<idcm<<") : "<<db.dcm[idcm-1].nInstrumentedFEBs<<std::endl;
902 
903  if ((db.dcm[idcm-1].nInstrumentedFEBs >= fMinFEBs) && //fMinFEBs // LOOK AT THE # OF APDs IN A DCM PER DIBLOCK
904  (db.dcm[idcm-1].nInstrumentedFEBs > -1) &&
905  (db.dcm[idcm-1].nInstrumentedFEBs <= 64) ){
906  Instr->Fill(db.num,idcm); // change idb to db.num
907  std::cout<<"FILLING No. of instrumentedFEBs ("<<idcm<<") : "<<db.dcm[idcm-1].nInstrumentedFEBs<<std::endl;
908  }
909 
910  if(fRH->IsDiBlockFullyInstrumented(idb)){
911  fullyinstr->Fill(idb,idcm);
912  }
913 
914  }
915  }
916  else{
917 
918  LOG_WARNING("NearlineAna") << " LOG_WAR: Error: Failed to LoadDAQRunHistory"
919  << " LOG_WAR: Histograms from Instrumented Detector and DCM Sync plots will be empty! " << std::endl;
920 
921  std::cerr << " STD CERR: Error: Failed to LoadDAQRunHistory" << std::endl;
922 
923  std::cerr << " STD CERR: Histograms from Instrumented Detector and DCM Sync plots will be empty! " << std::endl;
924 
925  }
926 
927  }
928  else{
929  LOG_WARNING("NearlineAna") << " LOG_WAR: Error: unknown detector"
930  << " LOG_WAR: Histograms from Instrumented Detector and DCM Sync plots will be empty! " << std::endl;
931 
932  std::cerr << " STD CERR: Error: unknown detector" << std::endl;
933 
934  std::cerr << " STD CERR: Histograms from Instrumented Detector and DCM Sync plots will be empty! " << std::endl;
935 
936  }
937  ////////////////////////////////////////////////////////////////////////////////////////////////////
938 
939  }
940  //......................................................................
942  {
943 
944  // needed for DCM sync status plots
946 
948 
949 
950  // Spill-related
951  double timediffnsec = -9999999.;
952  Double_t spillPoT = 0.;
953  double horncurrent = 0.;
954  bool isRHC = false;
955  double xposition = -9999.;
956  double yposition = -9999.;
957  double xwidth = -9999.;
958  double ywidth = -9999.;
959  bool goodbeam = false;
960  bool goodevent = false; //don't anything in the histogram if there is no good beam
961 
962  try {
963  evt.getByLabel("ifdbspillinfo", spill);
964 
965  timediffnsec = spill->deltaspilltimensec;
966  spillPoT = spill->spillpot;
967  isRHC = spill->isRHC;
968  horncurrent = spill->hornI;
969  xposition = spill->posx;
970  yposition = spill->posy;
971  xwidth = spill->widthx;
972  ywidth = spill->widthy;
973  goodbeam = spill->goodbeam;
974  goodevent = true;
975  std::cout << " spill " << spillPoT << " " << goodbeam << std::endl;
976  if(!goodbeam ) std::cout << " !!!!!!!!!!!!!! bad beam !!!!!!!!! " << std::endl;
977  }
978  catch(...) {
979  std::cerr << "No Spill Info!" << std::endl;
980  }
981 
982 
983  //
984  // Determine header info.
985  //
986 
987  unsigned int run = evt.run();
988  unsigned int subrun = evt.subRun();
989  unsigned int event = evt.id().event();
990  unsigned long long int time = evt.time().value();
991 
992  fNevents++;
993  fLastRun = run;
995 
996  // Set posy cut based on run number.
997  // Beam vertical position changed starting period 11.
999  if ( (rh->Detector() == "NearDet" && evt.run() < 13887) ||
1000  (rh->Detector() == "FarDet" && evt.run() < 38301) ) {
1001  fMinPosYCut = fMinPosYCutVec.at(0);
1002  fMaxPosYCut = fMaxPosYCutVec.at(0);
1003  }
1004  else {
1005  fMinPosYCut = fMinPosYCutVec.at(1);
1006  fMaxPosYCut = fMaxPosYCutVec.at(1);
1007  }
1008 
1009  // Get the partition and the trigger length from the raw data.
1010  static daqdataformats::RawEvent rawevt;
1011  try {
1013  evt.getByLabel("daq",flatdaq_handle);
1014  if (flatdaq_handle->size()!=1) {
1015  std::cerr << "Error: More than one flat daq data object!"
1016  << std::endl;
1017  }
1018  else {
1019  rawevt.readData((*flatdaq_handle)[0].getRawBufferPointer());
1020  fPartition = rawevt.getPartition();
1021 
1022  // Compute the live time for this event. Note: The tigger length is in units of 500 ns
1023  // and is always one microblock short of the the actual recorded time.
1024  double range = (double)rawevt.getTrigger()->getTriggerRange()->getTriggerLength();
1025  range = 100.0*floor(range/100.0)+100.0;
1026  range = range*5.0E-7;
1027 
1028  fLiveTime += range;
1029  }
1030  }
1031  catch (...) {
1032  std::cerr << "Error: Flat DAQ data object missing!" << std::endl;
1033  }
1034 
1035  // first/last event are not necessarily coorelated with earliest/latest time
1036  if(time < fStartTime)
1037  fStartTime = time;
1038  if((int)event < fFirstEvent)
1039  fFirstEvent = event;
1040  if(time > fEndTime)
1041  fEndTime = time;
1042  if((int)event > fLastEvent)
1043  fLastEvent = event;
1044 
1045 
1046 
1047  // counters...
1048  int NSlice = 0;
1049  int N2DTrack = 0;
1050  int N3DTrack = 0;
1051  int N3DContTrk = 0;
1052  int NTrackTot = 0;
1053 
1054  //
1055  // Compute information about slices.
1056  //
1057 
1058  // get the slices
1060  evt.getByLabel(fSlicerLabel, slices);
1061 
1062  // get associations between slices and tracks
1063  art::FindManyP<rb::Track> fmSlTrk(slices, evt, fTrackLabel);
1064 
1065 
1066 
1067  // Loop over all slices.
1068  for(unsigned int i = 0; i < slices->size(); ++i) {
1069 
1070  // define default values for the slice info
1071  int NumHitsX = -1;
1072  int NumHitsY = -1;
1073 
1074  double Pave = 0.0;
1075  double CXave = 0.0;
1076  double CYave = 0.0;
1077  double Tave = 0.0;
1078 
1079  double Psd = 0.0;
1080  double CXsd = 0.0;
1081  double CYsd = 0.0;
1082  double Tsd = 0.0;
1083 
1084  double Phi = -1.0e6;
1085  double Plo = 1.0e6;
1086  double Thi = -1.0e6;
1087  double Tlo = 1.0e6;
1088  double CXhi = -1.0e6;
1089  double CXlo = 1.0e6;
1090  double CYhi = -1.0e6;
1091  double CYlo = 1.0e6;
1092 
1093  NumHitsX = (*slices)[i].NXCell();
1094  NumHitsY = (*slices)[i].NYCell();
1095 
1096  // count the non-noise slices (to verify that there is only 1 noise slice)
1097  if(!(*slices)[i].IsNoise()) NSlice++;
1098 
1099 
1100 
1101  // If the slice is noise, only keep track of the number of hits/PE and skip everything else.
1102  if((*slices)[i].IsNoise()) {
1103  fNumHitsNoise ->Fill(NumHitsX+NumHitsY);
1104  fNumHitsXNoise->Fill(NumHitsX);
1105  fNumHitsYNoise->Fill(NumHitsY);
1106  // loop over all hits and add up PE
1107  for(unsigned int j = 0; j < (*slices)[i].NCell(); ++j) {
1108  const rb::CellHit* h = (*slices)[i].Cell(j).get();
1109  fADCAllHits->Fill(h->ADC());
1110  fADCNoiseHits->Fill(h->ADC());
1111  fPEAllHits->Fill(h->PE());
1112  fPENoiseHits->Fill(h->PE());
1113  }
1114  continue;
1115  }
1116 
1117 
1118 
1119  // Calculate average and st. dev. for plane #, cell #, and time for
1120  // hits in the slice
1121  // art::PtrVector< rb::CellHit > sliceHits = (*slices)[i].AllCells();
1122 
1123  double nx = 0.0, ny = 0.0;
1124 
1125  // loop over all hits
1126  for(unsigned int j = 0; j < (*slices)[i].NCell(); ++j) {
1127 
1128  const rb::CellHit* h = (*slices)[i].Cell(j).get();
1129 
1130  // If we've reached this point, this is a non-noise slice.
1131  fADCAllHits->Fill(h->ADC());
1132  fADCNonNoiseHits->Fill(h->ADC());
1133  fPEAllHits->Fill(h->PE());
1134  fPENonNoiseHits->Fill(h->PE());
1135 
1136  // Problems occur if you do the time calculations in ns since the numbers
1137  // are huge when you square them (even if you use doubles.) So I will
1138  // convert to microseconds to do my sums for Tave and Tsd.
1139  double Tus = (h->TNS())/1000.0;
1140 
1141  Pave += h->Plane();
1142  Tave += Tus;
1143  Psd += (h->Plane())*(h->Plane());
1144  Tsd += Tus*Tus;
1145 
1146  if(h->Plane() > Phi) Phi = h->Plane();
1147  if(h->Plane() < Plo) Plo = h->Plane();
1148  if(h->TNS() > Thi) Thi = h->TNS();
1149  if(h->TNS() < Tlo) Tlo = h->TNS();
1150 
1151  if(h->View() == geo::kX) {
1152  CXave += h->Cell();
1153  CXsd += (h->Cell())*(h->Cell());
1154  nx += 1.0;
1155  if(h->Cell() > CXhi) CXhi = h->Cell();
1156  if(h->Cell() < CXlo) CXlo = h->Cell();
1157  }
1158  else if(h->View() == geo::kY) {
1159  CYave += h->Cell();
1160  CYsd += (h->Cell())*(h->Cell());
1161  ny += 1.0;
1162  if(h->Cell() > CYhi) CYhi = h->Cell();
1163  if(h->Cell() < CYlo) CYlo = h->Cell();
1164  }
1165  else {
1166  // Trigger some kind of warning that an invalid view occured.
1167  CXave = 1.0e9;
1168  CYave = 1.0e9;
1169  }
1170  } // end loop over j
1171 
1172  if(nx == 0.0 && ny == 0.0) {
1173  // assign a negative number to attract attention
1174  Pave = -100.0;
1175  Tave = -100.0;
1176  Psd = -100.0;
1177  Tsd = -100.0;
1178  }
1179  else {
1180  Pave = Pave/(nx+ny);
1181  Tave = Tave/(nx+ny);
1182  Psd = sqrt(Psd/(nx+ny) - Pave*Pave);
1183  Tsd = sqrt(Tsd/(nx+ny) - Tave*Tave);
1184 
1185  // convert back to ns
1186  Tave = Tave*1000.0;
1187  Tsd = Tsd*1000.0;
1188  }
1189 
1190  if(nx != 0.0) {
1191  CXave = CXave/nx;
1192  CXsd = sqrt(CXsd/nx - CXave*CXave);
1193  }
1194  else {
1195  CXave = -100.0;
1196  CXsd = -100.0;
1197  }
1198 
1199  if(ny != 0.0) {
1200  CYave = CYave/ny;
1201  CYsd = sqrt(CYsd/ny - CYave*CYave);
1202  }
1203  else {
1204  CYave = -100.0;
1205  CYsd = -100.0;
1206  }
1207 
1208 
1209 
1210  // fill slice histos
1211  fNumHits ->Fill(NumHitsX+NumHitsY);
1212  fNumHitsX->Fill(NumHitsX);
1213  fNumHitsY->Fill(NumHitsY);
1214 
1215  fPCXave ->Fill(Pave,CXave);
1216  fPCYave ->Fill(Pave,CYave);
1217  fPCXaveCR->Fill(-Pave,-CXave);
1218  fPCYaveCR->Fill(-Pave, CYave);
1219 
1220  fPCXdiff ->Fill(Phi-Plo,CXhi-CXlo);
1221  fPCYdiff ->Fill(Phi-Plo,CYhi-CYlo);
1222  fTave ->Fill(Tave);
1223  fTsd ->Fill(Tsd);
1224 
1225 
1226 
1227  //
1228  // Get info about the tracks that go with this slice.
1229  //
1230 
1231  std::vector < art::Ptr< rb::Track > > tracks;
1232  if(fmSlTrk.isValid()) {
1233  tracks = fmSlTrk.at(i);
1234  }
1235 
1236  // set some counters
1237  int NHit3Dtracks = 0;
1238 
1239  // initializing counters for DCM sync status plots
1240  for (int idb=0; idb<14; ++idb) {
1241  for (int idcm=0; idcm<12; ++idcm) {
1242  counter3D[idb][idcm] = 0;
1243  counter2D[idb][idcm] = 0;
1244  }
1245  }
1246 
1247  for(unsigned int k = 0; k < tracks.size(); k++) {
1248 
1249  // Fill histos for 3D tracks
1250  if(tracks[k]->Is3D()) {
1251 
1252  NTrackTot += tracks.size();
1253  N3DTrack++;
1254  NHit3Dtracks += tracks[k]->NCell();
1255 
1256  // Get vectors for the end points of the track
1257  TVector3 start(tracks[k]->Start());
1258  TVector3 end(tracks[k]->Stop());
1259  TVector3 dir(tracks[k]->Dir());
1260  TVector3 length = end - start;
1261 
1262  // loop over all hits and count PE
1263  for(unsigned int j = 0; j < tracks[k]->NCell(); ++j) {
1264  const rb::CellHit* h = tracks[k]->Cell(j).get();
1265  fPETrackHitsAll3D->Fill(h->PE());
1266 
1267  // count hits by diblock/DCM
1268  const unsigned int chan = h->DaqChannel();
1269  const unsigned int dib = cmap->Map()->getDiBlock(chan);
1270  const unsigned int ldc = cmap->Map()->getDCM(chan);
1271 
1272  f3DHitNum->Fill(dib,ldc); // Filling the Hit rate histogram
1273  ++counter3D[dib-1][ldc-1];
1274  }
1275 
1276  // count tracks by diblock/DCM
1277  for(int i = 0; i < 14; i++){
1278  for(int j = 0; j < 12; j++){
1279  // count a track as contributing to a DCM if it has > fMinTrackHits
1280  if(counter3D[i][j] > fMinTrackHits){
1281  f3DTrackNum->Fill(i+1,j+1);
1282  }
1283  }
1284  }
1285 
1286  fTtrkAll3D->Fill(tracks[k]->MeanTNS());
1287 
1288  fStartPointTrackXZAll3D->Fill(start.Z(), start.X());
1289  fStartPointTrackYZAll3D->Fill(start.Z(), start.Y());
1290  fStopPointTrackXZAll3D->Fill(end.Z(), end.X());
1291  fStopPointTrackYZAll3D->Fill(end.Z(), end.Y());
1292 
1293  fStartPointTrackXZCRAll3D->Fill(-start.Z(), -start.X());
1294  fStartPointTrackYZCRAll3D->Fill(-start.Z(), start.Y());
1295  fStopPointTrackXZCRAll3D->Fill(-end.Z(), -end.X());
1296  fStopPointTrackYZCRAll3D->Fill(-end.Z(), end.Y());
1297 
1298  fTrackLengthAll3D->Fill(length.Mag());
1299 
1300  // track angles
1301  fTrackCosZenithAll3D->Fill(-dir.Y());
1302  fTrackCosAzimuthAll3D->Fill(-dir.Z()/util::pythag(dir.X(),dir.Z()));
1303  fTrackCosZenAziAll3D->Fill(-dir.Y(),-dir.Z()/util::pythag(dir.X(),dir.Z()));
1305  fTrackCosNumiAll3D->Fill(tracks[k]->Dir().Dot(geom->NuMIBeamDirection()));
1306 
1307  double angle = 0.0;
1308  fTrackZenithAll3D->Fill(acos(-dir.Y())*180.0/3.1415926536);
1309  angle = (atan2(dir.X(),-dir.Z()))*180.0/3.1415926536;
1310  if(angle < 0.0) angle += 360.0;
1311  fTrackAzimuthAll3D->Fill(angle);
1312  fTrackZenAziAll3D->Fill(acos(-dir.Y())*180.0/3.1415926536,angle);
1313  fTrackNumiAll3D->Fill(acos(tracks[k]->Dir().Dot(geom->NuMIBeamDirection()))*180.0/3.1415926536);
1314 
1315  // If track is contained, also fill the histos for contained 3D tracks
1316  if(this->IsContained(start.X(), start.Y(), start.Z()) &&
1317  this->IsContained(end.X(), end.Y(), end.Z()) ) {
1318 
1319  N3DContTrk++;
1320 
1321  // loop over all hits and count PE
1322  for(unsigned int j = 0; j < tracks[k]->NCell(); ++j) {
1323  const rb::CellHit* h = tracks[k]->Cell(j).get();
1324  fPETrackHitsCont3D->Fill(h->PE());
1325  }
1326 
1327  fTtrkCont3D->Fill(tracks[k]->MeanTNS());
1328 
1329  fStartPointTrackXZCont3D->Fill(start.Z(), start.X());
1330  fStartPointTrackYZCont3D->Fill(start.Z(), start.Y());
1331  fStopPointTrackXZCont3D->Fill(end.Z(), end.X());
1332  fStopPointTrackYZCont3D->Fill(end.Z(), end.Y());
1333 
1334  fStartPointTrackXZCRCont3D->Fill(-start.Z(), -start.X());
1335  fStartPointTrackYZCRCont3D->Fill(-start.Z(), start.Y());
1336  fStopPointTrackXZCRCont3D->Fill(-end.Z(), -end.X());
1337  fStopPointTrackYZCRCont3D->Fill(-end.Z(), end.Y());
1338 
1339  fTrackLengthCont3D->Fill(length.Mag());
1340 
1341  // track angles
1342  fTrackCosZenithCont3D->Fill(-dir.Y());
1343  fTrackCosAzimuthCont3D->Fill(-dir.Z()/util::pythag(dir.X(),dir.Z()));
1344  fTrackCosZenAziCont3D->Fill(-dir.Y(),-dir.Z()/util::pythag(dir.X(),dir.Z()));
1345  fTrackCosNumiCont3D->Fill(tracks[k]->Dir().Dot(geom->NuMIBeamDirection()));
1346 
1347  fTrackZenithCont3D->Fill(acos(-dir.Y())*180.0/3.1415926536);
1348  fTrackAzimuthCont3D->Fill(angle);
1349  fTrackZenAziCont3D->Fill(acos(-dir.Y())*180.0/3.1415926536,angle);
1350  fTrackNumiCont3D->Fill(acos(tracks[k]->Dir().Dot(geom->NuMIBeamDirection()))*180.0/3.1415926536);
1351 
1352  } // end IsContained
1353 
1354  } // end is 3D track
1355 
1356  // otherwise this must be a 2D track
1357  else {
1358 
1359  NTrackTot += tracks.size();
1360  N2DTrack++;
1361 
1362  // Get vectors for the end points of the track
1363  TVector3 start(tracks[k]->Start());
1364  TVector3 end(tracks[k]->Stop());
1365  TVector3 dir(tracks[k]->Dir());
1366  TVector3 length = end - start;
1367 
1368  // loop over all hits and count PE
1369  for(unsigned int j = 0; j < tracks[k]->NCell(); ++j) {
1370  const rb::CellHit* h = tracks[k]->Cell(j).get();
1371  fPETrackHitsAll2D->Fill(h->PE());
1372 
1373  // count hits by diblock/DCM
1374  const unsigned int chan = h->DaqChannel();
1375  const unsigned int dib = cmap->Map()->getDiBlock(chan);
1376  const unsigned int ldc = cmap->Map()->getDCM(chan);
1377 
1378  f2DHitNum->Fill(dib,ldc);
1379  ++counter2D[dib-1][ldc-1];
1380  }
1381 
1382  // count tracks by diblock/DCM
1383  for(int i = 0; i < 14; i++){
1384  for(int j = 0; j < 12; j++){
1385  // count a track as contributing to a DCM if it has > fMinTrackHits
1386  if(counter2D[i][j] > fMinTrackHits){
1387  f2DTrackNum->Fill(i+1,j+1);
1388  }
1389  }
1390  }
1391 
1392  fTtrkAll2D->Fill(tracks[k]->MeanTNS());
1393 
1394  fStartPointTrackXZAll2D->Fill(start.Z(), start.X());
1395  fStartPointTrackYZAll2D->Fill(start.Z(), start.Y());
1396  fStopPointTrackXZAll2D->Fill(end.Z(), end.X());
1397  fStopPointTrackYZAll2D->Fill(end.Z(), end.Y());
1398 
1399  fStartPointTrackXZCRAll2D->Fill(-start.Z(), -start.X());
1400  fStartPointTrackYZCRAll2D->Fill(-start.Z(), start.Y());
1401  fStopPointTrackXZCRAll2D->Fill(-end.Z(), -end.X());
1402  fStopPointTrackYZCRAll2D->Fill(-end.Z(), end.Y());
1403 
1404  fTrackLengthAll2D->Fill(length.Mag());
1405 
1406  // track angles
1407  fTrackCosZenithAll2D->Fill(-dir.Y());
1408  fTrackCosAzimuthAll2D->Fill(-dir.Z()/util::pythag(dir.X(),dir.Z()));
1409  fTrackCosZenAziAll2D->Fill(-dir.Y(),-dir.Z()/util::pythag(dir.X(),dir.Z()));
1411  fTrackCosNumiAll2D->Fill(tracks[k]->Dir().Dot(geom->NuMIBeamDirection()));
1412 
1413  double angle = 0.0;
1414  fTrackZenithAll2D->Fill(acos(-dir.Y())*180.0/3.1415926536);
1415  angle = (atan2(dir.X(),-dir.Z()))*180.0/3.1415926536;
1416  if(angle < 0.0) angle += 360.0;
1417  fTrackAzimuthAll2D->Fill(angle);
1418  fTrackZenAziAll2D->Fill(acos(-dir.Y())*180.0/3.1415926536,angle);
1419  fTrackNumiAll2D->Fill(acos(tracks[k]->Dir().Dot(geom->NuMIBeamDirection()))*180.0/3.1415926536);
1420 
1421  } // end is 2D track
1422 
1423  } // end loop over tracks (k)
1424 
1425  // fill histos with per slice info
1426  fSliceTrackNHitRatio->Fill((double)NHit3Dtracks/(double)(NumHitsX+NumHitsY));
1427  fSliceTrackNHitRatioVSnhit->Fill((double)(NumHitsX+NumHitsY),(double)NHit3Dtracks/(double)(NumHitsX+NumHitsY));
1428 
1429  } // end loop over slices (i)
1430 
1431 
1432 
1433  // fill histos with per trigger info
1434  fNumSlices ->Fill(NSlice);
1435  if(goodbeam) fNumSlicesGoodBeam->Fill(NSlice);
1436 
1437  // Spill-related
1438  if(goodevent==true){ //if there was no beam, don't fill the histograms
1439  fTimeDiffNanoSec->Fill(1e-9*timediffnsec);
1440  fHornCurrent->Fill(horncurrent);
1441  fIsRHC->Fill(isRHC);
1442  fXPosition->Fill(xposition);
1443  fYPosition->Fill(yposition);
1444  fXWidth->Fill(xwidth);
1445  fYWidth->Fill(ywidth);
1446  }
1447  fPOTSum->Fill(0.0,spillPoT*1e12);
1448  fspillPOT->Fill(spillPoT*1e12); //we still want to know that there were no POTs
1449  fGoodBeam->Fill(goodbeam);
1450 
1451  // 0-1:delta t cut, 1-2:POT cut, 2-3:horn I cut, 3-4:x position cut, 4-5:y position cut, 5-6: x width cut, 6-7:y width cut
1452  if (!goodbeam){
1453  fBadSpills->Fill(8,1);//count the total # of bad spills
1454 
1455  // if delta t condition is not met, record the spill as bad and don't worry about other quality cuts
1456  if (fMaxDeltaTCut<timediffnsec) {
1457  fBadSpills->Fill(1,1);
1458  }
1459 
1460  // if the delta t condition IS met, check the POT.
1461  // if the POT condition is not met, record the spill as bad and don't worry about other cuts
1462  else {
1463  if (spillPoT<fMinPOTCut) {
1464  fBadSpills->Fill(2,1);
1465  }
1466  // record the reason for the spill failure in all other cases. note, there may be overlap.
1467  else {
1468  if(horncurrent<fMinHornICut || fMaxHornICut<horncurrent) fBadSpills->Fill(3,1);
1469  if(xposition<fMinPosXCut || fMaxPosXCut<xposition) fBadSpills->Fill(4,1);
1470  if(yposition<fMinPosYCut || fMaxPosYCut<yposition) fBadSpills->Fill(5,1);
1471  if(xwidth<fMinWidthXCut || fMaxWidthXCut<xwidth) fBadSpills->Fill(6,1);
1472  if(ywidth<fMinWidthYCut || fMaxWidthYCut<ywidth) fBadSpills->Fill(7,1);
1473 
1474  }
1475  }
1476  }
1477 
1478 
1479 
1480  fNumTracksAll2D ->Fill(N2DTrack);
1481  fNumTracksAll3D ->Fill(N3DTrack);
1482  fNumTracksCont3D ->Fill(N3DContTrk);
1483  fTrackFractionAll2D ->Fill((double)N2DTrack/(double)NTrackTot);
1484  fTrackFractionAll3D ->Fill((double)N3DTrack/(double)NTrackTot);
1485  fTrackFractionCont3D->Fill((double)N3DContTrk/(double)NTrackTot);
1486  fDeltaSliceTrack ->Fill(NSlice - N3DTrack);
1487  fSliceTrackRatio ->Fill((double)N3DTrack/(double)NSlice);
1488 
1489 
1490  return;
1491 
1492  } // end analyze module
1493 
1494  //......................................................................
1495  bool NearlineAna::IsContained(double x, double y, double z)
1496  {
1497  if(x > fMinX && x < fMaxX && y > fMinY && y < fMaxY) {
1498  // If this is partition 1, then use the specific Z cut for partition 1
1499  if(fPartition == 1 && z > fMinZ && z < fP1MaxZ) return true;
1500  if(fPartition != 1 && z > fMinZ && z < fMaxZ) return true;
1501  }
1502  return false;
1503  }
1504 
1505 } // end namespace comi
1506 ////////////////////////////////////////////////////////////////////////
1507 
1508 
1509 
1511 
1512 namespace comi
1513 {
1515 }
double fMaxY
containment cut in Y
TH2D * fTrackCosZenAziAll2D
2D plot of cos zentih and cos azimuth (all 2D tracks)
float TNS() const
Definition: CellHit.h:46
int counter3D[14][12]
counter array for the number of hits/tracks per dcm
double fMaxHornICut
max horn current cut for beam quality
TH1D * fTimeDiffNanoSec
time difference between the spill times recorded as event timestamp and by IFDB
TH2F * Instr
Map view of the instrumented detector (DCM w/ > 50APDs)
TH1D * fTrackLengthCont3D
length of track [cm] (all contained 3D tracks)
TH1D * fNumHitsNoise
number hits in the noise slice
double fMaxX
containment cut in X
TH1D * fTtrkAll3D
track times (all 3D tracks)
bool isRHC
is the beam in antineutrino mode, aka RHC
Definition: SpillData.h:28
TH1D * fPETrackHitsCont3D
PE for hits on tracks (all contained 3D tracks)
SubRunNumber_t subRun() const
Definition: Event.h:72
TH1D * fTrackCosNumiAll3D
cosine theta of track with respect to NuMI beam (all 3D tracks)
TH1D * fNumHitsXNoise
number of X hits in the noise slice
double fMinZ
containment cut in Z
int NDiBlocks()
gives number of active diblocks only, may be less than 14
Definition: RunHistory.h:394
Double_t angle
Definition: plot.C:86
std::string fTrackLabel
Where to find Tracks.
std::vector< double > fMinPosYCutVec
min y position cut for beam quality vector (for change in cuts)
TH1D * fTrackAzimuthCont3D
track azimuthal angle (all contained 3D tracks)
TH1D * fNumHits
number of hits per non noise slice
TH1D * fNumSlicesGoodBeam
number of non-noise slices for good beam
TH2D * fStartPointTrackYZCont3D
2D histogram showing starting point of reco track in YZ view (all contained 3D tracks) ...
double fMaxZ
containment cut in Z
TH2 * rh
Definition: drawXsec.C:5
bool IsDiBlockFullyInstrumented(int idb)
returns true if nInstrumentedFEBs in diblock (which counts FEBs that are instrumented, active, and unmasked only) is >= 700
TH2D * fStartPointTrackXZAll2D
2D histogram showing starting point of reco track in XZ view (all 2D tracks)
unsigned int fLastSubrun
Header: last subrun number analyzed.
TH1D * fNumHitsYNoise
number of Y hits in the noise slice
float Dot(const Proxy &v) const
double fMinT
for cutting in T
int fNevents
Header: number of events processed.
TH1D * fPOTSum
sum of POT
TH2D * fStartPointTrackYZAll2D
2D histogram showing starting point of reco track in YZ view (all 2D tracks)
TH1D * fDeltaSliceTrack
number of slices minus number of 3D tracks
double fMinY
containment cut in Y
TH1D * fTrackFractionCont3D
fraction of total tracks that are contained 3D
TH2D * fTrackCosZenAziAll3D
2D plot of cos zentih and cos azimuth (all 3D tracks)
TH2D * fStopPointTrackYZCRCont3D
2D histogram showing stopping point of reco track in YZ view (control room view) (all contained 3D tr...
unsigned short Plane() const
Definition: CellHit.h:39
void beginRun(const art::Run &run)
TH2D * fStopPointTrackXZCRCont3D
2D histogram showing stopping point of reco track in XZ view (control room view) (all contained 3D tr...
TH1D * fADCNoiseHits
ADC for hits in the noise slice.
geo::View_t View() const
Definition: CellHit.h:41
TH2D * fPCYaveCR
for each non-noise slice, average plane/cell of hits (control room view)
TH1D * fSliceTrackNHitRatio
ratio of number of hits on 3D track to number of hits in the slice (0 means no track or 2D track) ...
T sqrt(T number)
Definition: d0nt_math.hpp:156
DiBlock GetDiBlock(int i, bool loadAll=true)
get ith diblock is RH list (which only includes diblocks with activity), starting with i=0...
Vertical planes which measure X.
Definition: PlaneGeo.h:28
TH1D * fADCNonNoiseHits
ADC for hits in non-noise slices.
int fLastEvent
Header: last event processed.
TH1D * fTrackCosAzimuthAll3D
cosine theta of track with respect to azimuth direction (all 3D tracks)
TH1D * fNumTracksCont3D
counter for number of tracks (all contained 3D tracks)
std::vector< double > fMaxPosYCutVec
max y position cut for beam quality vector (for change in cuts)
TH1D * fTrackZenithAll2D
track zenith angle (all 2D tracks)
TH2D * fStartPointTrackXZCRAll2D
2D histogram showing starting point of reco track in XZ view (control room view) (all 2D tracks) ...
TH2D * fTrackCosZenAziCont3D
2D plot of cos zentih and cos azimuth (all contained 3D tracks)
OStream cerr
Definition: OStream.cxx:7
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
unsigned int fEndYear
Header: year of last processed event (actual year since 0 A.D.)
TH2D * fStartPointTrackXZAll3D
2D histogram showing starting point of reco track in XZ view (all 3D tracks)
TH1D * fPEAllHits
PE for all hits.
int fMinFEBs
NEW Minimum number of FEBs in a DCM for allow diblock instrumented.
TH2D * f3DTrackNum
Number of 2D tracks per DCM.
double fMaxPosXCut
max x position cut for beam quality
TH2D * fStopPointTrackXZAll3D
2D histogram showing stopping point of reco track in XZ view (all 3D tracks)
DEFINE_ART_MODULE(TestTMapFile)
TH2D * fStartPointTrackXZCRCont3D
2D histogram showing starting point of reco track in XZ view (control room view) (all contained 3D tr...
double fP1MaxZ
containment cut in Z for partition 1
TH1D * fTrackNumiAll2D
track numi angle (all 2D tracks)
T acos(T number)
Definition: d0nt_math.hpp:54
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
TH2D * fTrackZenAziCont3D
2D plot of zentih and azimuth (all contained 3D tracks)
double fMinPOTCut
min POT cut for beam quality
TH1D * fTrackCosZenithCont3D
cosine theta of track with respect to zenith direction (all contained 3D tracks)
TH1D * fTrackAzimuthAll3D
track azimuthal angle (all 3D tracks)
TH2D * fPCYdiff
for each non-noise slice, difference btwn highest and lowest plane/cell
TH1D * fGoodBeam
value of goodbeam parameter, ie whether spill passed beam quality cuts
TH1D * fNumTracksAll3D
counter for number of tracks (all 3D tracks)
TH1D * fTrackZenithAll3D
track zenith angle (all 3D tracks)
TH1D * fXPosition
horizontal position of beam at target
constexpr TimeValue_t value() const
Definition: Timestamp.h:24
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
double fMinWidthXCut
min x width cut for beam quality
Definition: Run.h:31
TH1D * fPETrackHitsAll3D
PE for hits on tracks (all 3D tracks)
fhicl::ParameterSet fPSetNDOS
NearlineAna(fhicl::ParameterSet const &pset)
TH2D * fStopPointTrackXZCRAll2D
2D histogram showing stopping point of reco track in XZ view (control room view) (all 2D tracks) ...
double fMinWidthYCut
min y width cut for beam quality
TH2D * fStartPointTrackYZAll3D
2D histogram showing starting point of reco track in YZ view (all 3D tracks)
unsigned short Cell() const
Definition: CellHit.h:40
TH1D * fTrackCosZenithAll3D
cosine theta of track with respect to zenith direction (all 3D tracks)
unsigned long long int fStartTime
Header: time of first processed event - initalized to -1 to make it a HUGE positive number...
unsigned int fPartition
Header: partition number from last event analyzed.
TH1D * fTrackLengthAll2D
length of track [cm] (all 2D tracks)
Far Detector at Ash River, MN.
TH1D * fTrackZenithCont3D
track zenith angle (all contained 3D tracks)
length
Definition: demo0.py:21
unsigned int fEndMonth
Header: month of last processed event (actual month 1-12)
double fMinPosYCut
min y position cut for beam quality
int fMinTrackHits
minimum # of hits from a track within a DCM for the track to count as having passed through that DCM ...
uint32_t DaqChannel() const
Definition: RawDigit.h:85
TTree * fHeader
Header object to be written to disk with the histograms.
double fMinX
containment cut in X
signed long long int deltaspilltimensec
Definition: SpillData.h:24
TH2D * fPCXave
for each non-noise slice, average plane/cell of hits
TH2D * fStopPointTrackYZCRAll2D
2D histogram showing stopping point of reco track in YZ view (control room view) (all 2D tracks) ...
TH2D * fTrackZenAziAll3D
2D plot of zentih and azimuth (all 3D tracks)
TH1D * fTrackCosAzimuthAll2D
cosine theta of track with respect to azimuth direction (all 2D tracks)
TH1D * fTrackCosZenithAll2D
cosine theta of track with respect to zenith direction (all 2D tracks)
TH1D * fTrackNumiCont3D
track numi angle (all contained 3D tracks)
TH2D * fStartPointTrackYZCRAll2D
2D histogram showing starting point of reco track in YZ view (control room view) (all 2D tracks) ...
double fMaxWidthXCut
max x width cut for beam quality
Prototype Near Detector on the surface at FNAL.
Commissioning files to look at the quality of our data.
Definition: Cana_module.cc:39
TH1D * fTsd
for each non-noise slice, standard dev. of hit times
T get(std::string const &key) const
Definition: ParameterSet.h:231
TH1D * fTrackNumiAll3D
track numi angle (all 3D tracks)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
double widthx
mm
Definition: SpillData.h:36
int evt
float PE() const
Definition: CellHit.h:42
double fMaxDeltaTCut
mqax delta t cut for beam quality
Near Detector in the NuMI cavern.
TH2D * fStopPointTrackXZCont3D
2D histogram showing stopping point of reco track in XZ view (all contained 3D tracks) ...
TH1D * fTrackFractionAll3D
fraction of total tracks that are 3D
TH2F * fullyinstr
Counter of fully instrumented diblocks.
TH1D * fTrackCosNumiAll2D
cosine theta of track with respect to NuMI beam (all 2D tracks)
double fMinHornICut
min horn current cut for beam quality
TH1D * fXWidth
horizontal width of beam at TRTGT
const double j
Definition: BetheBloch.cxx:29
double hornI
kA
Definition: SpillData.h:27
TH2D * fStopPointTrackXZAll2D
2D histogram showing stopping point of reco track in XZ view (all 2D tracks)
TH2D * f3DHitNum
Number of hits on 3D tracks per DCM.
fvar< T > Phi(const fvar< T > &x)
Definition: Phi.hpp:12
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
TH1D * fPENoiseHits
PE for hits in the noise slice.
TH1D * fIsRHC
reverse horn current boolean
double fMaxT
for cutting in T
TH2D * fStopPointTrackYZCont3D
2D histogram showing stopping point of reco track in YZ view (all contained 3D tracks) ...
double posy
mm
Definition: SpillData.h:35
z
Definition: test.py:28
TH2D * fStartPointTrackYZCRCont3D
2D histogram showing starting point of reco track in YZ view (control room view) (all contained 3D tr...
TH2D * fStopPointTrackYZAll2D
2D histogram showing stopping point of reco track in YZ view (all 2D tracks)
fhicl::ParameterSet fPSetND
void analyze(const art::Event &evt)
TH1D * fNumHitsX
number of X hits in non-noise slices
TH1D * fNumHitsY
number of Y hits in non-noise slices
Definition: run.py:1
#define LOG_WARNING(category)
TH1D * fHornCurrent
value of horn current
TH1D * fSliceTrackRatio
ratio of number of 3D tracks to number of slices
OStream cout
Definition: OStream.cxx:6
unsigned int fEndDay
Header: day of last processed event (day of the month 1-31)
int counter2D[14][12]
counter array for the number of hits/tracks per dcm
TH2D * fPCXdiff
for each non-noise slice, difference btwn highest and lowest plane/cell
TH2D * fStopPointTrackXZCRAll3D
2D histogram showing stopping point of reco track in XZ view (control room view) (all 3D tracks) ...
TVector3 NuMIBeamDirection() const
Direction of neutrinos from the NuMI beam (unit vector)
EventNumber_t event() const
Definition: EventID.h:116
TH1D * fTrackAzimuthAll2D
track azimuthal angle (all 2D tracks)
TH1D * fTrackFractionAll2D
fraction of total tracks that are 2D
std::string fCellHitsListLabel
Where to find CellHits.
TH1D * fNumTracksAll2D
counter for number of tracks (all 2D tracks)
std::vector< DCM > dcm
Definition: RunHistory.h:311
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
T * make(ARGS...args) const
TH2D * f2DHitNum
Number of hits on 2D tracks per DCM.
TH2D * fStopPointTrackYZCRAll3D
2D histogram showing stopping point of reco track in YZ view (control room view) (all 3D tracks) ...
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
unsigned int fStartMonth
Header: month of first processed event (actual month 1-12)
double fMaxPosYCut
max y position cut for beam quality
bool IsContained(double x, double y, double z)
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TH2D * fSliceTrackNHitRatioVSnhit
ratio of number of hits on 3D track to number of hits in the slice, 2D plot vs nhit in slice (0 means...
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
fvar< T > floor(const fvar< T > &x)
Definition: floor.hpp:11
TH1D * fPENonNoiseHits
PE for hits in non-noise slices.
void geom(int which=0)
Definition: geom.C:163
TH2D * fStartPointTrackYZCRAll3D
2D histogram showing starting point of reco track in YZ view (control room view) (all 3D tracks) ...
TH1D * fTtrkAll2D
track times (all 2D tracks)
TH1D * fADCAllHits
ADC for all hits.
TH2D * fTrackZenAziAll2D
2D plot of zentih and azimuth (all 2D tracks)
TH1D * fTrackLengthAll3D
length of track [cm] (all 3D tracks)
TH2D * fPCYave
for each non-noise slice, average plane/cell of hits
double fMinPosXCut
min x position cut for beam quality
assert(nhit_max >=nhit_nbins)
TH1I * fBadSpills
failure modes for those spills that don&#39;t pass the beam quality cuts
Timestamp time() const
Definition: Event.h:61
std::string fSlicerLabel
Where to find Clusters.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
double fLiveTime
Header: total live time in seconds.
TH1D * fTtrkCont3D
track times (all contained 3D tracks)
TH1D * fTrackCosNumiCont3D
cosine theta of track with respect to NuMI beam (all contained 3D tracks)
TH2D * f2DTrackNum
Number of 3D tracks per DCM.
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.h:77
TH1D * fNumSlices
number of non-noise slices
TH2D * fPCXaveCR
for each non-noise slice, average plane/cell of hits (control room view - meaning X is flipped and Z ...
unsigned int fStartDay
Header: day of first processed event (day of the month 1-31)
double posx
mm
Definition: SpillData.h:34
int fFirstEvent
Header: first event processed.
TH1D * fTrackCosAzimuthCont3D
cosine theta of track with respect to azimuth direction (all contained 3D tracks) ...
unsigned int fStartYear
Header: year of first processed event (actual year since 0 A.D.)
double fStartHour
Header: hour of first processed event (since midnight 0.0 - 23.99999)
fhicl::ParameterSet fPSetFD
unsigned long long int fEndTime
Header: time of last processed event.
fhicl::ParameterSet fPSetTB
Parameter sets for each detector.
TH2D * fStopPointTrackYZAll3D
2D histogram showing stopping point of reco track in YZ view (all 3D tracks)
unsigned int fLastRun
Header: last run number analyzed.
double widthy
mm
Definition: SpillData.h:37
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
double spillpot
POT for spill normalized by 10^12.
Definition: SpillData.h:26
EventID id() const
Definition: Event.h:56
Encapsulate the geometry of one entire detector (near, far, ndos)
TH1D * fTave
for each non-noise slice, average time of hits
double fEndHour
Header: hour of last processed event (since midnight 0.0 - 23.99999)
TH1D * fYPosition
vertical position of beam at target
TH2D * fStartPointTrackXZCRAll3D
2D histogram showing starting point of reco track in XZ view (control room view) (all 3D tracks) ...
double fMaxWidthYCut
max y width cut for beam quality
T atan2(T number)
Definition: d0nt_math.hpp:72
TH2D * fStartPointTrackXZCont3D
2D histogram showing starting point of reco track in XZ view (all contained 3D tracks) ...
std::string Detector() const
Definition: RunHistory.h:376
TH1D * fspillPOT
spill POT
TH1D * fYWidth
vertical width of beam at TRTGT
TH1D * fPETrackHitsAll2D
PE for hits on tracks (all 2D tracks)
enum BeamMode string