21 #include "art_root_io/TFileService.h" 22 #include "art_root_io/TFileDirectory.h" 26 #include "lbne-raw-data/Overlays/TpcMilliSliceFragment.hh" 27 #include "lbne-raw-data/Overlays/PennMilliSlice.hh" 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();
98 fTree =
fTFS->make<TTree>(
"BadTimings",
"BadTimings");
124 for (
size_t fragIndex = 0; fragIndex < PTBRawFragments->size(); ++fragIndex) {
125 const artdaq::Fragment &singleFragment = (*PTBRawFragments)[fragIndex];
126 lbne::PennMilliSliceFragment msf(singleFragment);
128 lbne::PennMicroSlice::Payload_Header *word_header =
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;
138 payloadCount = msf.payloadCount(counter, trigger, timestamp);
145 while (payload_index <
uint32_t(payloadCount-1)) {
147 payload_data = msf.get_next_payload(payload_index,word_header);
148 if (payload_data ==
nullptr)
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)
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;
162 if (previous_timestamp !=
nullptr)
163 fPTBTriggerTimestamp = word_header->get_full_timestamp_post(previous_timestamp->nova_timestamp);
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;
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));
193 fRCE = rceIt->first - 100;
196 const artdaq::Fragment &singleFragment = (*RCERawFragments)[rceIt->second];
197 lbne::TpcMilliSliceFragment millisliceFragment(singleFragment);
201 auto numMicroSlices = millisliceFragment.microSliceCount();
202 for (
unsigned int i_micro = 0; i_micro < numMicroSlices; i_micro++) {
204 std::unique_ptr<const lbne::TpcMicroSlice> microSlice = millisliceFragment.microSlice(i_micro);
205 uint64_t rceTriggerTimestamp = microSlice->software_message() & (((
long int)0x1 << 56) - 1);
208 auto numNanoSlices = microSlice->nanoSliceCount();
214 std::cout <<
std::endl <<
"New trigger (RCE " <<
fRCE <<
") on microslice " << i_micro <<
" (event " << evt.
event() <<
")" <<
std::endl;
218 fMicrosliceWithTrigger = (rceTriggerTimestamp - microSlice->nanoSlice(0)->nova_timestamp()) * (15.625/500) * 1/1000;
231 std::cout <<
"End of trigger (RCE " <<
fRCE <<
") on microslice " << i_micro <<
" (event " << evt.
event() <<
")" <<
std::endl;
EventNumber_t event() const
std::vector< bool > fWithinTrigger
art::ServiceHandle< geo::Geometry > fGeometry
void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map< int, int > &channelMap)
EDAnalyzer(fhicl::ParameterSet const &pset)
lbne::PennMilliSlice::Header::timestamp_t fPTBTriggerTimestamp
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
object containing MC truth information necessary for making RawDigits and doing back tracking ...
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
#define DEFINE_ART_MODULE(klass)
int fDiffTriggerTimestamps
BadTimings(const fhicl::ParameterSet &pset)
T get(std::string const &key) const
unsigned __int64 uint64_t
std::map< int, int > fPTBMap
int fMicrosliceWithTrigger
Utility object to perform functions of association.
lbne::TpcNanoSlice::Header::nova_timestamp_t fRCETriggerTimestamp
art::ServiceHandle< art::TFileService > fTFS
void analyze(const art::Event &evt)
QTextStream & endl(QTextStream &s)
TH1I * hDiffTriggerTimestamps