MuonCounter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: Muoncounter
3 // Module Type: analyzer
4 // File: Muoncounter_module.cc
5 //
6 // Generated at Sun Mar 24 09:05:02 2013 by Tingjun Yang using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 #ifndef Muoncounter_Module
10 #define Muoncounter_Module
11 
12 // Framework includes
16 #include "fhiclcpp/ParameterSet.h"
21 #include "art_root_io/TFileService.h"
22 #include "art_root_io/TFileDirectory.h"
24 
25 // LArSoft includes
41 
42 // ROOT includes
43 #include "TTree.h"
44 #include "TTimeStamp.h"
45 #include "TH1D.h"
46 #include "TString.h"
47 #include "TText.h"
48 #include "TStyle.h"
49 
51 
52 namespace MyMuoncounter {
53 
54 class Muoncounter : public art::EDAnalyzer {
55 public:
56  explicit Muoncounter(fhicl::ParameterSet const & p);
57  virtual ~Muoncounter();
58 
59  void beginJob();
60  void endJob();
61 
62  void reconfigure(fhicl::ParameterSet const& pset);
63  void analyze (const art::Event& evt);
64 
65 private:
66 
67  int l_TSU = 0;
68  int u_TSU = 43;
69  int l_BSU = 44;
70  int u_BSU = 92;
71  int l_Extra = 93;
72  int u_Extra = 96;
73  int l_Trig = 100;
74  int u_Trig = 120;
75  int event_Count = 0;
76  double event_Length = 10e-3;
77 
78  TH1D *fHist1;
79  TH1D *fHist2;
80  TH1D *fHist3;
81 
83 
84  // RCE Fragments
86  // SSP Fragments
88  // PTB Fragments
90 
91  // Information for good run list histogram
92  long long RCETime = 0, SSPTime = 0, PTBTime = 0;
93  long long RCE_PTB_diff = 0, RCE_SSP_diff = 0, SSP_PTB_diff = 0;
98  int sumNADCs = 0;
100 
101  // Variables needed for the header info tree for Nearline:
102  TTree* fHeader;
103  unsigned int fRun;
104  unsigned int fSubrun;
107  int fNevents;
108  unsigned int fStartYear;
109  unsigned int fEndYear;
110  unsigned int fStartMonth;
111  unsigned int fEndMonth;
112  unsigned int fStartDay;
113  unsigned int fEndDay;
114  double fStartHour;
115  double fEndHour;
116  unsigned long long int fStartTime;
117  unsigned long long int fEndTime;
119 
120  //Histogram to store the
122 
123  //PTB Map
126 
127  std::map<int,int> fPTBMap;
128 };
129 
131  : EDAnalyzer(pset),
132  fHeader(0),
133  fRun(0),
134  fSubrun(0),
135  fFirstEvent(1e9),
136  fLastEvent(-1),
137  fNevents(0),
138  fStartYear(0),
139  fEndYear(0),
140  fStartMonth(0),
141  fEndMonth(0),
142  fStartDay(0),
143  fEndDay(0),
144  fStartHour(0.0),
145  fEndHour(0.0),
146  fStartTime(-1), // this is an unsigned int so it will default to a huge number
147  fEndTime(0),
148  sspReform(pset.get<fhicl::ParameterSet>("SSPReformatter"))
149 {
150  // Read in the parameters from the .fcl file.
151  this->reconfigure(pset);
152 }
153 
155 { // Read parameters from the .fcl file. The names in the arguments
156  // to p.get<TYPE> must match names in the .fcl file.
157  fCombinedTimeDelay = p.get< double >("CombinedTimeDelay");
158  fPTBMapFile = p.get<std::string>("PTBMapFile");
159  fPTBMapDir = p.get<std::string>("PTBMapDir");
160  fRCEFragType = p.get<std::string>("RCEFragType");
161  fRCERawDataLabel = p.get<std::string>("RCERawDataLabel");
162  fSSPFragType = p.get<std::string>("SSPFragType");
163  fSSPRawDataLabel = p.get<std::string>("SSPRawDataLabel");
164  fPTBFragType = p.get<std::string>("PTBFragType");
165  fPTBRawDataLabel = p.get<std::string>("PTBRawDataLabel");
166  DAQToOffline::BuildPTBChannelMap(fPTBMapDir, fPTBMapFile, fPTBMap);
167  return;
168 }
169 
171 {
172  // Clean up dynamic memory and other resources here.
173 }
174 
176 {
177 
178  // Get event number / timing information required by Nearline
179  //
180  // Extract event info for the header...
181  //
182  unsigned int run = evt.run();
183  unsigned int subrun = evt.subRun();
184  unsigned int event = evt.id().event();
185  unsigned long long int time = evt.time().value();
186 
187  fNevents++;
188  fRun = run;
189  fSubrun = subrun;
190 
191  // Don't assume first/last events are coorelated with start/end times...
192  if(time < fStartTime && evt.time() != art::Timestamp::invalidTimestamp()) fStartTime = time;
193  if((int)event < fFirstEvent) fFirstEvent = event;
194  if(time > fEndTime) fEndTime = time;
195  if((int)event > fLastEvent) fLastEvent = event;
196 
197  run = evt.run();
198  subrun = evt.subRun();
199  event = evt.id().event();
200 
201  // Reset some Good Events List parameters
202  RCETime = SSPTime = PTBTime = 0;
204  int NumADCs = 0, ConsistRCE = -1;
205  int ThisEv110 = 0, ThisEv111 = 0, ThisEv112 = 0, ThisEv113 = 0, ThisEv114 = 0, ThisEv115 = 0;
206 
207  bool PTBPresent = true;
208  art::Handle<artdaq::Fragments> PTBrawFragments;
209  evt.getByLabel(fPTBRawDataLabel, fPTBFragType, PTBrawFragments);
210 
211  // Check if there is PTB data in this event
212  // Don't crash code if not present, just don't save anything
213  try { PTBrawFragments->size(); }
214  catch(std::exception const&) {
215  mf::LogWarning("MuonCounter") << "WARNING: Raw PTB data not found in event " << evt.event();
216  PTBPresent = false;
217  }
218  unsigned int total_Hits= 0;
219  if (PTBPresent) {
220  // Check that the data is valid
221  if(!PTBrawFragments.isValid()){
222  mf::LogError("MuonCounter") << "Run: " << evt.run() << ", SubRun: " << evt.subRun() << ", Event: " << evt.event() << " is NOT VALID";
223  throw cet::exception("raw NOT VALID");
224  return;
225  }
226 
227  lbne::PennMicroSlice::Payload_Timestamp *FirstPTBTimestamp = nullptr;
228  auto trigs = DAQToOffline::PennFragmentToExternalTrigger(*PTBrawFragments, fPTBMap, FirstPTBTimestamp);
229  PTBTime = FirstPTBTimestamp->nova_timestamp;
230  if (PTBTime) ++nPTBPayloads;
231  //std::cout << "Got PTB start time, it is " << PTBTime << std::endl;
232 
233  total_Hits = trigs.size();
234 
235  for(unsigned int i = 0; i < total_Hits; i++) {
236  int auxdetid = trigs.at(i).GetTrigID();
237  if(auxdetid<=u_TSU) {
238  fHist1->Fill(auxdetid);
239  } else if(auxdetid>=l_BSU && auxdetid<=u_BSU) {
240  fHist2->Fill(auxdetid);
241  } else if(auxdetid>=l_Extra && auxdetid<=u_Extra) {
242  fHist1->Fill(auxdetid-49);
243  } else {
244  fHist3->Fill(auxdetid);
245  }
246 
247  // Want to count the number of PTB trigs for in this event.
248  if ( trigs.at(i).GetTrigID() == 110 ) ++ThisEv110;
249  else if ( trigs.at(i).GetTrigID() == 111 ) ++ThisEv111;
250  else if ( trigs.at(i).GetTrigID() == 112 ) ++ThisEv112;
251  else if ( trigs.at(i).GetTrigID() == 113 ) ++ThisEv113;
252  else if ( trigs.at(i).GetTrigID() == 114 ) ++ThisEv114;
253  else if ( trigs.at(i).GetTrigID() == 115 ) ++ThisEv115;
254 
255  if ( trigs.at(i).GetTrigID() > 109 ) {
256  std::cout << "Identifier:I Had a PTB trigger in event " << evt.event() << " on channel " << trigs.at(i).GetTrigID() << " at time " << trigs.at(i).GetTrigTime() << std::endl;
257  }
258  }
259  }
260  event_Count+=1;
261 
262  //---------------- SSP Good Event Timing stuff ----------------
263  bool SSPPresent = true;
264  art::Handle<artdaq::Fragments> SSPrawFragments;
265  evt.getByLabel(fSSPRawDataLabel, fSSPFragType, SSPrawFragments);
266 
267  try { SSPrawFragments->size(); }
268  catch(std::exception const&) {
269  mf::LogWarning("SSPToOffline") << "WARNING: Raw SSP data not found in event " << evt.event();
270  SSPPresent = false;
271  }
272 
273  if (SSPPresent) {
274  if(!SSPrawFragments.isValid()){
275  mf::LogError("SSPToOffline") << "Run: " << evt.run() << ", SubRun: " << evt.subRun() << ", Event: " << evt.event() << " is NOT VALID";
276  throw cet::exception("raw NOT VALID");
277  return;
278  }
279 
280  artdaq::Fragments const& rawFragmentsSSP = *SSPrawFragments;
282  //std::cout << "Got SSP start time, it is " << SSPTime << std::endl;
283 
284  // Checking whether I have any waveforms......
285  std::vector<raw::OpDetWaveform> waveforms = sspReform.SSPFragmentToOpDetWaveform(rawFragmentsSSP);
286  if ( waveforms.size() ) {
287  std::cout << "Identifier:Looking at event " << evt.event() << ", I have a vector of waveforms which has size " << waveforms.size() << std::endl;
288  std::cout << "Identifier:This event had " << total_Hits << " counter + trigger words " << std::endl;
289  }
290  } // SSP Present
291 
292  //---------------- RCE Good Event Timing stuff ----------------
293  bool RCEPresent = true;
294  art::Handle<artdaq::Fragments> RCErawFragments;
295  evt.getByLabel(fRCERawDataLabel, fRCEFragType, RCErawFragments);
296 
297  try { RCErawFragments->size(); }
298  catch(std::exception const&) {
299  mf::LogWarning("MuonCounter") << "WARNING: Raw RCE data not found in event " << evt.event() << std::endl;
300  RCEPresent = false;
301  }
302 
303  if (RCEPresent) {
304  if(!RCErawFragments.isValid()){
305  mf::LogError("SSPToOffline") << "Run: " << evt.run() << ", SubRun: " << evt.subRun() << ", Event: " << evt.event() << " is NOT VALID" << std::endl;
306  throw cet::exception("RCErawFragments NOT VALID");
307  return;
308  }
309  artdaq::Fragments const& rawFragmentsRCE = *RCErawFragments;
310  DAQToOffline::GetRCEFirstTimestamp ( rawFragmentsRCE, ConsistRCE, NumADCs, RCETime );
311  sumNADCs += NumADCs;
312  if (NumADCs)
313  std::cout << "Identifier:I had " << NumADCs << " ADCs in event " << evt.event() << ", first timestamp in this event is " << RCETime << "\n" << std::endl;
314  } //RCEPresent
315  //std::cout << "Got RCE start time, it is " << RCETime << std::endl;
316  if (ConsistRCE > -1 ) ++nRCEPayloads;
317  if (ConsistRCE == 1 ) ++nConsistRCEPayloads;
318 
319  // ---------------- Get the Good Event stuff ready for this event ----------------
322  if (SSPTime && PTBTime) SSP_PTB_diff = SSPTime - PTBTime;
323 
324  if (RCETime && SSPTime && PTBTime) { // Check that all components are synchronous.
327  if ( RCE_PTB_diff == 0 && RCE_SSP_diff == 0 ) ++nSynchronousEvents;
328  }
329 
330  if (ConsistRCE == 1) {
331  //std::cout << "!!!Got consistent RCEs so adding the trigger numbers" << std::endl;
332  nPTBTrigsOn110 += ThisEv110;
333  nPTBTrigsOn111 += ThisEv111;
334  nPTBTrigsOn112 += ThisEv112;
335  nPTBTrigsOn113 += ThisEv113;
336  nPTBTrigsOn114 += ThisEv114;
337  nPTBTrigsOn115 += ThisEv115;
338  }
339  if (fNevents%1000 == 0)
340  std::cout << "Looking at event " << evt.event() << " it had " << RCETime << " " << SSPTime << " " << PTBTime << " " << NumADCs
341  << " RCE_SSP " << RCE_SSP_diff << " RCE_PTB " << RCE_PTB_diff << " SSP_PTB " << SSP_PTB_diff << ". "
342  << "So far have had " << nPTBTrigsOn110 << " " << nPTBTrigsOn111 << " " << nPTBTrigsOn112 << " " << nPTBTrigsOn113 << " " << nPTBTrigsOn114 << " " << nPTBTrigsOn115 << " trigs on each coincidence"
343  << ", and " << sumNADCs << " ADCs." << std::endl;
344 }
345 
347  // Implementation of optional member function here.
349  fHist1 = tfs->make<TH1D>("h1", "h1", u_TSU-l_TSU+1+4, l_TSU, u_TSU+1+4);
350  fHist2 = tfs->make<TH1D>("h2", "h2", u_BSU-l_BSU+1, l_BSU, u_BSU+1);
351  fHist3 = tfs->make<TH1D>("h3", "h3", u_Trig-l_Trig, l_Trig, u_Trig);
352 
353  fGoodRunHisto = tfs->make<TH1D>("GoddRunHisto","GoodRunHisto", 12, 0, 12);
354  fGoodRunHisto->GetXaxis()->SetBinLabel(1 ,"PTB payload ratio");
355  fGoodRunHisto->GetXaxis()->SetBinLabel(2 ,"SSP payload ratio");
356  fGoodRunHisto->GetXaxis()->SetBinLabel(3 ,"RCE payload ratio");
357  fGoodRunHisto->GetXaxis()->SetBinLabel(4 ,"Consistent RCE ratio");
358  fGoodRunHisto->GetXaxis()->SetBinLabel(5 ,"Synchronous event ratio");
359  fGoodRunHisto->GetXaxis()->SetBinLabel(6 ,"Trigs on Chan 110");
360  fGoodRunHisto->GetXaxis()->SetBinLabel(7 ,"Trigs on Chan 111");
361  fGoodRunHisto->GetXaxis()->SetBinLabel(8 ,"Trigs on Chan 112");
362  fGoodRunHisto->GetXaxis()->SetBinLabel(9 ,"Trigs on Chan 113");
363  fGoodRunHisto->GetXaxis()->SetBinLabel(10,"Trigs on Chan 114");
364  fGoodRunHisto->GetXaxis()->SetBinLabel(11,"Trigs on Chan 115");
365  fGoodRunHisto->GetXaxis()->SetBinLabel(12,"Total ADCs");
366 
367 
368  //Making the Nearline header information tree
369  fHeader = tfs->make<TTree>("Header","Subrun Information");
370 
371  fHeader->Branch("Run",&fRun);
372  fHeader->Branch("Subrun",&fSubrun);
373  fHeader->Branch("FirstEvent",&fFirstEvent);
374  fHeader->Branch("LastEvent",&fLastEvent);
375  fHeader->Branch("Nevents",&fNevents);
376  fHeader->Branch("StartYear",&fStartYear);
377  fHeader->Branch("StartMonth",&fStartMonth);
378  fHeader->Branch("StartDay",&fStartDay);
379  fHeader->Branch("StartHour",&fStartHour);
380  fHeader->Branch("EndYear",&fEndYear);
381  fHeader->Branch("EndMonth",&fEndMonth);
382  fHeader->Branch("EndDay",&fEndDay);
383  fHeader->Branch("EndHour",&fEndHour);
384 
385  // Set Nearline Version Number
386  fHistNearlineVersion = tfs->make<TH1I>("hist_nearline_version", "hist_nearline_version", 2, 0, 2);
387  fHistNearlineVersion->GetXaxis()->SetBinLabel(1,"NearlineMinorVersion");
388  fHistNearlineVersion->GetXaxis()->SetBinLabel(2,"NearlineMajorVersion");
389  fHistNearlineVersion->SetBinContent(1, NearlineMinorVersion);
390  fHistNearlineVersion->SetBinContent(2, NearlineMajorVersion);
391 }
392 
394 {
395  double total_Time = (double)(event_Length*event_Count);
396  gStyle->SetOptStat(0);
397 
398  fHist1->Sumw2();
399  fHist2->Sumw2();
400  fHist3->Sumw2();
401  if(total_Time > 0.0) fHist1->Scale(1/total_Time);
402  if(total_Time > 0.0) fHist2->Scale(1/total_Time);
403  if(total_Time > 0.0) fHist3->Scale(1/total_Time);
404 
405  TString fHist1_Title = Form("TSU Frequency");
406  TString fHist2_Title = Form("BSU Frequency");
407  TString fHist3_Title = Form("Trigger Frequency");
408  TString fHist1_Name = Form("TSUs");
409  TString fHist2_Name = Form("BSUs");
410  TString fHist3_Name = Form("Triggers");
411 
412  fHist1->SetTitle(fHist1_Title);
413  fHist1->SetName(fHist1_Name);
414  fHist2->SetTitle(fHist2_Title);
415  fHist2->SetName(fHist2_Name);
416  fHist3->SetTitle(fHist3_Title);
417  fHist3->SetName(fHist3_Name);
418 
419  fHist1->GetXaxis()->SetTitle("Counter Number");
420  fHist1->GetYaxis()->SetTitle("Frequency, [Hz]. (No Hits/Run Time)");
421  fHist1->GetYaxis()->SetTitleOffset(1.3);
422 
423  fHist2->GetXaxis()->SetTitle("Counter Number");
424  fHist2->GetYaxis()->SetTitle("Frequency, [Hz]. (No Hits/Run Time)");
425  fHist2->GetYaxis()->SetTitleOffset(1.3);
426 
427  fHist3->GetXaxis()->SetTitle("Counter Number");
428  fHist3->GetYaxis()->SetTitle("Frequency, [Hz]. (No Hits/Run Time)");
429  fHist3->GetYaxis()->SetTitleOffset(1.3);
430 
431  for(int i = 28; i < 38; i++)
432  {
433  TString label = Form("WU%i", i-27);
434  fHist1->GetXaxis()->SetBinLabel(i+1, label);
435  }
436  for(int i = 22; i < 28; i++)
437  {
438  TString label = Form("NU%i", i-21);
439  fHist1->GetXaxis()->SetBinLabel(i+1, label);
440  }
441  for(int i = 0; i < 6; i++)
442  {
443  TString label = Form("SL%i", i+1);
444  fHist1->GetXaxis()->SetBinLabel(i+1, label);
445  }
446  for(int i = 16; i < 22; i++)
447  {
448  TString label = Form("NL%i", i-15);
449  fHist1->GetXaxis()->SetBinLabel(i+1, label);
450  }
451  for(int i = 1; i < 5; i++)
452  {
453  TString label = Form("XX%i", i);
454  fHist1->GetXaxis()->SetBinLabel(i+44, label);
455  }
456 
457  fHist1->GetXaxis()->SetBinLabel(15+1, "EL1");
458  fHist1->GetXaxis()->SetBinLabel(14+1, "EL2");
459  fHist1->GetXaxis()->SetBinLabel(13+1, "EL3");
460  fHist1->GetXaxis()->SetBinLabel(12+1, "EL4");
461  fHist1->GetXaxis()->SetBinLabel(11+1, "EL5");
462  fHist1->GetXaxis()->SetBinLabel(10+1, "EL6");
463  fHist1->GetXaxis()->SetBinLabel(9+1, "EL7");
464  fHist1->GetXaxis()->SetBinLabel(8+1, "EL8");
465  fHist1->GetXaxis()->SetBinLabel(7+1, "EL9");
466  fHist1->GetXaxis()->SetBinLabel(6+1, "EL10");
467 
468  fHist1->GetXaxis()->SetBinLabel(43+1, "SU1");
469  fHist1->GetXaxis()->SetBinLabel(42+1, "SU2");
470  fHist1->GetXaxis()->SetBinLabel(41+1, "SU3");
471  fHist1->GetXaxis()->SetBinLabel(40+1, "SU4");
472  fHist1->GetXaxis()->SetBinLabel(39+1, "SU5");
473  fHist1->GetXaxis()->SetBinLabel(38+1, "SU6");
474  fHist1->GetXaxis()->SetLabelSize(0.018);
475 
476  for(int i = 67; i < 83; i++)
477  {
478  TString label = Form("RM%i", i-66);
479  fHist2->GetXaxis()->SetBinLabel(i-43, label);
480  }
481  for(int i = 83; i < 93; i++)
482  {
483  TString label = Form("RL%i", i-82);
484  fHist2->GetXaxis()->SetBinLabel(i-43, label);
485  }
486  for(int i = 44; i < 57; i++)
487  {
488  TString label = Form("CL%i", i-43);
489  fHist2->GetXaxis()->SetBinLabel(i-43, label);
490  }
491 
492  fHist2->GetXaxis()->SetBinLabel(66+1-44, "CU1");
493  fHist2->GetXaxis()->SetBinLabel(65+1-44, "CU2");
494  fHist2->GetXaxis()->SetBinLabel(64+1-44, "CU3");
495  fHist2->GetXaxis()->SetBinLabel(63+1-44, "CU4");
496  fHist2->GetXaxis()->SetBinLabel(62+1-44, "CU5");
497  fHist2->GetXaxis()->SetBinLabel(61+1-44, "CU6");
498  fHist2->GetXaxis()->SetBinLabel(60+1-44, "CU7");
499  fHist2->GetXaxis()->SetBinLabel(59+1-44, "CU8");
500  fHist2->GetXaxis()->SetBinLabel(58+1-44, "CU9");
501  fHist2->GetXaxis()->SetBinLabel(57+1-44, "CU10");
502  fHist2->GetXaxis()->SetLabelSize(0.025);
503 
504  // -------------------- Stuff for Good Events List ---------------------
505  double PTBPayloadRat = nPTBPayloads / (double)fNevents;
506  double SSPPayloadRat = nSSPPayloads / (double)fNevents;
507  double RCEPayloadRat = nRCEPayloads / (double)fNevents;
508  double ConsistRCERat = nConsistRCEPayloads / (double)nRCEPayloads;
509  double SynchronRat = nSynchronousEvents / (double)fNevents;
510 
511  fGoodRunHisto->SetBinContent(1 , PTBPayloadRat);
512  fGoodRunHisto->SetBinContent(2 , SSPPayloadRat);
513  fGoodRunHisto->SetBinContent(3 , RCEPayloadRat);
514  fGoodRunHisto->SetBinContent(4 , ConsistRCERat);
515  fGoodRunHisto->SetBinContent(5 , SynchronRat);
516  fGoodRunHisto->SetBinContent(6 , nPTBTrigsOn110);
517  fGoodRunHisto->SetBinContent(7 , nPTBTrigsOn111);
518  fGoodRunHisto->SetBinContent(8 , nPTBTrigsOn112);
519  fGoodRunHisto->SetBinContent(9 , nPTBTrigsOn113);
520  fGoodRunHisto->SetBinContent(10, nPTBTrigsOn114);
521  fGoodRunHisto->SetBinContent(11, nPTBTrigsOn115);
522  fGoodRunHisto->SetBinContent(12, sumNADCs);
523 
524 
525  std::cout << "IDENTIFIER: Run: " << fRun << " SubRun " << fSubrun << " has " << fNevents << " events in total"
526  << ", ratio that have PTB payloads " << PTBPayloadRat
527  << ", ratio that have SSP payloads " << SSPPayloadRat
528  << ", ratio that have RCE payloads " << RCEPayloadRat << ", ratio which were consistent " << ConsistRCERat << ", I had a total of " << sumNADCs << " ADCs"
529  << ", ratio of synchronous events " << SynchronRat
530  << ". I had " << nPTBTrigsOn110 << " " << nPTBTrigsOn111 << " " << nPTBTrigsOn112 << " " << nPTBTrigsOn113 << " " << nPTBTrigsOn114 << " " << nPTBTrigsOn115 << " trigs on each coincidence."
531  << std::endl;
532 
533  //
534  // Compute header info.
535  //
536 
537  //
538  // DISECTING the time from evt.time().value() into "human readable" format to display the date & time
539  //
540  unsigned int hour, minute, second;
541  int nano;
542 
543  // Get the time stamp. art::Timestamp::value() returns a TimeValue_t which is a typedef to unsigned long long.
544  // The conventional use is for the upper 32 bits to have the seconds since 1970 epoch and the lower 32 bits to be
545  // the number of nanoseconds with the current second.
546  //
547  // NOTE: It seems that the above is NOT the convention for the 35t events. They only seem to use the lower 32 bits
548  // for the year/month/day/hour/second. For now, I have reversed the values of lup and llo to get the time right.
549  //
550  // THESE VARIABLES WILL NEED TO BE SWITCHED BACK IF USING THE LOWER 32 BITS FOR NANOSECONDS IS IMPLEMENTED!!!
551 
552 
553  const unsigned long int mask32 = 0xFFFFFFFFUL;
554 
555  // taking start time apart
556 
557  // unsigned long int lup = ( fStartTime >> 32 ) & mask32;
558  // unsigned long int llo = fStartTime & mask32;
559  unsigned long int llo = ( fStartTime >> 32 ) & mask32; // reversed value (see above comment)
560  unsigned long int lup = fStartTime & mask32; // reversed value (see above comment)
561  TTimeStamp ts1(lup, (int)llo);
562  ts1.GetDate(kTRUE,0,&fStartYear,&fStartMonth,&fStartDay);
563  ts1.GetTime(kTRUE,0,&hour,&minute,&second);
564  nano = ts1.GetNanoSec();
565  double sec = ((double)second + (double)nano/1.0e9);
566  fStartHour = (double)hour + (double)minute/60.0 + sec/3600.0;
567 
568  // taking end time apart
569  // lup = ( fEndTime >> 32 ) & mask32;
570  // llo = fEndTime & mask32;
571  llo = ( fEndTime >> 32 ) & mask32; // reversed value (see above comment)
572  lup = fEndTime & mask32; // reversed value (see above comment)
573  TTimeStamp ts2(lup, (int)llo);
574  ts2.GetDate(kTRUE,0,&fEndYear,&fEndMonth,&fEndDay);
575  ts2.GetTime(kTRUE,0,&hour,&minute,&second);
576  nano = ts2.GetNanoSec();
577  sec = ((double)second + (double)nano/1.0e9);
578  fEndHour = (double)hour + (double)minute/60.0 + sec/3600.0;
579 
580  fHeader->Fill();
581 
582 }
583 
584 
586 
587 } // namespace Muoncounter
588 
589 #endif // Muoncounter_Module
EventNumber_t event() const
Definition: DataViewImpl.cc:96
unsigned long long int fStartTime
unsigned int subrun
const int NearlineMajorVersion
std::string string
Definition: nybbler.cc:12
Declaration of signal hit object.
void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map< int, int > &channelMap)
void GetSSPFirstTimestamp(artdaq::Fragments const &Fragments, int &nSSPPayloads, long long &SSPTime)
Definition: CheckTime.cc:58
unsigned long long int fEndTime
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
Muoncounter(fhicl::ParameterSet const &p)
constexpr TimeValue_t value() const
Definition: Timestamp.h:23
bool isValid() const
Definition: Handle.h:183
const int NearlineMinorVersion
DAQToOffline::SSPReformatterAlgs sspReform
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
object containing MC truth information necessary for making RawDigits and doing back tracking ...
const double e
Timestamp time() const
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:89
RunNumber_t run() const
Definition: DataViewImpl.cc:82
Encapsulate the geometry of a wire.
void analyze(const art::Event &evt)
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
p
Definition: test.py:223
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
void reconfigure(fhicl::ParameterSet const &pset)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
EventNumber_t event() const
Definition: EventID.h:116
std::map< int, int > fPTBMap
void GetRCEFirstTimestamp(artdaq::Fragments const &Fragments, int &ConsistRCE, int &NumADCs, long long &RCETime)
Definition: CheckTime.cc:14
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
std::vector< raw::OpDetWaveform > SSPFragmentToOpDetWaveform(artdaq::Fragments const &raw)
Construct a waveform from each trigger.
std::vector< raw::ExternalTrigger > PennFragmentToExternalTrigger(artdaq::Fragments const &Fragments, std::map< int, int > &channelMap, lbne::PennMicroSlice::Payload_Timestamp *&FirstPTBTimestamp)
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:80
EventID id() const
Definition: Event.cc:37
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
Event finding and building.
unsigned int run