PennToOffline.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // File: PennToOffline.cc
3 // Author: Karl Warburton (Oct 2015)
4 //
5 // Utility to provide methods for reformatting the raw online PENN data
6 // into a structure which can be used in the splitter.
7 // Heavily uses lbne-artdaq/OnlineMonitoring/DataReformatter.cxx as a base
8 ////////////////////////////////////////////////////////////////////////
9 
10 #ifndef PennToOffline_h
11 #define PennToOffline_h
12 
14 #include "lbne-raw-data/Overlays/PennMilliSliceFragment.hh"
15 #include "artdaq-core/Data/Fragment.hh"
23 
24 #include <iostream>
25 #include <fstream>
26 #include <vector>
27 #include <map>
28 #include <bitset>
29 #include <utility>
30 #include <iterator>
31 #include "TMath.h"
32 #include "TVector3.h"
33 
34 namespace DAQToOffline {
35 
36  namespace TypeSizes {
37  static int const CounterWordSize = 104;
38  static int const TriggerWordSize = 32;
39  }
40  void CollectCounterBits(lbne::PennMicroSlice::Payload_Header *header,lbne::PennMicroSlice::Payload_Counter *trigger);
41  void CollectTrigger(lbne::PennMicroSlice::Payload_Header *header,lbne::PennMicroSlice::Payload_Trigger *trigger);
42 
43  typedef std::pair<lbne::PennMicroSlice::Payload_Header::short_nova_timestamp_t, std::bitset<TypeSizes::TriggerWordSize> > PTBTrigger;
44 
45  // Unpack the given artdaq::Fragment objects, and create a vector of raw::ExternalTrigger objects. The
46  // Fragments are expected to be carrying Penn Trigger board data; this is not checked.
47  std::vector<raw::ExternalTrigger> PennFragmentToExternalTrigger( artdaq::Fragments const& Fragments, std::map<int,int>& channelMap, lbne::PennMicroSlice::Payload_Timestamp *&FirstPTBTimestamp );
48 
49  // Function to get the full timestamp of a given payload
50  void GetTimestamp( lbne::PennMilliSliceFragment msf,
51  lbne::PennMicroSlice::Payload_Header*& word_header,
52  lbne::PennMicroSlice::Payload_Timestamp* const& previous_timestamp,
53  lbne::PennMicroSlice::Payload_Timestamp*& future_timestamp,
54  lbne::PennMicroSlice::Payload_Header*& future_timestamp_header,
55  std::vector<lbne::PennMicroSlice::Payload_Timestamp::timestamp_t> &TimeVector );
56 
57  // Function to decide whether to make a new External Trigger
58  bool MakeNewExtTrig( uint32_t pos, bool &PrevOn, bool NowOn );
59 
60  void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map<int,int>& channelMap);
61 
62  void MakeCounterPositionMap( std::string CounterDir, std::string CounterFile,
63  std::map< unsigned int, std::pair < TVector3, std::vector< TVector3 > > >& CounterPositionMap,
64  double fExtendCountersX=0, double fExtendCountersY=0, double fExtendCountersZ=0 );
65 
66  void MakeCounterCorners( int CountInd, double HalfLength, double HalfWidth1, double HalfWidth2, TVector3 Centre,
67  TVector3& TL, TVector3& TR, TVector3& BL, TVector3& BR,
68  double fExtendCountersX=0, double fExtendCountersY=0, double fExtendCountersZ=0 );
69 }
70 #endif
void MakeCounterCorners(int CountInd, double HalfLength, double HalfWidth1, double HalfWidth2, TVector3 Centre, TVector3 &TL, TVector3 &TR, TVector3 &BL, TVector3 &BR, double fExtendCountersX=0, double fExtendCountersY=0, double fExtendCountersZ=0)
std::pair< lbne::PennMicroSlice::Payload_Header::short_nova_timestamp_t, std::bitset< TypeSizes::TriggerWordSize > > PTBTrigger
Definition: PennToOffline.h:43
std::string string
Definition: nybbler.cc:12
void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map< int, int > &channelMap)
void GetTimestamp(lbne::PennMilliSliceFragment msf, lbne::PennMicroSlice::Payload_Header *&word_header, lbne::PennMicroSlice::Payload_Timestamp *const &previous_timestamp, lbne::PennMicroSlice::Payload_Timestamp *&future_timestamp, lbne::PennMicroSlice::Payload_Header *&future_timestamp_header, std::vector< lbne::PennMicroSlice::Payload_Timestamp::timestamp_t > &TimeVector)
bool MakeNewExtTrig(uint32_t pos, bool &PrevOn, bool NowOn)
unsigned int uint32_t
Definition: stdint.h:126
void CollectTrigger(lbne::PennMicroSlice::Payload_Header *header, lbne::PennMicroSlice::Payload_Trigger *trigger)
Encapsulate the geometry of an auxiliary detector.
void CollectCounterBits(lbne::PennMicroSlice::Payload_Header *header, lbne::PennMicroSlice::Payload_Counter *trigger)
static int const TriggerWordSize
Definition: PennToOffline.h:38
void MakeCounterPositionMap(std::string CounterDir, std::string CounterFile, std::map< unsigned int, std::pair< TVector3, std::vector< TVector3 > > > &CounterPositionMap, double fExtendCountersX=0, double fExtendCountersY=0, double fExtendCountersZ=0)
std::vector< raw::ExternalTrigger > PennFragmentToExternalTrigger(artdaq::Fragments const &Fragments, std::map< int, int > &channelMap, lbne::PennMicroSlice::Payload_Timestamp *&FirstPTBTimestamp)
static int const CounterWordSize
Definition: PennToOffline.h:37