Public Member Functions | Private Attributes | List of all members
DAQToOffline::BadTimings Class Reference
Inheritance diagram for DAQToOffline::BadTimings:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 BadTimings (const fhicl::ParameterSet &pset)
 
void analyze (const art::Event &evt)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string fTPCLabel
 
std::string fTPCInstance
 
std::string fPTBLabel
 
std::string fPTBInstance
 
lbne::TpcNanoSlice::Header::nova_timestamp_t fRCETriggerTimestamp
 
lbne::PennMilliSlice::Header::timestamp_t fPTBTriggerTimestamp
 
art::ServiceHandle< geo::GeometryfGeometry
 
art::ServiceHandle< art::TFileService > fTFS
 
std::string fPTBMapFile
 
std::map< int, int > fPTBMap
 
std::vector< boolfWithinTrigger
 
TTree * fTree
 
int fRun
 
int fEvent
 
int fRCE
 
int fDiffTriggerTimestamps
 
int fMicrosliceWithTrigger
 
TH1I * hDiffTriggerTimestamps
 
TH1I * hTriggerStart
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 48 of file BadTimings_module.cc.

Constructor & Destructor Documentation

DAQToOffline::BadTimings::BadTimings ( const fhicl::ParameterSet pset)
explicit

Definition at line 84 of file BadTimings_module.cc.

84  : EDAnalyzer(pset) {
85  fTPCLabel = pset.get<std::string>("TPCLabel");
86  fTPCInstance = pset.get<std::string>("TPCInstance");
87  fPTBLabel = pset.get<std::string>("PTBLabel");
88  fPTBInstance = pset.get<std::string>("PTBInstance");
89  fPTBMapFile = pset.get<std::string>("PTBMapFile");
90 
91  fWithinTrigger = std::vector<bool>(16,false);
92 
93  hDiffTriggerTimestamps = fTFS->make<TH1I>("PTBRCEDiffTimestamps",";RCE Trigger Timestamp - PTB Trigger Timestamp (NOvA ticks);",100,0,2000);
94  hTriggerStart = fTFS->make<TH1I>("TriggerStart",";Microslice number containing trigger;",15,0,15);
95  hTriggerStart->GetXaxis()->SetNdivisions(15);
96  hTriggerStart->GetXaxis()->CenterLabels();
97 
98  fTree = fTFS->make<TTree>("BadTimings","BadTimings");
99  fTree->Branch("Run", &fRun);
100  fTree->Branch("Event", &fEvent);
101  fTree->Branch("RCE", &fRCE);
102  // fTree->Branch("RCETriggerTimestamp", &fRCETriggerTimestamp);
103  // fTree->Branch("PTBTriggerTimestamp", &fPTBTriggerTimestamp);
104  fTree->Branch("DiffTriggerTimestamps",&fDiffTriggerTimestamps);
105  fTree->Branch("MicrosliceWithTrigger",&fMicrosliceWithTrigger);
106 
107  DAQToOffline::BuildPTBChannelMap("", fPTBMapFile, fPTBMap);
108 }
std::vector< bool > fWithinTrigger
std::string string
Definition: nybbler.cc:12
void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map< int, int > &channelMap)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::map< int, int > fPTBMap
art::ServiceHandle< art::TFileService > fTFS

Member Function Documentation

void DAQToOffline::BadTimings::analyze ( const art::Event evt)

Definition at line 110 of file BadTimings_module.cc.

110  {
111 
112  fRun = evt.run();
113  fEvent = evt.event();
114 
115  // Get the TPC data out of the event
116  art::Handle<artdaq::Fragments> RCERawFragments;
117  evt.getByLabel(fTPCLabel, fTPCInstance, RCERawFragments);
118 
119  // Get the counter data out of the event
120  art::Handle<artdaq::Fragments> PTBRawFragments;
121  evt.getByLabel(fPTBLabel, fPTBInstance, PTBRawFragments);
122 
123  // Look at PTB
124  for (size_t fragIndex = 0; fragIndex < PTBRawFragments->size(); ++fragIndex) {
125  const artdaq::Fragment &singleFragment = (*PTBRawFragments)[fragIndex];
126  lbne::PennMilliSliceFragment msf(singleFragment);
127 
128  lbne::PennMicroSlice::Payload_Header *word_header = nullptr;
129  //lbne::PennMicroSlice::Payload_Counter *word_p_counter = nullptr;
130  lbne::PennMicroSlice::Payload_Trigger *word_p_trigger = nullptr;
131  lbne::PennMicroSlice::Payload_Timestamp *previous_timestamp = nullptr;
132  lbne::PennMicroSlice::Payload_Header *future_timestamp_header = nullptr;
133  lbne::PennMicroSlice::Payload_Timestamp *future_timestamp = nullptr;
134  uint8_t* payload_data = nullptr;
135  uint32_t payload_index = 0;
136 
137  uint16_t counter, trigger, timestamp, payloadCount;
138  payloadCount = msf.payloadCount(counter, trigger, timestamp);
139 
140  if (trigger != 1) {
141  //std::cout << "Event has no trigger in PTB data" << std::endl;
142  return;
143  }
144 
145  while (payload_index < uint32_t(payloadCount-1)) {
146 
147  payload_data = msf.get_next_payload(payload_index,word_header);
148  if (payload_data == nullptr)
149  continue;
150 
151  if (word_header->data_packet_type == lbne::PennMicroSlice::DataTypeTimestamp)
152  previous_timestamp = reinterpret_cast<lbne::PennMicroSlice::Payload_Timestamp*>(payload_data);
153  if (word_header->data_packet_type != lbne::PennMicroSlice::DataTypeTrigger)
154  continue;
155 
156  word_p_trigger = reinterpret_cast<lbne::PennMicroSlice::Payload_Trigger*>(payload_data);
157  if (!word_p_trigger->has_muon_trigger()) {
158  std::cout << "Trigger is not from muon" << std::endl;
159  return;
160  }
161 
162  if (previous_timestamp != nullptr)
163  fPTBTriggerTimestamp = word_header->get_full_timestamp_post(previous_timestamp->nova_timestamp);
164  else {
165  if (future_timestamp == nullptr) {
166  future_timestamp = reinterpret_cast<lbne::PennMicroSlice::Payload_Timestamp*>(msf.get_next_timestamp(future_timestamp_header));
167  if (future_timestamp == nullptr) {
168  std::cerr << "CAN'T FIND PTB TIMESTAMP WORDS IN MILLISLICE FRAGMENT!!! Logic will fail." << std::endl;
169  return;
170  }
171  }
172  fPTBTriggerTimestamp = word_header->get_full_timestamp_pre(future_timestamp->nova_timestamp);
173  }
174 
175  } // loop over payloads
176 
177  } // fragments
178 
179  // Look at RCE
180  // Create a map containing (fragmentID, fragIndex) for the event, will be used to check if each channel is present
181  std::map<unsigned int,unsigned int> mapFragID;
182  for (size_t fragIndex = 0; fragIndex < RCERawFragments->size(); ++fragIndex) {
183  const artdaq::Fragment &singleFragment = (*RCERawFragments)[fragIndex];
184  unsigned int fragmentID = singleFragment.fragmentID();
185  mapFragID.insert(std::pair<unsigned int, unsigned int>(fragmentID,fragIndex));
186  }
187 
188  int maxRCEs = 16;
189 
190  // Loop over the RCEs
191  for (std::map<unsigned int,unsigned int>::iterator rceIt = mapFragID.begin(); rceIt != mapFragID.end() and std::distance(mapFragID.begin(),rceIt) < maxRCEs; ++rceIt) {
192 
193  fRCE = rceIt->first - 100;
194 
195  // Get millislice
196  const artdaq::Fragment &singleFragment = (*RCERawFragments)[rceIt->second];
197  lbne::TpcMilliSliceFragment millisliceFragment(singleFragment);
198  //uint64_t millisliceTimestamp = millisliceFragment.microSlice(0)->software_message() & (((long int)0x1 << 56) - 1);
199 
200  // Get microslices
201  auto numMicroSlices = millisliceFragment.microSliceCount();
202  for (unsigned int i_micro = 0; i_micro < numMicroSlices; i_micro++) {
203 
204  std::unique_ptr<const lbne::TpcMicroSlice> microSlice = millisliceFragment.microSlice(i_micro);
205  uint64_t rceTriggerTimestamp = microSlice->software_message() & (((long int)0x1 << 56) - 1);
206 
207  // Get nanoslices
208  auto numNanoSlices = microSlice->nanoSliceCount();
209 
210  if (!fWithinTrigger[fRCE] and numNanoSlices) {
211 
212  // New trigger
213  fWithinTrigger[fRCE] = true;
214  std::cout << std::endl << "New trigger (RCE " << fRCE << ") on microslice " << i_micro << " (event " << evt.event() << ")" << std::endl;
215  //uint64_t nanoSliceTimestamp = microSlice->nanoSlice(0)->nova_timestamp();
216 
217  fRCETriggerTimestamp = rceTriggerTimestamp;
218  fMicrosliceWithTrigger = (rceTriggerTimestamp - microSlice->nanoSlice(0)->nova_timestamp())/*time*/ * (15.625/500)/*nova->tpc tick*/ * 1/1000/* nano->micro*/;
220 
223 
224  fTree->Fill();
225 
226  }
227  else if (fWithinTrigger[fRCE] and !numNanoSlices) {
228 
229  // End of trigger
230  fWithinTrigger[fRCE] = false;
231  std::cout << "End of trigger (RCE " << fRCE << ") on microslice " << i_micro << " (event " << evt.event() << ")" << std::endl;
232 
233  }
234 
235  } // microslices
236 
237  } // rces
238 
239  return;
240 
241 }
intermediate_table::iterator iterator
EventNumber_t event() const
Definition: DataViewImpl.cc:96
std::vector< bool > fWithinTrigger
unsigned short uint16_t
Definition: stdint.h:125
unsigned char uint8_t
Definition: stdint.h:124
lbne::PennMilliSlice::Header::timestamp_t fPTBTriggerTimestamp
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
RunNumber_t run() const
Definition: DataViewImpl.cc:82
lbne::TpcNanoSlice::Header::nova_timestamp_t fRCETriggerTimestamp
QTextStream & endl(QTextStream &s)

Member Data Documentation

int DAQToOffline::BadTimings::fDiffTriggerTimestamps
private

Definition at line 76 of file BadTimings_module.cc.

int DAQToOffline::BadTimings::fEvent
private

Definition at line 75 of file BadTimings_module.cc.

art::ServiceHandle<geo::Geometry> DAQToOffline::BadTimings::fGeometry
private

Definition at line 66 of file BadTimings_module.cc.

int DAQToOffline::BadTimings::fMicrosliceWithTrigger
private

Definition at line 77 of file BadTimings_module.cc.

std::string DAQToOffline::BadTimings::fPTBInstance
private

Definition at line 59 of file BadTimings_module.cc.

std::string DAQToOffline::BadTimings::fPTBLabel
private

Definition at line 59 of file BadTimings_module.cc.

std::map<int,int> DAQToOffline::BadTimings::fPTBMap
private

Definition at line 70 of file BadTimings_module.cc.

std::string DAQToOffline::BadTimings::fPTBMapFile
private

Definition at line 69 of file BadTimings_module.cc.

lbne::PennMilliSlice::Header::timestamp_t DAQToOffline::BadTimings::fPTBTriggerTimestamp
private

Definition at line 62 of file BadTimings_module.cc.

int DAQToOffline::BadTimings::fRCE
private

Definition at line 75 of file BadTimings_module.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::BadTimings::fRCETriggerTimestamp
private

Definition at line 61 of file BadTimings_module.cc.

int DAQToOffline::BadTimings::fRun
private

Definition at line 75 of file BadTimings_module.cc.

art::ServiceHandle<art::TFileService> DAQToOffline::BadTimings::fTFS
private

Definition at line 67 of file BadTimings_module.cc.

std::string DAQToOffline::BadTimings::fTPCInstance
private

Definition at line 58 of file BadTimings_module.cc.

std::string DAQToOffline::BadTimings::fTPCLabel
private

Definition at line 58 of file BadTimings_module.cc.

TTree* DAQToOffline::BadTimings::fTree
private

Definition at line 74 of file BadTimings_module.cc.

std::vector<bool> DAQToOffline::BadTimings::fWithinTrigger
private

Definition at line 72 of file BadTimings_module.cc.

TH1I* DAQToOffline::BadTimings::hDiffTriggerTimestamps
private

Definition at line 79 of file BadTimings_module.cc.

TH1I* DAQToOffline::BadTimings::hTriggerStart
private

Definition at line 80 of file BadTimings_module.cc.


The documentation for this class was generated from the following file: