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