From 3f49311bb56f8d63ac74a35cf3513aec8c6f9d4a Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Sun, 13 Sep 2026 08:55:39 -0500 Subject: [PATCH 1/8] Structural Update to EventBuilderV2 for LAPPDs Limitations of existing framework - Metadata read from both ACDCs in 'LAPPDLoadStore.cpp', but beamgate and timestamps are constructed out of ACDC 0 metadata only. - This led to wrong beamgate alignment in the 'offsetFit_MultipleLAPPD.cpp', causing only ACDC 0 fit to be right. - Later only ACDC 0 offsets and corrections were propagated to downstream tools for matching during EventBuilding. - Not able to recover as much LAPPD events as expected despite moving towards a PPS pre-scale of 5. Updations to code - The structural changes are made to code such that all ACDC related variables are split into '0/1'. - This version is now dual-ACDC EBV2. - The tools are modified to accomodate both ACDCs for all chains of the event building stages. - Updated tools are 'LAPPDLoadStore', 'LAPPDTreeMaker', 'EBLAPPD', 'EBSaver', 'ProcessedLAPPDFilter' and 'ANNIEEventTreeMaker'. - Updated the matching logic in 'EBLAPPD' to use an OR condition between corrected timestamps from both ACDCs to maximize LAPPD event recovery. - The changes are validated over both beam data and laser data, in gpvms and grid submissions as well. - Other fixes include memory leak and code readability. - Cleaned up verbose logging and aligned verbose name with tool name in 'LAPPDLoadStoreConfig'. - Cleaned up 'ANNIEEventTreeMakerConfig'. Issues - With these changes, the existing processed data will not be able to run through 'BeamClusterAnalysis'. Pending - Update downstream analysis and support tools (outside of EBV2) to fully accommodate the new dual-ACDC architecture: - 'PrintDQ', 'LAPPDTreeMaker' (only relevant part was updated) and 'PhaseIITreeMaker'. --- .../ANNIEEventTreeMaker.cpp | 280 ++-- .../ANNIEEventTreeMaker/ANNIEEventTreeMaker.h | 123 +- UserTools/EBLAPPD/EBLAPPD.cpp | 492 ++++--- UserTools/EBLAPPD/EBLAPPD.h | 109 +- UserTools/EBSaver/EBSaver.cpp | 552 +++++--- UserTools/EBSaver/EBSaver.h | 56 +- UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp | 1210 +++++++++-------- UserTools/LAPPDLoadStore/LAPPDLoadStore.h | 214 +-- UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp | 122 +- UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h | 21 +- .../ProcessedLAPPDFilter.cpp | 171 ++- .../ANNIEEventTreeMakerConfig | 31 +- configfiles/BeamClusterAnalysis/ToolsConfig | 4 +- .../ANNIEEventTreeMakerConfig | 26 +- .../EventBuilderV2/LAPPDLoadStoreConfig | 4 +- .../EventBuilderV2_laser/LAPPDLoadStoreConfig | 4 +- 16 files changed, 2122 insertions(+), 1297 deletions(-) diff --git a/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.cpp b/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.cpp index 5c6dc815d..e54c03504 100644 --- a/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.cpp +++ b/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.cpp @@ -26,26 +26,26 @@ bool ANNIEEventTreeMaker::Initialise(std::string configfile, DataModel &data) fill_TriggerWord = {14, 47}; m_variables.Get("fillCleanEventsOnly", fillCleanEventsOnly); - m_variables.Get("fillLAPPDEventsOnly", fillLAPPDEventsOnly); m_variables.Get("TankHitInfo_fill", TankHitInfo_fill); m_variables.Get("TankCluster_fill", TankCluster_fill); m_variables.Get("cluster_TankHitInfo_fill", cluster_TankHitInfo_fill); m_variables.Get("MRDHitInfo_fill", MRDHitInfo_fill); m_variables.Get("RWMBRF_fill", RWMBRF_fill); + m_variables.Get("SiPMPulseInfo_fill", SiPMPulseInfo_fill); m_variables.Get("MCTruth_fill", MCTruth_fill); m_variables.Get("MRDReco_fill", MRDReco_fill); m_variables.Get("TankReco_fill", TankReco_fill); m_variables.Get("RecoDebug_fill", RecoDebug_fill); m_variables.Get("muonTruthRecoDiff_fill", muonTruthRecoDiff_fill); + m_variables.Get("RingCounting_fill", RingCounting_fill); + m_variables.Get("LAPPDData_fill", LAPPDData_fill); - m_variables.Get("SiPMPulseInfo_fill", SiPMPulseInfo_fill); m_variables.Get("LAPPDReco_fill", LAPPDReco_fill); m_variables.Get("LAPPD_PPS_fill", LAPPD_PPS_fill); m_variables.Get("LAPPD_Waveform_fill", LAPPD_Waveform_fill); m_variables.Get("LAPPD_MC_fill", LAPPD_MC_fill); - m_variables.Get("RingCounting_fill", RingCounting_fill); std::string output_filename = "ANNIEEventTree.root"; m_variables.Get("OutputFile", output_filename); @@ -196,25 +196,50 @@ bool ANNIEEventTreeMaker::Initialise(std::string configfile, DataModel &data) fANNIETree->Branch("LAPPD_ID", &fLAPPD_ID); fANNIETree->Branch("LAPPD_Position", &fLAPPD_Position); fANNIETree->Branch("LAPPD_Count", &fLAPPD_Count); - fANNIETree->Branch("LAPPD_Beamgate_ns", &fLAPPD_Beamgate_ns); - fANNIETree->Branch("LAPPD_Timestamp_ns", &fLAPPD_Timestamp_ns); - fANNIETree->Branch("LAPPD_Beamgate_Raw", &fLAPPD_Beamgate_Raw); - fANNIETree->Branch("LAPPD_Timestamp_Raw", &fLAPPD_Timestamp_Raw); - fANNIETree->Branch("LAPPD_Offset", &fLAPPD_Offset); - fANNIETree->Branch("LAPPD_TSCorrection", &fLAPPD_TSCorrection); - fANNIETree->Branch("LAPPD_BGCorrection", &fLAPPD_BGCorrection); - fANNIETree->Branch("LAPPD_OSInMinusPS", &fLAPPD_OSInMinusPS); + + // Board 0 Branches + fANNIETree->Branch("LAPPD_Beamgate_ns_0", &fLAPPD_Beamgate_ns_0); + fANNIETree->Branch("LAPPD_Timestamp_ns_0", &fLAPPD_Timestamp_ns_0); + fANNIETree->Branch("LAPPD_Beamgate_Raw_0", &fLAPPD_Beamgate_Raw_0); + fANNIETree->Branch("LAPPD_Timestamp_Raw_0", &fLAPPD_Timestamp_Raw_0); + fANNIETree->Branch("LAPPD_Offset_0", &fLAPPD_Offset_0); + fANNIETree->Branch("LAPPD_TSCorrection_0", &fLAPPD_TSCorrection_0); + fANNIETree->Branch("LAPPD_BGCorrection_0", &fLAPPD_BGCorrection_0); + fANNIETree->Branch("LAPPD_OSInMinusPS_0", &fLAPPD_OSInMinusPS_0); + + // Board 1 Branches + fANNIETree->Branch("LAPPD_Beamgate_ns_1", &fLAPPD_Beamgate_ns_1); + fANNIETree->Branch("LAPPD_Timestamp_ns_1", &fLAPPD_Timestamp_ns_1); + fANNIETree->Branch("LAPPD_Beamgate_Raw_1", &fLAPPD_Beamgate_Raw_1); + fANNIETree->Branch("LAPPD_Timestamp_Raw_1", &fLAPPD_Timestamp_Raw_1); + fANNIETree->Branch("LAPPD_Offset_1", &fLAPPD_Offset_1); + fANNIETree->Branch("LAPPD_TSCorrection_1", &fLAPPD_TSCorrection_1); + fANNIETree->Branch("LAPPD_BGCorrection_1", &fLAPPD_BGCorrection_1); + fANNIETree->Branch("LAPPD_OSInMinusPS_1", &fLAPPD_OSInMinusPS_1); + if (LAPPD_PPS_fill) { - fANNIETree->Branch("LAPPD_BGPPSBefore", &fLAPPD_BGPPSBefore); - fANNIETree->Branch("LAPPD_BGPPSAfter", &fLAPPD_BGPPSAfter); - fANNIETree->Branch("LAPPD_BGPPSDiff", &fLAPPD_BGPPSDiff); - fANNIETree->Branch("LAPPD_BGPPSMissing", &fLAPPD_BGPPSMissing); - fANNIETree->Branch("LAPPD_TSPPSBefore", &fLAPPD_TSPPSBefore); - fANNIETree->Branch("LAPPD_TSPPSAfter", &fLAPPD_TSPPSAfter); - fANNIETree->Branch("LAPPD_TSPPSDiff", &fLAPPD_TSPPSDiff); - fANNIETree->Branch("LAPPD_TSPPSMissing", &fLAPPD_TSPPSMissing); + // Board 0 PPS + fANNIETree->Branch("LAPPD_BGPPSBefore_0", &fLAPPD_BGPPSBefore_0); + fANNIETree->Branch("LAPPD_BGPPSAfter_0", &fLAPPD_BGPPSAfter_0); + fANNIETree->Branch("LAPPD_BGPPSDiff_0", &fLAPPD_BGPPSDiff_0); + fANNIETree->Branch("LAPPD_BGPPSMissing_0", &fLAPPD_BGPPSMissing_0); + fANNIETree->Branch("LAPPD_TSPPSBefore_0", &fLAPPD_TSPPSBefore_0); + fANNIETree->Branch("LAPPD_TSPPSAfter_0", &fLAPPD_TSPPSAfter_0); + fANNIETree->Branch("LAPPD_TSPPSDiff_0", &fLAPPD_TSPPSDiff_0); + fANNIETree->Branch("LAPPD_TSPPSMissing_0", &fLAPPD_TSPPSMissing_0); + + // Board 1 PPS + fANNIETree->Branch("LAPPD_BGPPSBefore_1", &fLAPPD_BGPPSBefore_1); + fANNIETree->Branch("LAPPD_BGPPSAfter_1", &fLAPPD_BGPPSAfter_1); + fANNIETree->Branch("LAPPD_BGPPSDiff_1", &fLAPPD_BGPPSDiff_1); + fANNIETree->Branch("LAPPD_BGPPSMissing_1", &fLAPPD_BGPPSMissing_1); + fANNIETree->Branch("LAPPD_TSPPSBefore_1", &fLAPPD_TSPPSBefore_1); + fANNIETree->Branch("LAPPD_TSPPSAfter_1", &fLAPPD_TSPPSAfter_1); + fANNIETree->Branch("LAPPD_TSPPSDiff_1", &fLAPPD_TSPPSDiff_1); + fANNIETree->Branch("LAPPD_TSPPSMissing_1", &fLAPPD_TSPPSMissing_1); } + fANNIETree->Branch("LAPPD_BG_switchBit0", &fLAPPD_BG_switchBit0); fANNIETree->Branch("LAPPD_BG_switchBit1", &fLAPPD_BG_switchBit1); @@ -769,25 +794,45 @@ void ANNIEEventTreeMaker::ResetVariables() fLAPPD_Count = 0; fLAPPD_ID.clear(); fLAPPD_Position.clear(); - fLAPPD_Beamgate_ns.clear(); - fLAPPD_Timestamp_ns.clear(); - fLAPPD_Beamgate_Raw.clear(); - fLAPPD_Timestamp_Raw.clear(); - fLAPPD_Offset.clear(); - fLAPPD_TSCorrection.clear(); - fLAPPD_BGCorrection.clear(); - fLAPPD_OSInMinusPS.clear(); + // Clear Board 0 + fLAPPD_Beamgate_ns_0.clear(); + fLAPPD_Timestamp_ns_0.clear(); + fLAPPD_Beamgate_Raw_0.clear(); + fLAPPD_Timestamp_Raw_0.clear(); + fLAPPD_Offset_0.clear(); + fLAPPD_TSCorrection_0.clear(); + fLAPPD_BGCorrection_0.clear(); + fLAPPD_OSInMinusPS_0.clear(); + // Clear Board 1 + fLAPPD_Beamgate_ns_1.clear(); + fLAPPD_Timestamp_ns_1.clear(); + fLAPPD_Beamgate_Raw_1.clear(); + fLAPPD_Timestamp_Raw_1.clear(); + fLAPPD_Offset_1.clear(); + fLAPPD_TSCorrection_1.clear(); + fLAPPD_BGCorrection_1.clear(); + fLAPPD_OSInMinusPS_1.clear(); fLAPPD_BG_switchBit0.clear(); fLAPPD_BG_switchBit1.clear(); // LAPPD_PPS_fill - fLAPPD_BGPPSBefore.clear(); - fLAPPD_BGPPSAfter.clear(); - fLAPPD_BGPPSDiff.clear(); - fLAPPD_BGPPSMissing.clear(); - fLAPPD_TSPPSBefore.clear(); - fLAPPD_TSPPSAfter.clear(); - fLAPPD_TSPPSDiff.clear(); - fLAPPD_TSPPSMissing.clear(); + // Clear Board 0 PPS + fLAPPD_BGPPSBefore_0.clear(); + fLAPPD_BGPPSAfter_0.clear(); + fLAPPD_BGPPSDiff_0.clear(); + fLAPPD_BGPPSMissing_0.clear(); + fLAPPD_TSPPSBefore_0.clear(); + fLAPPD_TSPPSAfter_0.clear(); + fLAPPD_TSPPSDiff_0.clear(); + fLAPPD_TSPPSMissing_0.clear(); + // Clear Board 1 PPS + fLAPPD_BGPPSBefore_1.clear(); + fLAPPD_BGPPSAfter_1.clear(); + fLAPPD_BGPPSDiff_1.clear(); + fLAPPD_BGPPSMissing_1.clear(); + fLAPPD_TSPPSBefore_1.clear(); + fLAPPD_TSPPSAfter_1.clear(); + fLAPPD_TSPPSDiff_1.clear(); + fLAPPD_TSPPSMissing_1.clear(); // LAPPD Reco Fill fLAPPDPulseTimeStampUL.clear(); @@ -838,13 +883,6 @@ void ANNIEEventTreeMaker::ResetVariables() fLAPPDHitP1FollowCharge.clear(); fLAPPDHitP2FollowCharge.clear(); - LAPPDWaveformChankey.clear(); - waveformMaxValue.clear(); - waveformRMSValue.clear(); - waveformMaxFoundNear.clear(); - waveformMaxNearingValue.clear(); - waveformMaxTimeBinValue.clear(); - // LAPPD waveform fill fLAPPDWaveforms.clear(); @@ -1076,34 +1114,45 @@ void ANNIEEventTreeMaker::ResetVariables() // LAPPDData_fill LAPPDDataMap.clear(); - LAPPDBeamgate_ns.clear(); - LAPPDTimeStamps_ns.clear(); - LAPPDTimeStampsRaw.clear(); - LAPPDBeamgatesRaw.clear(); - LAPPDOffsets.clear(); - LAPPDTSCorrection.clear(); - LAPPDBGCorrection.clear(); - LAPPDOSInMinusPS.clear(); + LAPPDBeamgate_ns_0.clear(); + LAPPDTimeStamps_ns_0.clear(); + LAPPDTimeStampsRaw_0.clear(); + LAPPDBeamgatesRaw_0.clear(); + LAPPDOffsets_0.clear(); + LAPPDTSCorrection_0.clear(); + LAPPDBGCorrection_0.clear(); + LAPPDOSInMinusPS_0.clear(); + LAPPDBeamgate_ns_1.clear(); + LAPPDTimeStamps_ns_1.clear(); + LAPPDTimeStampsRaw_1.clear(); + LAPPDBeamgatesRaw_1.clear(); + LAPPDOffsets_1.clear(); + LAPPDTSCorrection_1.clear(); + LAPPDBGCorrection_1.clear(); + LAPPDOSInMinusPS_1.clear(); SwitchBitBG.clear(); + // LAPPD_PPS_fill - LAPPDBG_PPSBefore.clear(); - LAPPDBG_PPSAfter.clear(); - LAPPDBG_PPSDiff.clear(); - LAPPDBG_PPSMissing.clear(); - LAPPDTS_PPSBefore.clear(); - LAPPDTS_PPSAfter.clear(); - LAPPDTS_PPSDiff.clear(); - LAPPDTS_PPSMissing.clear(); + LAPPDBG_PPSBefore_0.clear(); + LAPPDBG_PPSAfter_0.clear(); + LAPPDBG_PPSDiff_0.clear(); + LAPPDBG_PPSMissing_0.clear(); + LAPPDTS_PPSBefore_0.clear(); + LAPPDTS_PPSAfter_0.clear(); + LAPPDTS_PPSDiff_0.clear(); + LAPPDTS_PPSMissing_0.clear(); + LAPPDBG_PPSBefore_1.clear(); + LAPPDBG_PPSAfter_1.clear(); + LAPPDBG_PPSDiff_1.clear(); + LAPPDBG_PPSMissing_1.clear(); + LAPPDTS_PPSBefore_1.clear(); + LAPPDTS_PPSAfter_1.clear(); + LAPPDTS_PPSDiff_1.clear(); + LAPPDTS_PPSMissing_1.clear(); // LAPPD Reco Fill lappdPulses.clear(); lappdHits.clear(); - - waveformMax.clear(); - waveformRMS.clear(); - waveformMaxLast.clear(); - waveformMaxNearing.clear(); - waveformMaxTimeBin.clear(); } bool ANNIEEventTreeMaker::LoadEventInfo() @@ -1422,24 +1471,42 @@ void ANNIEEventTreeMaker::LoadSiPMHits() } void ANNIEEventTreeMaker::LoadLAPPDInfo() -{ +{ m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", LAPPDDataMap); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection); - m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_0", LAPPDOffsets_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_1", LAPPDOffsets_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); + m_data->Stores["ANNIEEvent"]->Get("SwitchBitBG", SwitchBitBG); if (LAPPDDataMap.size() != 0) @@ -1482,22 +1549,41 @@ void ANNIEEventTreeMaker::FillLAPPDInfo() fLAPPD_ID.push_back(LAPPD_IDInit); fLAPPD_Position.push_back(position); - fLAPPD_Beamgate_ns.push_back(LAPPDBeamgate_ns[key]); - fLAPPD_Timestamp_ns.push_back(LAPPDTimeStamps_ns[key]); - fLAPPD_Beamgate_Raw.push_back(LAPPDBeamgatesRaw[key]); - fLAPPD_Timestamp_Raw.push_back(LAPPDTimeStampsRaw[key]); - fLAPPD_Offset.push_back(LAPPDOffsets[key]); - fLAPPD_TSCorrection.push_back(LAPPDTSCorrection[key]); - fLAPPD_BGCorrection.push_back(LAPPDBGCorrection[key]); - fLAPPD_OSInMinusPS.push_back(LAPPDOSInMinusPS[key]); - fLAPPD_BGPPSBefore.push_back(LAPPDBG_PPSBefore[key]); - fLAPPD_BGPPSAfter.push_back(LAPPDBG_PPSAfter[key]); - fLAPPD_BGPPSDiff.push_back(LAPPDBG_PPSDiff[key]); - fLAPPD_BGPPSMissing.push_back(LAPPDBG_PPSMissing[key]); - fLAPPD_TSPPSBefore.push_back(LAPPDTS_PPSBefore[key]); - fLAPPD_TSPPSAfter.push_back(LAPPDTS_PPSAfter[key]); - fLAPPD_TSPPSDiff.push_back(LAPPDTS_PPSDiff[key]); - fLAPPD_TSPPSMissing.push_back(LAPPDTS_PPSMissing[key]); + + fLAPPD_Beamgate_ns_0.push_back(LAPPDBeamgate_ns_0[key]); + fLAPPD_Timestamp_ns_0.push_back(LAPPDTimeStamps_ns_0[key]); + fLAPPD_Beamgate_Raw_0.push_back(LAPPDBeamgatesRaw_0[key]); + fLAPPD_Timestamp_Raw_0.push_back(LAPPDTimeStampsRaw_0[key]); + fLAPPD_Offset_0.push_back(LAPPDOffsets_0[key]); + fLAPPD_TSCorrection_0.push_back(LAPPDTSCorrection_0[key]); + fLAPPD_BGCorrection_0.push_back(LAPPDBGCorrection_0[key]); + fLAPPD_OSInMinusPS_0.push_back(LAPPDOSInMinusPS_0[key]); + fLAPPD_Beamgate_ns_1.push_back(LAPPDBeamgate_ns_1[key]); + fLAPPD_Timestamp_ns_1.push_back(LAPPDTimeStamps_ns_1[key]); + fLAPPD_Beamgate_Raw_1.push_back(LAPPDBeamgatesRaw_1[key]); + fLAPPD_Timestamp_Raw_1.push_back(LAPPDTimeStampsRaw_1[key]); + fLAPPD_Offset_1.push_back(LAPPDOffsets_1[key]); + fLAPPD_TSCorrection_1.push_back(LAPPDTSCorrection_1[key]); + fLAPPD_BGCorrection_1.push_back(LAPPDBGCorrection_1[key]); + fLAPPD_OSInMinusPS_1.push_back(LAPPDOSInMinusPS_1[key]); + + fLAPPD_BGPPSBefore_0.push_back(LAPPDBG_PPSBefore_0[key]); + fLAPPD_BGPPSAfter_0.push_back(LAPPDBG_PPSAfter_0[key]); + fLAPPD_BGPPSDiff_0.push_back(LAPPDBG_PPSDiff_0[key]); + fLAPPD_BGPPSMissing_0.push_back(LAPPDBG_PPSMissing_0[key]); + fLAPPD_TSPPSBefore_0.push_back(LAPPDTS_PPSBefore_0[key]); + fLAPPD_TSPPSAfter_0.push_back(LAPPDTS_PPSAfter_0[key]); + fLAPPD_TSPPSDiff_0.push_back(LAPPDTS_PPSDiff_0[key]); + fLAPPD_TSPPSMissing_0.push_back(LAPPDTS_PPSMissing_0[key]); + fLAPPD_BGPPSBefore_1.push_back(LAPPDBG_PPSBefore_1[key]); + fLAPPD_BGPPSAfter_1.push_back(LAPPDBG_PPSAfter_1[key]); + fLAPPD_BGPPSDiff_1.push_back(LAPPDBG_PPSDiff_1[key]); + fLAPPD_BGPPSMissing_1.push_back(LAPPDBG_PPSMissing_1[key]); + fLAPPD_TSPPSBefore_1.push_back(LAPPDTS_PPSBefore_1[key]); + fLAPPD_TSPPSAfter_1.push_back(LAPPDTS_PPSAfter_1[key]); + fLAPPD_TSPPSDiff_1.push_back(LAPPDTS_PPSDiff_1[key]); + fLAPPD_TSPPSMissing_1.push_back(LAPPDTS_PPSMissing_1[key]); + // check if SwitchBitBG has the key if (SwitchBitBG.find(psecData.LAPPD_ID) != SwitchBitBG.end()) { diff --git a/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.h b/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.h index 44a321dba..5b815110c 100644 --- a/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.h +++ b/UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.h @@ -29,10 +29,12 @@ /** * \class ANNIEEventTreeMaker * - * * $Author: Yue Feng $ * $Date: 2024/8 $ * Contact: yuef@iastate.edu + * + * Updated by: Anuj Gupta (2026.09.07) + * */ class ANNIEEventTreeMaker : public Tool @@ -108,7 +110,6 @@ class ANNIEEventTreeMaker : public Tool // What events will be filled - status bool fillCleanEventsOnly = 0; // Only output events not flagged by EventSelector tool - bool fillLAPPDEventsOnly = 0; // Only fill events with LAPPD data // What information will be filled bool TankHitInfo_fill = 1; @@ -225,22 +226,41 @@ class ANNIEEventTreeMaker : public Tool int fLAPPD_Count; vector fLAPPD_ID; vector fLAPPD_Position; - vector fLAPPD_Beamgate_ns; - vector fLAPPD_Timestamp_ns; - vector fLAPPD_Beamgate_Raw; - vector fLAPPD_Timestamp_Raw; - vector fLAPPD_Offset; - vector fLAPPD_TSCorrection; - vector fLAPPD_BGCorrection; - vector fLAPPD_OSInMinusPS; - vector fLAPPD_BGPPSBefore; - vector fLAPPD_BGPPSAfter; - vector fLAPPD_BGPPSDiff; - vector fLAPPD_BGPPSMissing; - vector fLAPPD_TSPPSBefore; - vector fLAPPD_TSPPSAfter; - vector fLAPPD_TSPPSDiff; - vector fLAPPD_TSPPSMissing; + + vector fLAPPD_Beamgate_ns_0; + vector fLAPPD_Timestamp_ns_0; + vector fLAPPD_Beamgate_Raw_0; + vector fLAPPD_Timestamp_Raw_0; + vector fLAPPD_Offset_0; + vector fLAPPD_TSCorrection_0; + vector fLAPPD_BGCorrection_0; + vector fLAPPD_OSInMinusPS_0; + vector fLAPPD_Beamgate_ns_1; + vector fLAPPD_Timestamp_ns_1; + vector fLAPPD_Beamgate_Raw_1; + vector fLAPPD_Timestamp_Raw_1; + vector fLAPPD_Offset_1; + vector fLAPPD_TSCorrection_1; + vector fLAPPD_BGCorrection_1; + vector fLAPPD_OSInMinusPS_1; + + vector fLAPPD_BGPPSBefore_0; + vector fLAPPD_BGPPSAfter_0; + vector fLAPPD_BGPPSDiff_0; + vector fLAPPD_BGPPSMissing_0; + vector fLAPPD_TSPPSBefore_0; + vector fLAPPD_TSPPSAfter_0; + vector fLAPPD_TSPPSDiff_0; + vector fLAPPD_TSPPSMissing_0; + vector fLAPPD_BGPPSBefore_1; + vector fLAPPD_BGPPSAfter_1; + vector fLAPPD_BGPPSDiff_1; + vector fLAPPD_BGPPSMissing_1; + vector fLAPPD_TSPPSBefore_1; + vector fLAPPD_TSPPSAfter_1; + vector fLAPPD_TSPPSDiff_1; + vector fLAPPD_TSPPSMissing_1; + vector fLAPPD_BG_switchBit0; vector fLAPPD_BG_switchBit1; @@ -293,14 +313,6 @@ class ANNIEEventTreeMaker : public Tool vector fLAPPDHitP1FollowCharge; vector fLAPPDHitP2FollowCharge; - // waveform - vector LAPPDWaveformChankey; - vector waveformMaxValue; - vector waveformRMSValue; - vector waveformMaxFoundNear; - vector waveformMaxNearingValue; - vector waveformMaxTimeBinValue; - // LAPPD waveform Fill string LAPPDWaveformInputLabel; vector> fLAPPDWaveforms; @@ -544,22 +556,41 @@ class ANNIEEventTreeMaker : public Tool // LAPPDData_fill std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; - std::map LAPPDBG_PPSBefore; - std::map LAPPDBG_PPSAfter; - std::map LAPPDBG_PPSDiff; - std::map LAPPDBG_PPSMissing; - std::map LAPPDTS_PPSBefore; - std::map LAPPDTS_PPSAfter; - std::map LAPPDTS_PPSDiff; - std::map LAPPDTS_PPSMissing; + + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; + + std::map LAPPDBG_PPSBefore_0; + std::map LAPPDBG_PPSAfter_0; + std::map LAPPDBG_PPSDiff_0; + std::map LAPPDBG_PPSMissing_0; + std::map LAPPDTS_PPSBefore_0; + std::map LAPPDTS_PPSAfter_0; + std::map LAPPDTS_PPSDiff_0; + std::map LAPPDTS_PPSMissing_0; + std::map LAPPDBG_PPSBefore_1; + std::map LAPPDBG_PPSAfter_1; + std::map LAPPDBG_PPSDiff_1; + std::map LAPPDBG_PPSMissing_1; + std::map LAPPDTS_PPSBefore_1; + std::map LAPPDTS_PPSAfter_1; + std::map LAPPDTS_PPSDiff_1; + std::map LAPPDTS_PPSMissing_1; + std::map> SwitchBitBG; std::map>> lappdPulses; @@ -587,14 +618,6 @@ class ANNIEEventTreeMaker : public Tool // ************ Muon reconstruction level information ******** // std::string MRDTriggertype; - - // ************* LAPPD RecoInfo *********** // - // left for LAPPD waveforms if needed - std::map> waveformMax; // strip number+30*side, value - std::map> waveformRMS; - std::map> waveformMaxLast; - std::map> waveformMaxNearing; - std::map> waveformMaxTimeBin; }; #endif diff --git a/UserTools/EBLAPPD/EBLAPPD.cpp b/UserTools/EBLAPPD/EBLAPPD.cpp index e78ca5a18..a585830b0 100644 --- a/UserTools/EBLAPPD/EBLAPPD.cpp +++ b/UserTools/EBLAPPD/EBLAPPD.cpp @@ -31,25 +31,48 @@ bool EBLAPPD::Execute() m_data->CStore.Get("PairedLAPPDTriggerTimestamp", PairedCTCTimeStamps); m_data->CStore.Get("PairedLAPPDTimeStamps", PairedLAPPDTimeStamps); m_data->CStore.Get("PairedLAPPD_TriggerIndex", PairedLAPPD_TriggerIndex); - m_data->CStore.Get("Buffer_LAPPDData", Buffer_LAPPDData); - m_data->CStore.Get("Buffer_LAPPDTimestamp_ns", Buffer_LAPPDTimestamp_ns); - m_data->CStore.Get("Buffer_LAPPDBeamgate_ns", Buffer_LAPPDBeamgate_ns); - m_data->CStore.Get("Buffer_LAPPDOffset", Buffer_LAPPDOffset); - m_data->CStore.Get("Buffer_LAPPDBeamgate_Raw", Buffer_LAPPDBeamgate_Raw); - m_data->CStore.Get("Buffer_LAPPDTimestamp_Raw", Buffer_LAPPDTimestamp_Raw); - m_data->CStore.Get("Buffer_LAPPDBGCorrection", Buffer_LAPPDBGCorrection); - m_data->CStore.Get("Buffer_LAPPDTSCorrection", Buffer_LAPPDTSCorrection); - m_data->CStore.Get("Buffer_LAPPDOffset_minus_ps", Buffer_LAPPDOffset_minus_ps); + + // Shared buffers + m_data->CStore.Get("Buffer_LAPPDData", Buffer_LAPPDData); m_data->CStore.Get("Buffer_LAPPDRunCode", Buffer_RunCode); - m_data->CStore.Get("Buffer_LAPPDBG_PPSBefore", Buffer_LAPPDBG_PPSBefore); - m_data->CStore.Get("Buffer_LAPPDBG_PPSAfter", Buffer_LAPPDBG_PPSAfter); - m_data->CStore.Get("Buffer_LAPPDBG_PPSDiff", Buffer_LAPPDBG_PPSDiff); - m_data->CStore.Get("Buffer_LAPPDBG_PPSMissing", Buffer_LAPPDBG_PPSMissing); - m_data->CStore.Get("Buffer_LAPPDTS_PPSBefore", Buffer_LAPPDTS_PPSBefore); - m_data->CStore.Get("Buffer_LAPPDTS_PPSAfter", Buffer_LAPPDTS_PPSAfter); - m_data->CStore.Get("Buffer_LAPPDTS_PPSDiff", Buffer_LAPPDTS_PPSDiff); - m_data->CStore.Get("Buffer_LAPPDTS_PPSMissing", Buffer_LAPPDTS_PPSMissing); + // --- Board 0 Buffers Get --- + m_data->CStore.Get("Buffer_LAPPDTimestamp_ns_0", Buffer_LAPPDTimestamp_ns_0); + m_data->CStore.Get("Buffer_LAPPDBeamgate_ns_0", Buffer_LAPPDBeamgate_ns_0); + m_data->CStore.Get("Buffer_LAPPDOffset_0", Buffer_LAPPDOffset_0); + m_data->CStore.Get("Buffer_LAPPDBeamgate_Raw_0", Buffer_LAPPDBeamgate_Raw_0); + m_data->CStore.Get("Buffer_LAPPDTimestamp_Raw_0", Buffer_LAPPDTimestamp_Raw_0); + m_data->CStore.Get("Buffer_LAPPDBGCorrection_0", Buffer_LAPPDBGCorrection_0); + m_data->CStore.Get("Buffer_LAPPDTSCorrection_0", Buffer_LAPPDTSCorrection_0); + m_data->CStore.Get("Buffer_LAPPDOffset_minus_ps_0", Buffer_LAPPDOffset_minus_ps_0); + + m_data->CStore.Get("Buffer_LAPPDBG_PPSBefore_0", Buffer_LAPPDBG_PPSBefore_0); + m_data->CStore.Get("Buffer_LAPPDBG_PPSAfter_0", Buffer_LAPPDBG_PPSAfter_0); + m_data->CStore.Get("Buffer_LAPPDBG_PPSDiff_0", Buffer_LAPPDBG_PPSDiff_0); + m_data->CStore.Get("Buffer_LAPPDBG_PPSMissing_0", Buffer_LAPPDBG_PPSMissing_0); + m_data->CStore.Get("Buffer_LAPPDTS_PPSBefore_0", Buffer_LAPPDTS_PPSBefore_0); + m_data->CStore.Get("Buffer_LAPPDTS_PPSAfter_0", Buffer_LAPPDTS_PPSAfter_0); + m_data->CStore.Get("Buffer_LAPPDTS_PPSDiff_0", Buffer_LAPPDTS_PPSDiff_0); + m_data->CStore.Get("Buffer_LAPPDTS_PPSMissing_0", Buffer_LAPPDTS_PPSMissing_0); + + // --- Board 1 Buffers Get --- + m_data->CStore.Get("Buffer_LAPPDTimestamp_ns_1", Buffer_LAPPDTimestamp_ns_1); + m_data->CStore.Get("Buffer_LAPPDBeamgate_ns_1", Buffer_LAPPDBeamgate_ns_1); + m_data->CStore.Get("Buffer_LAPPDOffset_1", Buffer_LAPPDOffset_1); + m_data->CStore.Get("Buffer_LAPPDBeamgate_Raw_1", Buffer_LAPPDBeamgate_Raw_1); + m_data->CStore.Get("Buffer_LAPPDTimestamp_Raw_1", Buffer_LAPPDTimestamp_Raw_1); + m_data->CStore.Get("Buffer_LAPPDBGCorrection_1", Buffer_LAPPDBGCorrection_1); + m_data->CStore.Get("Buffer_LAPPDTSCorrection_1", Buffer_LAPPDTSCorrection_1); + m_data->CStore.Get("Buffer_LAPPDOffset_minus_ps_1", Buffer_LAPPDOffset_minus_ps_1); + + m_data->CStore.Get("Buffer_LAPPDBG_PPSBefore_1", Buffer_LAPPDBG_PPSBefore_1); + m_data->CStore.Get("Buffer_LAPPDBG_PPSAfter_1", Buffer_LAPPDBG_PPSAfter_1); + m_data->CStore.Get("Buffer_LAPPDBG_PPSDiff_1", Buffer_LAPPDBG_PPSDiff_1); + m_data->CStore.Get("Buffer_LAPPDBG_PPSMissing_1", Buffer_LAPPDBG_PPSMissing_1); + m_data->CStore.Get("Buffer_LAPPDTS_PPSBefore_1", Buffer_LAPPDTS_PPSBefore_1); + m_data->CStore.Get("Buffer_LAPPDTS_PPSAfter_1", Buffer_LAPPDTS_PPSAfter_1); + m_data->CStore.Get("Buffer_LAPPDTS_PPSDiff_1", Buffer_LAPPDTS_PPSDiff_1); + m_data->CStore.Get("Buffer_LAPPDTS_PPSMissing_1", Buffer_LAPPDTS_PPSMissing_1); Log("EBLAPPD: Got pairing information from CStore, PairedLAPPDTimeStamps[14] size = " + std::to_string(PairedLAPPDTimeStamps[14].size()), v_message, verbosityEBLAPPD); @@ -59,6 +82,7 @@ bool EBLAPPD::Execute() bool IsNewLAPPDData = false; m_data->CStore.Get("NewLAPPDDataAvailable", IsNewLAPPDData); Log("EBLAPPD: NewLAPPDDataAvailable = " + std::to_string(IsNewLAPPDData), v_message, verbosityEBLAPPD); + bool LoadingPPS = false; m_data->CStore.Get("LoadingPPS", LoadingPPS); @@ -80,7 +104,9 @@ bool EBLAPPD::Execute() if (stopLoop || runNum != thisRunNum || exeNum % exePerMatch == 0 || ForceLAPPDMatching) { Log("EBLAPPD: exeNum = " + std::to_string(exeNum) + ". Doing matching", v_message, verbosityEBLAPPD); - Log("EBLAPPD: Matching reason is stopLoop = " + std::to_string(stopLoop) + ", runNum = " + std::to_string(runNum) + ", exeNum = " + std::to_string(exeNum) + ", ForceLAPPDMatching = " + std::to_string(ForceLAPPDMatching), v_message, verbosityEBLAPPD); + Log("EBLAPPD: Matching reason is stopLoop = " + std::to_string(stopLoop) + ", runNum = " + std::to_string(runNum) + + ", exeNum = " + std::to_string(exeNum) + ", ForceLAPPDMatching = " + std::to_string(ForceLAPPDMatching), v_message, verbosityEBLAPPD); + if (matchToAllTriggers) { Matching(0, 0); @@ -128,34 +154,53 @@ bool EBLAPPD::Execute() m_data->CStore.Set("PairedLAPPDTriggerTimestamp", PairedCTCTimeStamps); m_data->CStore.Set("PairedLAPPDTimeStamps", PairedLAPPDTimeStamps); m_data->CStore.Set("PairedLAPPD_TriggerIndex", PairedLAPPD_TriggerIndex); + Log("EBLAPPD: Set pairing information to CStore, PairedLAPPDTimeStamps[14] size = " + std::to_string(PairedLAPPDTimeStamps[14].size()), v_message, verbosityEBLAPPD); Log("EBLAPPD: Set pairing information to CStore, PairedLAPPDTimeStamps[47] size = " + std::to_string(PairedLAPPDTimeStamps[47].size()), v_message, verbosityEBLAPPD); - // Set the indexing of buffer - m_data->CStore.Set("Buffer_LAPPDTimestamp_ns", Buffer_LAPPDTimestamp_ns); - - // Also set all buffers to CStore + // Set Shared Buffers m_data->CStore.Set("Buffer_LAPPDData", Buffer_LAPPDData); - m_data->CStore.Set("Buffer_LAPPDBeamgate_ns", Buffer_LAPPDBeamgate_ns); - m_data->CStore.Set("Buffer_LAPPDOffset", Buffer_LAPPDOffset); - m_data->CStore.Set("Buffer_LAPPDBeamgate_Raw", Buffer_LAPPDBeamgate_Raw); - m_data->CStore.Set("Buffer_LAPPDTimestamp_Raw", Buffer_LAPPDTimestamp_Raw); - m_data->CStore.Set("Buffer_LAPPDBGCorrection", Buffer_LAPPDBGCorrection); - m_data->CStore.Set("Buffer_LAPPDTSCorrection", Buffer_LAPPDTSCorrection); - m_data->CStore.Set("Buffer_LAPPDOffset_minus_ps", Buffer_LAPPDOffset_minus_ps); m_data->CStore.Set("Buffer_LAPPDRunCode", Buffer_RunCode); - m_data->CStore.Set("Buffer_LAPPDBG_PPSBefore", Buffer_LAPPDBG_PPSBefore); - m_data->CStore.Set("Buffer_LAPPDBG_PPSAfter", Buffer_LAPPDBG_PPSAfter); - m_data->CStore.Set("Buffer_LAPPDBG_PPSDiff", Buffer_LAPPDBG_PPSDiff); - m_data->CStore.Set("Buffer_LAPPDBG_PPSMissing", Buffer_LAPPDBG_PPSMissing); - m_data->CStore.Set("Buffer_LAPPDTS_PPSBefore", Buffer_LAPPDTS_PPSBefore); - m_data->CStore.Set("Buffer_LAPPDTS_PPSAfter", Buffer_LAPPDTS_PPSAfter); - m_data->CStore.Set("Buffer_LAPPDTS_PPSDiff", Buffer_LAPPDTS_PPSDiff); - m_data->CStore.Set("Buffer_LAPPDTS_PPSMissing", Buffer_LAPPDTS_PPSMissing); + // --- Board 0 Buffers Set --- + m_data->CStore.Set("Buffer_LAPPDTimestamp_ns_0", Buffer_LAPPDTimestamp_ns_0); + m_data->CStore.Set("Buffer_LAPPDBeamgate_ns_0", Buffer_LAPPDBeamgate_ns_0); + m_data->CStore.Set("Buffer_LAPPDOffset_0", Buffer_LAPPDOffset_0); + m_data->CStore.Set("Buffer_LAPPDBeamgate_Raw_0", Buffer_LAPPDBeamgate_Raw_0); + m_data->CStore.Set("Buffer_LAPPDTimestamp_Raw_0", Buffer_LAPPDTimestamp_Raw_0); + m_data->CStore.Set("Buffer_LAPPDBGCorrection_0", Buffer_LAPPDBGCorrection_0); + m_data->CStore.Set("Buffer_LAPPDTSCorrection_0", Buffer_LAPPDTSCorrection_0); + m_data->CStore.Set("Buffer_LAPPDOffset_minus_ps_0", Buffer_LAPPDOffset_minus_ps_0); + + m_data->CStore.Set("Buffer_LAPPDBG_PPSBefore_0", Buffer_LAPPDBG_PPSBefore_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSAfter_0", Buffer_LAPPDBG_PPSAfter_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSDiff_0", Buffer_LAPPDBG_PPSDiff_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSMissing_0", Buffer_LAPPDBG_PPSMissing_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSBefore_0", Buffer_LAPPDTS_PPSBefore_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSAfter_0", Buffer_LAPPDTS_PPSAfter_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSDiff_0", Buffer_LAPPDTS_PPSDiff_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSMissing_0", Buffer_LAPPDTS_PPSMissing_0); + + // --- Board 1 Buffers Set --- + m_data->CStore.Set("Buffer_LAPPDTimestamp_ns_1", Buffer_LAPPDTimestamp_ns_1); + m_data->CStore.Set("Buffer_LAPPDBeamgate_ns_1", Buffer_LAPPDBeamgate_ns_1); + m_data->CStore.Set("Buffer_LAPPDOffset_1", Buffer_LAPPDOffset_1); + m_data->CStore.Set("Buffer_LAPPDBeamgate_Raw_1", Buffer_LAPPDBeamgate_Raw_1); + m_data->CStore.Set("Buffer_LAPPDTimestamp_Raw_1", Buffer_LAPPDTimestamp_Raw_1); + m_data->CStore.Set("Buffer_LAPPDBGCorrection_1", Buffer_LAPPDBGCorrection_1); + m_data->CStore.Set("Buffer_LAPPDTSCorrection_1", Buffer_LAPPDTSCorrection_1); + m_data->CStore.Set("Buffer_LAPPDOffset_minus_ps_1", Buffer_LAPPDOffset_minus_ps_1); + + m_data->CStore.Set("Buffer_LAPPDBG_PPSBefore_1", Buffer_LAPPDBG_PPSBefore_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSAfter_1", Buffer_LAPPDBG_PPSAfter_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSDiff_1", Buffer_LAPPDBG_PPSDiff_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSMissing_1", Buffer_LAPPDBG_PPSMissing_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSBefore_1", Buffer_LAPPDTS_PPSBefore_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSAfter_1", Buffer_LAPPDTS_PPSAfter_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSDiff_1", Buffer_LAPPDTS_PPSDiff_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSMissing_1", Buffer_LAPPDTS_PPSMissing_1); exeNum++; - return true; } @@ -163,110 +208,181 @@ bool EBLAPPD::Finalise() { Log("\033[1;34mEBLAPPD: Finalising\033[0m", v_message, verbosityEBLAPPD); Log("EBLAPPD: Matched LAPPD number = " + std::to_string(matchedLAPPDNumber), v_message, verbosityEBLAPPD); - Log("EBLAPPD: Unmatched LAPPD number = " + std::to_string(MatchBuffer_LAPPDTimestamp_ns.size()), v_message, verbosityEBLAPPD); + Log("EBLAPPD: Unmatched LAPPD number = " + std::to_string(MatchBuffer_LAPPDTimestamp_ns_0.size()), v_message, verbosityEBLAPPD); return true; } bool EBLAPPD::CleanData() { - LAPPDBeamgate_ns = 0; - LAPPDTimestamp_ns = 0; - LAPPDOffset = 0; - LAPPDBeamgate_Raw = 0; - LAPPDTimestamp_Raw = 0; - LAPPDBGCorrection = 0; - LAPPDTSCorrection = 0; - LAPPDOffset_minus_ps = 0; - - LAPPDBG_PPSBefore = 0; - LAPPDBG_PPSAfter = 0; - LAPPDBG_PPSDiff = 0; - LAPPDBG_PPSMissing = 0; - LAPPDTS_PPSBefore = 0; - LAPPDTS_PPSAfter = 0; - LAPPDTS_PPSDiff = 0; - LAPPDTS_PPSMissing = 0; + // --- All Board 0 --- + LAPPDBeamgate_ns_0 = 0; + LAPPDTimestamp_ns_0 = 0; + LAPPDOffset_0 = 0; + LAPPDBeamgate_Raw_0 = 0; + LAPPDTimestamp_Raw_0 = 0; + LAPPDBGCorrection_0 = 0; + LAPPDTSCorrection_0 = 0; + LAPPDOffset_minus_ps_0 = 0; + + LAPPDBG_PPSBefore_0 = 0; + LAPPDBG_PPSAfter_0 = 0; + LAPPDBG_PPSDiff_0 = 0; + LAPPDBG_PPSMissing_0 = 0; + LAPPDTS_PPSBefore_0 = 0; + LAPPDTS_PPSAfter_0 = 0; + LAPPDTS_PPSDiff_0 = 0; + LAPPDTS_PPSMissing_0 = 0; + + // --- All Board 1 --- + LAPPDBeamgate_ns_1 = 0; + LAPPDTimestamp_ns_1 = 0; + LAPPDOffset_1 = 0; + LAPPDBeamgate_Raw_1 = 0; + LAPPDTimestamp_Raw_1 = 0; + LAPPDBGCorrection_1 = 0; + LAPPDTSCorrection_1 = 0; + LAPPDOffset_minus_ps_1 = 0; + + LAPPDBG_PPSBefore_1 = 0; + LAPPDBG_PPSAfter_1 = 0; + LAPPDBG_PPSDiff_1 = 0; + LAPPDBG_PPSMissing_1 = 0; + LAPPDTS_PPSBefore_1 = 0; + LAPPDTS_PPSAfter_1 = 0; + LAPPDTS_PPSDiff_1 = 0; + LAPPDTS_PPSMissing_1 = 0; return true; } bool EBLAPPD::LoadLAPPDData() { - // get the LAPPD beamgate - LAPPDBeamgate_Raw = 0; - LAPPDTimestamp_Raw = 0; - m_data->CStore.Get("LAPPDBeamgate_Raw", LAPPDBeamgate_Raw); - m_data->CStore.Get("LAPPDTimestamp_Raw", LAPPDTimestamp_Raw); - - LAPPDBeamgate_ns = LAPPDBeamgate_Raw * 3.125; - LAPPDTimestamp_ns = LAPPDTimestamp_Raw * 3.125; - - LAPPDBGCorrection = 0; - LAPPDTSCorrection = 0; - LAPPDOffset_minus_ps = 0; - m_data->CStore.Get("LAPPDBGCorrection", LAPPDBGCorrection); - m_data->CStore.Get("LAPPDTSCorrection", LAPPDTSCorrection); - m_data->CStore.Get("LAPPDOffset_minus_ps", LAPPDOffset_minus_ps); - LAPPDOffset = 0; - m_data->CStore.Get("LAPPDOffset", LAPPDOffset); - - LAPPDBeamgate_ns = LAPPDBeamgate_ns + LAPPDBGCorrection + LAPPDOffset; - LAPPDTimestamp_ns = LAPPDTimestamp_ns + LAPPDTSCorrection + LAPPDOffset; - - LAPPDBG_PPSBefore = 0; - LAPPDBG_PPSAfter = 0; - LAPPDBG_PPSDiff = 0; - LAPPDBG_PPSMissing = 0; - LAPPDTS_PPSBefore = 0; - LAPPDTS_PPSAfter = 0; - LAPPDTS_PPSDiff = 0; - LAPPDTS_PPSMissing = 0; - m_data->CStore.Get("BG_PPSBefore", LAPPDBG_PPSBefore); - m_data->CStore.Get("BG_PPSAfter", LAPPDBG_PPSAfter); - m_data->CStore.Get("BG_PPSDiff", LAPPDBG_PPSDiff); - m_data->CStore.Get("BG_PPSMissing", LAPPDBG_PPSMissing); - m_data->CStore.Get("TS_PPSBefore", LAPPDTS_PPSBefore); - m_data->CStore.Get("TS_PPSAfter", LAPPDTS_PPSAfter); - m_data->CStore.Get("TS_PPSDiff", LAPPDTS_PPSDiff); - m_data->CStore.Get("TS_PPSMissing", LAPPDTS_PPSMissing); + // Get the LAPPD beamgate + // --- All Board 0 --- + m_data->CStore.Get("LAPPDBeamgate0_Raw", LAPPDBeamgate_Raw_0); + m_data->CStore.Get("LAPPDTimestamp0_Raw", LAPPDTimestamp_Raw_0); + m_data->CStore.Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + m_data->CStore.Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + m_data->CStore.Get("LAPPDOffset_minus_ps_0", LAPPDOffset_minus_ps_0); + m_data->CStore.Get("LAPPDOffset_0", LAPPDOffset_0); + + // Convert to ns + LAPPDBeamgate_ns_0 = (LAPPDBeamgate_Raw_0 + LAPPDBGCorrection_0) * 3.125 + LAPPDOffset_0; + LAPPDTimestamp_ns_0 = (LAPPDTimestamp_Raw_0 + LAPPDTSCorrection_0) * 3.125 + LAPPDOffset_0; + + m_data->CStore.Get("BG_PPSBefore_0", LAPPDBG_PPSBefore_0); + m_data->CStore.Get("BG_PPSAfter_0", LAPPDBG_PPSAfter_0); + m_data->CStore.Get("BG_PPSDiff_0", LAPPDBG_PPSDiff_0); + m_data->CStore.Get("BG_PPSMissing_0", LAPPDBG_PPSMissing_0); + m_data->CStore.Get("TS_PPSBefore_0", LAPPDTS_PPSBefore_0); + m_data->CStore.Get("TS_PPSAfter_0", LAPPDTS_PPSAfter_0); + m_data->CStore.Get("TS_PPSDiff_0", LAPPDTS_PPSDiff_0); + m_data->CStore.Get("TS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + // --- All Board 1 --- + m_data->CStore.Get("LAPPDBeamgate1_Raw", LAPPDBeamgate_Raw_1); + m_data->CStore.Get("LAPPDTimestamp1_Raw", LAPPDTimestamp_Raw_1); + m_data->CStore.Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + m_data->CStore.Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + m_data->CStore.Get("LAPPDOffset_minus_ps_1", LAPPDOffset_minus_ps_1); + m_data->CStore.Get("LAPPDOffset_1", LAPPDOffset_1); + + // Convert to ns + LAPPDBeamgate_ns_1 = (LAPPDBeamgate_Raw_1 + LAPPDBGCorrection_1) * 3.125 + LAPPDOffset_1; + LAPPDTimestamp_ns_1 = (LAPPDTimestamp_Raw_1 + LAPPDTSCorrection_1) * 3.125 + LAPPDOffset_1; + + m_data->CStore.Get("BG_PPSBefore_1", LAPPDBG_PPSBefore_1); + m_data->CStore.Get("BG_PPSAfter_1", LAPPDBG_PPSAfter_1); + m_data->CStore.Get("BG_PPSDiff_1", LAPPDBG_PPSDiff_1); + m_data->CStore.Get("BG_PPSMissing_1", LAPPDBG_PPSMissing_1); + m_data->CStore.Get("TS_PPSBefore_1", LAPPDTS_PPSBefore_1); + m_data->CStore.Get("TS_PPSAfter_1", LAPPDTS_PPSAfter_1); + m_data->CStore.Get("TS_PPSDiff_1", LAPPDTS_PPSDiff_1); + m_data->CStore.Get("TS_PPSMissing_1", LAPPDTS_PPSMissing_1); if (verbosityEBLAPPD > 1) { - cout << "Processing new LAPPD data from store" << endl; - cout << "Got info: LAPPDBeamgate_Raw: " << LAPPDBeamgate_Raw << ", LAPPDTimestamp_Raw: " << LAPPDTimestamp_Raw << ", LAPPDBGCorrection: " << LAPPDBGCorrection << ", LAPPDTSCorrection: " << LAPPDTSCorrection << ", LAPPDOffset: " << LAPPDOffset << ", LAPPDOffset_minus_ps: " << LAPPDOffset_minus_ps << ", LAPPDBG_PPSBefore: " << LAPPDBG_PPSBefore << ", LAPPDBG_PPSAfter: " << LAPPDBG_PPSAfter << ", LAPPDBG_PPSDiff: " << LAPPDBG_PPSDiff << ", LAPPDBG_PPSMissing: " << LAPPDBG_PPSMissing << ", LAPPDTS_PPSBefore: " << LAPPDTS_PPSBefore << ", LAPPDTS_PPSAfter: " << LAPPDTS_PPSAfter << ", LAPPDTS_PPSDiff: " << LAPPDTS_PPSDiff << ", LAPPDTS_PPSMissing: " << LAPPDTS_PPSMissing << endl; - cout << "LAPPDBeamgate_ns: " << LAPPDBeamgate_ns << endl; - cout << "LAPPDTimestamp_ns: " << LAPPDTimestamp_ns << endl; + std::cout << "Processing new LAPPD data from store" << std::endl; + + // --- Logging Board 0 --- + std::cout << "Got info Board 0: LAPPDBeamgate_Raw: " << LAPPDBeamgate_Raw_0 << ", LAPPDTimestamp_Raw: " << LAPPDTimestamp_Raw_0 + << ", LAPPDBGCorrection: " << LAPPDBGCorrection_0 << ", LAPPDTSCorrection: " << LAPPDTSCorrection_0 + << ", LAPPDOffset: " << LAPPDOffset_0 << ", LAPPDOffset_minus_ps: " << LAPPDOffset_minus_ps_0 + << ", LAPPDBG_PPSBefore: " << LAPPDBG_PPSBefore_0 << ", LAPPDBG_PPSAfter: " << LAPPDBG_PPSAfter_0 + << ", LAPPDBG_PPSDiff: " << LAPPDBG_PPSDiff_0 << ", LAPPDBG_PPSMissing: " << LAPPDBG_PPSMissing_0 + << ", LAPPDTS_PPSBefore: " << LAPPDTS_PPSBefore_0 << ", LAPPDTS_PPSAfter: " << LAPPDTS_PPSAfter_0 + << ", LAPPDTS_PPSDiff: " << LAPPDTS_PPSDiff_0 << ", LAPPDTS_PPSMissing: " << LAPPDTS_PPSMissing_0 << std::endl; + std::cout << "LAPPDBeamgate_ns_0: " << LAPPDBeamgate_ns_0 << std::endl; + std::cout << "LAPPDTimestamp_ns_0: " << LAPPDTimestamp_ns_0 << std::endl; + + // --- Logging Board 1 --- + std::cout << "Got info Board 1: LAPPDBeamgate_Raw: " << LAPPDBeamgate_Raw_1 << ", LAPPDTimestamp_Raw: " << LAPPDTimestamp_Raw_1 + << ", LAPPDBGCorrection: " << LAPPDBGCorrection_1 << ", LAPPDTSCorrection: " << LAPPDTSCorrection_1 + << ", LAPPDOffset: " << LAPPDOffset_1 << ", LAPPDOffset_minus_ps: " << LAPPDOffset_minus_ps_1 + << ", LAPPDBG_PPSBefore: " << LAPPDBG_PPSBefore_1 << ", LAPPDBG_PPSAfter: " << LAPPDBG_PPSAfter_1 + << ", LAPPDBG_PPSDiff: " << LAPPDBG_PPSDiff_1 << ", LAPPDBG_PPSMissing: " << LAPPDBG_PPSMissing_1 + << ", LAPPDTS_PPSBefore: " << LAPPDTS_PPSBefore_1 << ", LAPPDTS_PPSAfter: " << LAPPDTS_PPSAfter_1 + << ", LAPPDTS_PPSDiff: " << LAPPDTS_PPSDiff_1 << ", LAPPDTS_PPSMissing: " << LAPPDTS_PPSMissing_1 << std::endl; + std::cout << "LAPPDBeamgate_ns_1: " << LAPPDBeamgate_ns_1 << std::endl; + std::cout << "LAPPDTimestamp_ns_1: " << LAPPDTimestamp_ns_1 << std::endl; } bool gotdata = m_data->CStore.Get("StoreLoadedLAPPDData", dat); - if (gotdata) { - Buffer_LAPPDTimestamp_ns.push_back(LAPPDTimestamp_ns); - + // Shared buffers Buffer_LAPPDData.push_back(dat); - Buffer_LAPPDBeamgate_ns.push_back(LAPPDBeamgate_ns); - Buffer_LAPPDOffset.push_back(LAPPDOffset); - Buffer_LAPPDBeamgate_Raw.push_back(LAPPDBeamgate_Raw); - Buffer_LAPPDTimestamp_Raw.push_back(LAPPDTimestamp_Raw); - Buffer_LAPPDBGCorrection.push_back(LAPPDBGCorrection); - Buffer_LAPPDTSCorrection.push_back(LAPPDTSCorrection); - Buffer_LAPPDOffset_minus_ps.push_back(LAPPDOffset_minus_ps); Buffer_RunCode.push_back(currentRunCode); - Buffer_LAPPDBG_PPSBefore.push_back(LAPPDBG_PPSBefore); - Buffer_LAPPDBG_PPSAfter.push_back(LAPPDBG_PPSAfter); - Buffer_LAPPDBG_PPSDiff.push_back(LAPPDBG_PPSDiff); - Buffer_LAPPDBG_PPSMissing.push_back(LAPPDBG_PPSMissing); - Buffer_LAPPDTS_PPSBefore.push_back(LAPPDTS_PPSBefore); - Buffer_LAPPDTS_PPSAfter.push_back(LAPPDTS_PPSAfter); - Buffer_LAPPDTS_PPSDiff.push_back(LAPPDTS_PPSDiff); - Buffer_LAPPDTS_PPSMissing.push_back(LAPPDTS_PPSMissing); - - MatchBuffer_LAPPDTimestamp_ns.push_back(LAPPDTimestamp_ns); - - if (LAPPDTS_PPSMissing != LAPPDBG_PPSMissing) - Log("EBLAPPD: PPS missing in BG and TS are different, BG: " + std::to_string(LAPPDBG_PPSMissing) + ", TS: " + std::to_string(LAPPDTS_PPSMissing), v_warning, verbosityEBLAPPD); + // --- Push all Board 0 buffers --- + Buffer_LAPPDTimestamp_ns_0.push_back(LAPPDTimestamp_ns_0); + Buffer_LAPPDBeamgate_ns_0.push_back(LAPPDBeamgate_ns_0); + Buffer_LAPPDOffset_0.push_back(LAPPDOffset_0); + Buffer_LAPPDBeamgate_Raw_0.push_back(LAPPDBeamgate_Raw_0); + Buffer_LAPPDTimestamp_Raw_0.push_back(LAPPDTimestamp_Raw_0); + Buffer_LAPPDBGCorrection_0.push_back(LAPPDBGCorrection_0); + Buffer_LAPPDTSCorrection_0.push_back(LAPPDTSCorrection_0); + Buffer_LAPPDOffset_minus_ps_0.push_back(LAPPDOffset_minus_ps_0); + + Buffer_LAPPDBG_PPSBefore_0.push_back(LAPPDBG_PPSBefore_0); + Buffer_LAPPDBG_PPSAfter_0.push_back(LAPPDBG_PPSAfter_0); + Buffer_LAPPDBG_PPSDiff_0.push_back(LAPPDBG_PPSDiff_0); + Buffer_LAPPDBG_PPSMissing_0.push_back(LAPPDBG_PPSMissing_0); + Buffer_LAPPDTS_PPSBefore_0.push_back(LAPPDTS_PPSBefore_0); + Buffer_LAPPDTS_PPSAfter_0.push_back(LAPPDTS_PPSAfter_0); + Buffer_LAPPDTS_PPSDiff_0.push_back(LAPPDTS_PPSDiff_0); + Buffer_LAPPDTS_PPSMissing_0.push_back(LAPPDTS_PPSMissing_0); + + MatchBuffer_LAPPDTimestamp_ns_0.push_back(LAPPDTimestamp_ns_0); + + // --- Push all Board 1 buffers --- + Buffer_LAPPDTimestamp_ns_1.push_back(LAPPDTimestamp_ns_1); + Buffer_LAPPDBeamgate_ns_1.push_back(LAPPDBeamgate_ns_1); + Buffer_LAPPDOffset_1.push_back(LAPPDOffset_1); + Buffer_LAPPDBeamgate_Raw_1.push_back(LAPPDBeamgate_Raw_1); + Buffer_LAPPDTimestamp_Raw_1.push_back(LAPPDTimestamp_Raw_1); + Buffer_LAPPDBGCorrection_1.push_back(LAPPDBGCorrection_1); + Buffer_LAPPDTSCorrection_1.push_back(LAPPDTSCorrection_1); + Buffer_LAPPDOffset_minus_ps_1.push_back(LAPPDOffset_minus_ps_1); + + Buffer_LAPPDBG_PPSBefore_1.push_back(LAPPDBG_PPSBefore_1); + Buffer_LAPPDBG_PPSAfter_1.push_back(LAPPDBG_PPSAfter_1); + Buffer_LAPPDBG_PPSDiff_1.push_back(LAPPDBG_PPSDiff_1); + Buffer_LAPPDBG_PPSMissing_1.push_back(LAPPDBG_PPSMissing_1); + Buffer_LAPPDTS_PPSBefore_1.push_back(LAPPDTS_PPSBefore_1); + Buffer_LAPPDTS_PPSAfter_1.push_back(LAPPDTS_PPSAfter_1); + Buffer_LAPPDTS_PPSDiff_1.push_back(LAPPDTS_PPSDiff_1); + Buffer_LAPPDTS_PPSMissing_1.push_back(LAPPDTS_PPSMissing_1); + + MatchBuffer_LAPPDTimestamp_ns_1.push_back(LAPPDTimestamp_ns_1); + + if (LAPPDTS_PPSMissing_0 != LAPPDBG_PPSMissing_0) + Log("EBLAPPD: PPS missing in BG and TS are different for Board 0, BG: " + std::to_string(LAPPDBG_PPSMissing_0) + ", TS: " + std::to_string(LAPPDTS_PPSMissing_0), + v_warning, verbosityEBLAPPD); + + if (LAPPDTS_PPSMissing_1 != LAPPDBG_PPSMissing_1) + Log("EBLAPPD: PPS missing in BG and TS are different for Board 1, BG: " + std::to_string(LAPPDBG_PPSMissing_1) + ", TS: " + std::to_string(LAPPDTS_PPSMissing_1), + v_warning, verbosityEBLAPPD); Log("EBLAPPD: Loaded LAPPD data to buffer, Buffer_LAPPDData size after this load is now " + std::to_string(Buffer_LAPPDData.size()), v_message, verbosityEBLAPPD); } @@ -281,101 +397,127 @@ bool EBLAPPD::Matching(int targetTrigger, int matchToTrack) std::map>> GroupedTriggersInTotal; // each map is a group of triggers, with the key is the target trigger word m_data->CStore.Get("GroupedTriggersInTotal", GroupedTriggersInTotal); - // print how many trigger groups in each track vector matchedLAPPDTimes; vector indexToRemove; std::map matchedNumberInTrack; - // loop the LAPPDDataBuffer keys, and loop all the grouped triggers - // in each group of trigger, find the target trigger word and it's time - // fine the minimum time difference, if smaller than matchTolerance_ns, then save the time to PairedCTCTimeStamps and PairedLAPPDTimeStamps - for (int i = 0; i < MatchBuffer_LAPPDTimestamp_ns.size(); i++) + // Loop over the LAPPDDataBuffer keys, and all the grouped triggers + // in each group of trigger, find the target trigger word and its time + // find the minimum time difference, if smaller than matchTolerance_ns, then save the time to PairedCTCTimeStamps and PairedLAPPDTimeStamps + + // We loop based on the size of Board 0's buffer (Board 1 is identical in size) + for (int i = 0; i < MatchBuffer_LAPPDTimestamp_ns_0.size(); i++) { - uint64_t LAPPDtime = MatchBuffer_LAPPDTimestamp_ns.at(i); - // if found LAPPDtime at PairedLAPPDTimeStamps, skip //shouldn't happen - if (std::find(PairedLAPPDTimeStamps[matchToTrack].begin(), PairedLAPPDTimeStamps[matchToTrack].end(), LAPPDtime) != PairedLAPPDTimeStamps[matchToTrack].end()) + + uint64_t LAPPDtime_0 = MatchBuffer_LAPPDTimestamp_ns_0.at(i); + uint64_t LAPPDtime_1 = MatchBuffer_LAPPDTimestamp_ns_1.at(i); + + // If found LAPPDtime at PairedLAPPDTimeStamps, skip + // Shouldn't happen + bool already_matched = + (std::find(PairedLAPPDTimeStamps[matchToTrack].begin(), PairedLAPPDTimeStamps[matchToTrack].end(), LAPPDtime_0) != PairedLAPPDTimeStamps[matchToTrack].end()) || + (std::find(PairedLAPPDTimeStamps[matchToTrack].begin(), PairedLAPPDTimeStamps[matchToTrack].end(), LAPPDtime_1) != PairedLAPPDTimeStamps[matchToTrack].end()); + + if (already_matched) { - Log("EBLAPPD: Buffer " + std::to_string(i) + " with time " + std::to_string(Buffer_LAPPDTimestamp_ns.at(i)) + ": Found a match already", v_message, verbosityEBLAPPD); - continue; + Log("EBLAPPD: Buffer " + std::to_string(i) + " with time " + std::to_string(Buffer_LAPPDTimestamp_ns_0.at(i)) + ": Found a match already", + v_message, verbosityEBLAPPD); + continue; } - // set minDT to 5 min - uint64_t minDT = 5 * 60 * 1e9; + // set minDT to 5 minutes + uint64_t minDT = 5ULL * 60ULL * 1000000000ULL; uint64_t minDTTrigger = 0; - uint64_t dt = 0; uint32_t matchedTrigWord = 0; int matchedTrack = 0; int matchedIndex = 0; + // We will keep track of which board actually provided the best match + uint64_t matchedLAPPDTime = 0; + std::string winningBoard = ""; + for (const std::pair>>& pair : GroupedTriggersInTotal) { - int TrackTriggerWord = pair.first; - if (matchedNumberInTrack.find(TrackTriggerWord) == matchedNumberInTrack.end()) - matchedNumberInTrack.emplace(TrackTriggerWord, 0); - if (TrackTriggerWord != matchToTrack && !matchToAllTriggers) - { - // Log("EBLAPPD: Skipping TrackTriggerWord " + std::to_string(TrackTriggerWord), v_debug, verbosityEBLAPPD); - continue; - } - const vector>& GroupedTriggers = pair.second; - - for (int j = 0; j < GroupedTriggers.size(); j++) - { - const map& groupedTrigger = GroupedTriggers.at(j); - // itearte over all the grouped triggers, if the value is target trigger, then calculate the time difference - for (const std::pair& p : groupedTrigger) + int TrackTriggerWord = pair.first; + if (matchedNumberInTrack.find(TrackTriggerWord) == matchedNumberInTrack.end()) + matchedNumberInTrack.emplace(TrackTriggerWord, 0); + + if (TrackTriggerWord != matchToTrack && !matchToAllTriggers) { - if (matchToAllTriggers || p.second == targetTrigger) - { - - if (LAPPDtime > p.first) - { - dt = LAPPDtime - p.first; - } - else - { - dt = p.first - LAPPDtime; - } - if (dt < minDT) + // Log("EBLAPPD: Skipping TrackTriggerWord " + std::to_string(TrackTriggerWord), v_debug, verbosityEBLAPPD); + continue; + } + + const vector>& GroupedTriggers = pair.second; + for (int j = 0; j < GroupedTriggers.size(); j++) + { + const map& groupedTrigger = GroupedTriggers.at(j); + + // Iterate over all the grouped triggers, if the value is target trigger, then calculate the time difference + for (const std::pair& p : groupedTrigger) { - minDT = dt; - minDTTrigger = p.first; - matchedTrigWord = p.second; - matchedTrack = TrackTriggerWord; - matchedIndex = j; + if (matchToAllTriggers || p.second == targetTrigger) + { + // Compute dt for both boards + uint64_t dt_0 = (LAPPDtime_0 > p.first) ? (LAPPDtime_0 - p.first) : (p.first - LAPPDtime_0); + uint64_t dt_1 = (LAPPDtime_1 > p.first) ? (LAPPDtime_1 - p.first) : (p.first - LAPPDtime_1); + + // Find the best dt between the two boards + uint64_t current_min_dt = std::min(dt_0, dt_1); + uint64_t current_best_time = (dt_0 < dt_1) ? LAPPDtime_0 : LAPPDtime_1; + std::string current_winning_board = (dt_0 < dt_1) ? "Board 0" : "Board 1"; + + if (current_min_dt < minDT) + { + minDT = current_min_dt; + minDTTrigger = p.first; + matchedTrigWord = p.second; + matchedTrack = TrackTriggerWord; + matchedIndex = j; + matchedLAPPDTime = current_best_time; + winningBoard = current_winning_board; + } + } } - } } - } } - Log("EBLAPPD: at buffer " + std::to_string(i) + " with time " + std::to_string(Buffer_LAPPDTimestamp_ns.at(i)) + ", minDT: " + std::to_string(minDT), v_debug, verbosityEBLAPPD); + Log("EBLAPPD: at buffer " + std::to_string(i) + " with times [B0: " + std::to_string(LAPPDtime_0) + ", B1: " + std::to_string(LAPPDtime_1) + "], minDT: " + + std::to_string(minDT), v_debug, verbosityEBLAPPD); + if (minDT < matchTolerance_ns) { PairedCTCTimeStamps[matchedTrack].push_back(minDTTrigger); - PairedLAPPDTimeStamps[matchedTrack].push_back(LAPPDtime); + PairedLAPPDTimeStamps[matchedTrack].push_back(matchedLAPPDTime); PairedLAPPD_TriggerIndex[matchedTrack].push_back(matchedIndex); - matchedLAPPDTimes.push_back(LAPPDtime); + matchedLAPPDTimes.push_back(matchedLAPPDTime); indexToRemove.push_back(i); matchedLAPPDNumber++; matchedNumberInTrack[matchedTrack]++; - Log("EBLAPPD: Buffer " + std::to_string(i) + " with time " + std::to_string(Buffer_LAPPDTimestamp_ns.at(i)) + ": Found a match for LAPPD data at " + std::to_string(LAPPDtime) + " with target trigger at " + std::to_string(minDTTrigger) + " with minDT " + std::to_string(minDT), v_message, verbosityEBLAPPD); + + Log("EBLAPPD: Buffer " + std::to_string(i) + " (" + winningBoard + ") found a match! LAPPD time: " + std::to_string(matchedLAPPDTime) + + ", Target trigger: " + std::to_string(minDTTrigger) + ", minDT: " + std::to_string(minDT), v_message, verbosityEBLAPPD); } } - Log("EBLAPPD: Finished matching LAPPD data with target triggers, " + std::to_string(matchedLAPPDTimes.size()) + " new matched found, total matchedLAPPDNumber = " + std::to_string(matchedLAPPDNumber) + " in buffer size = " + std::to_string(MatchBuffer_LAPPDTimestamp_ns.size()), v_message, verbosityEBLAPPD); + + Log("EBLAPPD: Finished matching LAPPD data with target triggers, " + std::to_string(matchedLAPPDTimes.size()) + + " new matches found, total matchedLAPPDNumber = " + std::to_string(matchedLAPPDNumber) + + " in buffer size = " + std::to_string(MatchBuffer_LAPPDTimestamp_ns_0.size()), v_message, verbosityEBLAPPD); for (int i = indexToRemove.size() - 1; i >= 0; i--) { - MatchBuffer_LAPPDTimestamp_ns.erase(MatchBuffer_LAPPDTimestamp_ns.begin() + indexToRemove.at(i)); + MatchBuffer_LAPPDTimestamp_ns_0.erase(MatchBuffer_LAPPDTimestamp_ns_0.begin() + indexToRemove.at(i)); + MatchBuffer_LAPPDTimestamp_ns_1.erase(MatchBuffer_LAPPDTimestamp_ns_1.begin() + indexToRemove.at(i)); } - Log("EBLAPPD: Finished removing paired LAPPD data from match buffer, MatchBuffer_LAPPDTimestamp_ns size is now " + std::to_string(MatchBuffer_LAPPDTimestamp_ns.size()), v_message, verbosityEBLAPPD); + Log("EBLAPPD: Finished removing paired LAPPD data from match buffers, size is now " + std::to_string(MatchBuffer_LAPPDTimestamp_ns_0.size()), v_message, verbosityEBLAPPD); + // print all elements in matchedNumberInTrack with key and value for (std::pair pair : matchedNumberInTrack) { - Log("EBLAPPD: Match finished, matched number in Track " + std::to_string(pair.first) + " is = " + std::to_string(pair.second), v_message, verbosityEBLAPPD); + Log("EBLAPPD: Match finished, matched number in Track " + std::to_string(pair.first) + " is = " + std::to_string(pair.second), v_message, verbosityEBLAPPD); } return true; diff --git a/UserTools/EBLAPPD/EBLAPPD.h b/UserTools/EBLAPPD/EBLAPPD.h index a1dd6cfa3..1deeb1ad7 100644 --- a/UserTools/EBLAPPD/EBLAPPD.h +++ b/UserTools/EBLAPPD/EBLAPPD.h @@ -15,6 +15,8 @@ * $Date: 2024/04 $ * Contact: yuef@iaistate.edu * + * Updated by: Anuj gupta (2026.09.03) + * */ class EBLAPPD : public Tool @@ -35,45 +37,84 @@ class EBLAPPD : public Tool int exePerMatch; PsecData dat; - uint64_t LAPPDBeamgate_ns; - uint64_t LAPPDTimestamp_ns; - uint64_t LAPPDOffset; - unsigned long LAPPDBeamgate_Raw; - unsigned long LAPPDTimestamp_Raw; - int LAPPDBGCorrection; - int LAPPDTSCorrection; - int LAPPDOffset_minus_ps; - uint64_t LAPPDBG_PPSBefore; - uint64_t LAPPDBG_PPSAfter; - uint64_t LAPPDBG_PPSDiff; - int LAPPDBG_PPSMissing; - uint64_t LAPPDTS_PPSBefore; - uint64_t LAPPDTS_PPSAfter; - uint64_t LAPPDTS_PPSDiff; - int LAPPDTS_PPSMissing; - - vector MatchBuffer_LAPPDTimestamp_ns; // used to indexing data for unmatched + + uint64_t LAPPDBeamgate_ns_0; + uint64_t LAPPDTimestamp_ns_0; + uint64_t LAPPDOffset_0; + unsigned long LAPPDBeamgate_Raw_0; + unsigned long LAPPDTimestamp_Raw_0; + int LAPPDBGCorrection_0; + int LAPPDTSCorrection_0; + int LAPPDOffset_minus_ps_0; + uint64_t LAPPDBG_PPSBefore_0; + uint64_t LAPPDBG_PPSAfter_0; + uint64_t LAPPDBG_PPSDiff_0; + int LAPPDBG_PPSMissing_0; + uint64_t LAPPDTS_PPSBefore_0; + uint64_t LAPPDTS_PPSAfter_0; + uint64_t LAPPDTS_PPSDiff_0; + int LAPPDTS_PPSMissing_0; + + uint64_t LAPPDBeamgate_ns_1; + uint64_t LAPPDTimestamp_ns_1; + uint64_t LAPPDOffset_1; + unsigned long LAPPDBeamgate_Raw_1; + unsigned long LAPPDTimestamp_Raw_1; + int LAPPDBGCorrection_1; + int LAPPDTSCorrection_1; + int LAPPDOffset_minus_ps_1; + uint64_t LAPPDBG_PPSBefore_1; + uint64_t LAPPDBG_PPSAfter_1; + uint64_t LAPPDBG_PPSDiff_1; + int LAPPDBG_PPSMissing_1; + uint64_t LAPPDTS_PPSBefore_1; + uint64_t LAPPDTS_PPSAfter_1; + uint64_t LAPPDTS_PPSDiff_1; + int LAPPDTS_PPSMissing_1; + + vector MatchBuffer_LAPPDTimestamp_ns_0; // used to indexing data for unmatched + vector MatchBuffer_LAPPDTimestamp_ns_1; // TODO, maybe make a new "LAPPDBuildData" class? - vector Buffer_LAPPDTimestamp_ns; // used to indexing the data + // Shared buffers vector Buffer_LAPPDData; - vector Buffer_LAPPDBeamgate_ns; - vector Buffer_LAPPDOffset; - vector Buffer_LAPPDBeamgate_Raw; - vector Buffer_LAPPDTimestamp_Raw; - vector Buffer_LAPPDBGCorrection; - vector Buffer_LAPPDTSCorrection; - vector Buffer_LAPPDOffset_minus_ps; vector Buffer_RunCode; - vector Buffer_LAPPDBG_PPSBefore; - vector Buffer_LAPPDBG_PPSAfter; - vector Buffer_LAPPDBG_PPSDiff; - vector Buffer_LAPPDBG_PPSMissing; - vector Buffer_LAPPDTS_PPSBefore; - vector Buffer_LAPPDTS_PPSAfter; - vector Buffer_LAPPDTS_PPSDiff; - vector Buffer_LAPPDTS_PPSMissing; + vector Buffer_LAPPDTimestamp_ns_0; + vector Buffer_LAPPDBeamgate_ns_0; + vector Buffer_LAPPDOffset_0; + vector Buffer_LAPPDBeamgate_Raw_0; + vector Buffer_LAPPDTimestamp_Raw_0; + vector Buffer_LAPPDBGCorrection_0; + vector Buffer_LAPPDTSCorrection_0; + vector Buffer_LAPPDOffset_minus_ps_0; + vector Buffer_LAPPDBG_PPSBefore_0; + vector Buffer_LAPPDBG_PPSAfter_0; + vector Buffer_LAPPDBG_PPSDiff_0; + vector Buffer_LAPPDBG_PPSMissing_0; + vector Buffer_LAPPDTS_PPSBefore_0; + vector Buffer_LAPPDTS_PPSAfter_0; + vector Buffer_LAPPDTS_PPSDiff_0; + vector Buffer_LAPPDTS_PPSMissing_0; + + + vector Buffer_LAPPDTimestamp_ns_1; + vector Buffer_LAPPDBeamgate_ns_1; + vector Buffer_LAPPDOffset_1; + vector Buffer_LAPPDBeamgate_Raw_1; + vector Buffer_LAPPDTimestamp_Raw_1; + vector Buffer_LAPPDBGCorrection_1; + vector Buffer_LAPPDTSCorrection_1; + vector Buffer_LAPPDOffset_minus_ps_1; + vector Buffer_LAPPDBG_PPSBefore_1; + vector Buffer_LAPPDBG_PPSAfter_1; + vector Buffer_LAPPDBG_PPSDiff_1; + vector Buffer_LAPPDBG_PPSMissing_1; + vector Buffer_LAPPDTS_PPSBefore_1; + vector Buffer_LAPPDTS_PPSAfter_1; + vector Buffer_LAPPDTS_PPSDiff_1; + vector Buffer_LAPPDTS_PPSMissing_1; + std::map> PairedCTCTimeStamps; std::map> PairedLAPPD_TriggerIndex; std::map> PairedLAPPDTimeStamps; diff --git a/UserTools/EBSaver/EBSaver.cpp b/UserTools/EBSaver/EBSaver.cpp index 8621243ac..05a5844e5 100644 --- a/UserTools/EBSaver/EBSaver.cpp +++ b/UserTools/EBSaver/EBSaver.cpp @@ -197,11 +197,16 @@ bool EBSaver::Execute() cout << i << ": " << times[i] << ", "; } // print everything in Buffer_LAPPDTimestamp_ns for debug - Log("EBSaver: Buffer_LAPPDTimestamp_ns size " + std::to_string(Buffer_LAPPDTimestamp_ns.size()), v_message, verbosityEBSaver); - for (int i = 0; i < Buffer_LAPPDTimestamp_ns.size(); i++) - cout << i << ": " << Buffer_LAPPDTimestamp_ns[i] << ", "; + Log("EBSaver: Buffer_LAPPDTimestamp_ns_0 size " + std::to_string(Buffer_LAPPDTimestamp_ns_0.size()), v_message, verbosityEBSaver); + for (int i = 0; i < Buffer_LAPPDTimestamp_ns_0.size(); i++) + cout << i << ": " << Buffer_LAPPDTimestamp_ns_0[i] << ", "; cout << endl; + Log("EBSaver: Buffer_LAPPDTimestamp_ns_1 size " + std::to_string(Buffer_LAPPDTimestamp_ns_1.size()), v_message, verbosityEBSaver); + for (int i = 0; i < Buffer_LAPPDTimestamp_ns_1.size(); i++) + cout << i << ": " << Buffer_LAPPDTimestamp_ns_1[i] << ", "; + cout << endl; + // delete LAPPD related timestamps int removedLAPPD = 0; for (auto const &track : LAPPDPairInfoToRemoveTime) @@ -376,7 +381,7 @@ bool EBSaver::Finalise() // count how many events not built for each trigger word if (verbosityEBSaver > 9) { - std::map unbuiltEvents; + std::map unbuiltEvents; for (int i = 0; i < track.second.size(); i++) { if (PairedLAPPDTimeStamps[track.first][i] != 0) @@ -389,9 +394,10 @@ bool EBSaver::Finalise() Log("EBSaver: left event number: ***********", v_message, verbosityEBSaver); Log("EBSaver: left PMT events in original data buffer " + std::to_string(InProgressHits->size()), v_message, verbosityEBSaver); Log("EBSaver: left MRD events in original data buffer " + std::to_string(MRDEvents.size()), v_message, verbosityEBSaver); - Log("EBSaver: left LAPPD events in original data buffer " + std::to_string(Buffer_LAPPDTimestamp_ns.size()), v_message, verbosityEBSaver); - // print the size of each track of - + Log("EBSaver: left LAPPD events in original data buffer (Board 0) " + std::to_string(Buffer_LAPPDTimestamp_ns_0.size()), v_message, verbosityEBSaver); + Log("EBSaver: left LAPPD events in original data buffer (Board 1) " + std::to_string(Buffer_LAPPDTimestamp_ns_1.size()), v_message, verbosityEBSaver); + + // print the size of each track // add debug print for the left MRD, print TriggerTimeWithoutMRD and PairedMRDTimeStamps to two txt file std::ofstream TriggerTimeWithoutMRDFile; TriggerTimeWithoutMRDFile.open("EBdebug_TriggerTimeWithoutMRD.txt"); @@ -862,8 +868,12 @@ bool EBSaver::SaveMRDData(uint64_t MRDTime) bool EBSaver::SaveLAPPDData(uint64_t LAPPDTime) { Log("EBSaver: Saving LAPPD data with LAPPDTime " + std::to_string(LAPPDTime), v_debug, verbosityEBSaver); - // find LAPPDTime in Buffer_LAPPDTimestamp_ns, if not found, return false - if (std::find(Buffer_LAPPDTimestamp_ns.begin(), Buffer_LAPPDTimestamp_ns.end(), LAPPDTime) == Buffer_LAPPDTimestamp_ns.end()) + + // find LAPPDTime in either board's timestamp buffer, if not found in both, return false + bool found_in_0 = std::find(Buffer_LAPPDTimestamp_ns_0.begin(), Buffer_LAPPDTimestamp_ns_0.end(), LAPPDTime) != Buffer_LAPPDTimestamp_ns_0.end(); + bool found_in_1 = std::find(Buffer_LAPPDTimestamp_ns_1.begin(), Buffer_LAPPDTimestamp_ns_1.end(), LAPPDTime) != Buffer_LAPPDTimestamp_ns_1.end(); + + if (!found_in_0 && !found_in_1) { Log("EBSaver: LAPPD data with LAPPDTime " + std::to_string(LAPPDTime) + " not found in Buffer_LAPPDTimestamp_ns", v_debug, verbosityEBSaver); return false; @@ -871,9 +881,9 @@ bool EBSaver::SaveLAPPDData(uint64_t LAPPDTime) // find the index of the LAPPDTime in PairedLAPPDTimeStamps int index = -1; - for (int i = 0; i < Buffer_LAPPDTimestamp_ns.size(); i++) + for (int i = 0; i < Buffer_LAPPDTimestamp_ns_0.size(); i++) { - if (Buffer_LAPPDTimestamp_ns.at(i) == LAPPDTime) + if (Buffer_LAPPDTimestamp_ns_0.at(i) == LAPPDTime || Buffer_LAPPDTimestamp_ns_1.at(i) == LAPPDTime) { index = i; break; @@ -884,102 +894,197 @@ bool EBSaver::SaveLAPPDData(uint64_t LAPPDTime) if (index != -1) { std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; - std::map LAPPDBG_PPSBefore; - std::map LAPPDBG_PPSAfter; - std::map LAPPDBG_PPSDiff; - std::map LAPPDBG_PPSMissing; - std::map LAPPDTS_PPSBefore; - std::map LAPPDTS_PPSAfter; - std::map LAPPDTS_PPSDiff; - std::map LAPPDTS_PPSMissing; - bool gotMap = ANNIEEvent->Get("LAPPDDataMap", LAPPDDataMap); - bool gotBeamgates_ns = ANNIEEvent->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - bool gotTimeStamps_ns = ANNIEEvent->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - bool gotTimeStampsRaw = ANNIEEvent->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - bool gotBeamgatesRaw = ANNIEEvent->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - bool gotOffsets = ANNIEEvent->Get("LAPPDOffsets", LAPPDOffsets); - bool gotTSCorrection = ANNIEEvent->Get("LAPPDTSCorrection", LAPPDTSCorrection); - bool gotDBGCorrection = ANNIEEvent->Get("LAPPDBGCorrection", LAPPDBGCorrection); - bool gotOSInMinusPS = ANNIEEvent->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); - bool gotBG_PPSBefore = ANNIEEvent->Get("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - bool gotBG_PPSAfter = ANNIEEvent->Get("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - bool gotBG_PPSDiff = ANNIEEvent->Get("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - bool gotBG_PPSMissing = ANNIEEvent->Get("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - bool gotTS_PPSBefore = ANNIEEvent->Get("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - bool gotTS_PPSAfter = ANNIEEvent->Get("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - bool gotTS_PPSDiff = ANNIEEvent->Get("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - bool gotTS_PPSMissing = ANNIEEvent->Get("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); - LAPPDDataMap.emplace(LAPPDTime, Buffer_LAPPDData.at(index)); - LAPPDBeamgate_ns.emplace(LAPPDTime, Buffer_LAPPDBeamgate_ns.at(index)); - LAPPDTimeStamps_ns.emplace(LAPPDTime, Buffer_LAPPDTimestamp_ns.at(index)); - LAPPDTimeStampsRaw.emplace(LAPPDTime, Buffer_LAPPDTimestamp_Raw.at(index)); - LAPPDBeamgatesRaw.emplace(LAPPDTime, Buffer_LAPPDBeamgate_Raw.at(index)); - LAPPDOffsets.emplace(LAPPDTime, Buffer_LAPPDOffset.at(index)); - LAPPDTSCorrection.emplace(LAPPDTime, Buffer_LAPPDTSCorrection.at(index)); - LAPPDBGCorrection.emplace(LAPPDTime, Buffer_LAPPDBGCorrection.at(index)); - LAPPDOSInMinusPS.emplace(LAPPDTime, Buffer_LAPPDOffset_minus_ps.at(index)); - LAPPDBG_PPSBefore.emplace(LAPPDTime, Buffer_LAPPDBG_PPSBefore.at(index)); - LAPPDBG_PPSAfter.emplace(LAPPDTime, Buffer_LAPPDBG_PPSAfter.at(index)); - LAPPDBG_PPSDiff.emplace(LAPPDTime, Buffer_LAPPDBG_PPSDiff.at(index)); - LAPPDBG_PPSMissing.emplace(LAPPDTime, Buffer_LAPPDBG_PPSMissing.at(index)); - LAPPDTS_PPSBefore.emplace(LAPPDTime, Buffer_LAPPDTS_PPSBefore.at(index)); - LAPPDTS_PPSAfter.emplace(LAPPDTime, Buffer_LAPPDTS_PPSAfter.at(index)); - LAPPDTS_PPSDiff.emplace(LAPPDTime, Buffer_LAPPDTS_PPSDiff.at(index)); - LAPPDTS_PPSMissing.emplace(LAPPDTime, Buffer_LAPPDTS_PPSMissing.at(index)); - - if (Buffer_LAPPDTS_PPSMissing.at(index) != Buffer_LAPPDBG_PPSMissing.at(index)) + + // --- Board 0 --- + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + std::map LAPPDBG_PPSBefore_0; + std::map LAPPDBG_PPSAfter_0; + std::map LAPPDBG_PPSDiff_0; + std::map LAPPDBG_PPSMissing_0; + std::map LAPPDTS_PPSBefore_0; + std::map LAPPDTS_PPSAfter_0; + std::map LAPPDTS_PPSDiff_0; + std::map LAPPDTS_PPSMissing_0; + + // --- Board 1 --- + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; + std::map LAPPDBG_PPSBefore_1; + std::map LAPPDBG_PPSAfter_1; + std::map LAPPDBG_PPSDiff_1; + std::map LAPPDBG_PPSMissing_1; + std::map LAPPDTS_PPSBefore_1; + std::map LAPPDTS_PPSAfter_1; + std::map LAPPDTS_PPSDiff_1; + std::map LAPPDTS_PPSMissing_1; + + bool gotBeamgates_ns_0 = ANNIEEvent->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + bool gotTimeStamps_ns_0 = ANNIEEvent->Get("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + bool gotTimeStampsRaw_0 = ANNIEEvent->Get("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + bool gotBeamgatesRaw_0 = ANNIEEvent->Get("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + bool gotOffsets_0 = ANNIEEvent->Get("LAPPDOffsets_0", LAPPDOffsets_0); + bool gotTSCorrection_0 = ANNIEEvent->Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + bool gotDBGCorrection_0 = ANNIEEvent->Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + bool gotOSInMinusPS_0 = ANNIEEvent->Get("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + bool gotBG_PPSBefore_0 = ANNIEEvent->Get("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + bool gotBG_PPSAfter_0 = ANNIEEvent->Get("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + bool gotBG_PPSDiff_0 = ANNIEEvent->Get("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + bool gotBG_PPSMissing_0 = ANNIEEvent->Get("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + bool gotTS_PPSBefore_0 = ANNIEEvent->Get("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + bool gotTS_PPSAfter_0 = ANNIEEvent->Get("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + bool gotTS_PPSDiff_0 = ANNIEEvent->Get("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + bool gotTS_PPSMissing_0 = ANNIEEvent->Get("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + bool gotBeamgates_ns_1 = ANNIEEvent->Get("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + bool gotTimeStamps_ns_1 = ANNIEEvent->Get("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + bool gotTimeStampsRaw_1 = ANNIEEvent->Get("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + bool gotBeamgatesRaw_1 = ANNIEEvent->Get("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + bool gotOffsets_1 = ANNIEEvent->Get("LAPPDOffsets_1", LAPPDOffsets_1); + bool gotTSCorrection_1 = ANNIEEvent->Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + bool gotDBGCorrection_1 = ANNIEEvent->Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + bool gotOSInMinusPS_1 = ANNIEEvent->Get("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + bool gotBG_PPSBefore_1 = ANNIEEvent->Get("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + bool gotBG_PPSAfter_1 = ANNIEEvent->Get("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + bool gotBG_PPSDiff_1 = ANNIEEvent->Get("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + bool gotBG_PPSMissing_1 = ANNIEEvent->Get("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + bool gotTS_PPSBefore_1 = ANNIEEvent->Get("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + bool gotTS_PPSAfter_1 = ANNIEEvent->Get("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + bool gotTS_PPSDiff_1 = ANNIEEvent->Get("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + bool gotTS_PPSMissing_1 = ANNIEEvent->Get("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); + + LAPPDBeamgate_ns_0.emplace(LAPPDTime, Buffer_LAPPDBeamgate_ns_0.at(index)); + LAPPDTimeStamps_ns_0.emplace(LAPPDTime, Buffer_LAPPDTimestamp_ns_0.at(index)); + LAPPDTimeStampsRaw_0.emplace(LAPPDTime, Buffer_LAPPDTimestamp_Raw_0.at(index)); + LAPPDBeamgatesRaw_0.emplace(LAPPDTime, Buffer_LAPPDBeamgate_Raw_0.at(index)); + LAPPDOffsets_0.emplace(LAPPDTime, Buffer_LAPPDOffset_0.at(index)); + LAPPDTSCorrection_0.emplace(LAPPDTime, Buffer_LAPPDTSCorrection_0.at(index)); + LAPPDBGCorrection_0.emplace(LAPPDTime, Buffer_LAPPDBGCorrection_0.at(index)); + LAPPDOSInMinusPS_0.emplace(LAPPDTime, Buffer_LAPPDOffset_minus_ps_0.at(index)); + LAPPDBG_PPSBefore_0.emplace(LAPPDTime, Buffer_LAPPDBG_PPSBefore_0.at(index)); + LAPPDBG_PPSAfter_0.emplace(LAPPDTime, Buffer_LAPPDBG_PPSAfter_0.at(index)); + LAPPDBG_PPSDiff_0.emplace(LAPPDTime, Buffer_LAPPDBG_PPSDiff_0.at(index)); + LAPPDBG_PPSMissing_0.emplace(LAPPDTime, Buffer_LAPPDBG_PPSMissing_0.at(index)); + LAPPDTS_PPSBefore_0.emplace(LAPPDTime, Buffer_LAPPDTS_PPSBefore_0.at(index)); + LAPPDTS_PPSAfter_0.emplace(LAPPDTime, Buffer_LAPPDTS_PPSAfter_0.at(index)); + LAPPDTS_PPSDiff_0.emplace(LAPPDTime, Buffer_LAPPDTS_PPSDiff_0.at(index)); + LAPPDTS_PPSMissing_0.emplace(LAPPDTime, Buffer_LAPPDTS_PPSMissing_0.at(index)); + + LAPPDBeamgate_ns_1.emplace(LAPPDTime, Buffer_LAPPDBeamgate_ns_1.at(index)); + LAPPDTimeStamps_ns_1.emplace(LAPPDTime, Buffer_LAPPDTimestamp_ns_1.at(index)); + LAPPDTimeStampsRaw_1.emplace(LAPPDTime, Buffer_LAPPDTimestamp_Raw_1.at(index)); + LAPPDBeamgatesRaw_1.emplace(LAPPDTime, Buffer_LAPPDBeamgate_Raw_1.at(index)); + LAPPDOffsets_1.emplace(LAPPDTime, Buffer_LAPPDOffset_1.at(index)); + LAPPDTSCorrection_1.emplace(LAPPDTime, Buffer_LAPPDTSCorrection_1.at(index)); + LAPPDBGCorrection_1.emplace(LAPPDTime, Buffer_LAPPDBGCorrection_1.at(index)); + LAPPDOSInMinusPS_1.emplace(LAPPDTime, Buffer_LAPPDOffset_minus_ps_1.at(index)); + LAPPDBG_PPSBefore_1.emplace(LAPPDTime, Buffer_LAPPDBG_PPSBefore_1.at(index)); + LAPPDBG_PPSAfter_1.emplace(LAPPDTime, Buffer_LAPPDBG_PPSAfter_1.at(index)); + LAPPDBG_PPSDiff_1.emplace(LAPPDTime, Buffer_LAPPDBG_PPSDiff_1.at(index)); + LAPPDBG_PPSMissing_1.emplace(LAPPDTime, Buffer_LAPPDBG_PPSMissing_1.at(index)); + LAPPDTS_PPSBefore_1.emplace(LAPPDTime, Buffer_LAPPDTS_PPSBefore_1.at(index)); + LAPPDTS_PPSAfter_1.emplace(LAPPDTime, Buffer_LAPPDTS_PPSAfter_1.at(index)); + LAPPDTS_PPSDiff_1.emplace(LAPPDTime, Buffer_LAPPDTS_PPSDiff_1.at(index)); + LAPPDTS_PPSMissing_1.emplace(LAPPDTime, Buffer_LAPPDTS_PPSMissing_1.at(index)); + + if (Buffer_LAPPDTS_PPSMissing_0.at(index) != Buffer_LAPPDBG_PPSMissing_0.at(index)) { - Log("EBSaver: LAPPDTS_PPSMissing is different from LAPPDBG_PPSMissing, LAPPDTS_PPSMissing " + std::to_string(Buffer_LAPPDTS_PPSMissing.at(index)) + " LAPPDBG_PPSMissing " + std::to_string(Buffer_LAPPDBG_PPSMissing.at(index)), v_message, verbosityEBSaver); + Log("EBSaver (Board 0): LAPPDTS_PPSMissing" + std::to_string(Buffer_LAPPDTS_PPSMissing_0.at(index)) + " differs from LAPPDBG_PPSMissing" + + std::to_string(Buffer_LAPPDBG_PPSMissing_0.at(index)), v_message, verbosityEBSaver); + } + + if (Buffer_LAPPDTS_PPSMissing_1.at(index) != Buffer_LAPPDBG_PPSMissing_1.at(index)) + { + Log("EBSaver (Board 1): LAPPDTS_PPSMissing" + std::to_string(Buffer_LAPPDTS_PPSMissing_1.at(index)) + " differs from LAPPDBG_PPSMissing" + + std::to_string(Buffer_LAPPDBG_PPSMissing_1.at(index)), v_message, verbosityEBSaver); } ANNIEEvent->Set("LAPPDDataMap", LAPPDDataMap); - ANNIEEvent->Set("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - ANNIEEvent->Set("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - ANNIEEvent->Set("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - ANNIEEvent->Set("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - ANNIEEvent->Set("LAPPDOffsets", LAPPDOffsets); - ANNIEEvent->Set("LAPPDTSCorrection", LAPPDTSCorrection); - ANNIEEvent->Set("LAPPDBGCorrection", LAPPDBGCorrection); - ANNIEEvent->Set("LAPPDOSInMinusPS", LAPPDOSInMinusPS); - ANNIEEvent->Set("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - ANNIEEvent->Set("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - ANNIEEvent->Set("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - ANNIEEvent->Set("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - ANNIEEvent->Set("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - ANNIEEvent->Set("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - ANNIEEvent->Set("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - ANNIEEvent->Set("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); + ANNIEEvent->Set("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + ANNIEEvent->Set("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + ANNIEEvent->Set("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + ANNIEEvent->Set("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + ANNIEEvent->Set("LAPPDOffsets_0", LAPPDOffsets_0); + ANNIEEvent->Set("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + ANNIEEvent->Set("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + ANNIEEvent->Set("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + ANNIEEvent->Set("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + ANNIEEvent->Set("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + ANNIEEvent->Set("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + ANNIEEvent->Set("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + ANNIEEvent->Set("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + ANNIEEvent->Set("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + ANNIEEvent->Set("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + ANNIEEvent->Set("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + ANNIEEvent->Set("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + ANNIEEvent->Set("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + ANNIEEvent->Set("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + ANNIEEvent->Set("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + ANNIEEvent->Set("LAPPDOffsets_1", LAPPDOffsets_1); + ANNIEEvent->Set("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + ANNIEEvent->Set("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + ANNIEEvent->Set("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + ANNIEEvent->Set("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + ANNIEEvent->Set("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + ANNIEEvent->Set("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + ANNIEEvent->Set("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + ANNIEEvent->Set("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + ANNIEEvent->Set("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + ANNIEEvent->Set("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + ANNIEEvent->Set("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); savedLAPPDNumber++; // erase the built data from original data buffer Buffer_LAPPDData.erase(Buffer_LAPPDData.begin() + index); - Buffer_LAPPDBeamgate_ns.erase(Buffer_LAPPDBeamgate_ns.begin() + index); - Buffer_LAPPDTimestamp_ns.erase(Buffer_LAPPDTimestamp_ns.begin() + index); - Buffer_LAPPDTimestamp_Raw.erase(Buffer_LAPPDTimestamp_Raw.begin() + index); - Buffer_LAPPDBeamgate_Raw.erase(Buffer_LAPPDBeamgate_Raw.begin() + index); - Buffer_LAPPDOffset.erase(Buffer_LAPPDOffset.begin() + index); - Buffer_LAPPDTSCorrection.erase(Buffer_LAPPDTSCorrection.begin() + index); - Buffer_LAPPDBGCorrection.erase(Buffer_LAPPDBGCorrection.begin() + index); - Buffer_LAPPDOffset_minus_ps.erase(Buffer_LAPPDOffset_minus_ps.begin() + index); - Buffer_LAPPDBG_PPSBefore.erase(Buffer_LAPPDBG_PPSBefore.begin() + index); - Buffer_LAPPDBG_PPSAfter.erase(Buffer_LAPPDBG_PPSAfter.begin() + index); - Buffer_LAPPDBG_PPSDiff.erase(Buffer_LAPPDBG_PPSDiff.begin() + index); - Buffer_LAPPDBG_PPSMissing.erase(Buffer_LAPPDBG_PPSMissing.begin() + index); - Buffer_LAPPDTS_PPSBefore.erase(Buffer_LAPPDTS_PPSBefore.begin() + index); - Buffer_LAPPDTS_PPSAfter.erase(Buffer_LAPPDTS_PPSAfter.begin() + index); - Buffer_LAPPDTS_PPSDiff.erase(Buffer_LAPPDTS_PPSDiff.begin() + index); - Buffer_LAPPDTS_PPSMissing.erase(Buffer_LAPPDTS_PPSMissing.begin() + index); + Buffer_LAPPDBeamgate_ns_0.erase(Buffer_LAPPDBeamgate_ns_0.begin() + index); + Buffer_LAPPDTimestamp_ns_0.erase(Buffer_LAPPDTimestamp_ns_0.begin() + index); + Buffer_LAPPDTimestamp_Raw_0.erase(Buffer_LAPPDTimestamp_Raw_0.begin() + index); + Buffer_LAPPDBeamgate_Raw_0.erase(Buffer_LAPPDBeamgate_Raw_0.begin() + index); + Buffer_LAPPDOffset_0.erase(Buffer_LAPPDOffset_0.begin() + index); + Buffer_LAPPDTSCorrection_0.erase(Buffer_LAPPDTSCorrection_0.begin() + index); + Buffer_LAPPDBGCorrection_0.erase(Buffer_LAPPDBGCorrection_0.begin() + index); + Buffer_LAPPDOffset_minus_ps_0.erase(Buffer_LAPPDOffset_minus_ps_0.begin() + index); + Buffer_LAPPDBG_PPSBefore_0.erase(Buffer_LAPPDBG_PPSBefore_0.begin() + index); + Buffer_LAPPDBG_PPSAfter_0.erase(Buffer_LAPPDBG_PPSAfter_0.begin() + index); + Buffer_LAPPDBG_PPSDiff_0.erase(Buffer_LAPPDBG_PPSDiff_0.begin() + index); + Buffer_LAPPDBG_PPSMissing_0.erase(Buffer_LAPPDBG_PPSMissing_0.begin() + index); + Buffer_LAPPDTS_PPSBefore_0.erase(Buffer_LAPPDTS_PPSBefore_0.begin() + index); + Buffer_LAPPDTS_PPSAfter_0.erase(Buffer_LAPPDTS_PPSAfter_0.begin() + index); + Buffer_LAPPDTS_PPSDiff_0.erase(Buffer_LAPPDTS_PPSDiff_0.begin() + index); + Buffer_LAPPDTS_PPSMissing_0.erase(Buffer_LAPPDTS_PPSMissing_0.begin() + index); + + Buffer_LAPPDBeamgate_ns_1.erase(Buffer_LAPPDBeamgate_ns_1.begin() + index); + Buffer_LAPPDTimestamp_ns_1.erase(Buffer_LAPPDTimestamp_ns_1.begin() + index); + Buffer_LAPPDTimestamp_Raw_1.erase(Buffer_LAPPDTimestamp_Raw_1.begin() + index); + Buffer_LAPPDBeamgate_Raw_1.erase(Buffer_LAPPDBeamgate_Raw_1.begin() + index); + Buffer_LAPPDOffset_1.erase(Buffer_LAPPDOffset_1.begin() + index); + Buffer_LAPPDTSCorrection_1.erase(Buffer_LAPPDTSCorrection_1.begin() + index); + Buffer_LAPPDBGCorrection_1.erase(Buffer_LAPPDBGCorrection_1.begin() + index); + Buffer_LAPPDOffset_minus_ps_1.erase(Buffer_LAPPDOffset_minus_ps_1.begin() + index); + Buffer_LAPPDBG_PPSBefore_1.erase(Buffer_LAPPDBG_PPSBefore_1.begin() + index); + Buffer_LAPPDBG_PPSAfter_1.erase(Buffer_LAPPDBG_PPSAfter_1.begin() + index); + Buffer_LAPPDBG_PPSDiff_1.erase(Buffer_LAPPDBG_PPSDiff_1.begin() + index); + Buffer_LAPPDBG_PPSMissing_1.erase(Buffer_LAPPDBG_PPSMissing_1.begin() + index); + Buffer_LAPPDTS_PPSBefore_1.erase(Buffer_LAPPDTS_PPSBefore_1.begin() + index); + Buffer_LAPPDTS_PPSAfter_1.erase(Buffer_LAPPDTS_PPSAfter_1.begin() + index); + Buffer_LAPPDTS_PPSDiff_1.erase(Buffer_LAPPDTS_PPSDiff_1.begin() + index); + Buffer_LAPPDTS_PPSMissing_1.erase(Buffer_LAPPDTS_PPSMissing_1.begin() + index); Log("EBSaver: Saved LAPPD data with LAPPDTime " + std::to_string(LAPPDTime), v_debug, verbosityEBSaver); return true; @@ -1088,35 +1193,76 @@ bool EBSaver::GotAllDataFromOriginalBuffer() bool gotMRDHitMapRunCode = m_data->CStore.Get("MRDHitMapRunCode", MRDHitMapRunCode); if (!gotPairedMRDTriggerTimestamp || !gotPairedMRDTimeStamps || !gotPairedMRD_TriggerIndex || !gotMRDHitMapRunCode) Log("EBSaver: Failed to get MRD match info from buffer", v_message, verbosityEBSaver); - // + // got LAPPD data - bool gotBuffer_LAPPDTimestamp_ns = m_data->CStore.Get("Buffer_LAPPDTimestamp_ns", Buffer_LAPPDTimestamp_ns); + bool gotBuffer_LAPPDTimestamp_ns_0 = m_data->CStore.Get("Buffer_LAPPDTimestamp_ns_0", Buffer_LAPPDTimestamp_ns_0); bool gotBuffer_LAPPDData = m_data->CStore.Get("Buffer_LAPPDData", Buffer_LAPPDData); - bool gotBuffer_LAPPDBeamgate_ns = m_data->CStore.Get("Buffer_LAPPDBeamgate_ns", Buffer_LAPPDBeamgate_ns); - bool gotBuffer_LAPPDOffset = m_data->CStore.Get("Buffer_LAPPDOffset", Buffer_LAPPDOffset); - bool gotBuffer_LAPPDBeamgate_Raw = m_data->CStore.Get("Buffer_LAPPDBeamgate_Raw", Buffer_LAPPDBeamgate_Raw); - bool gotBuffer_LAPPDTimestamp_Raw = m_data->CStore.Get("Buffer_LAPPDTimestamp_Raw", Buffer_LAPPDTimestamp_Raw); - bool gotBuffer_LAPPDBGCorrection = m_data->CStore.Get("Buffer_LAPPDBGCorrection", Buffer_LAPPDBGCorrection); - bool gotBuffer_LAPPDTSCorrection = m_data->CStore.Get("Buffer_LAPPDTSCorrection", Buffer_LAPPDTSCorrection); - bool gotBuffer_LAPPDOffset_minus_ps = m_data->CStore.Get("Buffer_LAPPDOffset_minus_ps", Buffer_LAPPDOffset_minus_ps); - if (!gotBuffer_LAPPDTimestamp_ns || !gotBuffer_LAPPDData || !gotBuffer_LAPPDBeamgate_ns || !gotBuffer_LAPPDOffset || !gotBuffer_LAPPDBeamgate_Raw || !gotBuffer_LAPPDTimestamp_Raw || !gotBuffer_LAPPDBGCorrection || !gotBuffer_LAPPDTSCorrection || !gotBuffer_LAPPDOffset_minus_ps) - Log("EBSaver: Failed to get some LAPPD data from buffer", v_message, verbosityEBSaver); - bool gotBuffer_LAPPDBG_PPSBefore = m_data->CStore.Get("Buffer_LAPPDBG_PPSBefore", Buffer_LAPPDBG_PPSBefore); - bool gotBuffer_LAPPDBG_PPSAfter = m_data->CStore.Get("Buffer_LAPPDBG_PPSAfter", Buffer_LAPPDBG_PPSAfter); - bool gotBuffer_LAPPDBG_PPSDiff = m_data->CStore.Get("Buffer_LAPPDBG_PPSDiff", Buffer_LAPPDBG_PPSDiff); - bool gotBuffer_LAPPDBG_PPSMissing = m_data->CStore.Get("Buffer_LAPPDBG_PPSMissing", Buffer_LAPPDBG_PPSMissing); - bool gotBuffer_LAPPDTS_PPSBefore = m_data->CStore.Get("Buffer_LAPPDTS_PPSBefore", Buffer_LAPPDTS_PPSBefore); - bool gotBuffer_LAPPDTS_PPSAfter = m_data->CStore.Get("Buffer_LAPPDTS_PPSAfter", Buffer_LAPPDTS_PPSAfter); - bool gotBuffer_LAPPDTS_PPSDiff = m_data->CStore.Get("Buffer_LAPPDTS_PPSDiff", Buffer_LAPPDTS_PPSDiff); - bool gotBuffer_LAPPDTS_PPSMissing = m_data->CStore.Get("Buffer_LAPPDTS_PPSMissing", Buffer_LAPPDTS_PPSMissing); - if (!gotBuffer_LAPPDBG_PPSBefore || !gotBuffer_LAPPDBG_PPSAfter || !gotBuffer_LAPPDBG_PPSDiff || !gotBuffer_LAPPDBG_PPSMissing || !gotBuffer_LAPPDTS_PPSBefore || !gotBuffer_LAPPDTS_PPSAfter || !gotBuffer_LAPPDTS_PPSDiff || !gotBuffer_LAPPDTS_PPSMissing) - Log("EBSaver: Failed to get LAPPD PPS data from buffer", v_message, verbosityEBSaver); + bool gotBuffer_LAPPDBeamgate_ns_0 = m_data->CStore.Get("Buffer_LAPPDBeamgate_ns_0", Buffer_LAPPDBeamgate_ns_0); + bool gotBuffer_LAPPDOffset_0 = m_data->CStore.Get("Buffer_LAPPDOffset_0", Buffer_LAPPDOffset_0); + bool gotBuffer_LAPPDBeamgate_Raw_0 = m_data->CStore.Get("Buffer_LAPPDBeamgate_Raw_0", Buffer_LAPPDBeamgate_Raw_0); + bool gotBuffer_LAPPDTimestamp_Raw_0 = m_data->CStore.Get("Buffer_LAPPDTimestamp_Raw_0", Buffer_LAPPDTimestamp_Raw_0); + bool gotBuffer_LAPPDBGCorrection_0 = m_data->CStore.Get("Buffer_LAPPDBGCorrection_0", Buffer_LAPPDBGCorrection_0); + bool gotBuffer_LAPPDTSCorrection_0 = m_data->CStore.Get("Buffer_LAPPDTSCorrection_0", Buffer_LAPPDTSCorrection_0); + bool gotBuffer_LAPPDOffset_minus_ps_0 = m_data->CStore.Get("Buffer_LAPPDOffset_minus_ps_0", Buffer_LAPPDOffset_minus_ps_0); + + if (!gotBuffer_LAPPDTimestamp_ns_0 || !gotBuffer_LAPPDData || !gotBuffer_LAPPDBeamgate_ns_0 || !gotBuffer_LAPPDOffset_0 || + !gotBuffer_LAPPDBeamgate_Raw_0 || !gotBuffer_LAPPDTimestamp_Raw_0 || !gotBuffer_LAPPDBGCorrection_0 || !gotBuffer_LAPPDTSCorrection_0 || + !gotBuffer_LAPPDOffset_minus_ps_0) + { + Log("EBSaver: Failed to get some LAPPD data from buffer for Board 0", v_message, verbosityEBSaver); + } + + bool gotBuffer_LAPPDBG_PPSBefore_0 = m_data->CStore.Get("Buffer_LAPPDBG_PPSBefore_0", Buffer_LAPPDBG_PPSBefore_0); + bool gotBuffer_LAPPDBG_PPSAfter_0 = m_data->CStore.Get("Buffer_LAPPDBG_PPSAfter_0", Buffer_LAPPDBG_PPSAfter_0); + bool gotBuffer_LAPPDBG_PPSDiff_0 = m_data->CStore.Get("Buffer_LAPPDBG_PPSDiff_0", Buffer_LAPPDBG_PPSDiff_0); + bool gotBuffer_LAPPDBG_PPSMissing_0 = m_data->CStore.Get("Buffer_LAPPDBG_PPSMissing_0", Buffer_LAPPDBG_PPSMissing_0); + bool gotBuffer_LAPPDTS_PPSBefore_0 = m_data->CStore.Get("Buffer_LAPPDTS_PPSBefore_0", Buffer_LAPPDTS_PPSBefore_0); + bool gotBuffer_LAPPDTS_PPSAfter_0 = m_data->CStore.Get("Buffer_LAPPDTS_PPSAfter_0", Buffer_LAPPDTS_PPSAfter_0); + bool gotBuffer_LAPPDTS_PPSDiff_0 = m_data->CStore.Get("Buffer_LAPPDTS_PPSDiff_0", Buffer_LAPPDTS_PPSDiff_0); + bool gotBuffer_LAPPDTS_PPSMissing_0 = m_data->CStore.Get("Buffer_LAPPDTS_PPSMissing_0", Buffer_LAPPDTS_PPSMissing_0); + + if (!gotBuffer_LAPPDBG_PPSBefore_0 || !gotBuffer_LAPPDBG_PPSAfter_0 || !gotBuffer_LAPPDBG_PPSDiff_0 || !gotBuffer_LAPPDBG_PPSMissing_0 || + !gotBuffer_LAPPDTS_PPSBefore_0 || !gotBuffer_LAPPDTS_PPSAfter_0 || !gotBuffer_LAPPDTS_PPSDiff_0 || !gotBuffer_LAPPDTS_PPSMissing_0) + { + Log("EBSaver: Failed to get LAPPD PPS data from buffer for Board 0", v_message, verbosityEBSaver); + } + + bool gotBuffer_LAPPDTimestamp_ns_1 = m_data->CStore.Get("Buffer_LAPPDTimestamp_ns_1", Buffer_LAPPDTimestamp_ns_1); + bool gotBuffer_LAPPDBeamgate_ns_1 = m_data->CStore.Get("Buffer_LAPPDBeamgate_ns_1", Buffer_LAPPDBeamgate_ns_1); + bool gotBuffer_LAPPDOffset_1 = m_data->CStore.Get("Buffer_LAPPDOffset_1", Buffer_LAPPDOffset_1); + bool gotBuffer_LAPPDBeamgate_Raw_1 = m_data->CStore.Get("Buffer_LAPPDBeamgate_Raw_1", Buffer_LAPPDBeamgate_Raw_1); + bool gotBuffer_LAPPDTimestamp_Raw_1 = m_data->CStore.Get("Buffer_LAPPDTimestamp_Raw_1", Buffer_LAPPDTimestamp_Raw_1); + bool gotBuffer_LAPPDBGCorrection_1 = m_data->CStore.Get("Buffer_LAPPDBGCorrection_1", Buffer_LAPPDBGCorrection_1); + bool gotBuffer_LAPPDTSCorrection_1 = m_data->CStore.Get("Buffer_LAPPDTSCorrection_1", Buffer_LAPPDTSCorrection_1); + bool gotBuffer_LAPPDOffset_minus_ps_1 = m_data->CStore.Get("Buffer_LAPPDOffset_minus_ps_1", Buffer_LAPPDOffset_minus_ps_1); + + if (!gotBuffer_LAPPDTimestamp_ns_1 || !gotBuffer_LAPPDData || !gotBuffer_LAPPDBeamgate_ns_1 || !gotBuffer_LAPPDOffset_1 || !gotBuffer_LAPPDBeamgate_Raw_1 || + !gotBuffer_LAPPDTimestamp_Raw_1 || !gotBuffer_LAPPDBGCorrection_1 || !gotBuffer_LAPPDTSCorrection_1 || !gotBuffer_LAPPDOffset_minus_ps_1) + { + Log("EBSaver: Failed to get some LAPPD data from buffer for Board 1", v_message, verbosityEBSaver); + } + + bool gotBuffer_LAPPDBG_PPSBefore_1 = m_data->CStore.Get("Buffer_LAPPDBG_PPSBefore_1", Buffer_LAPPDBG_PPSBefore_1); + bool gotBuffer_LAPPDBG_PPSAfter_1 = m_data->CStore.Get("Buffer_LAPPDBG_PPSAfter_1", Buffer_LAPPDBG_PPSAfter_1); + bool gotBuffer_LAPPDBG_PPSDiff_1 = m_data->CStore.Get("Buffer_LAPPDBG_PPSDiff_1", Buffer_LAPPDBG_PPSDiff_1); + bool gotBuffer_LAPPDBG_PPSMissing_1 = m_data->CStore.Get("Buffer_LAPPDBG_PPSMissing_1", Buffer_LAPPDBG_PPSMissing_1); + bool gotBuffer_LAPPDTS_PPSBefore_1 = m_data->CStore.Get("Buffer_LAPPDTS_PPSBefore_1", Buffer_LAPPDTS_PPSBefore_1); + bool gotBuffer_LAPPDTS_PPSAfter_1 = m_data->CStore.Get("Buffer_LAPPDTS_PPSAfter_1", Buffer_LAPPDTS_PPSAfter_1); + bool gotBuffer_LAPPDTS_PPSDiff_1 = m_data->CStore.Get("Buffer_LAPPDTS_PPSDiff_1", Buffer_LAPPDTS_PPSDiff_1); + bool gotBuffer_LAPPDTS_PPSMissing_1 = m_data->CStore.Get("Buffer_LAPPDTS_PPSMissing_1", Buffer_LAPPDTS_PPSMissing_1); + + if (!gotBuffer_LAPPDBG_PPSBefore_1 || !gotBuffer_LAPPDBG_PPSAfter_1 || !gotBuffer_LAPPDBG_PPSDiff_1 || !gotBuffer_LAPPDBG_PPSMissing_1 || + !gotBuffer_LAPPDTS_PPSBefore_1 || !gotBuffer_LAPPDTS_PPSAfter_1 || !gotBuffer_LAPPDTS_PPSDiff_1 || !gotBuffer_LAPPDTS_PPSMissing_1) + { + Log("EBSaver: Failed to get LAPPD PPS data from buffer for Board 1", v_message, verbosityEBSaver); + } // got LAPPD match info bool gotPairedLAPPDTriggerTimestamp = m_data->CStore.Get("PairedLAPPDTriggerTimestamp", PairedLAPPDTriggerTimestamp); bool gotPairedLAPPDTimeStamps = m_data->CStore.Get("PairedLAPPDTimeStamps", PairedLAPPDTimeStamps); bool gotPairedLAPPD_TriggerIndex = m_data->CStore.Get("PairedLAPPD_TriggerIndex", PairedLAPPD_TriggerIndex); bool gotLAPPDRunCode = m_data->CStore.Get("Buffer_LAPPDRunCode", Buffer_LAPPDRunCode); + if (!gotPairedLAPPDTriggerTimestamp || !gotPairedLAPPDTimeStamps || !gotPairedLAPPD_TriggerIndex || !gotLAPPDRunCode) { Log("EBSaver: Failed to get LAPPD match info from buffer", v_message, verbosityEBSaver); @@ -1166,10 +1312,16 @@ bool EBSaver::GotAllDataFromOriginalBuffer() } cout << endl; - // print Buffer_LAPPDBeamgate_ns - Log("EBSaver: got LAPPD pairing information buffer Buffer_LAPPDBeamgate_ns size " + std::to_string(Buffer_LAPPDBeamgate_ns.size()), v_message, verbosityEBSaver); - for (int i = 0; i < Buffer_LAPPDBeamgate_ns.size(); i++) - cout << i << ": " << Buffer_LAPPDBeamgate_ns[i] << ", "; + // print Buffer_LAPPDBeamgate_ns_0 + Log("EBSaver: got LAPPD buffer Buffer_LAPPDBeamgate_ns_0 size " + std::to_string(Buffer_LAPPDBeamgate_ns_0.size()), v_message, verbosityEBSaver); + for (int i = 0; i < Buffer_LAPPDBeamgate_ns_0.size(); i++) + cout << i << ": " << Buffer_LAPPDBeamgate_ns_0[i] << ", "; + cout << endl; + + // print Buffer_LAPPDBeamgate_ns_1 + Log("EBSaver: got LAPPD buffer Buffer_LAPPDBeamgate_ns_1 size " + std::to_string(Buffer_LAPPDBeamgate_ns_1.size()), v_message, verbosityEBSaver); + for (int i = 0; i < Buffer_LAPPDBeamgate_ns_1.size(); i++) + cout << i << ": " << Buffer_LAPPDBeamgate_ns_1[i] << ", "; cout << endl; return true; @@ -1187,39 +1339,63 @@ void EBSaver::SetDataObjects() m_data->CStore.Set("FinishedRawAcqSize", FinishedRawAcqSize); m_data->CStore.Set("RWMRawWaveforms", RWMRawWaveforms); m_data->CStore.Set("BRFRawWaveforms", BRFRawWaveforms); + // set PMT match info m_data->CStore.Set("PairedPMTTriggerTimestamp", PairedPMTTriggerTimestamp); m_data->CStore.Set("PairedPMTTimeStamps", PairedPMTTimeStamps); m_data->CStore.Set("PairedPMT_TriggerIndex", PairedPMT_TriggerIndex); m_data->CStore.Set("PMTHitmapRunCode", PMTHitmapRunCode); + // set MRD data m_data->CStore.Set("MRDEvents", MRDEvents); m_data->CStore.Set("MRDEventTriggerTypes", MRDEventTriggerTypes); m_data->CStore.Set("MRDBeamLoopback", MRDBeamLoopback); m_data->CStore.Set("MRDCosmicLoopback", MRDCosmicLoopback); + // set MRD match info m_data->CStore.Set("PairedMRDTriggerTimestamp", PairedMRDTriggerTimestamp); m_data->CStore.Set("PairedMRDTimeStamps", PairedMRDTimeStamps); m_data->CStore.Set("PairedMRD_TriggerIndex", PairedMRD_TriggerIndex); m_data->CStore.Set("MRDHitMapRunCode", MRDHitMapRunCode); - // set LAPPD data - m_data->CStore.Set("Buffer_LAPPDTimestamp_ns", Buffer_LAPPDTimestamp_ns); + + // --- set LAPPD data (Board 0) --- + m_data->CStore.Set("Buffer_LAPPDTimestamp_ns_0", Buffer_LAPPDTimestamp_ns_0); + m_data->CStore.Set("Buffer_LAPPDBeamgate_ns_0", Buffer_LAPPDBeamgate_ns_0); + m_data->CStore.Set("Buffer_LAPPDOffset_0", Buffer_LAPPDOffset_0); + m_data->CStore.Set("Buffer_LAPPDBeamgate_Raw_0", Buffer_LAPPDBeamgate_Raw_0); + m_data->CStore.Set("Buffer_LAPPDTimestamp_Raw_0", Buffer_LAPPDTimestamp_Raw_0); + m_data->CStore.Set("Buffer_LAPPDBGCorrection_0", Buffer_LAPPDBGCorrection_0); + m_data->CStore.Set("Buffer_LAPPDTSCorrection_0", Buffer_LAPPDTSCorrection_0); + m_data->CStore.Set("Buffer_LAPPDOffset_minus_ps_0", Buffer_LAPPDOffset_minus_ps_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSBefore_0", Buffer_LAPPDBG_PPSBefore_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSAfter_0", Buffer_LAPPDBG_PPSAfter_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSDiff_0", Buffer_LAPPDBG_PPSDiff_0); + m_data->CStore.Set("Buffer_LAPPDBG_PPSMissing_0", Buffer_LAPPDBG_PPSMissing_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSBefore_0", Buffer_LAPPDTS_PPSBefore_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSAfter_0", Buffer_LAPPDTS_PPSAfter_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSDiff_0", Buffer_LAPPDTS_PPSDiff_0); + m_data->CStore.Set("Buffer_LAPPDTS_PPSMissing_0", Buffer_LAPPDTS_PPSMissing_0); + + // --- set LAPPD data (Board 1) --- + m_data->CStore.Set("Buffer_LAPPDTimestamp_ns_1", Buffer_LAPPDTimestamp_ns_1); + m_data->CStore.Set("Buffer_LAPPDBeamgate_ns_1", Buffer_LAPPDBeamgate_ns_1); + m_data->CStore.Set("Buffer_LAPPDOffset_1", Buffer_LAPPDOffset_1); + m_data->CStore.Set("Buffer_LAPPDBeamgate_Raw_1", Buffer_LAPPDBeamgate_Raw_1); + m_data->CStore.Set("Buffer_LAPPDTimestamp_Raw_1", Buffer_LAPPDTimestamp_Raw_1); + m_data->CStore.Set("Buffer_LAPPDBGCorrection_1", Buffer_LAPPDBGCorrection_1); + m_data->CStore.Set("Buffer_LAPPDTSCorrection_1", Buffer_LAPPDTSCorrection_1); + m_data->CStore.Set("Buffer_LAPPDOffset_minus_ps_1", Buffer_LAPPDOffset_minus_ps_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSBefore_1", Buffer_LAPPDBG_PPSBefore_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSAfter_1", Buffer_LAPPDBG_PPSAfter_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSDiff_1", Buffer_LAPPDBG_PPSDiff_1); + m_data->CStore.Set("Buffer_LAPPDBG_PPSMissing_1", Buffer_LAPPDBG_PPSMissing_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSBefore_1", Buffer_LAPPDTS_PPSBefore_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSAfter_1", Buffer_LAPPDTS_PPSAfter_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSDiff_1", Buffer_LAPPDTS_PPSDiff_1); + m_data->CStore.Set("Buffer_LAPPDTS_PPSMissing_1", Buffer_LAPPDTS_PPSMissing_1); + m_data->CStore.Set("Buffer_LAPPDData", Buffer_LAPPDData); - m_data->CStore.Set("Buffer_LAPPDBeamgate_ns", Buffer_LAPPDBeamgate_ns); - m_data->CStore.Set("Buffer_LAPPDOffset", Buffer_LAPPDOffset); - m_data->CStore.Set("Buffer_LAPPDBeamgate_Raw", Buffer_LAPPDBeamgate_Raw); - m_data->CStore.Set("Buffer_LAPPDTimestamp_Raw", Buffer_LAPPDTimestamp_Raw); - m_data->CStore.Set("Buffer_LAPPDBGCorrection", Buffer_LAPPDBGCorrection); - m_data->CStore.Set("Buffer_LAPPDTSCorrection", Buffer_LAPPDTSCorrection); - m_data->CStore.Set("Buffer_LAPPDOffset_minus_ps", Buffer_LAPPDOffset_minus_ps); - m_data->CStore.Set("Buffer_LAPPDBG_PPSBefore", Buffer_LAPPDBG_PPSBefore); - m_data->CStore.Set("Buffer_LAPPDBG_PPSAfter", Buffer_LAPPDBG_PPSAfter); - m_data->CStore.Set("Buffer_LAPPDBG_PPSDiff", Buffer_LAPPDBG_PPSDiff); - m_data->CStore.Set("Buffer_LAPPDBG_PPSMissing", Buffer_LAPPDBG_PPSMissing); - m_data->CStore.Set("Buffer_LAPPDTS_PPSBefore", Buffer_LAPPDTS_PPSBefore); - m_data->CStore.Set("Buffer_LAPPDTS_PPSAfter", Buffer_LAPPDTS_PPSAfter); - m_data->CStore.Set("Buffer_LAPPDTS_PPSDiff", Buffer_LAPPDTS_PPSDiff); - m_data->CStore.Set("Buffer_LAPPDTS_PPSMissing", Buffer_LAPPDTS_PPSMissing); + // set LAPPD match info m_data->CStore.Set("PairedLAPPDTriggerTimestamp", PairedLAPPDTriggerTimestamp); m_data->CStore.Set("PairedLAPPDTimeStamps", PairedLAPPDTimeStamps); @@ -1258,40 +1434,76 @@ void EBSaver::BuildEmptyMRDData() void EBSaver::BuildEmptyLAPPDData() { std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; - std::map LAPPDBG_PPSBefore; - std::map LAPPDBG_PPSAfter; - std::map LAPPDBG_PPSDiff; - std::map LAPPDBG_PPSMissing; - std::map LAPPDTS_PPSBefore; - std::map LAPPDTS_PPSAfter; - std::map LAPPDTS_PPSDiff; - std::map LAPPDTS_PPSMissing; + + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; // key and data may not be same here as we now proceed with dual-ACDC matching + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + std::map LAPPDBG_PPSBefore_0; + std::map LAPPDBG_PPSAfter_0; + std::map LAPPDBG_PPSDiff_0; + std::map LAPPDBG_PPSMissing_0; + std::map LAPPDTS_PPSBefore_0; + std::map LAPPDTS_PPSAfter_0; + std::map LAPPDTS_PPSDiff_0; + std::map LAPPDTS_PPSMissing_0; + + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; + std::map LAPPDBG_PPSBefore_1; + std::map LAPPDBG_PPSAfter_1; + std::map LAPPDBG_PPSDiff_1; + std::map LAPPDBG_PPSMissing_1; + std::map LAPPDTS_PPSBefore_1; + std::map LAPPDTS_PPSAfter_1; + std::map LAPPDTS_PPSDiff_1; + std::map LAPPDTS_PPSMissing_1; ANNIEEvent->Set("LAPPDDataMap", LAPPDDataMap); - ANNIEEvent->Set("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - ANNIEEvent->Set("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - ANNIEEvent->Set("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - ANNIEEvent->Set("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - ANNIEEvent->Set("LAPPDOffsets", LAPPDOffsets); - ANNIEEvent->Set("LAPPDTSCorrection", LAPPDTSCorrection); - ANNIEEvent->Set("LAPPDBGCorrection", LAPPDBGCorrection); - ANNIEEvent->Set("LAPPDOSInMinusPS", LAPPDOSInMinusPS); - ANNIEEvent->Set("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - ANNIEEvent->Set("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - ANNIEEvent->Set("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - ANNIEEvent->Set("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - ANNIEEvent->Set("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - ANNIEEvent->Set("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - ANNIEEvent->Set("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - ANNIEEvent->Set("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); + + ANNIEEvent->Set("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + ANNIEEvent->Set("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + ANNIEEvent->Set("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + ANNIEEvent->Set("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + ANNIEEvent->Set("LAPPDOffsets_0", LAPPDOffsets_0); + ANNIEEvent->Set("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + ANNIEEvent->Set("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + ANNIEEvent->Set("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + ANNIEEvent->Set("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + ANNIEEvent->Set("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + ANNIEEvent->Set("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + ANNIEEvent->Set("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + ANNIEEvent->Set("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + ANNIEEvent->Set("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + ANNIEEvent->Set("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + ANNIEEvent->Set("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + ANNIEEvent->Set("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + ANNIEEvent->Set("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + ANNIEEvent->Set("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + ANNIEEvent->Set("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + ANNIEEvent->Set("LAPPDOffsets_1", LAPPDOffsets_1); + ANNIEEvent->Set("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + ANNIEEvent->Set("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + ANNIEEvent->Set("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + ANNIEEvent->Set("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + ANNIEEvent->Set("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + ANNIEEvent->Set("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + ANNIEEvent->Set("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + ANNIEEvent->Set("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + ANNIEEvent->Set("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + ANNIEEvent->Set("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + ANNIEEvent->Set("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); } bool EBSaver::LoadBeamInfo() diff --git a/UserTools/EBSaver/EBSaver.h b/UserTools/EBSaver/EBSaver.h index 70dc6a96d..38323c0e6 100644 --- a/UserTools/EBSaver/EBSaver.h +++ b/UserTools/EBSaver/EBSaver.h @@ -24,6 +24,8 @@ * $Date: 2024/04 $ * Contact: yuef@iaistate.edu * + * Updated by: Anuj Gupta (2026.09.04) + * */ class EBSaver : public Tool @@ -159,27 +161,43 @@ class EBSaver : public Tool // LAPPD related data object vector Buffer_IndexOfData; // index of unpaired data - vector Buffer_LAPPDTimestamp_ns; // used to match - - vector Buffer_LAPPDData; - vector Buffer_LAPPDBeamgate_ns; - vector Buffer_LAPPDOffset; - vector Buffer_LAPPDBeamgate_Raw; - vector Buffer_LAPPDTimestamp_Raw; - vector Buffer_LAPPDBGCorrection; - vector Buffer_LAPPDTSCorrection; - vector Buffer_LAPPDOffset_minus_ps; - vector Buffer_LAPPDBG_PPSBefore; - vector Buffer_LAPPDBG_PPSAfter; - vector Buffer_LAPPDBG_PPSDiff; - vector Buffer_LAPPDBG_PPSMissing; - vector Buffer_LAPPDTS_PPSBefore; - vector Buffer_LAPPDTS_PPSAfter; - vector Buffer_LAPPDTS_PPSDiff; - vector Buffer_LAPPDTS_PPSMissing; - + vector Buffer_LAPPDData; vector Buffer_LAPPDRunCode; + vector Buffer_LAPPDTimestamp_ns_0; + vector Buffer_LAPPDBeamgate_ns_0; + vector Buffer_LAPPDOffset_0; + vector Buffer_LAPPDBeamgate_Raw_0; + vector Buffer_LAPPDTimestamp_Raw_0; + vector Buffer_LAPPDBGCorrection_0; + vector Buffer_LAPPDTSCorrection_0; + vector Buffer_LAPPDOffset_minus_ps_0; + vector Buffer_LAPPDBG_PPSBefore_0; + vector Buffer_LAPPDBG_PPSAfter_0; + vector Buffer_LAPPDBG_PPSDiff_0; + vector Buffer_LAPPDBG_PPSMissing_0; + vector Buffer_LAPPDTS_PPSBefore_0; + vector Buffer_LAPPDTS_PPSAfter_0; + vector Buffer_LAPPDTS_PPSDiff_0; + vector Buffer_LAPPDTS_PPSMissing_0; + + vector Buffer_LAPPDTimestamp_ns_1; + vector Buffer_LAPPDBeamgate_ns_1; + vector Buffer_LAPPDOffset_1; + vector Buffer_LAPPDBeamgate_Raw_1; + vector Buffer_LAPPDTimestamp_Raw_1; + vector Buffer_LAPPDBGCorrection_1; + vector Buffer_LAPPDTSCorrection_1; + vector Buffer_LAPPDOffset_minus_ps_1; + vector Buffer_LAPPDBG_PPSBefore_1; + vector Buffer_LAPPDBG_PPSAfter_1; + vector Buffer_LAPPDBG_PPSDiff_1; + vector Buffer_LAPPDBG_PPSMissing_1; + vector Buffer_LAPPDTS_PPSBefore_1; + vector Buffer_LAPPDTS_PPSAfter_1; + vector Buffer_LAPPDTS_PPSDiff_1; + vector Buffer_LAPPDTS_PPSMissing_1; + std::map> PairedLAPPDTriggerTimestamp; std::map> PairedLAPPD_TriggerIndex; std::map> PairedLAPPDTimeStamps; diff --git a/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp b/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp index 56410ea1d..e11e35492 100644 --- a/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp +++ b/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp @@ -12,27 +12,23 @@ bool LAPPDLoadStore::Initialise(std::string configfile, DataModel &data) m_data = &data; // assigning transient data pointer ///////////////////////////////////////////////////////////////// - // Control variables // Control variables used in this tool retval = 0; eventNo = 0; - CLOCK_to_NSEC = 3.125; // 3.125 ns per clock cycle errorEventsNumber = 0; - // Control variables that you get from the config file, for this tool - m_variables.Get("ReadStore", ReadStore); + + // Load Config Variables for this tool m_variables.Get("Nboards", Nboards); - m_variables.Get("StorePedinputfile", PedFileName); m_variables.Get("PedinputfileTXT", PedFileNameTXT); m_variables.Get("DoPedSubtraction", DoPedSubtract); - m_variables.Get("LAPPDStoreReadInVerbosity", LAPPDStoreReadInVerbosity); + m_variables.Get("LAPPDLoadStoreVerbosity", LAPPDLoadStoreVerbosity); m_variables.Get("num_vector_data", num_vector_data); m_variables.Get("num_vector_pps", num_vector_pps); m_variables.Get("SelectSingleLAPPD", SelectSingleLAPPD); m_variables.Get("SelectedLAPPD", SelectedLAPPD); + mergingModeReadIn = false; m_variables.Get("mergingModeReadIn", mergingModeReadIn); - ReadStorePdeFile = false; - m_variables.Get("ReadStorePdeFile", ReadStorePdeFile); MultiLAPPDMap = false; m_variables.Get("MultiLAPPDMap", MultiLAPPDMap); loadPSEC = true; @@ -45,7 +41,7 @@ bool LAPPDLoadStore::Initialise(std::string configfile, DataModel &data) m_variables.Get("LoadBuiltPPSInfo", LoadBuiltPPSInfo); loadFromStoreDirectly = false; m_variables.Get("loadFromStoreDirectly", loadFromStoreDirectly); - // Control variables in this tool, initialized in this tool + NonEmptyEvents = 0; NonEmptyDataEvents = 0; PPSnumber = 0; @@ -53,6 +49,7 @@ bool LAPPDLoadStore::Initialise(std::string configfile, DataModel &data) isFiltered = false; isBLsub = false; isCFD = false; + // Global Control variables that you get from the config file m_variables.Get("stopEntries", stopEntries); m_variables.Get("PsecReceiveMode", PsecReceiveMode); @@ -63,70 +60,25 @@ bool LAPPDLoadStore::Initialise(std::string configfile, DataModel &data) m_variables.Get("TrigChannel", TrigChannel); m_variables.Get("SampleSize", SampleSize); m_variables.Get("LAPPDchannelOffset", LAPPDchannelOffset); - // Data variables - // Data variables you get from other tools (it not initialized in execute) - // Data variables you use in this tool - m_variables.Get("PSECinputfile", NewFileName); - // Verbosity - // Details on channels, samples and max vector sizes and trigger channel - m_variables.Get("Nsamples", Nsamples); - m_variables.Get("TrigChannel", TrigChannel); runNumber = 0; subRunNumber = 0; partFileNumber = 0; eventNumberInPF = 0; - ReadStore = 0; - - // get data file - /* - if (ReadStore == 1) - { - // get data from a StoreFile in ANNIEEvent format - m_data->Stores["ANNIEEvent"] = new BoostStore(false, 2); - m_data->Stores["ANNIEEvent"]->Initialise(NewFileName); - cout << "LAPPDStoreReadIn Reading new ANNIEevent from " << NewFileName << endl; - } - else if (ReadStore == 0) - { // get data from previous chain, or m_data - cout << "LAPPDStoreReadIn Using ANNIEevent or CStore" << endl; - }*/ // Grab all pedestal files and prepare the map channel|pedestal-vector for substraction if (DoPedSubtract == 1) { PedestalValues = new std::map>; - /*if (ReadStorePdeFile) - { - m_data->Stores["PedestalFile"] = new BoostStore(false, 2); - bool ret = false; - if (FILE *file = fopen(PedFileName.c_str(), "r")) - { - fclose(file); - ret = true; - cout << "Using Store Pedestal File" << endl; - } - if (ret) - { - m_data->Stores["PedestalFile"]->Initialise(PedFileName); - long Pedentries; - m_data->Stores["PedestalFile"]->Header->Get("TotalEntries", Pedentries); - if (LAPPDStoreReadInVerbosity > 0) - cout << PedFileName << " got " << Pedentries << endl; - m_data->Stores["PedestalFile"]->Get("PedestalMap", PedestalValues); - } - } - else*/ - { - for (int i = 0; i < Nboards; i++) - { - if (LAPPDStoreReadInVerbosity > 0) - cout << "Reading Pedestal File " << PedFileNameTXT << " " << i << endl; - ReadPedestals(i); + for (int i = 0; i < Nboards; i++) { + if (LAPPDLoadStoreVerbosity > 0) { + std::cout << "Reading Pedestal File " << PedFileNameTXT << " " << i << std::endl; } + ReadPedestals(i); } - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) { cout << "PEDSIZES: " << PedestalValues->size() << " " << PedestalValues->at(0).size() << " " << PedestalValues->at(4).at(5) << endl; + } } // set some control variables for later tools @@ -141,20 +93,22 @@ bool LAPPDLoadStore::Initialise(std::string configfile, DataModel &data) m_data->Stores["ANNIEEvent"]->Set("isCFD", isCFD); LAPPDEventIndex_ID = {0, 0, 0, 0, 0}; // initialize for five LAPPDs + if (loadOffsets) LoadOffsetsAndCorrections(); - if (LAPPDStoreReadInVerbosity > 11) - debugStoreReadIn.open("debugStoreReadIn.txt"); + + if (LAPPDLoadStoreVerbosity > 5) + debugLoadStore.open("debugLoadStore.txt"); std::string ACCIDConfigFile; get_ok = m_variables.Get("ACCIDConfigFile", ACCIDConfigFile); if(!get_ok) { - Log("LAPPDLoadStore: Missing ACCIDConfigFile in config!",v_error,LAPPDStoreReadInVerbosity); + Log("LAPPDLoadStore: Missing ACCIDConfigFile in config!",v_error,LAPPDLoadStoreVerbosity); return false; } idConfigRecords = LoadIDConfig(ACCIDConfigFile); - if (LAPPDStoreReadInVerbosity > 1) + if (LAPPDLoadStoreVerbosity > 1) { // print the ACCID config records for debug cout << "Loaded LAPPD ID Config Records from " << ACCIDConfigFile << ":" << endl; @@ -184,9 +138,7 @@ void LAPPDLoadStore::CleanDataObjects() Parse_buffer.clear(); ReadBoards.clear(); data.clear(); - meta.clear(); pps.clear(); - LAPPDWaveforms.clear(); EventType = -9999; LAPPDana = false; ParaBoards.clear(); @@ -199,19 +151,43 @@ void LAPPDLoadStore::CleanDataObjects() runInfoLoaded = false; LAPPD_IDs.clear(); - LAPPDLoadedTimeStampsRaw.clear(); - LAPPDLoadedBeamgatesRaw.clear(); - LAPPDLoadedOffsets.clear(); - LAPPDLoadedTSCorrections.clear(); - LAPPDLoadedBGCorrections.clear(); - LAPPDLoadedOSInMinusPS.clear(); + + LAPPDLoadedTimeStampsRaw_0.clear(); + LAPPDLoadedBeamgatesRaw_0.clear(); + LAPPDLoadedOffsets_0.clear(); + LAPPDLoadedTSCorrections_0.clear(); + LAPPDLoadedBGCorrections_0.clear(); + LAPPDLoadedOSInMinusPS_0.clear(); + LAPPDLoadedBG_PPSBefore_0.clear(); + LAPPDLoadedBG_PPSAfter_0.clear(); + LAPPDLoadedBG_PPSDiff_0.clear(); + LAPPDLoadedBG_PPSMissing_0.clear(); + LAPPDLoadedTS_PPSBefore_0.clear(); + LAPPDLoadedTS_PPSAfter_0.clear(); + LAPPDLoadedTS_PPSDiff_0.clear(); + LAPPDLoadedTS_PPSMissing_0.clear(); + + LAPPDLoadedTimeStampsRaw_1.clear(); + LAPPDLoadedBeamgatesRaw_1.clear(); + LAPPDLoadedOffsets_1.clear(); + LAPPDLoadedTSCorrections_1.clear(); + LAPPDLoadedBGCorrections_1.clear(); + LAPPDLoadedOSInMinusPS_1.clear(); + LAPPDLoadedBG_PPSBefore_1.clear(); + LAPPDLoadedBG_PPSAfter_1.clear(); + LAPPDLoadedBG_PPSDiff_1.clear(); + LAPPDLoadedBG_PPSMissing_1.clear(); + LAPPDLoadedTS_PPSBefore_1.clear(); + LAPPDLoadedTS_PPSAfter_1.clear(); + LAPPDLoadedTS_PPSDiff_1.clear(); + LAPPDLoadedTS_PPSMissing_1.clear(); } bool LAPPDLoadStore::Execute() { - // 1. clean data variables - // 2. decide loading data or not, load the data from PsecData dat to tool - // 3. parse and pass data to later tools + // 1. Clean data variables + // 2. Decide loading data or not, load the data from PsecData data to tool + // 3. Parse and pass data to later tools CleanDataObjects(); m_data->CStore.Set("LAPPD_new_event", false); @@ -221,34 +197,69 @@ bool LAPPDLoadStore::Execute() { bool gotDataStream = m_data->Stores["ANNIEEvent"]->Get("DataStreams", DataStreams); bool getMap = m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", LAPPDDataMap); + if (getMap && DataStreams["LAPPD"] == true && LAPPDDataMap.size() > 0) { - // cout << "Outside, size of LAPPDDatamap = " << LAPPDDataMap.size() << endl; - bool gotBeamgates_ns = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - bool gotTimeStamps_ns = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - bool gotTimeStampsRaw = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - bool gotBeamgatesRaw = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - bool gotOffsets = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets); - bool gotTSCorrection = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection); - bool gotDBGCorrection = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection); - bool gotOSInMinusPS = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); + bool gotBeamgates_ns_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + bool gotTimeStamps_ns_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + bool gotTimeStampsRaw_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + bool gotBeamgatesRaw_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + bool gotOffsets_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_0", LAPPDOffsets_0); + bool gotTSCorrection_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + bool gotDBGCorrection_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + bool gotOSInMinusPS_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + + bool gotBeamgates_ns_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + bool gotTimeStamps_ns_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + bool gotTimeStampsRaw_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + bool gotBeamgatesRaw_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + bool gotOffsets_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_1", LAPPDOffsets_1); + bool gotTSCorrection_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + bool gotDBGCorrection_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + bool gotOSInMinusPS_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + if (LoadBuiltPPSInfo) { - bool gotBG_PPSBefore = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - bool gotBG_PPSAfter = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - bool gotBG_PPSDiff = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - bool gotBG_PPSMissing = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - bool gotTS_PPSBefore = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - bool gotTS_PPSAfter = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - bool gotTS_PPSDiff = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - bool gotTS_PPSMissing = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); - if (LAPPDStoreReadInVerbosity > 3) + bool gotBG_PPSBefore_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + bool gotBG_PPSAfter_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + bool gotBG_PPSDiff_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + bool gotBG_PPSMissing_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + bool gotTS_PPSBefore_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + bool gotTS_PPSAfter_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + bool gotTS_PPSDiff_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + bool gotTS_PPSMissing_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + bool gotBG_PPSBefore_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + bool gotBG_PPSAfter_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + bool gotBG_PPSDiff_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + bool gotBG_PPSMissing_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + bool gotTS_PPSBefore_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + bool gotTS_PPSAfter_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + bool gotTS_PPSDiff_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + bool gotTS_PPSMissing_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); + + if (LAPPDLoadStoreVerbosity > 3) { - cout << "LAPPDLoadStore: gotOffsets = " << gotOffsets << ", gotBG_PPSBefore = " << gotBG_PPSBefore << ", gotTS_PPSBefore = " << gotTS_PPSBefore << endl; - cout << "Size of LAPPDDataMap = " << LAPPDDataMap.size() << ", LAPPDOffsets = " << LAPPDOffsets.size() << ", LAPPDBG_PPSBefore = " << LAPPDBG_PPSBefore.size() << ", LAPPDTS_PPSBefore = " << LAPPDTS_PPSBefore.size() << endl; - - cout << "gotBG_PPSBefore = " << gotBG_PPSBefore << ", gotBG_PPSAfter = " << gotBG_PPSAfter << ", gotBG_PPSDiff = " << gotBG_PPSDiff << ", gotBG_PPSMissing = " << gotBG_PPSMissing << endl; - cout << "gotTS_PPSBefore = " << gotTS_PPSBefore << ", gotTS_PPSAfter = " << gotTS_PPSAfter << ", gotTS_PPSDiff = " << gotTS_PPSDiff << ", gotTS_PPSMissing = " << gotTS_PPSMissing << endl; + std::cout << "LAPPDLoadStore: gotOffsets = " << gotOffsets_0 << std::endl; + std::cout << "Size of LAPPDDataMap = " << LAPPDDataMap.size() + << ", LAPPDOffsets_0 = " << LAPPDOffsets_0.size() + << ", LAPPDOffsets_1 = " << LAPPDOffsets_1.size() + << ", LAPPDBG_PPSBefore_0 = " << LAPPDBG_PPSBefore_0.size() + << ", LAPPDTS_PPSBefore_0 = " << LAPPDTS_PPSBefore_0.size() + << ", LAPPDBG_PPSBefore_1 = " << LAPPDBG_PPSBefore_1.size() + << ", LAPPDTS_PPSBefore_1 = " << LAPPDTS_PPSBefore_1.size() << std::endl; + + std::cout << "Board 0: gotBG_PPSBefore = " << gotBG_PPSBefore_0 << ", gotBG_PPSAfter = " << gotBG_PPSAfter_0 + << ", gotBG_PPSDiff = " << gotBG_PPSDiff_0 << ", gotBG_PPSMissing = " << gotBG_PPSMissing_0 << std::endl; + + std::cout << "Board 0: gotTS_PPSBefore = " << gotTS_PPSBefore_0 << ", gotTS_PPSAfter = " << gotTS_PPSAfter_0 + << ", gotTS_PPSDiff = " << gotTS_PPSDiff_0 << ", gotTS_PPSMissing = " << gotTS_PPSMissing_0 << std::endl; + + std::cout << "Board 1: gotBG_PPSBefore = " << gotBG_PPSBefore_1 << ", gotBG_PPSAfter = " << gotBG_PPSAfter_1 + << ", gotBG_PPSDiff = " << gotBG_PPSDiff_1 << ", gotBG_PPSMissing = " << gotBG_PPSMissing_1 << std::endl; + + std::cout << "Board 1: gotTS_PPSBefore = " << gotTS_PPSBefore_1 << ", gotTS_PPSAfter = " << gotTS_PPSAfter_1 + << ", gotTS_PPSDiff = " << gotTS_PPSDiff_1 << ", gotTS_PPSMissing = " << gotTS_PPSMissing_1 << std::endl;\ } } } @@ -261,7 +272,7 @@ bool LAPPDLoadStore::Execute() // decide loading data or not, set to LAPPDana for later tools LAPPDana = LoadData(); m_data->CStore.Set("LAPPDana", LAPPDana); - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "LAPPDana for loading was set to " << LAPPDana << endl; if (!LAPPDana) { @@ -295,8 +306,8 @@ bool LAPPDLoadStore::Execute() m_data->CStore.Set("LAPPD_ID", LAPPD_ID); m_data->Stores["ANNIEEvent"]->Set("LAPPD_ID", LAPPD_ID); m_data->CStore.Set("LoadingPPS", true); - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn: PPS data loaded, LAPPDanaData is false, set LAPPDana to false" << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore: PPS data loaded, LAPPDanaData is false, set LAPPDana to false" << endl; return true; } @@ -312,7 +323,7 @@ bool LAPPDLoadStore::Execute() if (!parsData) { - cout << "LAPPDStoreReadIn: PSEC data parsing failed, set LAPPDana to false and return" << endl; + cout << "LAPPDLoadStore: PSEC data parsing failed, set LAPPDana to false and return" << endl; return true; } @@ -333,8 +344,8 @@ bool LAPPDLoadStore::Execute() // cout << "ReadedBoards loaded with " << *it << endl; } - if (LAPPDStoreReadInVerbosity > 0) - cout << "*************************END LAPPDStoreReadIn************************************" << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "*************************END LAPPDLoadStore************************************" << endl; m_data->CStore.Set("LAPPD_ID", LAPPD_ID); m_data->Stores["ANNIEEvent"]->Set("LAPPD_ID", LAPPD_ID); m_data->Stores["ANNIEEvent"]->Set("RawLAPPDData", LAPPDWaveforms); // leave this only for the merger tool @@ -347,14 +358,14 @@ bool LAPPDLoadStore::Execute() m_data->Stores["ANNIEEvent"]->Set("ReadedBoards", ReadedBoards); m_data->CStore.Set("NewLAPPDDataAvailable", true); - if (LAPPDStoreReadInVerbosity > 11) - debugStoreReadIn << " Set NewLAPPDDataAvailable to true" << endl; + if (LAPPDLoadStoreVerbosity > 5) + debugLoadStore << " Set NewLAPPDDataAvailable to true" << endl; NonEmptyEvents += 1; eventNo++; - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) { - cout << "Finish LAPPDStoreReadIn, Printing the ANNIEEvent" << endl; + cout << "Finish LAPPDLoadStore, Printing the ANNIEEvent" << endl; m_data->Stores["ANNIEEvent"]->Print(false); } } @@ -370,8 +381,8 @@ bool LAPPDLoadStore::Execute() vector ReadedBoards; vector ACDCReadedLAPPDID; - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn: LAPPDDataMap has " << LAPPDDataMap.size() << " LAPPD PSEC data " << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore: LAPPDDataMap has " << LAPPDDataMap.size() << " LAPPD PSEC data " << endl; bool ValidDataLoaded = false; std::map::iterator it; for (it = LAPPDDataMap.begin(); it != LAPPDDataMap.end(); it++) @@ -385,7 +396,7 @@ bool LAPPDLoadStore::Execute() if (LAPPD_ID>20) { tuple queryResult = queryNearestACCID(idConfigRecords, runNumber, LAPPD_ID); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "LAPPDLoadStore: Mapped ManufacturerID " << LAPPD_ID << " to ACCID " << get<0>(queryResult) << " for run " << runNumber << endl; LAPPD_ID = get<0>(queryResult); @@ -402,7 +413,7 @@ bool LAPPDLoadStore::Execute() // return true; } - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) { // print ReadBoards cout << "LAPPD ID " << LAPPD_ID << " ReadBoards size is " << ReadBoards.size() << ", data: " << endl; @@ -424,11 +435,11 @@ bool LAPPDLoadStore::Execute() int frametype = static_cast(Raw_buffer.size() / ReadBoards.size()); if (frametype != num_vector_data) { - cout << "LAPPDStoreReadIn: For LAPPD_ID " << LAPPD_ID << " frametype is not num_vector_data, skip this LAPPD" << endl; + cout << "LAPPDLoadStore: For LAPPD_ID " << LAPPD_ID << " frametype is not num_vector_data, skip this LAPPD" << endl; continue; } m_data->CStore.Set("LAPPDanaData", true); - if (LAPPDStoreReadInVerbosity > 3) + if (LAPPDLoadStoreVerbosity > 3) { cout << "Before parsing data, printing size and element in ReadBoards, ReadedBoards, ParaBoards" << endl; cout << "ReadBoards size is " << ReadBoards.size() << endl; @@ -454,54 +465,100 @@ bool LAPPDLoadStore::Execute() if (parsData) { ValidDataLoaded = true; - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "LAPPDLoadStore: Loaded LAPPD data for LAPPD_ID " << LAPPD_ID << " at time " << time << endl; LAPPDLoadedTimeStamps.push_back(time); LAPPD_IDs.push_back(LAPPD_ID); - // print the size of LAPPDTimeStampsRaw, print all keys in it - if (LAPPDStoreReadInVerbosity > 0) + + // print the size of LAPPDTimeStampsRaw for Board 0 and Board 1, print all keys in them + if (LAPPDLoadStoreVerbosity > 0) { - cout << "LAPPDTimeStampsRaw size is " << LAPPDTimeStampsRaw.size() << endl; - for (auto it = LAPPDTimeStampsRaw.begin(); it != LAPPDTimeStampsRaw.end(); it++) + std::cout << "LAPPDTimeStampsRaw_0 size is " << LAPPDTimeStampsRaw_0.size() << std::endl; + for (auto it = LAPPDTimeStampsRaw_0.begin(); it != LAPPDTimeStampsRaw_0.end(); it++) + { + std::cout << "LAPPDTimeStampsRaw_0 key is " << it->first << std::endl; + } + std::cout << "LAPPDTimeStampsRaw_1 size is " << LAPPDTimeStampsRaw_1.size() << std::endl; + for (auto it = LAPPDTimeStampsRaw_1.begin(); it != LAPPDTimeStampsRaw_1.end(); it++) { - cout << "LAPPDTimeStampsRaw key is " << it->first << endl; + std::cout << "LAPPDTimeStampsRaw_1 key is " << it->first << std::endl; } } - // print the size of LAPPDOffsets, print all keys in it - if (LAPPDStoreReadInVerbosity > 0) + + // print the size of LAPPDOffsets for Board 0 and Board 1, print all keys in it + if (LAPPDLoadStoreVerbosity > 0) { - cout << "LAPPDOffsets size is " << LAPPDOffsets.size() << endl; - for (auto it = LAPPDOffsets.begin(); it != LAPPDOffsets.end(); it++) + std::cout << "LAPPDOffsets_0 size is " << LAPPDOffsets_0.size() << std::endl; + for (auto it = LAPPDOffsets_0.begin(); it != LAPPDOffsets_0.end(); it++) + { + std::cout << "LAPPDOffsets_0 key is " << it->first << std::endl; + } + std::cout << "LAPPDOffsets_1 size is " << LAPPDOffsets_1.size() << std::endl; + for (auto it = LAPPDOffsets_1.begin(); it != LAPPDOffsets_1.end(); it++) { - cout << "LAPPDOffsets key is " << it->first << endl; + std::cout << "LAPPDOffsets_1 key is " << it->first << std::endl; } } - LAPPDLoadedTimeStampsRaw.push_back(LAPPDTimeStampsRaw.at(time)); - LAPPDLoadedBeamgatesRaw.push_back(LAPPDBeamgatesRaw.at(time)); - LAPPDLoadedOffsets.push_back(LAPPDOffsets.at(time)); - LAPPDLoadedTSCorrections.push_back(LAPPDTSCorrection.at(time)); - LAPPDLoadedBGCorrections.push_back(LAPPDBGCorrection.at(time)); - LAPPDLoadedOSInMinusPS.push_back(LAPPDOSInMinusPS.at(time)); - - if (LAPPDStoreReadInVerbosity > 2) + LAPPDLoadedTimeStampsRaw_0.push_back(LAPPDTimeStampsRaw_0.at(time)); + LAPPDLoadedBeamgatesRaw_0.push_back(LAPPDBeamgatesRaw_0.at(time)); + LAPPDLoadedOffsets_0.push_back(LAPPDOffsets_0.at(time)); + LAPPDLoadedTSCorrections_0.push_back(LAPPDTSCorrection_0.at(time)); + LAPPDLoadedBGCorrections_0.push_back(LAPPDBGCorrection_0.at(time)); + LAPPDLoadedOSInMinusPS_0.push_back(LAPPDOSInMinusPS_0.at(time)); + + LAPPDLoadedTimeStampsRaw_1.push_back(LAPPDTimeStampsRaw_1.at(time)); + LAPPDLoadedBeamgatesRaw_1.push_back(LAPPDBeamgatesRaw_1.at(time)); + LAPPDLoadedOffsets_1.push_back(LAPPDOffsets_1.at(time)); + LAPPDLoadedTSCorrections_1.push_back(LAPPDTSCorrection_1.at(time)); + LAPPDLoadedBGCorrections_1.push_back(LAPPDBGCorrection_1.at(time)); + LAPPDLoadedOSInMinusPS_1.push_back(LAPPDOSInMinusPS_1.at(time)); + + if (LAPPDLoadStoreVerbosity > 2) cout << "parsing finished for LAPPD_ID " << LAPPD_ID << " at time " << time << endl; if (LoadBuiltPPSInfo) { - LAPPDLoadedBG_PPSBefore.push_back(LAPPDBG_PPSBefore.at(time)); - LAPPDLoadedBG_PPSAfter.push_back(LAPPDBG_PPSAfter.at(time)); - LAPPDLoadedBG_PPSDiff.push_back(LAPPDBG_PPSDiff.at(time)); - LAPPDLoadedBG_PPSMissing.push_back(LAPPDBG_PPSMissing.at(time)); - LAPPDLoadedTS_PPSBefore.push_back(LAPPDTS_PPSBefore.at(time)); - LAPPDLoadedTS_PPSAfter.push_back(LAPPDTS_PPSAfter.at(time)); - LAPPDLoadedTS_PPSDiff.push_back(LAPPDTS_PPSDiff.at(time)); - LAPPDLoadedTS_PPSMissing.push_back(LAPPDTS_PPSMissing.at(time)); - - if (LAPPDTS_PPSMissing.at(time) != LAPPDBG_PPSMissing.at(time) && ((LAPPDTS_PPSMissing.at(time) > -100 && LAPPDTS_PPSMissing.at(time) < 100) || (LAPPDBG_PPSMissing.at(time) > -100 && LAPPDBG_PPSMissing.at(time) < 100))) + LAPPDLoadedBG_PPSBefore_0.push_back(LAPPDBG_PPSBefore_0.at(time)); + LAPPDLoadedBG_PPSAfter_0.push_back(LAPPDBG_PPSAfter_0.at(time)); + LAPPDLoadedBG_PPSDiff_0.push_back(LAPPDBG_PPSDiff_0.at(time)); + LAPPDLoadedBG_PPSMissing_0.push_back(LAPPDBG_PPSMissing_0.at(time)); + LAPPDLoadedTS_PPSBefore_0.push_back(LAPPDTS_PPSBefore_0.at(time)); + LAPPDLoadedTS_PPSAfter_0.push_back(LAPPDTS_PPSAfter_0.at(time)); + LAPPDLoadedTS_PPSDiff_0.push_back(LAPPDTS_PPSDiff_0.at(time)); + LAPPDLoadedTS_PPSMissing_0.push_back(LAPPDTS_PPSMissing_0.at(time)); + + LAPPDLoadedBG_PPSBefore_1.push_back(LAPPDBG_PPSBefore_1.at(time)); + LAPPDLoadedBG_PPSAfter_1.push_back(LAPPDBG_PPSAfter_1.at(time)); + LAPPDLoadedBG_PPSDiff_1.push_back(LAPPDBG_PPSDiff_1.at(time)); + LAPPDLoadedBG_PPSMissing_1.push_back(LAPPDBG_PPSMissing_1.at(time)); + LAPPDLoadedTS_PPSBefore_1.push_back(LAPPDTS_PPSBefore_1.at(time)); + LAPPDLoadedTS_PPSAfter_1.push_back(LAPPDTS_PPSAfter_1.at(time)); + LAPPDLoadedTS_PPSDiff_1.push_back(LAPPDTS_PPSDiff_1.at(time)); + LAPPDLoadedTS_PPSMissing_1.push_back(LAPPDTS_PPSMissing_1.at(time)); + + // --- Board 0 Check --- + if (LAPPDTS_PPSMissing_0.at(time) != LAPPDBG_PPSMissing_0.at(time) && + ((LAPPDTS_PPSMissing_0.at(time) > -100 && LAPPDTS_PPSMissing_0.at(time) < 100) || + (LAPPDBG_PPSMissing_0.at(time) > -100 && LAPPDBG_PPSMissing_0.at(time) < 100))) { - cout << "LAPPDLoadStore: PPS missing number is not the same on BG and TS for LAPPD_ID " << LAPPD_ID << " at time " << time << ", BG: " << LAPPDBG_PPSMissing.at(time) << ", TS: " << LAPPDTS_PPSMissing.at(time) << endl; - cout << "LAPPDLoadStore: BG_PPSDiff: " << LAPPDBG_PPSDiff.at(time) << ", TS_PPSDiff: " << LAPPDTS_PPSDiff.at(time) << endl; + std::cout << "LAPPDLoadStore: [Board 0] PPS missing mismatch for LAPPD_ID " << LAPPD_ID + << " at time " << time << ", BG: " << LAPPDBG_PPSMissing_0.at(time) + << ", TS: " << LAPPDTS_PPSMissing_0.at(time) << std::endl; + std::cout << "LAPPDLoadStore: [Board 0] BG_PPSDiff: " << LAPPDBG_PPSDiff_0.at(time) + << ", TS_PPSDiff: " << LAPPDTS_PPSDiff_0.at(time) << std::endl; + } + + // --- Board 1 Check --- + if (LAPPDTS_PPSMissing_1.at(time) != LAPPDBG_PPSMissing_1.at(time) && + ((LAPPDTS_PPSMissing_1.at(time) > -100 && LAPPDTS_PPSMissing_1.at(time) < 100) || + (LAPPDBG_PPSMissing_1.at(time) > -100 && LAPPDBG_PPSMissing_1.at(time) < 100))) + { + std::cout << "LAPPDLoadStore: [Board 1] PPS missing mismatch for LAPPD_ID " << LAPPD_ID + << " at time " << time << ", BG: " << LAPPDBG_PPSMissing_1.at(time) + << ", TS: " << LAPPDTS_PPSMissing_1.at(time) << std::endl; + std::cout << "LAPPDLoadStore: [Board 1] BG_PPSDiff: " << LAPPDBG_PPSDiff_1.at(time) + << ", TS_PPSDiff: " << LAPPDTS_PPSDiff_1.at(time) << std::endl; } } } @@ -509,6 +566,7 @@ bool LAPPDLoadStore::Execute() NonEmptyDataEvents += 1; } eventNo++; + LAPPDana = ValidDataLoaded; m_data->CStore.Set("LAPPDana", LAPPDana); DoPedestalSubtract(); @@ -522,34 +580,53 @@ bool LAPPDLoadStore::Execute() m_data->Stores["ANNIEEvent"]->Set("LAPPDDataMap", LAPPDDataMap); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - m_data->Stores["ANNIEEvent"]->Set("LAPPDOffsets", LAPPDOffsets); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTSCorrection", LAPPDTSCorrection); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBGCorrection", LAPPDBGCorrection); - m_data->Stores["ANNIEEvent"]->Set("LAPPDOSInMinusPS", LAPPDOSInMinusPS); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDOffsets_0", LAPPDOffsets_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + + m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDOffsets_1", LAPPDOffsets_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + if (LoadBuiltPPSInfo) { - m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); } + // TODO: save other timestamps, variables and metadata for later use - if (eventNo % 100 == 0) - { - cout << "LAPPDLoadStore: Loaded " << eventNo << " events, " << NonEmptyDataEvents << " non empty LAPPD PSEC data loaded from all LAPPDs" << endl; + if (eventNo % 100 == 0) { + std::cout << "LAPPDLoadStore: Loaded " << eventNo << " events, " << NonEmptyDataEvents << " non empty LAPPD PSEC data loaded from all LAPPDs" << std::endl; } } - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "LAPPDLoadStore: Finished loading LAPPD data" << endl; return true; @@ -569,7 +646,7 @@ bool LAPPDLoadStore::Finalise() bool LAPPDLoadStore::ReadPedestals(int boardNo) { - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "Getting Pedestals " << boardNo << endl; std::string LoadName = PedFileNameTXT; @@ -584,7 +661,7 @@ bool LAPPDLoadStore::ReadPedestals(int boardNo) cout << "Failed to open " << LoadName << "!" << endl; return false; } - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "Opened file: " << LoadName << endl; int sampleNo = 0; // sample number @@ -607,7 +684,7 @@ bool LAPPDLoadStore::ReadPedestals(int boardNo) tempPed.push_back(tempValue); // cout<<"First time: "<insert(pair>(channelNo, tempPed)); - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "Inserting pedestal at channelNo " << channelNo << endl; // newboard=false; } @@ -621,7 +698,7 @@ bool LAPPDLoadStore::ReadPedestals(int boardNo) } sampleNo++; } - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "FINAL SAMPLE NUMBER: " << PedestalValues->size() << " " << (((PedestalValues->find(0))->second)).size() << endl; PedFile.close(); return true; @@ -691,17 +768,17 @@ int LAPPDLoadStore::getParsedMeta(std::vector buffer, int BoardI { for (int ch = 0; ch < NUM_CH / NUM_PSEC; ch++) { - if (LAPPDStoreReadInVerbosity > 10) + if (LAPPDLoadStoreVerbosity > 10) cout << "parsing meta step1-1" << endl; // Find the trigger data at begin + last_metadata_start + 13_info_words + 1_end_word + 1 bit = buffer.begin() + start_indices[4] + 13 + 1 + 1 + ch + (chip * (NUM_CH / NUM_PSEC)); - if (LAPPDStoreReadInVerbosity > 10) + if (LAPPDLoadStoreVerbosity > 10) cout << "parsing meta step1-2" << endl; PsecTriggerInfo[chip].push_back(*bit); } } - if (LAPPDStoreReadInVerbosity > 10) + if (LAPPDLoadStoreVerbosity > 10) cout << "parsing meta step1.5" << endl; // Fill the combined trigger CombinedTriggerRateCount = buffer[7792]; @@ -717,7 +794,7 @@ int LAPPDLoadStore::getParsedMeta(std::vector buffer, int BoardI // cout<<"size of trigger word is "< 10) + if (LAPPDLoadStoreVerbosity > 10) cout << "parsing meta step2-1 infoword " << INFOWORD << endl; if (PsecInfo[CHIP].size() < 13) { @@ -743,7 +820,7 @@ int LAPPDLoadStore::getParsedMeta(std::vector buffer, int BoardI } for (int TRIGGERWORD = 0; TRIGGERWORD < 6; TRIGGERWORD++) { - if (LAPPDStoreReadInVerbosity > 10) + if (LAPPDLoadStoreVerbosity > 10) cout << "parsing meta step2-2 trigger word" << endl; if (PsecTriggerInfo[CHIP].size() < 6) @@ -813,7 +890,7 @@ int LAPPDLoadStore::getParsedData(std::vector buffer, int ch_sta if (InfoWord.size() == NUM_SAMP) { data.insert(pair>(ch_start + channel_count, InfoWord)); - if (LAPPDStoreReadInVerbosity > 5) + if (LAPPDLoadStoreVerbosity > 5) cout << "inserted data to channel " << ch_start + channel_count << endl; InfoWord.clear(); channel_count++; @@ -833,14 +910,14 @@ bool LAPPDLoadStore::LoadData() if (loadFromStoreDirectly) m_data->Stores["ANNIEEvent"]->GetEntry(eventNo); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "Got eventNo " << eventNo << endl; // if loaded enough events, stop the loop and return false if (NonEmptyEvents == stopEntries || NonEmptyEvents > stopEntries || NonEmptyDataEvents == stopEntries || NonEmptyDataEvents > stopEntries) { - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn: NonEmptyEvents is " << NonEmptyEvents << ", NonEmptyDataEvents is " << NonEmptyDataEvents << ", stopEntries is " << stopEntries << ", stop the loop" << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore: NonEmptyEvents is " << NonEmptyEvents << ", NonEmptyDataEvents is " << NonEmptyDataEvents << ", stopEntries is " << stopEntries << ", stop the loop" << endl; m_data->vars.Set("StopLoop", 1); return false; } @@ -849,9 +926,9 @@ bool LAPPDLoadStore::LoadData() // DataStreams["LAPPD"] = true; // print the load information: DataStreams["LAPPD"] value, PsecReceiveMode, MultiLAPPDMap - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) { - cout << "LAPPDStoreReadIn: DataStreams[LAPPD] is " << DataStreams["LAPPD"] << ", PsecReceiveMode is " << PsecReceiveMode << ", MultiLAPPDMap is " << MultiLAPPDMap << endl; + cout << "LAPPDLoadStore: DataStreams[LAPPD] is " << DataStreams["LAPPD"] << ", PsecReceiveMode is " << PsecReceiveMode << ", MultiLAPPDMap is " << MultiLAPPDMap << endl; } if (loadPSEC || loadPPS) @@ -878,15 +955,15 @@ bool LAPPDLoadStore::LoadData() { m_data->CStore.Set("StoreLoadedLAPPDData", dat); } - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn: getting LAPPDData from CStore" << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore: getting LAPPDData from CStore" << endl; bool mergingLoad; // if in merging mode, but no LAPPD data in CStore, return false, don't load m_data->CStore.Get("LAPPDanaData", mergingLoad); if (!mergingLoad && mergingModeReadIn) { - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn: mergingMode is true but LAPPDanaData is false, set LAPPDana to false" << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore: mergingMode is true but LAPPDanaData is false, set LAPPDana to false" << endl; return false; } if (getData) @@ -894,7 +971,7 @@ bool LAPPDLoadStore::LoadData() vector errorcodes = dat.errorcodes; if (errorcodes.size() == 1 && errorcodes[0] == 0x00000000) { - if (LAPPDStoreReadInVerbosity > 1) + if (LAPPDLoadStoreVerbosity > 1) printf("No errorcodes found all good: 0x%08x\n", errorcodes[0]); } else @@ -918,7 +995,7 @@ bool LAPPDLoadStore::LoadData() if (LAPPD_ID>20) { tuple queryResult = queryNearestACCID(idConfigRecords, runNumber, LAPPD_ID); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "LAPPDLoadStore: Mapped ManufacturerID " << LAPPD_ID << " to ACCID " << get<0>(queryResult) << " for run " << runNumber << endl; LAPPD_ID = get<0>(queryResult); @@ -927,14 +1004,14 @@ bool LAPPDLoadStore::LoadData() if (LAPPD_ID != SelectedLAPPD && SelectSingleLAPPD) return false; m_data->CStore.Set("PsecTimestamp", dat.Timestamp); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) { cout << " Got Data " << endl; dat.Print(); } int frameType = static_cast(Raw_buffer.size() / ReadBoards.size()); - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn: got Data from CStore, frame type is " << frameType << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore: got Data from CStore, frame type is " << frameType << endl; if (loadPSEC) { if (frameType == num_vector_data) @@ -968,7 +1045,7 @@ bool LAPPDLoadStore::LoadData() if (LAPPD_ID>20) { tuple queryResult = queryNearestACCID(idConfigRecords, runNumber, LAPPD_ID); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "LAPPDLoadStore: Mapped ManufacturerID " << LAPPD_ID << " to ACCID " << get<0>(queryResult) << " for run " << runNumber << endl; LAPPD_ID = get<0>(queryResult); @@ -980,7 +1057,7 @@ bool LAPPDLoadStore::LoadData() if (Raw_buffer.size() != 0 || ReadBoards.size() != 0) { - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) { cout << "Getting data length format" << static_cast(Raw_buffer.size() / ReadBoards.size()) << ", psec timestamp is " << dat.Timestamp << endl; cout << "ReadBoards size " << ReadBoards.size() << " Raw_buffer size " << Raw_buffer.size() << " LAPPD_ID " << LAPPD_ID << endl; @@ -988,7 +1065,7 @@ bool LAPPDLoadStore::LoadData() } else { - cout << "LAPPDStoreReadIn: loading data with raw buffer size 0 or ReadBoards size 0, skip loading" << endl; + cout << "LAPPDLoadStore: loading data with raw buffer size 0 or ReadBoards size 0, skip loading" << endl; cout << "ReadBoards size " << ReadBoards.size() << " Raw_buffer size " << Raw_buffer.size() << " LAPPD_ID " << LAPPD_ID << endl; return false; @@ -997,7 +1074,7 @@ bool LAPPDLoadStore::LoadData() } else if (DataStreams["LAPPD"] && PsecReceiveMode == 0 && MultiLAPPDMap) // if not receive from cstore, and load multi lappd map { - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "LAPPDLoadStore: Loading multiple LAPPD data from ANNIEEvent" << "Inside, size of LAPPDDatamap = " << LAPPDDataMap.size() << endl; if (LAPPDDataMap.size() == 0) @@ -1014,7 +1091,7 @@ bool LAPPDLoadStore::LoadData() void LAPPDLoadStore::ParsePPSData() { - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "Loading PPS frame size " << pps.size() << endl; std::vector pps = Raw_buffer; std::vector pps_vector; @@ -1033,13 +1110,13 @@ void LAPPDLoadStore::ParsePPSData() std::bitset<16> bits_pps_31_16(pps_31_16); std::bitset<16> bits_pps_15_0(pps_15_0); unsigned long pps_63_0 = (static_cast(pps_63_48) << 48) + (static_cast(pps_47_32) << 32) + (static_cast(pps_31_16) << 16) + (static_cast(pps_15_0)); - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) std::cout << "pps combined: " << pps_63_0 << std::endl; std::bitset<64> bits_pps_63_0(pps_63_0); // pps_timestamp = pps_63_0 * (CLOCK_to_NSEC); // NOTE: Don't do convert to ns because of the precision, do this in later tools pps_timestamp = pps_63_0; // LAPPDPPS->push_back(pps_timestamp); - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) std::cout << "Adding timestamp " << pps_timestamp << " to LAPPDPPS" << std::endl; pps_vector.push_back(pps_timestamp); @@ -1048,13 +1125,13 @@ void LAPPDLoadStore::ParsePPSData() std::bitset<16> bits_ppscount_31_16(ppscount_31_16); std::bitset<16> bits_ppscount_15_0(ppscount_15_0); unsigned long ppscount_31_0 = (static_cast(ppscount_31_16) << 16) + (static_cast(ppscount_15_0)); - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) std::cout << "pps count combined: " << ppscount_31_0 << std::endl; std::bitset<32> bits_ppscount_31_0(ppscount_31_0); ppscount = ppscount_31_0; pps_count_vector.push_back(ppscount); - if (LAPPDStoreReadInVerbosity > 8) + if (LAPPDLoadStoreVerbosity > 8) { // Print the bitsets cout << "******************************" << endl; @@ -1098,7 +1175,7 @@ void LAPPDLoadStore::ParsePPSData() bool LAPPDLoadStore::ParsePSECData() { - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) std::cout << "PSEC Data Frame was read! Starting the parsing!" << std::endl; // while loading single PsecData Object, parse the data by LAPPDID and number of boards on each LAPPD and channel on each board @@ -1106,18 +1183,18 @@ bool LAPPDLoadStore::ParsePSECData() // the board indices goes with LAPPD ID. For example, LAPPD ID = 2, we will have board = 4,5 // this need to be converted to 0,1 int nbi = ReadBoards.size(); - if (LAPPDStoreReadInVerbosity > 0 && nbi != 2) + if (LAPPDLoadStoreVerbosity > 0 && nbi != 2) cout << "Number of board is " << nbi << endl; if (nbi == 0) { - cout << "LAPPDStoreReadIn: error here! number of board is 0" << endl; + cout << "LAPPDLoadStore: error here! number of board is 0" << endl; errorEventsNumber++; return false; } if (nbi % 2 != 0) { errorEventsNumber++; - cout << "LAPPDStoreReadIn: uneven number of boards in this event" << endl; + cout << "LAPPDLoadStore: uneven number of boards in this event" << endl; if (nbi == 1) { ParaBoards.push_back(ReadBoards[0]); @@ -1132,12 +1209,12 @@ bool LAPPDLoadStore::ParsePSECData() for (int cbi = 0; cbi < nbi; cbi++) { ParaBoards.push_back(cbi); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "Board " << cbi << " is added to the list of boards to be parsed!" << endl; } } // loop all boards, 0, 1 - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) { cout << "ParaBoards size is " << ParaBoards.size() << endl; for (int i = 0; i < ParaBoards.size(); i++) @@ -1149,7 +1226,7 @@ bool LAPPDLoadStore::ParsePSECData() { int bi = ParaBoards.at(i) % 2; Parse_buffer.clear(); - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) std::cout << "Parsing board with ReadBoards ID" << ReadBoards[bi] << std::endl; // Go over all ACDC board data frames by seperating them int frametype = static_cast(Raw_buffer.size() / ReadBoards.size()); @@ -1157,20 +1234,20 @@ bool LAPPDLoadStore::ParsePSECData() { Parse_buffer.push_back(Raw_buffer[c]); } - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) std::cout << "Data for " << i << "_th board with board number = " << ReadBoards[bi] << " was grabbed!" << std::endl; // Grab the parsed data and give it to a global variable 'data' // insert the data start with channel number 30*ReadBoards[bi] // for instance, when bi=0 , LAPPD ID = 2, ReadBoards[bi] = 4, insert to channel number start with 120, to 150 int channelShift = bi * NUM_CH + LAPPD_ID * NUM_CH * 2; - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) std::cout << "bi= " << bi << ", LAPPD_ID= " << LAPPD_ID << ", NUM_CH= " << NUM_CH << ", channelShift= " << channelShift << std::endl; retval = getParsedData(Parse_buffer, channelShift); //(because there are only 2 boards, so it's 0*30 or 1*30). Inserting the channel number start from this then ++ to 30 if (retval == 0) { - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) std::cout << "Data for board with number = " << ReadBoards[bi] << " was parsed with channel shift " << channelShift << endl; // Grab the parsed metadata and give it to a global variable 'meta' retval = getParsedMeta(Parse_buffer, bi + LAPPD_ID * 2); @@ -1181,7 +1258,7 @@ bool LAPPDLoadStore::ParsePSECData() } else { - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) std::cout << "Meta for board " << ReadBoards[bi] << " was parsed!" << std::endl; } } @@ -1192,9 +1269,8 @@ bool LAPPDLoadStore::ParsePSECData() } } - LAPPDEventIndex_ID[LAPPD_ID] += 1; - if (LAPPDStoreReadInVerbosity > 1) + if (LAPPDLoadStoreVerbosity > 1) { cout << "Adding one new event with LAPPD_ID = " << LAPPD_ID << " to the LAPPDEventIndex_ID, now it is: " << endl; for (int i = 0; i < LAPPDEventIndex_ID.size(); i++) @@ -1204,21 +1280,21 @@ bool LAPPDLoadStore::ParsePSECData() cout << endl; } - if (LAPPDStoreReadInVerbosity > 2) + if (LAPPDLoadStoreVerbosity > 2) cout << "Parsed all boards for this event finished" << endl; return true; } bool LAPPDLoadStore::DoPedestalSubtract() { - if (LAPPDStoreReadInVerbosity > 0) + if (LAPPDLoadStoreVerbosity > 0) cout << "LAPPDLoadStore::DoPedestalSubtract()" << endl; if (DoPedSubtract == 0) return true; Waveform tmpWave; vector> VecTmpWave; int pedval, val; - if (LAPPDStoreReadInVerbosity > 3) + if (LAPPDLoadStoreVerbosity > 3) { // print the size of data and all keys, and the size of PedestalValues and all keys cout << "Size of data is " << data.size() << endl; @@ -1238,7 +1314,7 @@ bool LAPPDLoadStore::DoPedestalSubtract() for (std::map>::iterator it = data.begin(); it != data.end(); ++it) // looping over the data map by channel number, from 0 to 60 { int wrongPedChannel = 0; - if (LAPPDStoreReadInVerbosity > 5) + if (LAPPDLoadStoreVerbosity > 5) cout << "Do Pedestal sub at Channel " << it->first; for (int kvec = 0; kvec < it->second.size(); kvec++) @@ -1246,7 +1322,7 @@ bool LAPPDLoadStore::DoPedestalSubtract() if (DoPedSubtract == 1) { auto iter = PedestalValues->find((it->first)); - if (kvec == 0 && LAPPDStoreReadInVerbosity > 5) + if (kvec == 0 && LAPPDLoadStoreVerbosity > 5) cout << std::fixed << ", found PedestalValues for channel " << it->first << " with value = " << iter->second.at(0); if (iter != PedestalValues->end() && iter->second.size() > kvec) { @@ -1264,7 +1340,7 @@ bool LAPPDLoadStore::DoPedestalSubtract() } val = it->second.at(kvec); tmpWave.PushSample(0.3 * (double)(val - pedval)); - if (LAPPDStoreReadInVerbosity > 5 && kvec < 10) + if (LAPPDLoadStoreVerbosity > 5 && kvec < 10) cout << ", " << val << "-" << pedval << "=" << 0.3 * (double)(val - pedval); } if (wrongPedChannel != 0) @@ -1284,60 +1360,150 @@ bool LAPPDLoadStore::DoPedestalSubtract() void LAPPDLoadStore::SaveTimeStamps() { - unsigned short beamgate_63_48 = meta.at(7); - unsigned short beamgate_47_32 = meta.at(27); - unsigned short beamgate_31_16 = meta.at(47); - unsigned short beamgate_15_0 = meta.at(67); - std::bitset<16> bits_beamgate_63_48(beamgate_63_48); - std::bitset<16> bits_beamgate_47_32(beamgate_47_32); - std::bitset<16> bits_beamgate_31_16(beamgate_31_16); - std::bitset<16> bits_beamgate_15_0(beamgate_15_0); - unsigned long beamgate_63_0 = (static_cast(beamgate_63_48) << 48) + (static_cast(beamgate_47_32) << 32) + (static_cast(beamgate_31_16) << 16) + (static_cast(beamgate_15_0)); - std::bitset<64> bits_beamgate_63_0(beamgate_63_0); - unsigned long beamgate_timestamp = beamgate_63_0 * (CLOCK_to_NSEC); - m_data->CStore.Set("LAPPDbeamgate", beamgate_timestamp); - m_data->CStore.Set("LAPPDBeamgate_Raw", beamgate_63_0); - - unsigned long BGTruncation = beamgate_63_0 % 8; - unsigned long BGTruncated = beamgate_63_0 - BGTruncation; - unsigned long BGInt = BGTruncated / 8 * 25; - unsigned long BGIntTruncation = BGTruncation * 3; - // save these two to CStore - double BGFloat = BGTruncation * 0.125; - unsigned long BGIntCombined = BGInt + BGIntTruncation; - m_data->CStore.Set("LAPPDBGIntCombined", BGIntCombined); - m_data->CStore.Set("LAPPDBGFloat", BGFloat); - - unsigned short timestamp_63_48 = meta.at(70); - unsigned short timestamp_47_32 = meta.at(50); - unsigned short timestamp_31_16 = meta.at(30); - unsigned short timestamp_15_0 = meta.at(10); - std::bitset<16> bits_timestamp_63_48(timestamp_63_48); - std::bitset<16> bits_timestamp_47_32(timestamp_47_32); - std::bitset<16> bits_timestamp_31_16(timestamp_31_16); - std::bitset<16> bits_timestamp_15_0(timestamp_15_0); - unsigned long timestamp_63_0 = (static_cast(timestamp_63_48) << 48) + (static_cast(timestamp_47_32) << 32) + (static_cast(timestamp_31_16) << 16) + (static_cast(timestamp_15_0)); - unsigned long lappd_timestamp = timestamp_63_0 * (CLOCK_to_NSEC); - m_data->CStore.Set("LAPPDtimestamp", lappd_timestamp); - m_data->CStore.Set("LAPPDTimestamp_Raw", timestamp_63_0); - - unsigned long TSTruncation = timestamp_63_0 % 8; - unsigned long TSTruncated = timestamp_63_0 - TSTruncation; - unsigned long TSInt = TSTruncated / 8 * 25; - unsigned long TSIntTruncation = TSTruncation * 3; - // save these two to CStore - double TSFloat = TSTruncation * 0.125; - unsigned long TSIntCombined = TSInt + TSIntTruncation; - m_data->CStore.Set("LAPPDTSIntCombined", TSIntCombined); - m_data->CStore.Set("LAPPDTSFloat", TSFloat); - - m_data->Stores["ANNIEEvent"]->Set("LAPPDbeamgate", beamgate_timestamp); // in ns - m_data->Stores["ANNIEEvent"]->Set("LAPPDtimestamp", lappd_timestamp); // in ns - m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate_Raw", beamgate_63_0); - m_data->Stores["ANNIEEvent"]->Set("LAPPDTimestamp_Raw", timestamp_63_0); - - if (LAPPDStoreReadInVerbosity > 11) - debugStoreReadIn << eventNo << " LAPPDStoreReadIn, Saving timestamps, beamgate_timestamp: " << beamgate_63_0 << ", lappd_timestamp: " << timestamp_63_0 << endl; + + // PROTECTION: We expect exactly two boards (ACDC 0 and ACDC 1) for each LAPPD. + // Each board produces 103 metadata words (total 206). + // If either ACDC 0 OR ACDC 1 is missing, the offset fitting script ignored this event. + // We must abort and roll back the index to prevent desynchronization from the ROOT tree. + if (meta.size() < 206) + { + std::cout << "LAPPDLoadStore::SaveTimeStamps, WARNING: Event " << eventNo + << " is missing a board (meta size: " << meta.size() + << "). Expected = 206. Skipping to maintain offset index sync!" << std::endl; + + // Roll back the index that was incremented in ParsePSECData + if (LAPPDEventIndex_ID[LAPPD_ID] > 0) { + LAPPDEventIndex_ID[LAPPD_ID] -= 1; + } + return; + } + + // Reconstructing beamgate from ACDC 0 + unsigned short beamgate0_63_48 = meta.at(7); + unsigned short beamgate0_47_32 = meta.at(27); + unsigned short beamgate0_31_16 = meta.at(47); + unsigned short beamgate0_15_0 = meta.at(67); + + unsigned long beamgate0_63_0 = (static_cast(beamgate0_63_48) << 48) + + (static_cast(beamgate0_47_32) << 32) + + (static_cast(beamgate0_31_16) << 16) + + (static_cast(beamgate0_15_0)); + + unsigned long beamgate0_timestamp = beamgate0_63_0 * CLOCK_TO_NSEC; + + // Reconstructing beamgate from ACDC 1 + // There are 103 metadata words per ACDC, so the ACDC 1 beamgate is located 103 words after the corresponding ACDC 0 beamgate words. + unsigned short beamgate1_63_48 = meta.at(7 + ACDC_META_WORDS); + unsigned short beamgate1_47_32 = meta.at(27 + ACDC_META_WORDS); + unsigned short beamgate1_31_16 = meta.at(47 + ACDC_META_WORDS); + unsigned short beamgate1_15_0 = meta.at(67 + ACDC_META_WORDS); + + unsigned long beamgate1_63_0 = + (static_cast(beamgate1_63_48) << 48) + + (static_cast(beamgate1_47_32) << 32) + + (static_cast(beamgate1_31_16) << 16) + + static_cast(beamgate1_15_0); + + unsigned long beamgate1_timestamp = beamgate1_63_0 * CLOCK_TO_NSEC; + + m_data->CStore.Set("LAPPDbeamgate0", beamgate0_timestamp); + m_data->CStore.Set("LAPPDBeamgate0_Raw", beamgate0_63_0); + m_data->CStore.Set("LAPPDbeamgate1", beamgate1_timestamp); + m_data->CStore.Set("LAPPDBeamgate1_Raw", beamgate1_63_0); + + unsigned long BG0_Truncation = beamgate0_63_0 % 8; + unsigned long BG0_Truncated = beamgate0_63_0 - BG0_Truncation; + unsigned long BG0_Int = BG0_Truncated / 8 * 25; + unsigned long BG0_IntTruncation = BG0_Truncation * 3; + double BG0_Float = BG0_Truncation * 0.125; + unsigned long BG0_IntCombined = BG0_Int + BG0_IntTruncation; + + unsigned long BG1_Truncation = beamgate1_63_0 % 8; + unsigned long BG1_Truncated = beamgate1_63_0 - BG1_Truncation; + unsigned long BG1_Int = BG1_Truncated / 8 * 25; + unsigned long BG1_IntTruncation = BG1_Truncation * 3; + double BG1_Float = BG1_Truncation * 0.125; + unsigned long BG1_IntCombined = BG1_Int + BG1_IntTruncation; + + m_data->CStore.Set("LAPPDBG0_IntCombined", BG0_IntCombined); + m_data->CStore.Set("LAPPDBG0_Float", BG0_Float); + m_data->CStore.Set("LAPPDBG1_IntCombined", BG1_IntCombined); + m_data->CStore.Set("LAPPDBG1_Float", BG1_Float); + + // Reconstructing timestamp from ACDC 0 + unsigned short timestamp0_63_48 = meta.at(70); + unsigned short timestamp0_47_32 = meta.at(50); + unsigned short timestamp0_31_16 = meta.at(30); + unsigned short timestamp0_15_0 = meta.at(10); + + unsigned long timestamp0_63_0 = + (static_cast(timestamp0_63_48) << 48) + + (static_cast(timestamp0_47_32) << 32) + + (static_cast(timestamp0_31_16) << 16) + + (static_cast(timestamp0_15_0)); + + unsigned long lappd_timestamp0 = timestamp0_63_0 * CLOCK_TO_NSEC; + + // Reconstructing timestamp from ACDC 1 + unsigned short timestamp1_63_48 = meta.at(70 + ACDC_META_WORDS); + unsigned short timestamp1_47_32 = meta.at(50 + ACDC_META_WORDS); + unsigned short timestamp1_31_16 = meta.at(30 + ACDC_META_WORDS); + unsigned short timestamp1_15_0 = meta.at(10 + ACDC_META_WORDS); + + unsigned long timestamp1_63_0 = + (static_cast(timestamp1_63_48) << 48) + + (static_cast(timestamp1_47_32) << 32) + + (static_cast(timestamp1_31_16) << 16) + + (static_cast(timestamp1_15_0)); + + unsigned long lappd_timestamp1 = timestamp1_63_0 * CLOCK_TO_NSEC; + + m_data->CStore.Set("LAPPDtimestamp0", lappd_timestamp0); + m_data->CStore.Set("LAPPDTimestamp0_Raw", timestamp0_63_0); + m_data->CStore.Set("LAPPDtimestamp1", lappd_timestamp1); + m_data->CStore.Set("LAPPDTimestamp1_Raw", timestamp1_63_0); + + unsigned long TS0_Truncation = timestamp0_63_0 % 8; + unsigned long TS0_Truncated = timestamp0_63_0 - TS0_Truncation; + unsigned long TS0_Int = TS0_Truncated / 8 * 25; + unsigned long TS0_IntTruncation = TS0_Truncation * 3; + double TS0_Float = TS0_Truncation * 0.125; + unsigned long TS0_IntCombined = TS0_Int + TS0_IntTruncation; + + unsigned long TS1_Truncation = timestamp1_63_0 % 8; + unsigned long TS1_Truncated = timestamp1_63_0 - TS1_Truncation; + unsigned long TS1_Int = TS1_Truncated / 8 * 25; + unsigned long TS1_IntTruncation = TS1_Truncation * 3; + double TS1_Float = TS1_Truncation * 0.125; + unsigned long TS1_IntCombined = TS1_Int + TS1_IntTruncation; + + m_data->CStore.Set("LAPPDTS0_IntCombined", TS0_IntCombined); + m_data->CStore.Set("LAPPDTS0_Float", TS0_Float); + m_data->CStore.Set("LAPPDTS1_IntCombined", TS1_IntCombined); + m_data->CStore.Set("LAPPDTS1_Float", TS1_Float); + + m_data->Stores["ANNIEEvent"]->Set("LAPPDbeamgate0", beamgate0_timestamp); // in ns + m_data->Stores["ANNIEEvent"]->Set("LAPPDtimestamp0", lappd_timestamp0); // in ns + m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate0_Raw", beamgate0_63_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTimestamp0_Raw", timestamp0_63_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDbeamgate1", beamgate1_timestamp); // in ns + m_data->Stores["ANNIEEvent"]->Set("LAPPDtimestamp1", lappd_timestamp1); // in ns + m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate1_Raw", beamgate1_63_0); + m_data->Stores["ANNIEEvent"]->Set("LAPPDTimestamp1_Raw", timestamp1_63_0); + + if (LAPPDLoadStoreVerbosity > 5) { + debugLoadStore + << "Event number: " << eventNo + << ", LAPPD ID: " << LAPPD_ID + << ", PSEC index: " << LAPPDEventIndex_ID[LAPPD_ID] + << ", ACC: " << meta[0] + << ", PPS index: " << PPSnumber + << ", Timestamp0: " << timestamp0_63_0 + << ", Beamgate0: " << beamgate0_63_0 + << ", Timestamp1: " << timestamp1_63_0 + << ", Beamgate1: " << beamgate1_63_0 + << std::endl; + } if (loadOffsets && runInfoLoaded) { @@ -1352,221 +1518,146 @@ void LAPPDLoadStore::SaveTimeStamps() void LAPPDLoadStore::SaveOffsets() { int LoadingOffsetID = LAPPD_ID; - if(LoadingOffsetID+1 > LAPPDEventIndex_ID.size()) + if(LoadingOffsetID + 1 > LAPPDEventIndex_ID.size()) { - LAPPDEventIndex_ID.resize(LoadingOffsetID+1); - } - int GetOffsetIndex_byID = LAPPDEventIndex_ID[LoadingOffsetID]; - if(LAPPDStoreReadInVerbosity>0) - cout << "LAPPDStoreReadIn, SavingOffsets, LoadingOffset for LAPPD_ID: " << LoadingOffsetID << ", OffsetIndex of this event: " << GetOffsetIndex_byID << endl; - - std::string key = std::to_string(runNumber) + "_" + std::to_string(subRunNumber) + "_" + std::to_string(partFileNumber) + "_" + std::to_string(LAPPD_ID); - - int LAPPDBGCorrection = 0; - int LAPPDTSCorrection = 0; - int LAPPDOffset_minus_ps = 0; - uint64_t LAPPDOffset = 0; - - uint64_t BG_PPSBefore = 0; - uint64_t BG_PPSAfter = 0; - uint64_t BG_PPSDiff = 0; - uint64_t TS_PPSBefore = 0; - uint64_t TS_PPSAfter = 0; - uint64_t TS_PPSDiff = 0; - int BG_PPSMissing = 0; - int TS_PPSMissing = 0; - - // Check if the key exists and the index is within range for BGCorrections - if (BGCorrections.find(key) != BGCorrections.end() && GetOffsetIndex_byID < BGCorrections[key].size()) - { - LAPPDBGCorrection = BGCorrections[key][GetOffsetIndex_byID]; - } - else - { - if (BGCorrections.find(key) == BGCorrections.end()) - { - std::cerr << "Error: Key not found in BGCorrections: " << key << std::endl; - } - else - { - std::cerr << "Error: GetOffsetIndex_byID out of range for BGCorrections with key: " << key << std::endl; - } + LAPPDEventIndex_ID.resize(LoadingOffsetID + 1); } + + int GetOffsetIndex_byID = LAPPDEventIndex_ID[LoadingOffsetID] - 1; - // Repeat the checks for TSCorrections, Offsets_minus_ps, and Offsets - if (TSCorrections.find(key) != TSCorrections.end() && GetOffsetIndex_byID < TSCorrections[key].size()) - { - LAPPDTSCorrection = TSCorrections[key][GetOffsetIndex_byID]; - } - else - { - if (TSCorrections.find(key) == TSCorrections.end()) - { - std::cerr << "Error: Key not found in TSCorrections: " << key << std::endl; - } - else - { - std::cerr << "Error: GetOffsetIndex_byID out of range for TSCorrections with key: " << key << std::endl; - } + if(LAPPDLoadStoreVerbosity > 0) { + cout << "LAPPDLoadStore::SaveOffsets, Loading offset for LAPPD_ID: " << LoadingOffsetID << ", OffsetIndex of this event: " << GetOffsetIndex_byID << endl; } - if (Offsets_minus_ps.find(key) != Offsets_minus_ps.end() && GetOffsetIndex_byID < Offsets_minus_ps[key].size()) - { - LAPPDOffset_minus_ps = Offsets_minus_ps[key][GetOffsetIndex_byID]; - } - else - { - if (Offsets_minus_ps.find(key) == Offsets_minus_ps.end()) - { - std::cerr << "Error: Key not found in Offsets_minus_ps: " << key << std::endl; - } - else - { - std::cerr << "Error: GetOffsetIndex_byID out of range for Offsets_minus_ps with key: " << key << std::endl; - } - } + std::string key = std::to_string(runNumber) + "_" + std::to_string(subRunNumber) + "_" + std::to_string(partFileNumber) + "_" + std::to_string(LAPPD_ID); - if (Offsets.find(key) != Offsets.end() && GetOffsetIndex_byID < Offsets[key].size()) - { - LAPPDOffset = Offsets[key][GetOffsetIndex_byID]; - } - else - { - if (Offsets.find(key) == Offsets.end()) - { - std::cerr << "Error: Key not found in Offsets: " << key << std::endl; - } - else - { - std::cerr << "Error: GetOffsetIndex_byID out of range for Offsets with key: " << key << std::endl; + // Variables for Board 0 + int LAPPDBGCorrection_0 = 0, LAPPDTSCorrection_0 = 0; + int LAPPDOffset_minus_ps_0 = 0; + uint64_t LAPPDOffset_0 = 0; + uint64_t BG_PPSBefore_0 = 0, BG_PPSAfter_0 = 0, BG_PPSDiff_0 = 0; + uint64_t TS_PPSBefore_0 = 0, TS_PPSAfter_0 = 0, TS_PPSDiff_0 = 0; + int BG_PPSMissing_0 = 0, TS_PPSMissing_0 = 0; + + // Variables for Board 1 + int LAPPDBGCorrection_1 = 0, LAPPDTSCorrection_1 = 0; + int LAPPDOffset_minus_ps_1 = 0; + uint64_t LAPPDOffset_1 = 0; + uint64_t BG_PPSBefore_1 = 0, BG_PPSAfter_1 = 0, BG_PPSDiff_1 = 0; + uint64_t TS_PPSBefore_1 = 0, TS_PPSAfter_1 = 0, TS_PPSDiff_1 = 0; + int BG_PPSMissing_1 = 0, TS_PPSMissing_1 = 0; + + // Check if the key exists and the index is within range for loaded offsets and corrections + auto fetchValue = [&](const auto& mapObj, const std::string& mapName, auto& targetVar) { + auto it = mapObj.find(key); + if (it != mapObj.end() && GetOffsetIndex_byID < it->second.size()) { + targetVar = it->second[GetOffsetIndex_byID]; + } else { + if (it == mapObj.end()) { + std::cerr << "Error: Key not found in " << mapName << ": " << key << std::endl; + } else { + std::cerr << "Error: Index out of range for " << mapName << " with key: " << key << std::endl; + } } + }; + + // Fetch Board 0 variables + fetchValue(BGCorrections_0, "BGCorrections_0", LAPPDBGCorrection_0); + fetchValue(TSCorrections_0, "TSCorrections_0", LAPPDTSCorrection_0); + fetchValue(Offsets_minus_ps_0, "Offsets_minus_ps_0", LAPPDOffset_minus_ps_0); + fetchValue(Offsets_0, "Offsets_0", LAPPDOffset_0); + fetchValue(BG_PPSBefore_loaded_0, "BG_PPSBefore_loaded_0", BG_PPSBefore_0); + fetchValue(BG_PPSAfter_loaded_0, "BG_PPSAfter_loaded_0", BG_PPSAfter_0); + fetchValue(BG_PPSDiff_loaded_0, "BG_PPSDiff_loaded_0", BG_PPSDiff_0); + fetchValue(BG_PPSMissing_loaded_0, "BG_PPSMissing_loaded_0", BG_PPSMissing_0); + fetchValue(TS_PPSBefore_loaded_0, "TS_PPSBefore_loaded_0", TS_PPSBefore_0); + fetchValue(TS_PPSAfter_loaded_0, "TS_PPSAfter_loaded_0", TS_PPSAfter_0); + fetchValue(TS_PPSDiff_loaded_0, "TS_PPSDiff_loaded_0", TS_PPSDiff_0); + fetchValue(TS_PPSMissing_loaded_0, "TS_PPSMissing_loaded_0", TS_PPSMissing_0); + + // Fetch Board 1 variables + fetchValue(BGCorrections_1, "BGCorrections_1", LAPPDBGCorrection_1); + fetchValue(TSCorrections_1, "TSCorrections_1", LAPPDTSCorrection_1); + fetchValue(Offsets_minus_ps_1, "Offsets_minus_ps_1", LAPPDOffset_minus_ps_1); + fetchValue(Offsets_1, "Offsets_1", LAPPDOffset_1); + fetchValue(BG_PPSBefore_loaded_1, "BG_PPSBefore_loaded_1", BG_PPSBefore_1); + fetchValue(BG_PPSAfter_loaded_1, "BG_PPSAfter_loaded_1", BG_PPSAfter_1); + fetchValue(BG_PPSDiff_loaded_1, "BG_PPSDiff_loaded_1", BG_PPSDiff_1); + fetchValue(BG_PPSMissing_loaded_1, "BG_PPSMissing_loaded_1", BG_PPSMissing_1); + fetchValue(TS_PPSBefore_loaded_1, "TS_PPSBefore_loaded_1", TS_PPSBefore_1); + fetchValue(TS_PPSAfter_loaded_1, "TS_PPSAfter_loaded_1", TS_PPSAfter_1); + fetchValue(TS_PPSDiff_loaded_1, "TS_PPSDiff_loaded_1", TS_PPSDiff_1); + fetchValue(TS_PPSMissing_loaded_1, "TS_PPSMissing_loaded_1", TS_PPSMissing_1); + + // Push Board 0 to CStore + m_data->CStore.Set("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + m_data->CStore.Set("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + m_data->CStore.Set("LAPPDOffset_0", LAPPDOffset_0); + m_data->CStore.Set("LAPPDOffset_minus_ps_0", LAPPDOffset_minus_ps_0); + m_data->CStore.Set("BG_PPSBefore_0", BG_PPSBefore_0); + m_data->CStore.Set("BG_PPSAfter_0", BG_PPSAfter_0); + m_data->CStore.Set("BG_PPSDiff_0", BG_PPSDiff_0); + m_data->CStore.Set("BG_PPSMissing_0", BG_PPSMissing_0); + m_data->CStore.Set("TS_PPSBefore_0", TS_PPSBefore_0); + m_data->CStore.Set("TS_PPSAfter_0", TS_PPSAfter_0); + m_data->CStore.Set("TS_PPSDiff_0", TS_PPSDiff_0); + m_data->CStore.Set("TS_PPSMissing_0", TS_PPSMissing_0); + + // Push Board 1 to CStore + m_data->CStore.Set("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + m_data->CStore.Set("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + m_data->CStore.Set("LAPPDOffset_1", LAPPDOffset_1); + m_data->CStore.Set("LAPPDOffset_minus_ps_1", LAPPDOffset_minus_ps_1); + m_data->CStore.Set("BG_PPSBefore_1", BG_PPSBefore_1); + m_data->CStore.Set("BG_PPSAfter_1", BG_PPSAfter_1); + m_data->CStore.Set("BG_PPSDiff_1", BG_PPSDiff_1); + m_data->CStore.Set("BG_PPSMissing_1", BG_PPSMissing_1); + m_data->CStore.Set("TS_PPSBefore_1", TS_PPSBefore_1); + m_data->CStore.Set("TS_PPSAfter_1", TS_PPSAfter_1); + m_data->CStore.Set("TS_PPSDiff_1", TS_PPSDiff_1); + m_data->CStore.Set("TS_PPSMissing_1", TS_PPSMissing_1); + + if (TS_PPSMissing_0 != BG_PPSMissing_0 || TS_PPSMissing_1 != BG_PPSMissing_1) { + std::cout << "LAPPDLoadStore::SaveOffsets, PPS Missing mismatch detected. BG_0: " << BG_PPSMissing_0 + << " TS_0: " << TS_PPSMissing_0 << " | BG_1: " << BG_PPSMissing_1 + << " TS_1: " << TS_PPSMissing_1 << std::endl; } - - if (BG_PPSBefore_loaded.find(key) != BG_PPSBefore_loaded.end() && GetOffsetIndex_byID < BG_PPSBefore_loaded[key].size()) - { - BG_PPSBefore = BG_PPSBefore_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (BG_PPSBefore_loaded.find(key) == BG_PPSBefore_loaded.end()) - std::cerr << "Error: Key not found in BG_PPSBefore_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for BG_PPSBefore_loaded with key: " << key << std::endl; - } - - if (BG_PPSAfter_loaded.find(key) != BG_PPSAfter_loaded.end() && GetOffsetIndex_byID < BG_PPSAfter_loaded[key].size()) - { - BG_PPSAfter = BG_PPSAfter_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (BG_PPSAfter_loaded.find(key) == BG_PPSAfter_loaded.end()) - std::cerr << "Error: Key not found in BG_PPSAfter_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for BG_PPSAfter_loaded with key: " << key << std::endl; + + if (LAPPDLoadStoreVerbosity > 5) { + debugLoadStore + << "Event number: " << eventNo + << ", LAPPDLoadStore, Saving offsets, key: " << key + << ", LAPPD_ID: " << LAPPD_ID + << ", idx: " << GetOffsetIndex_byID + << std::endl; + + debugLoadStore + << ", TS_PPSBefore_0: " << TS_PPSBefore_0 + << ", BG_PPSBefore_0: " << BG_PPSBefore_0 + << ", TS_PPSAfter_0: " << TS_PPSAfter_0 + << ", BG_PPSAfter_0: " << BG_PPSAfter_0 + << ", LAPPDOffset_0: " << LAPPDOffset_0 + << ", LAPPDOffset_minus_ps_0: " << LAPPDOffset_minus_ps_0 + << ", LAPPDTSCorrection_0: " << LAPPDTSCorrection_0 + << ", LAPPDBGCorrection_0: " << LAPPDBGCorrection_0 + << std::endl; + + debugLoadStore + << ", TS_PPSBefore_1: " << TS_PPSBefore_1 + << ", BG_PPSBefore_1: " << BG_PPSBefore_1 + << ", TS_PPSAfter_1: " << TS_PPSAfter_1 + << ", BG_PPSAfter_1: " << BG_PPSAfter_1 + << ", LAPPDOffset_1: " << LAPPDOffset_1 + << ", LAPPDOffset_minus_ps_1: " << LAPPDOffset_minus_ps_1 + << ", LAPPDTSCorrection_1: " << LAPPDTSCorrection_1 + << ", LAPPDBGCorrection_1: " << LAPPDBGCorrection_1 + << std::endl; } - - if (BG_PPSDiff_loaded.find(key) != BG_PPSDiff_loaded.end() && GetOffsetIndex_byID < BG_PPSDiff_loaded[key].size()) - { - BG_PPSDiff = BG_PPSDiff_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (BG_PPSDiff_loaded.find(key) == BG_PPSDiff_loaded.end()) - std::cerr << "Error: Key not found in BG_PPSDiff_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for BG_PPSDiff_loaded with key: " << key << std::endl; - } - - if (BG_PPSMissing_loaded.find(key) != BG_PPSMissing_loaded.end() && GetOffsetIndex_byID < BG_PPSMissing_loaded[key].size()) - { - BG_PPSMissing = BG_PPSMissing_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (BG_PPSMissing_loaded.find(key) == BG_PPSMissing_loaded.end()) - std::cerr << "Error: Key not found in BG_PPSMissing_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for BG_PPSMissing_loaded with key: " << key << std::endl; - } - - if (TS_PPSBefore_loaded.find(key) != TS_PPSBefore_loaded.end() && GetOffsetIndex_byID < TS_PPSBefore_loaded[key].size()) - { - TS_PPSBefore = TS_PPSBefore_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (TS_PPSBefore_loaded.find(key) == TS_PPSBefore_loaded.end()) - std::cerr << "Error: Key not found in TS_PPSBefore_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for TS_PPSBefore_loaded with key: " << key << std::endl; - } - - if (TS_PPSAfter_loaded.find(key) != TS_PPSAfter_loaded.end() && GetOffsetIndex_byID < TS_PPSAfter_loaded[key].size()) - { - TS_PPSAfter = TS_PPSAfter_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (TS_PPSAfter_loaded.find(key) == TS_PPSAfter_loaded.end()) - std::cerr << "Error: Key not found in TS_PPSAfter_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for TS_PPSAfter_loaded with key: " << key << std::endl; - } - - if (TS_PPSDiff_loaded.find(key) != TS_PPSDiff_loaded.end() && GetOffsetIndex_byID < TS_PPSDiff_loaded[key].size()) - { - TS_PPSDiff = TS_PPSDiff_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (TS_PPSDiff_loaded.find(key) == TS_PPSDiff_loaded.end()) - std::cerr << "Error: Key not found in TS_PPSDiff_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for TS_PPSDiff_loaded with key: " << key << std::endl; - } - - if (TS_PPSMissing_loaded.find(key) != TS_PPSMissing_loaded.end() && GetOffsetIndex_byID < TS_PPSMissing_loaded[key].size()) - { - TS_PPSMissing = TS_PPSMissing_loaded[key][GetOffsetIndex_byID]; - } - else - { - if (TS_PPSMissing_loaded.find(key) == TS_PPSMissing_loaded.end()) - std::cerr << "Error: Key not found in TS_PPSMissing_loaded: " << key << std::endl; - else - std::cerr << "Error: GetOffsetIndex_byID out of range for TS_PPSMissing_loaded with key: " << key << std::endl; - } - - // start to fill data - m_data->CStore.Set("LAPPDBGCorrection", LAPPDBGCorrection); - m_data->CStore.Set("LAPPDTSCorrection", LAPPDTSCorrection); - m_data->CStore.Set("LAPPDOffset", LAPPDOffset); - m_data->CStore.Set("LAPPDOffset_minus_ps", LAPPDOffset_minus_ps); - - m_data->CStore.Set("BG_PPSBefore", BG_PPSBefore); - m_data->CStore.Set("BG_PPSAfter", BG_PPSAfter); - m_data->CStore.Set("BG_PPSDiff", BG_PPSDiff); - m_data->CStore.Set("BG_PPSMissing", BG_PPSMissing); - m_data->CStore.Set("TS_PPSBefore", TS_PPSBefore); - m_data->CStore.Set("TS_PPSAfter", TS_PPSAfter); - m_data->CStore.Set("TS_PPSDiff", TS_PPSDiff); - m_data->CStore.Set("TS_PPSMissing", TS_PPSMissing); - - if (TS_PPSMissing != BG_PPSMissing) - { - cout << "LAPPDLoadStore: BG_PPSMissing != TS_PPSMissing, BG_PPSMissing: " << BG_PPSMissing << ", TS_PPSMissing: " << TS_PPSMissing << endl; - } - - // cout << "LAPPDStoreReadIn, Saving offsets and corrections, key: " << key << ", LAPPDOffset: " << LAPPDOffset << ", LAPPDOffset_minus_ps: " << LAPPDOffset_minus_ps << ", LAPPDBGCorrection: " << LAPPDBGCorrection << ", LAPPDTSCorrection: " << LAPPDTSCorrection << ", BG_PPSBefore: " << BG_PPSBefore << ", BG_PPSAfter: " << BG_PPSAfter << ", BG_PPSDiff: " << BG_PPSDiff << ", BG_PPSMissing: " << BG_PPSMissing << ", TS_PPSBefore: " << TS_PPSBefore << ", TS_PPSAfter: " << TS_PPSAfter << ", TS_PPSDiff: " << TS_PPSDiff << ", TS_PPSMissing: " << TS_PPSMissing << endl; - - if (LAPPDStoreReadInVerbosity > 11) - debugStoreReadIn << eventNo << "+LAPPDStoreReadIn, Saving offsets and corrections, key: " << key << ", LAPPDOffset: " << LAPPDOffset << ", LAPPDOffset_minus_ps: " << LAPPDOffset_minus_ps << ", LAPPDBGCorrection: " << LAPPDBGCorrection << ", LAPPDTSCorrection: " << LAPPDTSCorrection << endl; } void LAPPDLoadStore::LoadOffsetsAndCorrections() { - // load here from the root tree to: + // Load Offsets from both ACDCs here from the offsetFitResult.root output. /* std::map> Offsets; //Loaded offset, use string = run number + sub run number + partfile number as key. std::map> Offsets_minus_ps; //offset in ps, use offset - this/1e3 as the real offset @@ -1580,89 +1671,132 @@ void LAPPDLoadStore::LoadOffsetsAndCorrections() if (!tree) { - std::cerr << "LAPPDStoreReadIn Loading offsets, Tree not found!" << std::endl; + std::cerr << "LAPPDLoadStore Loading offsets, Tree not found!" << std::endl; return; } int runNumber, subRunNumber, partFileNumber, LAPPD_ID; - ULong64_t final_offset_ns_0, final_offset_ps_negative_0, EventIndex; - ULong64_t BGCorrection_tick, TSCorrection_tick; - - ULong64_t BG_PPSBefore_tick; - ULong64_t BG_PPSAfter_tick; - ULong64_t BG_PPSDiff_tick; - ULong64_t BG_PPSMissing_tick; - ULong64_t TS_PPSBefore_tick; - ULong64_t TS_PPSAfter_tick; - ULong64_t TS_PPSDiff_tick; - ULong64_t TS_PPSMissing_tick; - ULong64_t TS_driftCorrection_ns; - ULong64_t BG_driftCorrection_ns; + ULong64_t EventIndex; + + // ACDC 0 variables + ULong64_t final_offset_ns_0, final_offset_ps_negative_0; + ULong64_t BGCorrection_tick_0, TSCorrection_tick_0; + ULong64_t BG_PPSBefore_tick_0, BG_PPSAfter_tick_0, BG_PPSDiff_tick_0, BG_PPSMissing_tick_0; + ULong64_t TS_PPSBefore_tick_0, TS_PPSAfter_tick_0, TS_PPSDiff_tick_0, TS_PPSMissing_tick_0; + ULong64_t TS_driftCorrection_ns_0, BG_driftCorrection_ns_0; + + // ACDC 1 variables + ULong64_t final_offset_ns_1, final_offset_ps_negative_1; + ULong64_t BGCorrection_tick_1, TSCorrection_tick_1; + ULong64_t BG_PPSBefore_tick_1, BG_PPSAfter_tick_1, BG_PPSDiff_tick_1, BG_PPSMissing_tick_1; + ULong64_t TS_PPSBefore_tick_1, TS_PPSAfter_tick_1, TS_PPSDiff_tick_1, TS_PPSMissing_tick_1; + ULong64_t TS_driftCorrection_ns_1, BG_driftCorrection_ns_1; tree->SetBranchAddress("runNumber", &runNumber); tree->SetBranchAddress("subRunNumber", &subRunNumber); tree->SetBranchAddress("partFileNumber", &partFileNumber); tree->SetBranchAddress("LAPPD_ID", &LAPPD_ID); tree->SetBranchAddress("EventIndex", &EventIndex); + + // Map ACDC 0 branches tree->SetBranchAddress("final_offset_ns_0", &final_offset_ns_0); tree->SetBranchAddress("final_offset_ps_negative_0", &final_offset_ps_negative_0); - tree->SetBranchAddress("BGCorrection_tick", &BGCorrection_tick); - tree->SetBranchAddress("TSCorrection_tick", &TSCorrection_tick); - tree->SetBranchAddress("BG_PPSBefore_tick", &BG_PPSBefore_tick); - tree->SetBranchAddress("BG_PPSAfter_tick", &BG_PPSAfter_tick); - tree->SetBranchAddress("BG_PPSDiff_tick", &BG_PPSDiff_tick); - tree->SetBranchAddress("BG_PPSMissing_tick", &BG_PPSMissing_tick); - tree->SetBranchAddress("TS_PPSBefore_tick", &TS_PPSBefore_tick); - tree->SetBranchAddress("TS_PPSAfter_tick", &TS_PPSAfter_tick); - tree->SetBranchAddress("TS_PPSDiff_tick", &TS_PPSDiff_tick); - tree->SetBranchAddress("TS_PPSMissing_tick", &TS_PPSMissing_tick); - tree->SetBranchAddress("TS_driftCorrection_ns", &TS_driftCorrection_ns); - tree->SetBranchAddress("BG_driftCorrection_ns", &BG_driftCorrection_ns); + tree->SetBranchAddress("BGCorrection_tick_0", &BGCorrection_tick_0); + tree->SetBranchAddress("TSCorrection_tick_0", &TSCorrection_tick_0); + tree->SetBranchAddress("BG_PPSBefore_tick_0", &BG_PPSBefore_tick_0); + tree->SetBranchAddress("BG_PPSAfter_tick_0", &BG_PPSAfter_tick_0); + tree->SetBranchAddress("BG_PPSDiff_tick_0", &BG_PPSDiff_tick_0); + tree->SetBranchAddress("BG_PPSMissing_tick_0", &BG_PPSMissing_tick_0); + tree->SetBranchAddress("TS_PPSBefore_tick_0", &TS_PPSBefore_tick_0); + tree->SetBranchAddress("TS_PPSAfter_tick_0", &TS_PPSAfter_tick_0); + tree->SetBranchAddress("TS_PPSDiff_tick_0", &TS_PPSDiff_tick_0); + tree->SetBranchAddress("TS_PPSMissing_tick_0", &TS_PPSMissing_tick_0); + tree->SetBranchAddress("TS_driftCorrection_ns_0", &TS_driftCorrection_ns_0); + tree->SetBranchAddress("BG_driftCorrection_ns_0", &BG_driftCorrection_ns_0); + + // Map ACDC 1 branches + tree->SetBranchAddress("final_offset_ns_1", &final_offset_ns_1); + tree->SetBranchAddress("final_offset_ps_negative_1", &final_offset_ps_negative_1); + tree->SetBranchAddress("BGCorrection_tick_1", &BGCorrection_tick_1); + tree->SetBranchAddress("TSCorrection_tick_1", &TSCorrection_tick_1); + tree->SetBranchAddress("BG_PPSBefore_tick_1", &BG_PPSBefore_tick_1); + tree->SetBranchAddress("BG_PPSAfter_tick_1", &BG_PPSAfter_tick_1); + tree->SetBranchAddress("BG_PPSDiff_tick_1", &BG_PPSDiff_tick_1); + tree->SetBranchAddress("BG_PPSMissing_tick_1", &BG_PPSMissing_tick_1); + tree->SetBranchAddress("TS_PPSBefore_tick_1", &TS_PPSBefore_tick_1); + tree->SetBranchAddress("TS_PPSAfter_tick_1", &TS_PPSAfter_tick_1); + tree->SetBranchAddress("TS_PPSDiff_tick_1", &TS_PPSDiff_tick_1); + tree->SetBranchAddress("TS_PPSMissing_tick_1", &TS_PPSMissing_tick_1); + tree->SetBranchAddress("TS_driftCorrection_ns_1", &TS_driftCorrection_ns_1); + tree->SetBranchAddress("BG_driftCorrection_ns_1", &BG_driftCorrection_ns_1); Long64_t nentries = tree->GetEntries(); - cout << "LAPPDStoreReadIn Loading offsets and corrections, total entries: " << nentries << endl; + std::cout << "LAPPDLoadStore::LoadOffsetsAndCorrections, total entries: " << nentries << std::endl; for (Long64_t i = 0; i < nentries; ++i) { tree->GetEntry(i); - std::string key = std::to_string(runNumber) + "_" + std::to_string(subRunNumber) + "_" + std::to_string(partFileNumber) + "_" + std::to_string(LAPPD_ID); - // Prepare the vector sizes for each map - if (Offsets[key].size() <= EventIndex) + // Resize vectors dynamically for EventIndex + if (Offsets_0[key].size() <= EventIndex) { - Offsets[key].resize(EventIndex + 1); - Offsets_minus_ps[key].resize(EventIndex + 1); - BGCorrections[key].resize(EventIndex + 1); - TSCorrections[key].resize(EventIndex + 1); - BG_PPSBefore_loaded[key].resize(EventIndex + 1); - BG_PPSAfter_loaded[key].resize(EventIndex + 1); - BG_PPSDiff_loaded[key].resize(EventIndex + 1); - BG_PPSMissing_loaded[key].resize(EventIndex + 1); - TS_PPSBefore_loaded[key].resize(EventIndex + 1); - TS_PPSAfter_loaded[key].resize(EventIndex + 1); - TS_PPSDiff_loaded[key].resize(EventIndex + 1); - TS_PPSMissing_loaded[key].resize(EventIndex + 1); + Offsets_0[key].resize(EventIndex + 1); + Offsets_minus_ps_0[key].resize(EventIndex + 1); + BGCorrections_0[key].resize(EventIndex + 1); + TSCorrections_0[key].resize(EventIndex + 1); + BG_PPSBefore_loaded_0[key].resize(EventIndex + 1); + BG_PPSAfter_loaded_0[key].resize(EventIndex + 1); + BG_PPSDiff_loaded_0[key].resize(EventIndex + 1); + BG_PPSMissing_loaded_0[key].resize(EventIndex + 1); + TS_PPSBefore_loaded_0[key].resize(EventIndex + 1); + TS_PPSAfter_loaded_0[key].resize(EventIndex + 1); + TS_PPSDiff_loaded_0[key].resize(EventIndex + 1); + TS_PPSMissing_loaded_0[key].resize(EventIndex + 1); + + Offsets_1[key].resize(EventIndex + 1); + Offsets_minus_ps_1[key].resize(EventIndex + 1); + BGCorrections_1[key].resize(EventIndex + 1); + TSCorrections_1[key].resize(EventIndex + 1); + BG_PPSBefore_loaded_1[key].resize(EventIndex + 1); + BG_PPSAfter_loaded_1[key].resize(EventIndex + 1); + BG_PPSDiff_loaded_1[key].resize(EventIndex + 1); + BG_PPSMissing_loaded_1[key].resize(EventIndex + 1); + TS_PPSBefore_loaded_1[key].resize(EventIndex + 1); + TS_PPSAfter_loaded_1[key].resize(EventIndex + 1); + TS_PPSDiff_loaded_1[key].resize(EventIndex + 1); + TS_PPSMissing_loaded_1[key].resize(EventIndex + 1); } // Now using EventIndex to place each event correctly - Offsets[key][EventIndex] = final_offset_ns_0 + TS_driftCorrection_ns; - Offsets_minus_ps[key][EventIndex] = static_cast(final_offset_ps_negative_0); - BGCorrections[key][EventIndex] = static_cast(BGCorrection_tick) - 1000; - TSCorrections[key][EventIndex] = static_cast(TSCorrection_tick) - 1000; - - BG_PPSBefore_loaded[key][EventIndex] = BG_PPSBefore_tick; - BG_PPSAfter_loaded[key][EventIndex] = BG_PPSAfter_tick; - BG_PPSDiff_loaded[key][EventIndex] = BG_PPSDiff_tick; - BG_PPSMissing_loaded[key][EventIndex] = static_cast(BG_PPSMissing_tick) - 1000; - TS_PPSBefore_loaded[key][EventIndex] = TS_PPSBefore_tick; - TS_PPSAfter_loaded[key][EventIndex] = TS_PPSAfter_tick; - TS_PPSDiff_loaded[key][EventIndex] = TS_PPSDiff_tick; - TS_PPSMissing_loaded[key][EventIndex] = static_cast(TS_PPSMissing_tick) - 1000; + Offsets_0[key][EventIndex] = final_offset_ns_0 + TS_driftCorrection_ns_0; + Offsets_minus_ps_0[key][EventIndex] = static_cast(final_offset_ps_negative_0); + BGCorrections_0[key][EventIndex] = static_cast(BGCorrection_tick_0) - 1000; + TSCorrections_0[key][EventIndex] = static_cast(TSCorrection_tick_0) - 1000; + BG_PPSBefore_loaded_0[key][EventIndex] = BG_PPSBefore_tick_0; + BG_PPSAfter_loaded_0[key][EventIndex] = BG_PPSAfter_tick_0; + BG_PPSDiff_loaded_0[key][EventIndex] = BG_PPSDiff_tick_0; + BG_PPSMissing_loaded_0[key][EventIndex] = static_cast(BG_PPSMissing_tick_0) - 1000; + TS_PPSBefore_loaded_0[key][EventIndex] = TS_PPSBefore_tick_0; + TS_PPSAfter_loaded_0[key][EventIndex] = TS_PPSAfter_tick_0; + TS_PPSDiff_loaded_0[key][EventIndex] = TS_PPSDiff_tick_0; + TS_PPSMissing_loaded_0[key][EventIndex] = static_cast(TS_PPSMissing_tick_0) - 1000; + + Offsets_1[key][EventIndex] = final_offset_ns_1 + TS_driftCorrection_ns_1; + Offsets_minus_ps_1[key][EventIndex] = static_cast(final_offset_ps_negative_1); + BGCorrections_1[key][EventIndex] = static_cast(BGCorrection_tick_1) - 1000; + TSCorrections_1[key][EventIndex] = static_cast(TSCorrection_tick_1) - 1000; + BG_PPSBefore_loaded_1[key][EventIndex] = BG_PPSBefore_tick_1; + BG_PPSAfter_loaded_1[key][EventIndex] = BG_PPSAfter_tick_1; + BG_PPSDiff_loaded_1[key][EventIndex] = BG_PPSDiff_tick_1; + BG_PPSMissing_loaded_1[key][EventIndex] = static_cast(BG_PPSMissing_tick_1) - 1000; + TS_PPSBefore_loaded_1[key][EventIndex] = TS_PPSBefore_tick_1; + TS_PPSAfter_loaded_1[key][EventIndex] = TS_PPSAfter_tick_1; + TS_PPSDiff_loaded_1[key][EventIndex] = TS_PPSDiff_tick_1; + TS_PPSMissing_loaded_1[key][EventIndex] = static_cast(TS_PPSMissing_tick_1) - 1000; if (nentries > 10 && i % (static_cast(nentries / 10)) == 0) { - cout << "LAPPDStoreReadIn Loading offsets and corrections, " << i << " entries loaded" << endl; - cout << "Printing key: " << key << ", EventIndex: " << EventIndex << ", final_offset_ns_0: " << final_offset_ns_0 << ", final_offset_ps_negative_0: " << final_offset_ps_negative_0 << ", BGCorrection_tick: " << BGCorrection_tick << ", TSCorrection_tick: " << TSCorrection_tick << ", BG_PPSMissing_tick: " << BG_PPSMissing_tick << ", TS_PPSMissing_tick: " << TS_PPSMissing_tick << ", TS_driftCorrection_ns: " << TS_driftCorrection_ns << ", BG_driftCorrection_ns: " << BG_driftCorrection_ns << endl; + std::cout << "LAPPDLoadStore::LoadOffsetsAndCorrections, " << i << " entries loaded" << std::endl; } } @@ -1674,8 +1808,8 @@ void LAPPDLoadStore::LoadOffsetsAndCorrections() void LAPPDLoadStore::LoadRunInfo() { - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn, Loading run info" << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore, Loading run info" << endl; int PFNumberBeforeGet = partFileNumber; m_data->CStore.Get("rawFileNumber", partFileNumber); m_data->CStore.Get("runNumber", runNumber); @@ -1694,19 +1828,19 @@ void LAPPDLoadStore::LoadRunInfo() { eventNumberInPF++; } - if (LAPPDStoreReadInVerbosity > 0) - cout << "LAPPDStoreReadIn, Loaded run info, runNumber: " << runNumber << ", subRunNumber: " << subRunNumber << ", partFileNumber: " << partFileNumber << ", eventNumberInPF: " << eventNumberInPF << endl; + if (LAPPDLoadStoreVerbosity > 0) + cout << "LAPPDLoadStore, Loaded run info, runNumber: " << runNumber << ", subRunNumber: " << subRunNumber << ", partFileNumber: " << partFileNumber << ", eventNumberInPF: " << eventNumberInPF << endl; if (runNumber<1) { - if (LAPPDStoreReadInVerbosity > 1) - cout << "LAPPDStoreReadIn, runNumber is "<< runNumber << ", trying to get from ANNIEEvent Store" << endl; + if (LAPPDLoadStoreVerbosity > 1) + cout << "LAPPDLoadStore, runNumber is "<< runNumber << ", trying to get from ANNIEEvent Store" << endl; m_data->Stores["ANNIEEvent"]->Get("RunNumber", runNumber); m_data->Stores["ANNIEEvent"]->Get("SubRunNumber", subRunNumber); m_data->Stores["ANNIEEvent"]->Get("PartNumber", partFileNumber); - if (LAPPDStoreReadInVerbosity > 1) - cout << "LAPPDStoreReadIn, Got run info from ANNIEEvent Store, runNumber: " << runNumber << ", subRunNumber: " << subRunNumber << ", partFileNumber: " << partFileNumber << endl; + if (LAPPDLoadStoreVerbosity > 1) + cout << "LAPPDLoadStore, Got run info from ANNIEEvent Store, runNumber: " << runNumber << ", subRunNumber: " << subRunNumber << ", partFileNumber: " << partFileNumber << endl; } } diff --git a/UserTools/LAPPDLoadStore/LAPPDLoadStore.h b/UserTools/LAPPDLoadStore/LAPPDLoadStore.h index 6b69bb6ec..d49aa228d 100644 --- a/UserTools/LAPPDLoadStore/LAPPDLoadStore.h +++ b/UserTools/LAPPDLoadStore/LAPPDLoadStore.h @@ -16,20 +16,19 @@ #define NUM_SAMP 256 using namespace std; -/** - * \class LAPPDLoadStore - * - * Load LAPPD PSEC data and PPS data from BoostStore. - * - */ + +// class LAPPDLoadStore +// Load LAPPD PSEC data and PPS data from BoostStore. + class LAPPDLoadStore : public Tool { public: LAPPDLoadStore(); ///< Simple constructor - bool Initialise(std::string configfile, DataModel &data); ///< Initialise Function for setting up Tool resources. @param configfile The path and name of the dynamic configuration file to read in. @param data A reference to the transient data class used to pass information between Tools. + bool Initialise(std::string configfile, DataModel &data); ///< Initialise Function for setting up Tool resources. bool Execute(); ///< Execute function used to perform Tool purpose. bool Finalise(); ///< Finalise function used to clean up resources. + bool ReadPedestals(int boardNo); ///< Read in the Pedestal Files bool MakePedestals(); ///< Make a Pedestal File @@ -50,37 +49,38 @@ class LAPPDLoadStore : public Tool tuple queryNearestACCID(const vector& data, int targetRun, int manufacturerID); private: - // This tool, control variables (only used in this tool, every thing that is not an data object) - // Variables that you get from the config file - int ReadStore; // read data from a StoreFile (tool chain start with this tool rather than LoadANNIEEvent) - int Nboards; // total number of boards to load pedestal file, LAPPD number * 2 - string PedFileName; // store format pedestal file name - string PedFileNameTXT; // txt format pedestal file name - int DoPedSubtract; // 1: do pedestal subtraction, 0: don't do pedestal subtraction - int LAPPDStoreReadInVerbosity; + static constexpr double CLOCK_TO_NSEC = 3.125; + static constexpr int ACDC_META_WORDS = 103; + + // Tool Control Variables (Loaded from config file) + int ReadStore; // read data from a StoreFile (tool chain start with this tool rather than LoadANNIEEvent) + int Nboards; // total number of boards to load pedestal file, LAPPD count * 2 + string PedFileNameTXT; // txt format pedestal file name + int DoPedSubtract; // 1: do pedestal subtraction, 0: don't do pedestal subtraction + int LAPPDLoadStoreVerbosity; int num_vector_data; int num_vector_pps; bool SelectSingleLAPPD; int SelectedLAPPD; bool mergingModeReadIn; bool ReadStorePdeFile; - bool MultiLAPPDMap; // loading map of multiple LAPPDs from ANNIEEvent + bool MultiLAPPDMap; // loading map of multiple LAPPDs from ANNIEEvent bool loadOffsets; bool LoadBuiltPPSInfo; bool loadFromStoreDirectly; - // Variables that you need in the tool - int retval; // track the data parsing and meta parsing status + + // Internal Tool State Variables + int retval; // track the data parsing and meta parsing status int eventNo; - double CLOCK_to_NSEC; - int errorEventsNumber; + int errorEventsNumber; + int stopEntries; // stop tool chain after loading this number of PSEC data events + int NonEmptyEvents; // count how many non empty data events were loaded + int NonEmptyDataEvents; // count how many non empty data events were loaded bool runInfoLoaded; - // LAPPD tool chain, control variables (Will be shared in multiple LAPPD tools to show the state of the tool chain in each loop) + // LAPPD Tool Chain Variables (Shared across multiple LAPPD tools) // Variables that you get from the config file - int stopEntries; // stop tool chain after loading this number of PSEC data events - int NonEmptyEvents; // count how many non empty data events were loaded - int NonEmptyDataEvents; // count how many non empty data events were loaded - bool PsecReceiveMode; // Get PSEC data from CStore or Stores["ANNIEEvent"]. 1: CStore, 0: Stores["ANNIEEvent"] + bool PsecReceiveMode; // Get PSEC data from CStore or Stores["ANNIEEvent"]. 1: CStore, 0: Stores["ANNIEEvent"] string OutputWavLabel; string InputWavLabel; int NChannels; @@ -91,39 +91,53 @@ class LAPPDLoadStore : public Tool int PPSnumber; bool loadPPS; bool loadPSEC; - bool mergedEvent; // in some merged Event, the LAPPD events was merged to ANNIEEvent, but the data stream was not changed to be true. use this = 1 to read it - bool LAPPDana; // run other LAPPD tools - // Variables that you need in the tool + bool mergedEvent; // in some merged Event, the LAPPD events was merged to ANNIEEvent, but the data stream was not changed to be true. use this = 1 to read it + bool LAPPDana; // run other LAPPD tools + bool isCFD; bool isBLsub; bool isFiltered; - int EventType; // 0: PSEC, 1: PPS - // LAPPD tool chain, data variables. (Will be used in multiple LAPPD tools) - // everything you get or set to Store, which means it may be used in other tools or it's from other tools + int EventType; // 0: PSEC, 1: PPS + + // Store Data Variables (Written to / Read from BoostStore) int LAPPD_ID; vector LAPPD_IDs; vector LAPPDLoadedTimeStamps; - vector LAPPDLoadedTimeStampsRaw; - vector LAPPDLoadedBeamgatesRaw; - vector LAPPDLoadedOffsets; - vector LAPPDLoadedTSCorrections; - vector LAPPDLoadedBGCorrections; - vector LAPPDLoadedOSInMinusPS; - vector LAPPDLoadedBG_PPSBefore; - vector LAPPDLoadedBG_PPSAfter; - vector LAPPDLoadedBG_PPSDiff; - vector LAPPDLoadedBG_PPSMissing; - vector LAPPDLoadedTS_PPSBefore; - vector LAPPDLoadedTS_PPSAfter; - vector LAPPDLoadedTS_PPSDiff; - vector LAPPDLoadedTS_PPSMissing; - - vector ParaBoards; // save the board index for this PsecData + + vector LAPPDLoadedTimeStampsRaw_0; + vector LAPPDLoadedBeamgatesRaw_0; + vector LAPPDLoadedOffsets_0; + vector LAPPDLoadedTSCorrections_0; + vector LAPPDLoadedBGCorrections_0; + vector LAPPDLoadedOSInMinusPS_0; + vector LAPPDLoadedBG_PPSBefore_0; + vector LAPPDLoadedBG_PPSAfter_0; + vector LAPPDLoadedBG_PPSDiff_0; + vector LAPPDLoadedBG_PPSMissing_0; + vector LAPPDLoadedTS_PPSBefore_0; + vector LAPPDLoadedTS_PPSAfter_0; + vector LAPPDLoadedTS_PPSDiff_0; + vector LAPPDLoadedTS_PPSMissing_0; + + vector LAPPDLoadedTimeStampsRaw_1; + vector LAPPDLoadedBeamgatesRaw_1; + vector LAPPDLoadedOffsets_1; + vector LAPPDLoadedTSCorrections_1; + vector LAPPDLoadedBGCorrections_1; + vector LAPPDLoadedOSInMinusPS_1; + vector LAPPDLoadedBG_PPSBefore_1; + vector LAPPDLoadedBG_PPSAfter_1; + vector LAPPDLoadedBG_PPSDiff_1; + vector LAPPDLoadedBG_PPSMissing_1; + vector LAPPDLoadedTS_PPSBefore_1; + vector LAPPDLoadedTS_PPSAfter_1; + vector LAPPDLoadedTS_PPSDiff_1; + vector LAPPDLoadedTS_PPSMissing_1; + + vector ParaBoards; // save the board index for this PsecData std::map>> LAPPDWaveforms; - // This tool, data variables (only used in this tool, every thing that is an data object) - ifstream PedFile; // stream for reading in the Pedestal Files - string NewFileName; // name of the new Data File + ifstream PedFile; // stream for reading in the Pedestal Files std::map> *PedestalValues; std::vector Raw_buffer; std::vector Parse_buffer; @@ -131,54 +145,90 @@ class LAPPDLoadStore : public Tool std::map> data; vector meta; vector pps; + vector LAPPD_ID_Channel; // for each LAPPD, how many channels on it's each board vector LAPPD_ID_BoardNumber; // for each LAPPD, how many boards with it + std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; std::map DataStreams; - std::vector LAPPDEventIndex_ID; // for each LAPPD ID, count the index of current loaded event - // For example, this part file may have a ID=0 event, b ID=1 event, while loading data object c and loaded 3 ID=0 and 4 ID=1, I may have - // LAPPDEventIndex_ID = {3, 4} + + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; + + // For each LAPPD ID, count the index of current loaded event. + // (e.g. part file has 3 ID=0 events and 4 ID=1 events -> LAPPDEventIndex_ID = {3, 4}) + std::vector LAPPDEventIndex_ID; vector idConfigRecords; // save PPS info for the second order correction - std::map LAPPDBG_PPSBefore; - std::map LAPPDBG_PPSAfter; - std::map LAPPDBG_PPSDiff; - std::map LAPPDBG_PPSMissing; - std::map LAPPDTS_PPSBefore; - std::map LAPPDTS_PPSAfter; - std::map LAPPDTS_PPSDiff; - std::map LAPPDTS_PPSMissing; + // save PPS info for the second order correction + std::map LAPPDBG_PPSBefore_0; + std::map LAPPDBG_PPSAfter_0; + std::map LAPPDBG_PPSDiff_0; + std::map LAPPDBG_PPSMissing_0; + std::map LAPPDTS_PPSBefore_0; + std::map LAPPDTS_PPSAfter_0; + std::map LAPPDTS_PPSDiff_0; + std::map LAPPDTS_PPSMissing_0; + + std::map LAPPDBG_PPSBefore_1; + std::map LAPPDBG_PPSAfter_1; + std::map LAPPDBG_PPSDiff_1; + std::map LAPPDBG_PPSMissing_1; + std::map LAPPDTS_PPSBefore_1; + std::map LAPPDTS_PPSAfter_1; + std::map LAPPDTS_PPSDiff_1; + std::map LAPPDTS_PPSMissing_1; // data variables don't need to be cleared in each loop // these are loaded offset for event building - std::map> Offsets; // Loaded offset, use string = run number + sub run number + partfile number as key. - std::map> Offsets_minus_ps; // offset in ps, use offset - this/1e3 as the real offset - std::map> BGCorrections; // Loaded BGcorrections, same key as Offsets, but offset saved on event by event basis in that part file, in unit of ticks - std::map> TSCorrections; // TS corrections, in unit of ticks - std::map> BG_PPSBefore_loaded; // BG PPS before, in unit of ticks - std::map> BG_PPSAfter_loaded; // BG PPS after, in unit of ticks - std::map> BG_PPSDiff_loaded; // BG PPS Diff - std::map> BG_PPSMissing_loaded; // BG PPS Missing - std::map> TS_PPSBefore_loaded; // TS PPS before, in unit of ticks - std::map> TS_PPSAfter_loaded; // TS PPS after, in unit of ticks - std::map> TS_PPSDiff_loaded; // TS PPS Diff - std::map> TS_PPSMissing_loaded; // TS PPS Missing + std::map> Offsets_0; + std::map> Offsets_minus_ps_0; + std::map> BGCorrections_0; + std::map> TSCorrections_0; + std::map> BG_PPSBefore_loaded_0; + std::map> BG_PPSAfter_loaded_0; + std::map> BG_PPSDiff_loaded_0; + std::map> BG_PPSMissing_loaded_0; + std::map> TS_PPSBefore_loaded_0; + std::map> TS_PPSAfter_loaded_0; + std::map> TS_PPSDiff_loaded_0; + std::map> TS_PPSMissing_loaded_0; + + std::map> Offsets_1; + std::map> Offsets_minus_ps_1; + std::map> BGCorrections_1; + std::map> TSCorrections_1; + std::map> BG_PPSBefore_loaded_1; + std::map> BG_PPSAfter_loaded_1; + std::map> BG_PPSDiff_loaded_1; + std::map> BG_PPSMissing_loaded_1; + std::map> TS_PPSBefore_loaded_1; + std::map> TS_PPSAfter_loaded_1; + std::map> TS_PPSDiff_loaded_1; + std::map> TS_PPSMissing_loaded_1; int runNumber; int subRunNumber; int partFileNumber; int eventNumberInPF; - std::ofstream debugStoreReadIn; + std::ofstream debugLoadStore; // verbosity levels: if 'verbosity' < this level, the message type will be logged. int v_error=0; diff --git a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp index f4e5cec6b..251d36868 100644 --- a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp +++ b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp @@ -58,8 +58,8 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fPulse->Branch("PartFileNumber", &PartFileNumber, "PartFileNumber/I"); fPulse->Branch("EventNumber", &EventNumber, "EventNumber/I"); fPulse->Branch("LAPPD_ID", &LAPPD_ID, "LAPPD_ID/I"); - fPulse->Branch("LAPPDDataTimeStampUL", &LAPPDDataTimeStampUL, "LAPPDDataTimeStampUL/l"); - fPulse->Branch("LAPPDDataBeamgateUL", &LAPPDDataBeamgateUL, "LAPPDDataBeamgateUL/l"); + fPulse->Branch("LAPPDDataTimeStamp0_UL", &LAPPDDataTimeStamp0_UL, "LAPPDDataTimeStamp0_UL/l"); + fPulse->Branch("LAPPDDataBeamgate0_UL", &LAPPDDataBeamgate0_UL, "LAPPDDataBeamgate0_UL/l"); fPulse->Branch("ChannelID", &ChannelID, "ChannelID/I"); fPulse->Branch("StripNumber", &StripNumber, "StripNumber/I"); fPulse->Branch("PeakTime", &PeakTime, "PeakTime/D"); @@ -87,8 +87,8 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fHit->Branch("PartFileNumber", &PartFileNumber, "PartFileNumber/I"); fHit->Branch("EventNumber", &EventNumber, "EventNumber/I"); fHit->Branch("LAPPD_ID", &LAPPD_ID, "LAPPD_ID/I"); - fHit->Branch("LAPPDDataTimeStampUL", &LAPPDDataTimeStampUL, "LAPPDDataTimeStampUL/l"); - fHit->Branch("LAPPDDataBeamgateUL", &LAPPDDataBeamgateUL, "LAPPDDataBeamgateUL/l"); + fHit->Branch("LAPPDDataTimeStamp0_UL", &LAPPDDataTimeStamp0_UL, "LAPPDDataTimeStamp0_UL/l"); + fHit->Branch("LAPPDDataBeamgate0_UL", &LAPPDDataBeamgate0_UL, "LAPPDDataBeamgate0_UL/l"); fHit->Branch("StripNumber", &StripNumber, "StripNumber/I"); fHit->Branch("HitTime", &HitTime, "HitTime/D"); fHit->Branch("HitAmp", &HitAmp, "HitAmp/D"); @@ -117,8 +117,8 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fWaveform->Branch("PartFileNumber", &PartFileNumber, "PartFileNumber/I"); fWaveform->Branch("EventNumber", &EventNumber, "EventNumber/I"); fWaveform->Branch("LAPPD_ID", &LAPPD_ID, "LAPPD_ID/I"); - fWaveform->Branch("LAPPDDataTimeStampUL", &LAPPDDataTimeStampUL, "LAPPDDataTimeStampUL/l"); - fWaveform->Branch("LAPPDDataBeamgateUL", &LAPPDDataBeamgateUL, "LAPPDDataBeamgateUL/l"); + fWaveform->Branch("LAPPDDataTimeStamp0_UL", &LAPPDDataTimeStamp0_UL, "LAPPDDataTimeStamp0_UL/l"); + fWaveform->Branch("LAPPDDataBeamgate0_UL", &LAPPDDataBeamgate0_UL, "LAPPDDataBeamgate0_UL/l"); fWaveform->Branch("StripNumber", &StripNumber, "StripNumber/I"); fWaveform->Branch("PulseSide", &PulseSide, "PulseSide/I"); fWaveform->Branch("WaveformMax", &waveformMaxValue, "WaveformMax/D"); @@ -142,12 +142,18 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fTimeStamp->Branch("PartFileNumber", &PartFileNumber, "PartFileNumber/I"); fTimeStamp->Branch("EventNumber", &EventNumber, "EventNumber/I"); fTimeStamp->Branch("LAPPD_ID", &LAPPD_ID, "LAPPD_ID/I"); - fTimeStamp->Branch("LAPPDDataTimeStampUL", &LAPPDDataTimeStampUL, "LAPPDDataTimeStampUL/l"); - fTimeStamp->Branch("LAPPDDataBeamgateUL", &LAPPDDataBeamgateUL, "LAPPDDataBeamgateUL/l"); - fTimeStamp->Branch("LAPPDDataTimestamp", &LAPPDDataTimestampPart1, "LAPPDDataTimestamp/l"); - fTimeStamp->Branch("LAPPDDataBeamgate", &LAPPDDataBeamgatePart1, "LAPPDDataBeamgate/l"); - fTimeStamp->Branch("LAPPDDataTimestampFloat", &LAPPDDataTimestampPart2, "LAPPDDataTimestampFloat/D"); - fTimeStamp->Branch("LAPPDDataBeamgateFloat", &LAPPDDataBeamgatePart2, "LAPPDDataBeamgateFloat/D"); + fTimeStamp->Branch("LAPPDDataTimeStamp0_UL", &LAPPDDataTimeStamp0_UL, "LAPPDDataTimeStamp0_UL/l"); + fTimeStamp->Branch("LAPPDDataBeamgate0_UL", &LAPPDDataBeamgate0_UL, "LAPPDDataBeamgate0_UL/l"); + fTimeStamp->Branch("LAPPDDataTimestamp0", &LAPPDDataTimestamp0_Part1, "LAPPDDataTimestamp0/l"); + fTimeStamp->Branch("LAPPDDataBeamgate0", &LAPPDDataBeamgate0_Part1, "LAPPDDataBeamgate0/l"); + fTimeStamp->Branch("LAPPDDataTimestamp0_Float", &LAPPDDataTimestamp0_Part2, "LAPPDDataTimestamp0_Float/D"); + fTimeStamp->Branch("LAPPDDataBeamgate0_Float", &LAPPDDataBeamgate0_Part2, "LAPPDDataBeamgate0_Float/D"); + fTimeStamp->Branch("LAPPDDataTimeStamp1_UL", &LAPPDDataTimeStamp1_UL, "LAPPDDataTimeStamp1_UL/l"); + fTimeStamp->Branch("LAPPDDataBeamgate1_UL", &LAPPDDataBeamgate1_UL, "LAPPDDataBeamgate1_UL/l"); + fTimeStamp->Branch("LAPPDDataTimestamp1", &LAPPDDataTimestamp1_Part1, "LAPPDDataTimestamp1/l"); + fTimeStamp->Branch("LAPPDDataBeamgate1", &LAPPDDataBeamgate1_Part1, "LAPPDDataBeamgate1/l"); + fTimeStamp->Branch("LAPPDDataTimestamp1_Float", &LAPPDDataTimestamp1_Part2, "LAPPDDataTimestamp1_Float/D"); + fTimeStamp->Branch("LAPPDDataBeamgate1_Float", &LAPPDDataBeamgate1_Part2, "LAPPDDataBeamgate1_Float/D"); fTimeStamp->Branch("ppsDiff", &ppsDiff, "ppsDiff/L"); fTimeStamp->Branch("ppsCount0", &ppsCount0, "ppsCount0/l"); fTimeStamp->Branch("ppsCount1", &ppsCount1, "ppsCount1/l"); @@ -418,12 +424,21 @@ void LAPPDTreeMaker::CleanVariables() Pulse1LastTime = -9999; Pulse2LastTime = -9999; - LAPPDDataTimeStampUL = 0; - LAPPDDataBeamgateUL = 0; - LAPPDDataTimestampPart1 = 0; - LAPPDDataBeamgatePart1 = 0; - LAPPDDataTimestampPart2 = -9999; - LAPPDDataBeamgatePart2 = -9999; + // ACDC 0 + LAPPDDataTimeStamp0_UL = 0; + LAPPDDataBeamgate0_UL = 0; + LAPPDDataTimestamp0_Part1 = 0; + LAPPDDataBeamgate0_Part1 = 0; + LAPPDDataTimestamp0_Part2 = -9999; + LAPPDDataBeamgate0_Part2 = -9999; + + // ACDC 1 + LAPPDDataTimeStamp1_UL = 0; + LAPPDDataBeamgate1_UL = 0; + LAPPDDataTimestamp1_Part1 = 0; + LAPPDDataBeamgate1_Part1 = 0; + LAPPDDataTimestamp1_Part2 = -9999; + LAPPDDataBeamgate1_Part2 = -9999; ppsDiff = -9999; ppsCount0 = 0; @@ -755,16 +770,45 @@ bool LAPPDTreeMaker::FillPPSTimestamp() bool LAPPDTreeMaker::FillLAPPDDataTimeStamp() { - if (treeMakerVerbosity > 0) - cout << "LAPPDTreeMaker::FillLAPPDDataTimeStamp. Before fill: LAPPDDataTimeStampUL: " << LAPPDDataTimeStampUL << ", LAPPDDataBeamgateUL: " << LAPPDDataBeamgateUL << ", LAPPDDataTimestampPart1: " << LAPPDDataTimestampPart1 << ", LAPPDDataBeamgatePart1: " << LAPPDDataBeamgatePart1 << ", LAPPDDataTimestampPart2: " << LAPPDDataTimestampPart2 << ", LAPPDDataBeamgatePart2: " << LAPPDDataBeamgatePart2 << endl; + if (treeMakerVerbosity > 0) { + std::cout << "LAPPDTreeMaker::FillLAPPDDataTimeStamp, before fill:" + << "\n ACDC 0:" + << "\n Timestamp UL = " << LAPPDDataTimeStamp0_UL + << "\n Beamgate UL = " << LAPPDDataBeamgate0_UL + << "\n Timestamp Part1 = " << LAPPDDataTimestamp0_Part1 + << "\n Beamgate Part1 = " << LAPPDDataBeamgate0_Part1 + << "\n Timestamp Part2 = " << LAPPDDataTimestamp0_Part2 + << "\n Beamgate Part2 = " << LAPPDDataBeamgate0_Part2 + << "\n ACDC 1:" + << "\n Timestamp UL = " << LAPPDDataTimeStamp1_UL + << "\n Beamgate UL = " << LAPPDDataBeamgate1_UL + << "\n Timestamp Part1 = " << LAPPDDataTimestamp1_Part1 + << "\n Beamgate Part1 = " << LAPPDDataBeamgate1_Part1 + << "\n Timestamp Part2 = " << LAPPDDataTimestamp1_Part2 + << "\n Beamgate Part2 = " << LAPPDDataBeamgate1_Part2 + << "\n LAPPD ID = " << LAPPD_ID + << std::endl; + } + if (!MultiLAPPDMapTreeMaker) { - m_data->CStore.Get("LAPPDBeamgate_Raw", LAPPDDataBeamgateUL); - m_data->CStore.Get("LAPPDTimestamp_Raw", LAPPDDataTimeStampUL); - m_data->CStore.Get("LAPPDBGIntCombined", LAPPDDataBeamgatePart1); - m_data->CStore.Get("LAPPDBGFloat", LAPPDDataBeamgatePart2); - m_data->CStore.Get("LAPPDTSIntCombined", LAPPDDataTimestampPart1); - m_data->CStore.Get("LAPPDTSFloat", LAPPDDataTimestampPart2); + + // Retrieve ACDC 0 reconstructed objects + m_data->CStore.Get("LAPPDBeamgate0_Raw", LAPPDDataBeamgate0_UL); + m_data->CStore.Get("LAPPDTimestamp0_Raw", LAPPDDataTimeStamp0_UL); + m_data->CStore.Get("LAPPDBG0_IntCombined", LAPPDDataBeamgate0_Part1); + m_data->CStore.Get("LAPPDBG0_Float", LAPPDDataBeamgate0_Part2); + m_data->CStore.Get("LAPPDTS0_IntCombined", LAPPDDataTimestamp0_Part1); + m_data->CStore.Get("LAPPDTS0_Float", LAPPDDataTimestamp0_Part2); + + // Retrieve ACDC 1 reconstructed objects + m_data->CStore.Get("LAPPDBeamgate1_Raw", LAPPDDataBeamgate1_UL); + m_data->CStore.Get("LAPPDTimestamp1_Raw", LAPPDDataTimeStamp1_UL); + m_data->CStore.Get("LAPPDBG1_IntCombined", LAPPDDataBeamgate1_Part1); + m_data->CStore.Get("LAPPDBG1_Float", LAPPDDataBeamgate1_Part2); + m_data->CStore.Get("LAPPDTS1_IntCombined", LAPPDDataTimestamp1_Part1); + m_data->CStore.Get("LAPPDTS1_Float", LAPPDDataTimestamp1_Part2); + m_data->CStore.Get("LAPPD_ID", LAPPD_ID); fTimeStamp->Fill(); } @@ -773,13 +817,31 @@ bool LAPPDTreeMaker::FillLAPPDDataTimeStamp() for (int i = 0; i < LAPPD_IDs.size(); i++) { LAPPD_ID = LAPPD_IDs.at(i); - LAPPDDataBeamgateUL = LAPPDMapBeamgateRaw.at(i); - LAPPDDataTimeStampUL = LAPPDMapTimeStampRaw.at(i); + LAPPDDataBeamgate0_UL = LAPPDMapBeamgateRaw.at(i); + LAPPDDataTimeStamp0_UL = LAPPDMapTimeStampRaw.at(i); fTimeStamp->Fill(); } } - if (treeMakerVerbosity > 0) - cout << "LAPPDDataTimeStampUL: " << LAPPDDataTimeStampUL << ", LAPPDDataBeamgateUL: " << LAPPDDataBeamgateUL << ", LAPPDDataTimestampPart1: " << LAPPDDataTimestampPart1 << ", LAPPDDataBeamgatePart1: " << LAPPDDataBeamgatePart1 << ", LAPPDDataTimestampPart2: " << LAPPDDataTimestampPart2 << ", LAPPDDataBeamgatePart2: " << LAPPDDataBeamgatePart2 << endl; + if (treeMakerVerbosity > 0) { + std::cout << "LAPPDTreeMaker::FillLAPPDDataTimeStamp, after fill:" + << "\n ACDC 0:" + << "\n Timestamp UL = " << LAPPDDataTimeStamp0_UL + << "\n Beamgate UL = " << LAPPDDataBeamgate0_UL + << "\n Timestamp Part1 = " << LAPPDDataTimestamp0_Part1 + << "\n Beamgate Part1 = " << LAPPDDataBeamgate0_Part1 + << "\n Timestamp Part2 = " << LAPPDDataTimestamp0_Part2 + << "\n Beamgate Part2 = " << LAPPDDataBeamgate0_Part2 + << "\n ACDC 1:" + << "\n Timestamp UL = " << LAPPDDataTimeStamp1_UL + << "\n Beamgate UL = " << LAPPDDataBeamgate1_UL + << "\n Timestamp Part1 = " << LAPPDDataTimestamp1_Part1 + << "\n Beamgate Part1 = " << LAPPDDataBeamgate1_Part1 + << "\n Timestamp Part2 = " << LAPPDDataTimestamp1_Part2 + << "\n Beamgate Part2 = " << LAPPDDataBeamgate1_Part2 + << "\n LAPPD ID = " << LAPPD_ID + << std::endl; + } + return true; } diff --git a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h index 9fc491e2b..b2feac887 100644 --- a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h +++ b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h @@ -134,12 +134,21 @@ class LAPPDTreeMaker : public Tool double Pulse1LastTime; double Pulse2LastTime; - unsigned long LAPPDDataTimeStampUL; - unsigned long LAPPDDataBeamgateUL; - unsigned long LAPPDDataTimestampPart1; - unsigned long LAPPDDataBeamgatePart1; - double LAPPDDataTimestampPart2; - double LAPPDDataBeamgatePart2; + // ACDC 0 + unsigned long LAPPDDataTimeStamp0_UL; + unsigned long LAPPDDataBeamgate0_UL; + unsigned long LAPPDDataTimestamp0_Part1; + unsigned long LAPPDDataBeamgate0_Part1; + double LAPPDDataTimestamp0_Part2; + double LAPPDDataBeamgate0_Part2; + + // ACDC 1 + unsigned long LAPPDDataTimeStamp1_UL; + unsigned long LAPPDDataBeamgate1_UL; + unsigned long LAPPDDataTimestamp1_Part1; + unsigned long LAPPDDataBeamgate1_Part1; + double LAPPDDataTimestamp1_Part2; + double LAPPDDataBeamgate1_Part2; vector pps_vector; vector pps_count_vector; diff --git a/UserTools/ProcessedLAPPDFilter/ProcessedLAPPDFilter.cpp b/UserTools/ProcessedLAPPDFilter/ProcessedLAPPDFilter.cpp index 8fb4ff3e0..30f945df9 100644 --- a/UserTools/ProcessedLAPPDFilter/ProcessedLAPPDFilter.cpp +++ b/UserTools/ProcessedLAPPDFilter/ProcessedLAPPDFilter.cpp @@ -267,10 +267,9 @@ bool ProcessedLAPPDFilter::Execute() - std::map LAPPDBeamgate_ns; - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - PsecDataNumber += LAPPDBeamgate_ns.size(); - m_data->Stores["ANNIEEvent"]->Set("LAPPDBeamgate_ns", LAPPDBeamgate_ns); + std::map LAPPDBeamgate_ns_0; + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + PsecDataNumber += LAPPDBeamgate_ns_0.size(); std::vector> MrdTimeClusters; bool get_clusters_mrd = m_data->CStore.Get("MrdTimeClusters", MrdTimeClusters); @@ -325,9 +324,9 @@ bool ProcessedLAPPDFilter::Execute() if (filterType == "PMTCluster") { - std::map LAPPDBeamgate_ns; - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - PsecDataNumber += LAPPDBeamgate_ns.size(); + std::map LAPPDBeamgate_ns_0; + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + PsecDataNumber += LAPPDBeamgate_ns_0.size(); gotEventPMTCluster = false; @@ -571,33 +570,63 @@ bool ProcessedLAPPDFilter::GotANNIEEventAndSave(BoostStore *BS, string savePath) BS->Set("CTCWordExtended", CTCWordExtended); std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; + + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", LAPPDDataMap); BS->Set("LAPPDDataMap", LAPPDDataMap); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - BS->Set("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - BS->Set("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - BS->Set("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - BS->Set("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets); - BS->Set("LAPPDOffsets", LAPPDOffsets); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection); - BS->Set("LAPPDTSCorrection", LAPPDTSCorrection); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection); - BS->Set("LAPPDBGCorrection", LAPPDBGCorrection); - m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); - BS->Set("LAPPDOSInMinusPS", LAPPDOSInMinusPS); + + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_0", LAPPDOffsets_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + + BS->Set("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + BS->Set("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + BS->Set("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + BS->Set("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + BS->Set("LAPPDOffsets_0", LAPPDOffsets_0); + BS->Set("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + BS->Set("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + BS->Set("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_1", LAPPDOffsets_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); + + BS->Set("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + BS->Set("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + BS->Set("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + BS->Set("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + BS->Set("LAPPDOffsets_1", LAPPDOffsets_1); + BS->Set("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + BS->Set("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + BS->Set("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); uint64_t beamInfoTime = 0; int64_t timeDiff = -9999; @@ -653,31 +682,59 @@ bool ProcessedLAPPDFilter::GotANNIEEventAndSave(BoostStore *BS, string savePath) m_data->Stores["ANNIEEvent"]->Get("BRFRawWaveform", BRFRawWaveform); BS->Set("BRFRawWaveform", BRFRawWaveform); - std::map LAPPDBG_PPSBefore; - std::map LAPPDBG_PPSAfter; - std::map LAPPDBG_PPSDiff; - std::map LAPPDBG_PPSMissing; - std::map LAPPDTS_PPSBefore; - std::map LAPPDTS_PPSAfter; - std::map LAPPDTS_PPSDiff; - std::map LAPPDTS_PPSMissing; - - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - BS->Set("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - BS->Set("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - BS->Set("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - BS->Set("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - BS->Set("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - BS->Set("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - BS->Set("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); - BS->Set("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing); + std::map LAPPDBG_PPSBefore_0; + std::map LAPPDBG_PPSAfter_0; + std::map LAPPDBG_PPSDiff_0; + std::map LAPPDBG_PPSMissing_0; + std::map LAPPDTS_PPSBefore_0; + std::map LAPPDTS_PPSAfter_0; + std::map LAPPDTS_PPSDiff_0; + std::map LAPPDTS_PPSMissing_0; + + std::map LAPPDBG_PPSBefore_1; + std::map LAPPDBG_PPSAfter_1; + std::map LAPPDBG_PPSDiff_1; + std::map LAPPDBG_PPSMissing_1; + std::map LAPPDTS_PPSBefore_1; + std::map LAPPDTS_PPSAfter_1; + std::map LAPPDTS_PPSDiff_1; + std::map LAPPDTS_PPSMissing_1; + + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + BS->Set("LAPPDBG_PPSBefore_0", LAPPDBG_PPSBefore_0); + BS->Set("LAPPDBG_PPSAfter_0", LAPPDBG_PPSAfter_0); + BS->Set("LAPPDBG_PPSDiff_0", LAPPDBG_PPSDiff_0); + BS->Set("LAPPDBG_PPSMissing_0", LAPPDBG_PPSMissing_0); + BS->Set("LAPPDTS_PPSBefore_0", LAPPDTS_PPSBefore_0); + BS->Set("LAPPDTS_PPSAfter_0", LAPPDTS_PPSAfter_0); + BS->Set("LAPPDTS_PPSDiff_0", LAPPDTS_PPSDiff_0); + BS->Set("LAPPDTS_PPSMissing_0", LAPPDTS_PPSMissing_0); + + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); + + BS->Set("LAPPDBG_PPSBefore_1", LAPPDBG_PPSBefore_1); + BS->Set("LAPPDBG_PPSAfter_1", LAPPDBG_PPSAfter_1); + BS->Set("LAPPDBG_PPSDiff_1", LAPPDBG_PPSDiff_1); + BS->Set("LAPPDBG_PPSMissing_1", LAPPDBG_PPSMissing_1); + BS->Set("LAPPDTS_PPSBefore_1", LAPPDTS_PPSBefore_1); + BS->Set("LAPPDTS_PPSAfter_1", LAPPDTS_PPSAfter_1); + BS->Set("LAPPDTS_PPSDiff_1", LAPPDTS_PPSDiff_1); + BS->Set("LAPPDTS_PPSMissing_1", LAPPDTS_PPSMissing_1); BS->Save(savePath); if (FilterVerbosity > 2) @@ -700,4 +757,4 @@ bool ProcessedLAPPDFilter::GotANNIEEventAndSave(BoostStore *BS, string savePath) delete HitsCopy;*/ return true; -} \ No newline at end of file +} diff --git a/configfiles/BeamClusterAnalysis/ANNIEEventTreeMakerConfig b/configfiles/BeamClusterAnalysis/ANNIEEventTreeMakerConfig index 8084b3635..061cc4a01 100644 --- a/configfiles/BeamClusterAnalysis/ANNIEEventTreeMakerConfig +++ b/configfiles/BeamClusterAnalysis/ANNIEEventTreeMakerConfig @@ -1,32 +1,29 @@ ANNIEEventTreeMakerVerbosity 0 +isData 1 +HasGenie 0 + +OutputFile ANNIETree.root fillAllTriggers 1 fill_singleTrigger 0 -fillLAPPDEventsOnly 0 -TankCluster_fill 1 -cluster_TankHitInfo_fill 1 - -TankReco_fill 0 +fillCleanEventsOnly 0 -OutputFile ANNIETree.root -TankClusterProcessing 1 -MRDClusterProcessing 1 -TriggerProcessing 1 TankHitInfo_fill 1 +TankCluster_fill 1 +cluster_TankHitInfo_fill 1 MRDHitInfo_fill 1 -MRDReco_fill 1 +RWMBRF_fill 1 SiPMPulseInfo_fill 0 -fillCleanEventsOnly 0 + +MRDReco_fill 1 MCTruth_fill 0 -Reco_fill 1 +TankReco_fill 0 RecoDebug_fill 0 muonTruthRecoDiff_fill 0 -isData 1 -HasGenie 0 -RingCounting_fill 1 +RingCounting_fill 0 LAPPDData_fill 1 LAPPDReco_fill 1 -RWMBRF_fill 1 LAPPD_PPS_fill 1 -LAPPD_Waveform_fill 0 +LAPPD_Waveform_fill 1 +LAPPD_MC_fill 0 diff --git a/configfiles/BeamClusterAnalysis/ToolsConfig b/configfiles/BeamClusterAnalysis/ToolsConfig index a4441e5bb..f03291c91 100644 --- a/configfiles/BeamClusterAnalysis/ToolsConfig +++ b/configfiles/BeamClusterAnalysis/ToolsConfig @@ -18,7 +18,7 @@ LAPPDThresReco LAPPDThresReco configfiles/LAPPDProcessedAna/ConfigPlot FitRWMWaveform FitRWMWaveform ./configfiles/BeamClusterAnalysis/FitRWMWaveformConfig -myCNNImage CNNImage ./configfiles/BeamClusterAnalysis/CNNImageConfig -myRingCounting PythonScript configfiles/BeamClusterAnalysis/RingCountingConfig +#myCNNImage CNNImage ./configfiles/BeamClusterAnalysis/CNNImageConfig +#myRingCounting PythonScript configfiles/BeamClusterAnalysis/RingCountingConfig ANNIEEventTreeMaker ANNIEEventTreeMaker ./configfiles/BeamClusterAnalysis/ANNIEEventTreeMakerConfig diff --git a/configfiles/BeamClusterAnalysisMC/ANNIEEventTreeMakerConfig b/configfiles/BeamClusterAnalysisMC/ANNIEEventTreeMakerConfig index 3917232a3..7553fa4cc 100644 --- a/configfiles/BeamClusterAnalysisMC/ANNIEEventTreeMakerConfig +++ b/configfiles/BeamClusterAnalysisMC/ANNIEEventTreeMakerConfig @@ -1,35 +1,29 @@ ANNIEEventTreeMakerVerbosity 0 OutputFile ANNIETree_MC.root - +isData 0 +HasGenie 1 fillAllTriggers 1 fill_singleTrigger 0 -fillLAPPDEventsOnly 0 -TankCluster_fill 1 -cluster_TankHitInfo_fill 1 - -TankReco_fill 0 -RingCounting_fill 1 +fillCleanEventsOnly 0 -TankClusterProcessing 1 -MRDClusterProcessing 1 -TriggerProcessing 1 TankHitInfo_fill 1 +TankCluster_fill 1 +cluster_TankHitInfo_fill 1 MRDHitInfo_fill 1 -MRDReco_fill 1 +RWMBRF_fill 0 SiPMPulseInfo_fill 0 -fillCleanEventsOnly 0 + MCTruth_fill 1 -Reco_fill 0 +MRDReco_fill 1 +TankReco_fill 0 +RingCounting_fill 0 RecoDebug_fill 0 muonTruthRecoDiff_fill 0 -isData 0 -HasGenie 1 LAPPDData_fill 0 LAPPDReco_fill 0 -RWMBRF_fill 0 LAPPD_PPS_fill 0 LAPPD_Waveform_fill 0 LAPPD_MC_fill 1 diff --git a/configfiles/EventBuilderV2/LAPPDLoadStoreConfig b/configfiles/EventBuilderV2/LAPPDLoadStoreConfig index 23507f01b..5a90f15fb 100644 --- a/configfiles/EventBuilderV2/LAPPDLoadStoreConfig +++ b/configfiles/EventBuilderV2/LAPPDLoadStoreConfig @@ -1,4 +1,4 @@ - General Parameters +#General Parameters Nsamples 256 #Number of samples in a waveform SampleSize 100 #Sample size for baseline substraction TrigChannel 5 #Specified channel the trigger signal will be on @@ -6,7 +6,7 @@ NUM_VECTOR_METADATA 103 #Fixed META vector size LAPPDchannelOffset 1000 NChannels 30 -LAPPDStoreReadInVerbosity 0 +LAPPDLoadStoreVerbosity 0 mergingModeReadIn 0 RawDataInputWavLabel RawWaveform diff --git a/configfiles/EventBuilderV2_laser/LAPPDLoadStoreConfig b/configfiles/EventBuilderV2_laser/LAPPDLoadStoreConfig index 23507f01b..5a90f15fb 100644 --- a/configfiles/EventBuilderV2_laser/LAPPDLoadStoreConfig +++ b/configfiles/EventBuilderV2_laser/LAPPDLoadStoreConfig @@ -1,4 +1,4 @@ - General Parameters +#General Parameters Nsamples 256 #Number of samples in a waveform SampleSize 100 #Sample size for baseline substraction TrigChannel 5 #Specified channel the trigger signal will be on @@ -6,7 +6,7 @@ NUM_VECTOR_METADATA 103 #Fixed META vector size LAPPDchannelOffset 1000 NChannels 30 -LAPPDStoreReadInVerbosity 0 +LAPPDLoadStoreVerbosity 0 mergingModeReadIn 0 RawDataInputWavLabel RawWaveform From 42a24682f0507b608d53d9c77be572e81beb9cb1 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Sun, 20 Sep 2026 15:42:04 -0500 Subject: [PATCH 2/8] Update `LAPPDLoadStore` tool to support legacy single-board data - Implemented fallback logic to support older data files that lack explicit ACDC board identifiers. - Safely routes legacy single-board data to downstream tools. - ACDC 1 variables will be set to zero as default in such cases. --- UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp | 108 ++++++++++++++++---- configfiles/LAPPDProcessedAna/Configs | 6 +- 2 files changed, 92 insertions(+), 22 deletions(-) diff --git a/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp b/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp index e11e35492..29fc44802 100644 --- a/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp +++ b/UserTools/LAPPDLoadStore/LAPPDLoadStore.cpp @@ -262,6 +262,41 @@ bool LAPPDLoadStore::Execute() << ", gotTS_PPSDiff = " << gotTS_PPSDiff_1 << ", gotTS_PPSMissing = " << gotTS_PPSMissing_1 << std::endl;\ } } + + // --- BACKWARD COMPATIBILITY BLOCK --- + // If the _0 identifiers were not found, this is older processed data. + // Fetch the legacy variables (no suffixes) and map them to ACDC 0. + if (!gotBeamgates_ns_0) + { + if (LAPPDLoadStoreVerbosity > 0) + std::cout << "LAPPDLoadStore: Legacy data detected. Mapping old variables to ACDC 0." << std::endl; + + bool gotLegacy = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns_0); + + if (gotLegacy) + { + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS_0); + } + + if (LoadBuiltPPSInfo && gotLegacy) + { + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSBefore", LAPPDBG_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSAfter", LAPPDBG_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSDiff", LAPPDBG_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBG_PPSMissing", LAPPDBG_PPSMissing_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSBefore", LAPPDTS_PPSBefore_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSAfter", LAPPDTS_PPSAfter_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSDiff", LAPPDTS_PPSDiff_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing_0); + } + } + // --- END BACKWARD COMPATIBILITY BLOCK --- } else { @@ -500,6 +535,8 @@ bool LAPPDLoadStore::Execute() } } + // --- ACDC 0 Loading --- + // (Legacy data was mapped to _0, so these maps are guaranteed to have data) LAPPDLoadedTimeStampsRaw_0.push_back(LAPPDTimeStampsRaw_0.at(time)); LAPPDLoadedBeamgatesRaw_0.push_back(LAPPDBeamgatesRaw_0.at(time)); LAPPDLoadedOffsets_0.push_back(LAPPDOffsets_0.at(time)); @@ -507,12 +544,27 @@ bool LAPPDLoadStore::Execute() LAPPDLoadedBGCorrections_0.push_back(LAPPDBGCorrection_0.at(time)); LAPPDLoadedOSInMinusPS_0.push_back(LAPPDOSInMinusPS_0.at(time)); - LAPPDLoadedTimeStampsRaw_1.push_back(LAPPDTimeStampsRaw_1.at(time)); - LAPPDLoadedBeamgatesRaw_1.push_back(LAPPDBeamgatesRaw_1.at(time)); - LAPPDLoadedOffsets_1.push_back(LAPPDOffsets_1.at(time)); - LAPPDLoadedTSCorrections_1.push_back(LAPPDTSCorrection_1.at(time)); - LAPPDLoadedBGCorrections_1.push_back(LAPPDBGCorrection_1.at(time)); - LAPPDLoadedOSInMinusPS_1.push_back(LAPPDOSInMinusPS_1.at(time)); + // --- ACDC 1 Loading --- + // Check whether ACDC 1 has data; if not, this is legacy data with no ACDC 1 identifier + if (LAPPDTimeStampsRaw_1.count(time) > 0) + { + LAPPDLoadedTimeStampsRaw_1.push_back(LAPPDTimeStampsRaw_1.at(time)); + LAPPDLoadedBeamgatesRaw_1.push_back(LAPPDBeamgatesRaw_1.at(time)); + LAPPDLoadedOffsets_1.push_back(LAPPDOffsets_1.at(time)); + LAPPDLoadedTSCorrections_1.push_back(LAPPDTSCorrection_1.at(time)); + LAPPDLoadedBGCorrections_1.push_back(LAPPDBGCorrection_1.at(time)); + LAPPDLoadedOSInMinusPS_1.push_back(LAPPDOSInMinusPS_1.at(time)); + } + else + { + // Legacy data fallback: safely fill ACDC 1 with dummy zeros + LAPPDLoadedTimeStampsRaw_1.push_back(-1); + LAPPDLoadedBeamgatesRaw_1.push_back(-1); + LAPPDLoadedOffsets_1.push_back(-1); + LAPPDLoadedTSCorrections_1.push_back(-1); + LAPPDLoadedBGCorrections_1.push_back(-1); + LAPPDLoadedOSInMinusPS_1.push_back(-1); + } if (LAPPDLoadStoreVerbosity > 2) cout << "parsing finished for LAPPD_ID " << LAPPD_ID << " at time " << time << endl; @@ -528,14 +580,28 @@ bool LAPPDLoadStore::Execute() LAPPDLoadedTS_PPSDiff_0.push_back(LAPPDTS_PPSDiff_0.at(time)); LAPPDLoadedTS_PPSMissing_0.push_back(LAPPDTS_PPSMissing_0.at(time)); - LAPPDLoadedBG_PPSBefore_1.push_back(LAPPDBG_PPSBefore_1.at(time)); - LAPPDLoadedBG_PPSAfter_1.push_back(LAPPDBG_PPSAfter_1.at(time)); - LAPPDLoadedBG_PPSDiff_1.push_back(LAPPDBG_PPSDiff_1.at(time)); - LAPPDLoadedBG_PPSMissing_1.push_back(LAPPDBG_PPSMissing_1.at(time)); - LAPPDLoadedTS_PPSBefore_1.push_back(LAPPDTS_PPSBefore_1.at(time)); - LAPPDLoadedTS_PPSAfter_1.push_back(LAPPDTS_PPSAfter_1.at(time)); - LAPPDLoadedTS_PPSDiff_1.push_back(LAPPDTS_PPSDiff_1.at(time)); - LAPPDLoadedTS_PPSMissing_1.push_back(LAPPDTS_PPSMissing_1.at(time)); + if (LAPPDBG_PPSBefore_1.count(time) > 0) + { + LAPPDLoadedBG_PPSBefore_1.push_back(LAPPDBG_PPSBefore_1.at(time)); + LAPPDLoadedBG_PPSAfter_1.push_back(LAPPDBG_PPSAfter_1.at(time)); + LAPPDLoadedBG_PPSDiff_1.push_back(LAPPDBG_PPSDiff_1.at(time)); + LAPPDLoadedBG_PPSMissing_1.push_back(LAPPDBG_PPSMissing_1.at(time)); + LAPPDLoadedTS_PPSBefore_1.push_back(LAPPDTS_PPSBefore_1.at(time)); + LAPPDLoadedTS_PPSAfter_1.push_back(LAPPDTS_PPSAfter_1.at(time)); + LAPPDLoadedTS_PPSDiff_1.push_back(LAPPDTS_PPSDiff_1.at(time)); + LAPPDLoadedTS_PPSMissing_1.push_back(LAPPDTS_PPSMissing_1.at(time)); + } + else + { + LAPPDLoadedBG_PPSBefore_1.push_back(-1); + LAPPDLoadedBG_PPSAfter_1.push_back(-1); + LAPPDLoadedBG_PPSDiff_1.push_back(-1); + LAPPDLoadedBG_PPSMissing_1.push_back(-1); + LAPPDLoadedTS_PPSBefore_1.push_back(-1); + LAPPDLoadedTS_PPSAfter_1.push_back(-1); + LAPPDLoadedTS_PPSDiff_1.push_back(-1); + LAPPDLoadedTS_PPSMissing_1.push_back(-1); + } // --- Board 0 Check --- if (LAPPDTS_PPSMissing_0.at(time) != LAPPDBG_PPSMissing_0.at(time) && @@ -550,15 +616,17 @@ bool LAPPDLoadStore::Execute() } // --- Board 1 Check --- - if (LAPPDTS_PPSMissing_1.at(time) != LAPPDBG_PPSMissing_1.at(time) && - ((LAPPDTS_PPSMissing_1.at(time) > -100 && LAPPDTS_PPSMissing_1.at(time) < 100) || - (LAPPDBG_PPSMissing_1.at(time) > -100 && LAPPDBG_PPSMissing_1.at(time) < 100))) - { - std::cout << "LAPPDLoadStore: [Board 1] PPS missing mismatch for LAPPD_ID " << LAPPD_ID + if (LAPPDTS_PPSMissing_1.count(time) > 0) { + if (LAPPDTS_PPSMissing_1.at(time) != LAPPDBG_PPSMissing_1.at(time) && + ((LAPPDTS_PPSMissing_1.at(time) > -100 && LAPPDTS_PPSMissing_1.at(time) < 100) || + (LAPPDBG_PPSMissing_1.at(time) > -100 && LAPPDBG_PPSMissing_1.at(time) < 100))) + { + std::cout << "LAPPDLoadStore: [Board 1] PPS missing mismatch for LAPPD_ID " << LAPPD_ID << " at time " << time << ", BG: " << LAPPDBG_PPSMissing_1.at(time) << ", TS: " << LAPPDTS_PPSMissing_1.at(time) << std::endl; - std::cout << "LAPPDLoadStore: [Board 1] BG_PPSDiff: " << LAPPDBG_PPSDiff_1.at(time) + std::cout << "LAPPDLoadStore: [Board 1] BG_PPSDiff: " << LAPPDBG_PPSDiff_1.at(time) << ", TS_PPSDiff: " << LAPPDTS_PPSDiff_1.at(time) << std::endl; + } } } } diff --git a/configfiles/LAPPDProcessedAna/Configs b/configfiles/LAPPDProcessedAna/Configs index ffaba8870..15e206067 100644 --- a/configfiles/LAPPDProcessedAna/Configs +++ b/configfiles/LAPPDProcessedAna/Configs @@ -8,7 +8,7 @@ NUM_VECTOR_METADATA 103 #Fixed META vector size LAPPDchannelOffset 1000 NChannels 30 -LAPPDStoreReadInVerbosity 0 +LAPPDLoadStoreVerbosity 0 mergingModeReadIn 0 RawDataInputWavLabel RawWaveform @@ -23,7 +23,9 @@ DoPedSubtraction 1 Nboards 6 #Number of pedestal files to be read in #PedinputfileTXT ../Pedestals/LAPPD645839/P #PedinputfileTXT ../Pedestals/LAPPD40/P -PedinputfileTXT /pnfs/annie/persistent/processed/processed_EBV2_LAPPDFiltered/Pedestal/2022_LAPPD40/P +#PedinputfileTXT /pnfs/annie/persistent/processed/processed_EBV2_LAPPDFiltered/Pedestal/2022_LAPPD40/P +#PedinputfileTXT /pnfs/annie/persistent/users/anujgupt/LAPPDs/Pedestals/2025_LAPPD151/P +PedinputfileTXT /pnfs/annie/persistent/processed/LAPPD_Pedestals_corrected/Pedestals/2025_LAPPD645839/P ACCIDConfigFile ./configfiles/LAPPDProcessedAna/LAPPDIDConfig.csv From 9894562d433d8668dd3f18dedbe618c68c88389a Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Sun, 20 Sep 2026 15:56:22 -0500 Subject: [PATCH 3/8] Update PhaseIITreeMaker and LAPPDTreeMaker for dual-ACDC EBV2 - Refactored tree making tools to fully support the new dual-ACDC data configurations. - Note: These are tools used outside the primary data processing chain, so they currently have limited test coverage. --- UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp | 418 +++++++++++------- UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h | 69 ++- .../PhaseIITreeMaker/PhaseIITreeMaker.cpp | 180 +++++--- UserTools/PhaseIITreeMaker/PhaseIITreeMaker.h | 52 ++- 4 files changed, 463 insertions(+), 256 deletions(-) diff --git a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp index 251d36868..19dd188bd 100644 --- a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp +++ b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.cpp @@ -73,12 +73,20 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fPulse->Branch("PulseBaseline", &PulseBaseline, "PulseBaseline/D"); if (MultiLAPPDMapTreeMaker) { - fPulse->Branch("LTSRaw", <SRaw, "LTSRaw/l"); - fPulse->Branch("LBGRaw", &LBGRaw, "LBGRaw/l"); - fPulse->Branch("LOffset_ns", &LOffset_ns, "LOffset_ns/l"); - fPulse->Branch("LTSCorrection", <SCorrection, "LTSCorrection/I"); - fPulse->Branch("LBGCorrection", &LBGCorrection, "LBGCorrection/I"); - fPulse->Branch("LOSInMinusPS", &LOSInMinusPS, "LOSInMinusPS/I"); + fPulse->Branch("LTSRaw_0", <SRaw_0, "LTSRaw_0/l"); // Change fPulse to fHit/fWaveform for those trees + fPulse->Branch("LBGRaw_0", &LBGRaw_0, "LBGRaw_0/l"); + fPulse->Branch("LOffset_ns_0", &LOffset_ns_0, "LOffset_ns_0/l"); + fPulse->Branch("LTSCorrection_0", <SCorrection_0, "LTSCorrection_0/I"); + fPulse->Branch("LBGCorrection_0", &LBGCorrection_0, "LBGCorrection_0/I"); + fPulse->Branch("LOSInMinusPS_0", &LOSInMinusPS_0, "LOSInMinusPS_0/I"); + + fPulse->Branch("LTSRaw_1", <SRaw_1, "LTSRaw_1/l"); + fPulse->Branch("LBGRaw_1", &LBGRaw_1, "LBGRaw_1/l"); + fPulse->Branch("LOffset_ns_1", &LOffset_ns_1, "LOffset_ns_1/l"); + fPulse->Branch("LTSCorrection_1", <SCorrection_1, "LTSCorrection_1/I"); + fPulse->Branch("LBGCorrection_1", &LBGCorrection_1, "LBGCorrection_1/I"); + fPulse->Branch("LOSInMinusPS_1", &LOSInMinusPS_1, "LOSInMinusPS_1/I"); + fPulse->Branch("CTCPrimeTriggerTime", &CTCPrimeTriggerTime, "CTCPrimeTriggerTime/l"); } @@ -103,12 +111,20 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fHit->Branch("Pulse2LastTime", &Pulse2LastTime, "Pulse2LastTime/D"); if (MultiLAPPDMapTreeMaker) { - fHit->Branch("LTSRaw", <SRaw, "LTSRaw/l"); - fHit->Branch("LBGRaw", &LBGRaw, "LBGRaw/l"); - fHit->Branch("LOffset_ns", &LOffset_ns, "LOffset_ns/l"); - fHit->Branch("LTSCorrection", <SCorrection, "LTSCorrection/I"); - fHit->Branch("LBGCorrection", &LBGCorrection, "LBGCorrection/I"); - fHit->Branch("LOSInMinusPS", &LOSInMinusPS, "LOSInMinusPS/I"); + fHit->Branch("LTSRaw_0", <SRaw_0, "LTSRaw_0/l"); + fHit->Branch("LBGRaw_0", &LBGRaw_0, "LBGRaw_0/l"); + fHit->Branch("LOffset_ns_0", &LOffset_ns_0, "LOffset_ns_0/l"); + fHit->Branch("LTSCorrection_0", <SCorrection_0, "LTSCorrection_0/I"); + fHit->Branch("LBGCorrection_0", &LBGCorrection_0, "LBGCorrection_0/I"); + fHit->Branch("LOSInMinusPS_0", &LOSInMinusPS_0, "LOSInMinusPS_0/I"); + + fHit->Branch("LTSRaw_1", <SRaw_1, "LTSRaw_1/l"); + fHit->Branch("LBGRaw_1", &LBGRaw_1, "LBGRaw_1/l"); + fHit->Branch("LOffset_ns_1", &LOffset_ns_1, "LOffset_ns_1/l"); + fHit->Branch("LTSCorrection_1", <SCorrection_1, "LTSCorrection_1/I"); + fHit->Branch("LBGCorrection_1", &LBGCorrection_1, "LBGCorrection_1/I"); + fHit->Branch("LOSInMinusPS_1", &LOSInMinusPS_1, "LOSInMinusPS_1/I"); + fHit->Branch("CTCPrimeTriggerTime", &CTCPrimeTriggerTime, "CTCPrimeTriggerTime/l"); } @@ -128,12 +144,20 @@ bool LAPPDTreeMaker::Initialise(std::string configfile, DataModel &data) fWaveform->Branch("WaveformMaxNearing", &waveformMaxNearingValue, "WaveformMaxNearing/D"); if (MultiLAPPDMapTreeMaker) { - fWaveform->Branch("LTSRaw", <SRaw, "LTSRaw/l"); - fWaveform->Branch("LBGRaw", &LBGRaw, "LBGRaw/l"); - fWaveform->Branch("LOffset_ns", &LOffset_ns, "LOffset_ns/l"); - fWaveform->Branch("LTSCorrection", <SCorrection, "LTSCorrection/I"); - fWaveform->Branch("LBGCorrection", &LBGCorrection, "LBGCorrection/I"); - fWaveform->Branch("LOSInMinusPS", &LOSInMinusPS, "LOSInMinusPS/I"); + fWaveform->Branch("LTSRaw_0", <SRaw_0, "LTSRaw_0/l"); + fWaveform->Branch("LBGRaw_0", &LBGRaw_0, "LBGRaw_0/l"); + fWaveform->Branch("LOffset_ns_0", &LOffset_ns_0, "LOffset_ns_0/l"); + fWaveform->Branch("LTSCorrection_0", <SCorrection_0, "LTSCorrection_0/I"); + fWaveform->Branch("LBGCorrection_0", &LBGCorrection_0, "LBGCorrection_0/I"); + fWaveform->Branch("LOSInMinusPS_0", &LOSInMinusPS_0, "LOSInMinusPS_0/I"); + + fWaveform->Branch("LTSRaw_1", <SRaw_1, "LTSRaw_1/l"); + fWaveform->Branch("LBGRaw_1", &LBGRaw_1, "LBGRaw_1/l"); + fWaveform->Branch("LOffset_ns_1", &LOffset_ns_1, "LOffset_ns_1/l"); + fWaveform->Branch("LTSCorrection_1", <SCorrection_1, "LTSCorrection_1/I"); + fWaveform->Branch("LBGCorrection_1", &LBGCorrection_1, "LBGCorrection_1/I"); + fWaveform->Branch("LOSInMinusPS_1", &LOSInMinusPS_1, "LOSInMinusPS_1/I"); + fWaveform->Branch("CTCPrimeTriggerTime", &CTCPrimeTriggerTime, "CTCPrimeTriggerTime/l"); } @@ -230,62 +254,20 @@ bool LAPPDTreeMaker::Execute() { m_data->Stores["ANNIEEvent"]->Get("PrimaryTriggerTime", CTCPrimeTriggerTime); if (treeMakerVerbosity > 0) - cout << "LAPPDTreeMaker::Execute() MultiLAPPDMapTreeMaker" << endl; + std::cout << "LAPPDTreeMaker::Execute() MultiLAPPDMapTreeMaker" << std::endl; + LoadLAPPDMapInfo(); - bool getMap = m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", LAPPDDataMap); - bool gotBeamgates_ns = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - bool gotTimeStamps_ns = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - bool gotTimeStampsRaw = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - bool gotBeamgatesRaw = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - bool gotOffsets = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets); - bool gotTSCorrection = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection); - bool gotDBGCorrection = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection); - bool gotOSInMinusPS = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); + if (treeMakerVerbosity > 0) - cout << "LAPPDTreeMaker::Execute() MultiLAPPDMapTreeMaker get map = " << getMap << endl; - if (getMap) { - if (treeMakerVerbosity > 0) - cout << "map size: " << LAPPDDataMap.size() << endl; - for (auto &item : LAPPDDataMap) - { - PsecData thisData = item.second; - int thisLAPPD_ID = thisData.LAPPD_ID; - - uint64_t thisDataTime = item.first; - uint64_t thisTSRaw = LAPPDTimeStampsRaw.at(thisDataTime); - uint64_t thisBGRaw = LAPPDBeamgatesRaw.at(thisDataTime); - uint64_t thisOffset = LAPPDOffsets.at(thisDataTime); - int thisTSCorr = LAPPDTSCorrection.at(thisDataTime); - int thisDBGCorr = LAPPDBGCorrection.at(thisDataTime); - int thisOSInMinusPS = LAPPDOSInMinusPS.at(thisDataTime); - - if (treeMakerVerbosity > 0) - cout << "outside tree maker, Got LAPPD ID: " << thisLAPPD_ID << ", time stamp: " << thisDataTime << ", TSraw " << thisTSRaw << ", BGraw " << thisBGRaw << ", offset " << thisOffset << ", TSCorr " << thisTSCorr << ", DBGCorr " << thisDBGCorr << ", OSInMinusPS " << thisOSInMinusPS << endl; - - LAPPD_IDs.push_back(thisLAPPD_ID); - LAPPDMapTimeStampRaw.push_back(thisTSRaw); - LAPPDMapBeamgateRaw.push_back(thisBGRaw); - LAPPDMapOffsets.push_back(thisOffset); - LAPPDMapTSCorrections.push_back(thisTSCorr); - LAPPDMapBGCorrections.push_back(thisDBGCorr); - LAPPDMapOSInMinusPS.push_back(thisOSInMinusPS); + std::cout << "LAPPDMapTimeStampRaw: "; + for (auto &item : LAPPDMapTimeStampRaw_0) + std::cout << item << " "; - if (treeMakerVerbosity > 0) - cout << "outside size of LAPPD_IDs: " << LAPPD_IDs.size() << endl; - } - } - else - { - cout << "outside LAPPDTreeMaker::LoadLAPPDMapInfo, no LAPPDDataMap found" << endl; - } + for (auto &item : LAPPDMapTimeStampRaw_1) + std::cout << item << " "; - if (treeMakerVerbosity > 0) - { - cout << "LAPPDMapTimeStampRaw: "; - for (auto &item : LAPPDMapTimeStampRaw) - cout << item << " "; - cout << "LAPPDTreeMaker::Execute() MultiLAPPDMapTreeMaker finished " << endl; + std::cout << "LAPPDTreeMaker::Execute() MultiLAPPDMapTreeMaker finished " << std::endl; } } @@ -461,22 +443,40 @@ void LAPPDTreeMaker::CleanVariables() groupedTriggerType = -9999; LAPPD_IDs.clear(); - LAPPDMapTimeStampRaw.clear(); - LAPPDMapBeamgateRaw.clear(); - LAPPDMapOffsets.clear(); - LAPPDMapTSCorrections.clear(); - LAPPDMapBGCorrections.clear(); - LAPPDMapOSInMinusPS.clear(); + + LAPPDMapTimeStampRaw_0.clear(); + LAPPDMapBeamgateRaw_0.clear(); + LAPPDMapOffsets_0.clear(); + LAPPDMapTSCorrections_0.clear(); + LAPPDMapBGCorrections_0.clear(); + LAPPDMapOSInMinusPS_0.clear(); + + LAPPDMapTimeStampRaw_1.clear(); + LAPPDMapBeamgateRaw_1.clear(); + LAPPDMapOffsets_1.clear(); + LAPPDMapTSCorrections_1.clear(); + LAPPDMapBGCorrections_1.clear(); + LAPPDMapOSInMinusPS_1.clear(); LAPPDDataMap.clear(); - LAPPDBeamgate_ns.clear(); - LAPPDTimeStamps_ns.clear(); - LAPPDTimeStampsRaw.clear(); - LAPPDBeamgatesRaw.clear(); - LAPPDOffsets.clear(); - LAPPDTSCorrection.clear(); - LAPPDBGCorrection.clear(); - LAPPDOSInMinusPS.clear(); + + LAPPDBeamgate_ns_0.clear(); + LAPPDTimeStamps_ns_0.clear(); + LAPPDTimeStampsRaw_0.clear(); + LAPPDBeamgatesRaw_0.clear(); + LAPPDOffsets_0.clear(); + LAPPDTSCorrection_0.clear(); + LAPPDBGCorrection_0.clear(); + LAPPDOSInMinusPS_0.clear(); + + LAPPDBeamgate_ns_1.clear(); + LAPPDTimeStamps_ns_1.clear(); + LAPPDTimeStampsRaw_1.clear(); + LAPPDBeamgatesRaw_1.clear(); + LAPPDOffsets_1.clear(); + LAPPDTSCorrection_1.clear(); + LAPPDBGCorrection_1.clear(); + LAPPDOSInMinusPS_1.clear(); } bool LAPPDTreeMaker::LoadRunInfoFromRaw() @@ -539,23 +539,37 @@ bool LAPPDTreeMaker::FillPulseTree() // use that index to get the timestamp and beamgate // if not found, set them to zero int index = std::distance(LAPPD_IDs.begin(), std::find(LAPPD_IDs.begin(), LAPPD_IDs.end(), LAPPD_ID)); - if (index < LAPPDMapTimeStampRaw.size()) + if (index < LAPPDMapTimeStampRaw_0.size()) { - LTSRaw = LAPPDMapTimeStampRaw.at(index); - LBGRaw = LAPPDMapBeamgateRaw.at(index); - LOffset_ns = LAPPDMapOffsets.at(index); - LTSCorrection = LAPPDMapTSCorrections.at(index); - LBGCorrection = LAPPDMapBGCorrections.at(index); - LOSInMinusPS = LAPPDMapOSInMinusPS.at(index); + LTSRaw_0 = LAPPDMapTimeStampRaw_0.at(index); + LBGRaw_0 = LAPPDMapBeamgateRaw_0.at(index); + LOffset_ns_0 = LAPPDMapOffsets_0.at(index); + LTSCorrection_0 = LAPPDMapTSCorrections_0.at(index); + LBGCorrection_0 = LAPPDMapBGCorrections_0.at(index); + LOSInMinusPS_0 = LAPPDMapOSInMinusPS_0.at(index); + + LTSRaw_1 = LAPPDMapTimeStampRaw_1.at(index); + LBGRaw_1 = LAPPDMapBeamgateRaw_1.at(index); + LOffset_ns_1 = LAPPDMapOffsets_1.at(index); + LTSCorrection_1 = LAPPDMapTSCorrections_1.at(index); + LBGCorrection_1 = LAPPDMapBGCorrections_1.at(index); + LOSInMinusPS_1 = LAPPDMapOSInMinusPS_1.at(index); } else { - LTSRaw = 0; - LBGRaw = 0; - LOffset_ns = 0; - LTSCorrection = 0; - LBGCorrection = 0; - LOSInMinusPS = 0; + LTSRaw_0 = 0; + LBGRaw_0 = 0; + LOffset_ns_0 = 0; + LTSCorrection_0 = 0; + LBGCorrection_0 = 0; + LOSInMinusPS_0 = 0; + + LTSRaw_1 = 0; + LBGRaw_1 = 0; + LOffset_ns_1 = 0; + LTSCorrection_1 = 0; + LBGCorrection_1 = 0; + LOSInMinusPS_1 = 0; } } @@ -586,23 +600,37 @@ bool LAPPDTreeMaker::FillPulseTree() { // find the index of LAPPD_ID in LAPPD_IDs, use that index to assign the timestamlUL and beam gate UL, if not found set them to zero int index = std::distance(LAPPD_IDs.begin(), std::find(LAPPD_IDs.begin(), LAPPD_IDs.end(), LAPPD_ID)); - if (index < LAPPDMapTimeStampRaw.size()) + if (index < LAPPDMapTimeStampRaw_0.size()) { - LTSRaw = LAPPDMapTimeStampRaw.at(index); - LBGRaw = LAPPDMapBeamgateRaw.at(index); - LOffset_ns = LAPPDMapOffsets.at(index); - LTSCorrection = LAPPDMapTSCorrections.at(index); - LBGCorrection = LAPPDMapBGCorrections.at(index); - LOSInMinusPS = LAPPDMapOSInMinusPS.at(index); + LTSRaw_0 = LAPPDMapTimeStampRaw_0.at(index); + LBGRaw_0 = LAPPDMapBeamgateRaw_0.at(index); + LOffset_ns_0 = LAPPDMapOffsets_0.at(index); + LTSCorrection_0 = LAPPDMapTSCorrections_0.at(index); + LBGCorrection_0 = LAPPDMapBGCorrections_0.at(index); + LOSInMinusPS_0 = LAPPDMapOSInMinusPS_0.at(index); + + LTSRaw_1 = LAPPDMapTimeStampRaw_1.at(index); + LBGRaw_1 = LAPPDMapBeamgateRaw_1.at(index); + LOffset_ns_1 = LAPPDMapOffsets_1.at(index); + LTSCorrection_1 = LAPPDMapTSCorrections_1.at(index); + LBGCorrection_1 = LAPPDMapBGCorrections_1.at(index); + LOSInMinusPS_1 = LAPPDMapOSInMinusPS_1.at(index); } else { - LTSRaw = 0; - LBGRaw = 0; - LOffset_ns = 0; - LTSCorrection = 0; - LBGCorrection = 0; - LOSInMinusPS = 0; + LTSRaw_0 = 0; + LBGRaw_0 = 0; + LOffset_ns_0 = 0; + LTSCorrection_0 = 0; + LBGCorrection_0 = 0; + LOSInMinusPS_0 = 0; + + LTSRaw_1 = 0; + LBGRaw_1 = 0; + LOffset_ns_1 = 0; + LTSCorrection_1 = 0; + LBGCorrection_1 = 0; + LOSInMinusPS_1 = 0; } } fPulse->Fill(); @@ -662,23 +690,37 @@ bool LAPPDTreeMaker::FillHitTree() // use that index to get the timestamp and beamgate // if not found, set them to zero int index = std::distance(LAPPD_IDs.begin(), std::find(LAPPD_IDs.begin(), LAPPD_IDs.end(), LAPPD_ID)); - if (index < LAPPDMapTimeStampRaw.size()) + if (index < LAPPDMapTimeStampRaw_0.size()) { - LTSRaw = LAPPDMapTimeStampRaw.at(index); - LBGRaw = LAPPDMapBeamgateRaw.at(index); - LOffset_ns = LAPPDMapOffsets.at(index); - LTSCorrection = LAPPDMapTSCorrections.at(index); - LBGCorrection = LAPPDMapBGCorrections.at(index); - LOSInMinusPS = LAPPDMapOSInMinusPS.at(index); + LTSRaw_0 = LAPPDMapTimeStampRaw_0.at(index); + LBGRaw_0 = LAPPDMapBeamgateRaw_0.at(index); + LOffset_ns_0 = LAPPDMapOffsets_0.at(index); + LTSCorrection_0 = LAPPDMapTSCorrections_0.at(index); + LBGCorrection_0 = LAPPDMapBGCorrections_0.at(index); + LOSInMinusPS_0 = LAPPDMapOSInMinusPS_0.at(index); + + LTSRaw_1 = LAPPDMapTimeStampRaw_1.at(index); + LBGRaw_1 = LAPPDMapBeamgateRaw_1.at(index); + LOffset_ns_1 = LAPPDMapOffsets_1.at(index); + LTSCorrection_1 = LAPPDMapTSCorrections_1.at(index); + LBGCorrection_1 = LAPPDMapBGCorrections_1.at(index); + LOSInMinusPS_1 = LAPPDMapOSInMinusPS_1.at(index); } else { - LTSRaw = 0; - LBGRaw = 0; - LOffset_ns = 0; - LTSCorrection = 0; - LBGCorrection = 0; - LOSInMinusPS = 0; + LTSRaw_0 = 0; + LBGRaw_0 = 0; + LOffset_ns_0 = 0; + LTSCorrection_0 = 0; + LBGCorrection_0 = 0; + LOSInMinusPS_0 = 0; + + LTSRaw_1 = 0; + LBGRaw_1 = 0; + LOffset_ns_1 = 0; + LTSCorrection_1 = 0; + LBGCorrection_1 = 0; + LOSInMinusPS_1 = 0; } } fHit->Fill(); @@ -727,23 +769,38 @@ bool LAPPDTreeMaker::FillWaveformTree() // use that index to get the timestamp and beamgate // if not found, set them to zero int index = std::distance(LAPPD_IDs.begin(), std::find(LAPPD_IDs.begin(), LAPPD_IDs.end(), LAPPD_ID)); - if (index < LAPPDMapTimeStampRaw.size()) + + if (index < LAPPDMapTimeStampRaw_0.size()) { - LTSRaw = LAPPDMapTimeStampRaw.at(index); - LBGRaw = LAPPDMapBeamgateRaw.at(index); - LOffset_ns = LAPPDMapOffsets.at(index); - LTSCorrection = LAPPDMapTSCorrections.at(index); - LBGCorrection = LAPPDMapBGCorrections.at(index); - LOSInMinusPS = LAPPDMapOSInMinusPS.at(index); + LTSRaw_0 = LAPPDMapTimeStampRaw_0.at(index); + LBGRaw_0 = LAPPDMapBeamgateRaw_0.at(index); + LOffset_ns_0 = LAPPDMapOffsets_0.at(index); + LTSCorrection_0 = LAPPDMapTSCorrections_0.at(index); + LBGCorrection_0 = LAPPDMapBGCorrections_0.at(index); + LOSInMinusPS_0 = LAPPDMapOSInMinusPS_0.at(index); + + LTSRaw_1 = LAPPDMapTimeStampRaw_1.at(index); + LBGRaw_1 = LAPPDMapBeamgateRaw_1.at(index); + LOffset_ns_1 = LAPPDMapOffsets_1.at(index); + LTSCorrection_1 = LAPPDMapTSCorrections_1.at(index); + LBGCorrection_1 = LAPPDMapBGCorrections_1.at(index); + LOSInMinusPS_1 = LAPPDMapOSInMinusPS_1.at(index); } else { - LTSRaw = 0; - LBGRaw = 0; - LOffset_ns = 0; - LTSCorrection = 0; - LBGCorrection = 0; - LOSInMinusPS = 0; + LTSRaw_0 = 0; + LBGRaw_0 = 0; + LOffset_ns_0 = 0; + LTSCorrection_0 = 0; + LBGCorrection_0 = 0; + LOSInMinusPS_0 = 0; + + LTSRaw_1 = 0; + LBGRaw_1 = 0; + LOffset_ns_1 = 0; + LTSCorrection_1 = 0; + LBGCorrection_1 = 0; + LOSInMinusPS_1 = 0; } } fWaveform->Fill(); @@ -817,8 +874,13 @@ bool LAPPDTreeMaker::FillLAPPDDataTimeStamp() for (int i = 0; i < LAPPD_IDs.size(); i++) { LAPPD_ID = LAPPD_IDs.at(i); - LAPPDDataBeamgate0_UL = LAPPDMapBeamgateRaw.at(i); - LAPPDDataTimeStamp0_UL = LAPPDMapTimeStampRaw.at(i); + + LAPPDDataBeamgate0_UL = LAPPDMapBeamgateRaw_0.at(i); + LAPPDDataTimeStamp0_UL = LAPPDMapTimeStampRaw_0.at(i); + + LAPPDDataBeamgate1_UL = LAPPDMapBeamgateRaw_1.at(i); + LAPPDDataTimeStamp1_UL = LAPPDMapTimeStampRaw_1.at(i); + fTimeStamp->Fill(); } } @@ -1106,45 +1168,77 @@ void LAPPDTreeMaker::CleanTriggers() void LAPPDTreeMaker::LoadLAPPDMapInfo() { - // cout << "LAPPDTreeMaker::LoadLAPPDMapInfo" << endl; bool getMap = m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", LAPPDDataMap); - bool gotBeamgates_ns = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - bool gotTimeStamps_ns = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - bool gotTimeStampsRaw = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - bool gotBeamgatesRaw = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - bool gotOffsets = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets); - bool gotTSCorrection = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection); - bool gotDBGCorrection = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection); - bool gotOSInMinusPS = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); - // cout << "LAPPDTreeMaker::LoadLAPPDMapInfo() get map = " << getMap << endl; + + // ACDC 0 + bool gotBeamgates_ns_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + bool gotTimeStamps_ns_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + bool gotTimeStampsRaw_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + bool gotBeamgatesRaw_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + bool gotOffsets_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_0", LAPPDOffsets_0); + bool gotTSCorrection_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + bool gotDBGCorrection_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + bool gotOSInMinusPS_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + + // ACDC 1 + bool gotBeamgates_ns_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + bool gotTimeStamps_ns_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + bool gotTimeStampsRaw_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + bool gotBeamgatesRaw_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + bool gotOffsets_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_1", LAPPDOffsets_1); + bool gotTSCorrection_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + bool gotDBGCorrection_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + bool gotOSInMinusPS_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); if (getMap) { if (treeMakerVerbosity > 0) cout << "map size: " << LAPPDDataMap.size() << endl; + for (auto &item : LAPPDDataMap) { PsecData thisData = item.second; int thisLAPPD_ID = thisData.LAPPD_ID; uint64_t thisDataTime = item.first; - uint64_t thisTSRaw = LAPPDTimeStampsRaw.at(thisDataTime); - uint64_t thisBGRaw = LAPPDBeamgatesRaw.at(thisDataTime); - uint64_t thisOffset = LAPPDOffsets.at(thisDataTime); - int thisTSCorr = LAPPDTSCorrection.at(thisDataTime); - int thisDBGCorr = LAPPDBGCorrection.at(thisDataTime); - int thisOSInMinusPS = LAPPDOSInMinusPS.at(thisDataTime); - - if (treeMakerVerbosity > 0) - cout << "tree maker, Got LAPPD ID: " << thisLAPPD_ID << ", time stamp: " << thisDataTime << ", TSraw " << thisTSRaw << ", BGraw " << thisBGRaw << ", offset " << thisOffset << ", TSCorr " << thisTSCorr << ", DBGCorr " << thisDBGCorr << ", OSInMinusPS " << thisOSInMinusPS << endl; + + uint64_t thisTSRaw_0 = LAPPDTimeStampsRaw_0.at(thisDataTime); + uint64_t thisBGRaw_0 = LAPPDBeamgatesRaw_0.at(thisDataTime); + uint64_t thisOffset_0 = LAPPDOffsets_0.at(thisDataTime); + int thisTSCorr_0 = LAPPDTSCorrection_0.at(thisDataTime); + int thisDBGCorr_0 = LAPPDBGCorrection_0.at(thisDataTime); + int thisOSInMinusPS_0 = LAPPDOSInMinusPS_0.at(thisDataTime); + + uint64_t thisTSRaw_1 = LAPPDTimeStampsRaw_1.at(thisDataTime); + uint64_t thisBGRaw_1 = LAPPDBeamgatesRaw_1.at(thisDataTime); + uint64_t thisOffset_1 = LAPPDOffsets_1.at(thisDataTime); + int thisTSCorr_1 = LAPPDTSCorrection_1.at(thisDataTime); + int thisDBGCorr_1 = LAPPDBGCorrection_1.at(thisDataTime); + int thisOSInMinusPS_1 = LAPPDOSInMinusPS_1.at(thisDataTime); + + if (treeMakerVerbosity > 0) { + cout << "tree maker, Got LAPPD ID: " << thisLAPPD_ID << ", time stamp: " << thisDataTime + << "\n ACDC 0 - TSraw " << thisTSRaw_0 << ", BGraw " << thisBGRaw_0 << ", offset " << thisOffset_0 + << ", TSCorr " << thisTSCorr_0 << ", DBGCorr " << thisDBGCorr_0 << ", OSInMinusPS " << thisOSInMinusPS_0 + << "\n ACDC 1 - TSraw " << thisTSRaw_1 << ", BGraw " << thisBGRaw_1 << ", offset " << thisOffset_1 + << ", TSCorr " << thisTSCorr_1 << ", DBGCorr " << thisDBGCorr_1 << ", OSInMinusPS " << thisOSInMinusPS_1 << endl; + } LAPPD_IDs.push_back(thisLAPPD_ID); - LAPPDMapTimeStampRaw.push_back(thisTSRaw); - LAPPDMapBeamgateRaw.push_back(thisBGRaw); - LAPPDMapOffsets.push_back(thisOffset); - LAPPDMapTSCorrections.push_back(thisTSCorr); - LAPPDMapBGCorrections.push_back(thisDBGCorr); - LAPPDMapOSInMinusPS.push_back(thisOSInMinusPS); + + LAPPDMapTimeStampRaw_0.push_back(thisTSRaw_0); + LAPPDMapBeamgateRaw_0.push_back(thisBGRaw_0); + LAPPDMapOffsets_0.push_back(thisOffset_0); + LAPPDMapTSCorrections_0.push_back(thisTSCorr_0); + LAPPDMapBGCorrections_0.push_back(thisDBGCorr_0); + LAPPDMapOSInMinusPS_0.push_back(thisOSInMinusPS_0); + + LAPPDMapTimeStampRaw_1.push_back(thisTSRaw_1); + LAPPDMapBeamgateRaw_1.push_back(thisBGRaw_1); + LAPPDMapOffsets_1.push_back(thisOffset_1); + LAPPDMapTSCorrections_1.push_back(thisTSCorr_1); + LAPPDMapBGCorrections_1.push_back(thisDBGCorr_1); + LAPPDMapOSInMinusPS_1.push_back(thisOSInMinusPS_1); if (treeMakerVerbosity > 0) cout << "size of LAPPD_IDs: " << LAPPD_IDs.size() << endl; diff --git a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h index b2feac887..cf19293e6 100644 --- a/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h +++ b/UserTools/LAPPDTreeMaker/LAPPDTreeMaker.h @@ -164,30 +164,55 @@ class LAPPDTreeMaker : public Tool bool MultiLAPPDMapTreeMaker; vector LAPPD_IDs; - vector LAPPDMapTimeStampRaw; - vector LAPPDMapBeamgateRaw; - vector LAPPDMapOffsets; - vector LAPPDMapTSCorrections; - vector LAPPDMapBGCorrections; - vector LAPPDMapOSInMinusPS; + + vector LAPPDMapTimeStampRaw_0; + vector LAPPDMapBeamgateRaw_0; + vector LAPPDMapOffsets_0; + vector LAPPDMapTSCorrections_0; + vector LAPPDMapBGCorrections_0; + vector LAPPDMapOSInMinusPS_0; + + vector LAPPDMapTimeStampRaw_1; + vector LAPPDMapBeamgateRaw_1; + vector LAPPDMapOffsets_1; + vector LAPPDMapTSCorrections_1; + vector LAPPDMapBGCorrections_1; + vector LAPPDMapOSInMinusPS_1; std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; - - - uint64_t LTSRaw; - uint64_t LBGRaw; - uint64_t LOffset_ns; - int LTSCorrection; - int LBGCorrection; - int LOSInMinusPS; + + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; + + uint64_t LTSRaw_0; + uint64_t LBGRaw_0; + uint64_t LOffset_ns_0; + int LTSCorrection_0; + int LBGCorrection_0; + int LOSInMinusPS_0; + + uint64_t LTSRaw_1; + uint64_t LBGRaw_1; + uint64_t LOffset_ns_1; + int LTSCorrection_1; + int LBGCorrection_1; + int LOSInMinusPS_1; + uint64_t CTCPrimeTriggerTime; }; diff --git a/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.cpp b/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.cpp index 9d0e8295f..9507e552c 100644 --- a/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.cpp +++ b/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.cpp @@ -119,14 +119,24 @@ bool PhaseIITreeMaker::Initialise(std::string configfile, DataModel &data){ if(LAPPDData_fill) { fPhaseIITankClusterTree->Branch("LAPPD_ID",&fLAPPD_ID); - fPhaseIITankClusterTree->Branch("LAPPD_Beamgate_ns",&fLAPPD_Beamgate_ns); - fPhaseIITankClusterTree->Branch("LAPPD_Timestamp_ns",&fLAPPD_Timestamp_ns); - fPhaseIITankClusterTree->Branch("LAPPD_Beamgate_Raw",&fLAPPD_Beamgate_Raw); - fPhaseIITankClusterTree->Branch("LAPPD_Timestamp_Raw",&fLAPPD_Timestamp_Raw); - fPhaseIITankClusterTree->Branch("LAPPD_Offset",&fLAPPD_Offset); - fPhaseIITankClusterTree->Branch("LAPPD_TSCorrection",&fLAPPD_TSCorrection); - fPhaseIITankClusterTree->Branch("LAPPD_BGCorrection",&fLAPPD_BGCorrection); - fPhaseIITankClusterTree->Branch("LAPPD_OSInMinusPS",&fLAPPD_OSInMinusPS); + + fPhaseIITankClusterTree->Branch("LAPPD_Beamgate_ns_0",&fLAPPD_Beamgate_ns_0); + fPhaseIITankClusterTree->Branch("LAPPD_Timestamp_ns_0",&fLAPPD_Timestamp_ns_0); + fPhaseIITankClusterTree->Branch("LAPPD_Beamgate_Raw_0",&fLAPPD_Beamgate_Raw_0); + fPhaseIITankClusterTree->Branch("LAPPD_Timestamp_Raw_0",&fLAPPD_Timestamp_Raw_0); + fPhaseIITankClusterTree->Branch("LAPPD_Offset_0",&fLAPPD_Offset_0); + fPhaseIITankClusterTree->Branch("LAPPD_TSCorrection_0",&fLAPPD_TSCorrection_0); + fPhaseIITankClusterTree->Branch("LAPPD_BGCorrection_0",&fLAPPD_BGCorrection_0); + fPhaseIITankClusterTree->Branch("LAPPD_OSInMinusPS_0",&fLAPPD_OSInMinusPS_0); + + fPhaseIITankClusterTree->Branch("LAPPD_Beamgate_ns_1",&fLAPPD_Beamgate_ns_1); + fPhaseIITankClusterTree->Branch("LAPPD_Timestamp_ns_1",&fLAPPD_Timestamp_ns_1); + fPhaseIITankClusterTree->Branch("LAPPD_Beamgate_Raw_1",&fLAPPD_Beamgate_Raw_1); + fPhaseIITankClusterTree->Branch("LAPPD_Timestamp_Raw_1",&fLAPPD_Timestamp_Raw_1); + fPhaseIITankClusterTree->Branch("LAPPD_Offset_1",&fLAPPD_Offset_1); + fPhaseIITankClusterTree->Branch("LAPPD_TSCorrection_1",&fLAPPD_TSCorrection_1); + fPhaseIITankClusterTree->Branch("LAPPD_BGCorrection_1",&fLAPPD_BGCorrection_1); + fPhaseIITankClusterTree->Branch("LAPPD_OSInMinusPS_1",&fLAPPD_OSInMinusPS_1); fPhaseIITankClusterTree->Branch("GroupedTriggerTime",&fGroupedTriggerTime); fPhaseIITankClusterTree->Branch("GroupedTriggerWord",&fGroupedTriggerWord); @@ -229,14 +239,24 @@ bool PhaseIITreeMaker::Initialise(std::string configfile, DataModel &data){ if(LAPPDData_fill) { fPhaseIIMRDClusterTree->Branch("LAPPD_ID",&fLAPPD_ID); - fPhaseIIMRDClusterTree->Branch("LAPPD_Beamgate_ns",&fLAPPD_Beamgate_ns); - fPhaseIIMRDClusterTree->Branch("LAPPD_Timestamp_ns",&fLAPPD_Timestamp_ns); - fPhaseIIMRDClusterTree->Branch("LAPPD_Beamgate_Raw",&fLAPPD_Beamgate_Raw); - fPhaseIIMRDClusterTree->Branch("LAPPD_Timestamp_Raw",&fLAPPD_Timestamp_Raw); - fPhaseIIMRDClusterTree->Branch("LAPPD_Offset",&fLAPPD_Offset); - fPhaseIIMRDClusterTree->Branch("LAPPD_TSCorrection",&fLAPPD_TSCorrection); - fPhaseIIMRDClusterTree->Branch("LAPPD_BGCorrection",&fLAPPD_BGCorrection); - fPhaseIIMRDClusterTree->Branch("LAPPD_OSInMinusPS",&fLAPPD_OSInMinusPS); + + fPhaseIIMRDClusterTree->Branch("LAPPD_Beamgate_ns_0",&fLAPPD_Beamgate_ns_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_Timestamp_ns_0",&fLAPPD_Timestamp_ns_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_Beamgate_Raw_0",&fLAPPD_Beamgate_Raw_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_Timestamp_Raw_0",&fLAPPD_Timestamp_Raw_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_Offset_0",&fLAPPD_Offset_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_TSCorrection_0",&fLAPPD_TSCorrection_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_BGCorrection_0",&fLAPPD_BGCorrection_0); + fPhaseIIMRDClusterTree->Branch("LAPPD_OSInMinusPS_0",&fLAPPD_OSInMinusPS_0); + + fPhaseIIMRDClusterTree->Branch("LAPPD_Beamgate_ns_1",&fLAPPD_Beamgate_ns_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_Timestamp_ns_1",&fLAPPD_Timestamp_ns_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_Beamgate_Raw_1",&fLAPPD_Beamgate_Raw_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_Timestamp_Raw_1",&fLAPPD_Timestamp_Raw_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_Offset_1",&fLAPPD_Offset_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_TSCorrection_1",&fLAPPD_TSCorrection_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_BGCorrection_1",&fLAPPD_BGCorrection_1); + fPhaseIIMRDClusterTree->Branch("LAPPD_OSInMinusPS_1",&fLAPPD_OSInMinusPS_1); fPhaseIIMRDClusterTree->Branch("GroupedTriggerTime",&fGroupedTriggerTime); fPhaseIIMRDClusterTree->Branch("GroupedTriggerWord",&fGroupedTriggerWord); @@ -604,14 +624,24 @@ bool PhaseIITreeMaker::Initialise(std::string configfile, DataModel &data){ if(LAPPDData_fill) { fPhaseIITrigTree->Branch("LAPPD_ID",&fLAPPD_ID); - fPhaseIITrigTree->Branch("LAPPD_Beamgate_ns",&fLAPPD_Beamgate_ns); - fPhaseIITrigTree->Branch("LAPPD_Timestamp_ns",&fLAPPD_Timestamp_ns); - fPhaseIITrigTree->Branch("LAPPD_Beamgate_Raw",&fLAPPD_Beamgate_Raw); - fPhaseIITrigTree->Branch("LAPPD_Timestamp_Raw",&fLAPPD_Timestamp_Raw); - fPhaseIITrigTree->Branch("LAPPD_Offset",&fLAPPD_Offset); - fPhaseIITrigTree->Branch("LAPPD_TSCorrection",&fLAPPD_TSCorrection); - fPhaseIITrigTree->Branch("LAPPD_BGCorrection",&fLAPPD_BGCorrection); - fPhaseIITrigTree->Branch("LAPPD_OSInMinusPS",&fLAPPD_OSInMinusPS); + + fPhaseIITrigTree->Branch("LAPPD_Beamgate_ns_0",&fLAPPD_Beamgate_ns_0); + fPhaseIITrigTree->Branch("LAPPD_Timestamp_ns_0",&fLAPPD_Timestamp_ns_0); + fPhaseIITrigTree->Branch("LAPPD_Beamgate_Raw_0",&fLAPPD_Beamgate_Raw_0); + fPhaseIITrigTree->Branch("LAPPD_Timestamp_Raw_0",&fLAPPD_Timestamp_Raw_0); + fPhaseIITrigTree->Branch("LAPPD_Offset_0",&fLAPPD_Offset_0); + fPhaseIITrigTree->Branch("LAPPD_TSCorrection_0",&fLAPPD_TSCorrection_0); + fPhaseIITrigTree->Branch("LAPPD_BGCorrection_0",&fLAPPD_BGCorrection_0); + fPhaseIITrigTree->Branch("LAPPD_OSInMinusPS_0",&fLAPPD_OSInMinusPS_0); + + fPhaseIITrigTree->Branch("LAPPD_Beamgate_ns_1",&fLAPPD_Beamgate_ns_1); + fPhaseIITrigTree->Branch("LAPPD_Timestamp_ns_1",&fLAPPD_Timestamp_ns_1); + fPhaseIITrigTree->Branch("LAPPD_Beamgate_Raw_1",&fLAPPD_Beamgate_Raw_1); + fPhaseIITrigTree->Branch("LAPPD_Timestamp_Raw_1",&fLAPPD_Timestamp_Raw_1); + fPhaseIITrigTree->Branch("LAPPD_Offset_1",&fLAPPD_Offset_1); + fPhaseIITrigTree->Branch("LAPPD_TSCorrection_1",&fLAPPD_TSCorrection_1); + fPhaseIITrigTree->Branch("LAPPD_BGCorrection_1",&fLAPPD_BGCorrection_1); + fPhaseIITrigTree->Branch("LAPPD_OSInMinusPS_1",&fLAPPD_OSInMinusPS_1); fPhaseIITrigTree->Branch("GroupedTriggerTime",&fGroupedTriggerTime); fPhaseIITrigTree->Branch("GroupedTriggerWord",&fGroupedTriggerWord); @@ -1526,24 +1556,44 @@ void PhaseIITreeMaker::ResetVariables() { if(LAPPDData_fill){ LAPPDDataMap.clear(); - LAPPDBeamgate_ns.clear(); - LAPPDTimeStamps_ns.clear(); - LAPPDTimeStampsRaw.clear(); - LAPPDBeamgatesRaw.clear(); - LAPPDOffsets.clear(); - LAPPDTSCorrection.clear(); - LAPPDBGCorrection.clear(); - LAPPDOSInMinusPS.clear(); + + LAPPDBeamgate_ns_0.clear(); + LAPPDTimeStamps_ns_0.clear(); + LAPPDTimeStampsRaw_0.clear(); + LAPPDBeamgatesRaw_0.clear(); + LAPPDOffsets_0.clear(); + LAPPDTSCorrection_0.clear(); + LAPPDBGCorrection_0.clear(); + LAPPDOSInMinusPS_0.clear(); + + LAPPDBeamgate_ns_1.clear(); + LAPPDTimeStamps_ns_1.clear(); + LAPPDTimeStampsRaw_1.clear(); + LAPPDBeamgatesRaw_1.clear(); + LAPPDOffsets_1.clear(); + LAPPDTSCorrection_1.clear(); + LAPPDBGCorrection_1.clear(); + LAPPDOSInMinusPS_1.clear(); fLAPPD_ID.clear(); - fLAPPD_Beamgate_ns.clear(); - fLAPPD_Timestamp_ns.clear(); - fLAPPD_Beamgate_Raw.clear(); - fLAPPD_Timestamp_Raw.clear(); - fLAPPD_Offset.clear(); - fLAPPD_TSCorrection.clear(); - fLAPPD_BGCorrection.clear(); - fLAPPD_OSInMinusPS.clear(); + + fLAPPD_Beamgate_ns_0.clear(); + fLAPPD_Timestamp_ns_0.clear(); + fLAPPD_Beamgate_Raw_0.clear(); + fLAPPD_Timestamp_Raw_0.clear(); + fLAPPD_Offset_0.clear(); + fLAPPD_TSCorrection_0.clear(); + fLAPPD_BGCorrection_0.clear(); + fLAPPD_OSInMinusPS_0.clear(); + + fLAPPD_Beamgate_ns_1.clear(); + fLAPPD_Timestamp_ns_1.clear(); + fLAPPD_Beamgate_Raw_1.clear(); + fLAPPD_Timestamp_Raw_1.clear(); + fLAPPD_Offset_1.clear(); + fLAPPD_TSCorrection_1.clear(); + fLAPPD_BGCorrection_1.clear(); + fLAPPD_OSInMinusPS_1.clear(); GroupedTrigger.clear(); @@ -2570,14 +2620,23 @@ for (std::map::iterator it = LAPPDDataMap.begin(); it != LAP fLAPPD_ID.push_back(psecData.LAPPD_ID); - fLAPPD_Beamgate_ns.push_back(LAPPDBeamgate_ns[key]); - fLAPPD_Timestamp_ns.push_back(LAPPDTimeStamps_ns[key]); - fLAPPD_Beamgate_Raw.push_back(LAPPDBeamgatesRaw[key]); - fLAPPD_Timestamp_Raw.push_back(LAPPDTimeStampsRaw[key]); - fLAPPD_Offset.push_back(LAPPDOffsets[key]); - fLAPPD_TSCorrection.push_back(LAPPDTSCorrection[key]); - fLAPPD_BGCorrection.push_back(LAPPDBGCorrection[key]); - fLAPPD_OSInMinusPS.push_back(LAPPDOSInMinusPS[key]); + fLAPPD_Beamgate_ns_0.push_back(LAPPDBeamgate_ns_0[key]); + fLAPPD_Timestamp_ns_0.push_back(LAPPDTimeStamps_ns_0[key]); + fLAPPD_Beamgate_Raw_0.push_back(LAPPDBeamgatesRaw_0[key]); + fLAPPD_Timestamp_Raw_0.push_back(LAPPDTimeStampsRaw_0[key]); + fLAPPD_Offset_0.push_back(LAPPDOffsets_0[key]); + fLAPPD_TSCorrection_0.push_back(LAPPDTSCorrection_0[key]); + fLAPPD_BGCorrection_0.push_back(LAPPDBGCorrection_0[key]); + fLAPPD_OSInMinusPS_0.push_back(LAPPDOSInMinusPS_0[key]); + + fLAPPD_Beamgate_ns_1.push_back(LAPPDBeamgate_ns_1[key]); + fLAPPD_Timestamp_ns_1.push_back(LAPPDTimeStamps_ns_1[key]); + fLAPPD_Beamgate_Raw_1.push_back(LAPPDBeamgatesRaw_1[key]); + fLAPPD_Timestamp_Raw_1.push_back(LAPPDTimeStampsRaw_1[key]); + fLAPPD_Offset_1.push_back(LAPPDOffsets_1[key]); + fLAPPD_TSCorrection_1.push_back(LAPPDTSCorrection_1[key]); + fLAPPD_BGCorrection_1.push_back(LAPPDBGCorrection_1[key]); + fLAPPD_OSInMinusPS_1.push_back(LAPPDOSInMinusPS_1[key]); } //cout<<"Grouped Trigger Size: "<::iterator it = LAPPDDataMap.begin(); it != LAP void PhaseIITreeMaker::LoadLAPPDData() { m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", LAPPDDataMap); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns", LAPPDBeamgate_ns); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns", LAPPDTimeStamps_ns); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw", LAPPDTimeStampsRaw); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw", LAPPDBeamgatesRaw); - m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets", LAPPDOffsets); - m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection", LAPPDTSCorrection); - m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection", LAPPDBGCorrection); - m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS", LAPPDOSInMinusPS); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_0", LAPPDBeamgate_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_0", LAPPDTimeStamps_ns_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_0", LAPPDTimeStampsRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_0", LAPPDBeamgatesRaw_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_0", LAPPDOffsets_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_0", LAPPDTSCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_0", LAPPDBGCorrection_0); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_0", LAPPDOSInMinusPS_0); + + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgate_ns_1", LAPPDBeamgate_ns_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStamps_ns_1", LAPPDTimeStamps_ns_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTimeStampsRaw_1", LAPPDTimeStampsRaw_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBeamgatesRaw_1", LAPPDBeamgatesRaw_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOffsets_1", LAPPDOffsets_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDTSCorrection_1", LAPPDTSCorrection_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDBGCorrection_1", LAPPDBGCorrection_1); + m_data->Stores["ANNIEEvent"]->Get("LAPPDOSInMinusPS_1", LAPPDOSInMinusPS_1); m_data->Stores["ANNIEEvent"]->Get("GroupedTrigger", GroupedTrigger); if(LAPPDDataMap.size() != 0) diff --git a/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.h b/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.h index 3153ee0b3..0cd95cc9f 100644 --- a/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.h +++ b/UserTools/PhaseIITreeMaker/PhaseIITreeMaker.h @@ -490,24 +490,44 @@ class PhaseIITreeMaker: public Tool { bool LAPPDData_fill = 0; int gotLAPPDNumber; std::map LAPPDDataMap; - std::map LAPPDBeamgate_ns; - std::map LAPPDTimeStamps_ns; // data and key are the same - std::map LAPPDTimeStampsRaw; - std::map LAPPDBeamgatesRaw; - std::map LAPPDOffsets; - std::map LAPPDTSCorrection; - std::map LAPPDBGCorrection; - std::map LAPPDOSInMinusPS; + + std::map LAPPDBeamgate_ns_0; + std::map LAPPDTimeStamps_ns_0; + std::map LAPPDTimeStampsRaw_0; + std::map LAPPDBeamgatesRaw_0; + std::map LAPPDOffsets_0; + std::map LAPPDTSCorrection_0; + std::map LAPPDBGCorrection_0; + std::map LAPPDOSInMinusPS_0; + + std::map LAPPDBeamgate_ns_1; + std::map LAPPDTimeStamps_ns_1; + std::map LAPPDTimeStampsRaw_1; + std::map LAPPDBeamgatesRaw_1; + std::map LAPPDOffsets_1; + std::map LAPPDTSCorrection_1; + std::map LAPPDBGCorrection_1; + std::map LAPPDOSInMinusPS_1; vector fLAPPD_ID; - vector fLAPPD_Beamgate_ns; - vector fLAPPD_Timestamp_ns; - vector fLAPPD_Beamgate_Raw; - vector fLAPPD_Timestamp_Raw; - vector fLAPPD_Offset; - vector fLAPPD_TSCorrection; - vector fLAPPD_BGCorrection; - vector fLAPPD_OSInMinusPS; + + vector fLAPPD_Beamgate_ns_0; + vector fLAPPD_Timestamp_ns_0; + vector fLAPPD_Beamgate_Raw_0; + vector fLAPPD_Timestamp_Raw_0; + vector fLAPPD_Offset_0; + vector fLAPPD_TSCorrection_0; + vector fLAPPD_BGCorrection_0; + vector fLAPPD_OSInMinusPS_0; + + vector fLAPPD_Beamgate_ns_1; + vector fLAPPD_Timestamp_ns_1; + vector fLAPPD_Beamgate_Raw_1; + vector fLAPPD_Timestamp_Raw_1; + vector fLAPPD_Offset_1; + vector fLAPPD_TSCorrection_1; + vector fLAPPD_BGCorrection_1; + vector fLAPPD_OSInMinusPS_1; std::map GroupedTrigger; From fa48d31ca6ca70c42832a868ccee7e158b8e7291 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Fri, 3 Jul 2026 05:02:55 -0500 Subject: [PATCH 4/8] Update the tool with LAPPD-related metrics --- UserTools/PrintDQ/PrintDQ.cpp | 42 ++++++++++++++++++++++++++++++++++- UserTools/PrintDQ/PrintDQ.h | 11 ++++++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/UserTools/PrintDQ/PrintDQ.cpp b/UserTools/PrintDQ/PrintDQ.cpp index b75bcd004..ee86ee73c 100644 --- a/UserTools/PrintDQ/PrintDQ.cpp +++ b/UserTools/PrintDQ/PrintDQ.cpp @@ -36,6 +36,9 @@ bool PrintDQ::Initialise(std::string configfile, DataModel &data){ totaltimezero = 0; totalclusters_in_spill = 0; + // LAPPD related metric + totalPassPPS_check = 0; + return true; } @@ -100,6 +103,7 @@ bool PrintDQ::Finalise() float_t clusters_in_spill = totalclusters_in_spill * 100 / totalclusters; float_t clusters_in_prompt = totalclusters_in_prompt * 100 / totalclusters; float_t clusters_in_ext = totalclusters_in_ext * 100 / totalclusters; + float_t okay_pps_quality = totalPassPPS_check * 100 / totalhas_lappd; if (verbosity >= v_debug) { std::cout << "PrintDQ: Calculating errors" << std::endl; @@ -120,6 +124,7 @@ bool PrintDQ::Finalise() float_t er_clusters_in_spill = CalculateStatError(totalclusters_in_spill, totalclusters); float_t er_clusters_in_prompt = CalculateStatError(totalclusters_in_prompt, totalclusters); float_t er_clusters_in_ext = CalculateStatError(totalclusters_in_ext, totalclusters); + float_t er_okay_pps_quality = CalculateStatError(totalPassPPS_check, totalhas_lappd); // output std::cout << "" << std::endl; @@ -143,6 +148,7 @@ bool PrintDQ::Finalise() std::cout << "1 MRD track: " << totalhas_track << " (" << has_track << "% +/- " << er_has_track << "%)" << std::endl; std::cout << "Tank+Veto coinc: " << totalveto_hit << " (" << veto_hit << "% +/- " << er_veto_hit << "%)" << std::endl; std::cout << "Tank+MRD+Veto coinc: " << totalveto_tmrd_coinc << " (" << veto_tmrd_coinc << "% +/- " << er_veto_tmrd_coinc << "%)" << std::endl; + std::cout << "Pass PPS quality: " << totalPassPPS_check << " (" << okay_pps_quality << "% +/- " << er_okay_pps_quality << "%)" << std::endl; std::cout << "" << std::endl; std::cout << "" << std::endl; @@ -170,6 +176,7 @@ bool PrintDQ::Finalise() WritetoCSV(csv_file, "1 MRD Track", totalhas_track, has_track, er_has_track); WritetoCSV(csv_file, "Tank+Veto Coinc", totalveto_hit, veto_hit, er_veto_hit); WritetoCSV(csv_file, "Tank+MRD+Veto Coinc", totalveto_tmrd_coinc, veto_tmrd_coinc, er_veto_tmrd_coinc); + WritetoCSV(csv_file, "Pass PPS quality", totalPassPPS_check, okay_pps_quality, er_okay_pps_quality); csv_file.close(); @@ -228,6 +235,19 @@ void PrintDQ::FindCounts() { if (fHasLAPPD == 1) { totalhas_lappd++; Log("PrintDQ: ext = 2 for this event", v_debug, verbosity); + + // Check PPS quality for all LAPPDs in this event + bool skip = false; + for (size_t k = 0; k < fLAPPD_TSPPSMissing.size(); k++) { + if (fLAPPD_TSPPSMissing[k] != 0) { + skip = true; + break; + } + } + if (!skip) { + totalPassPPS_check++; + Log("PrintDQ: All LAPPDs passed PPS missing tick check", v_debug, verbosity); + } } @@ -376,6 +396,16 @@ bool PrintDQ::LoadStores() Log("PrintDQ: No MRD clusters found! Did you run the TimeClustering tool?", v_debug, verbosity); } + bool get_lappd_data = m_data->Stores["ANNIEEvent"]->Get("LAPPDDataMap", fLAPPDDataMap); + if (!get_lappd_data) { + Log("PrintDQ: No LAPPDDataMap found! Did you run the LAPPDLoadStore tool?", v_debug, verbosity); + } + + bool get_ts_pps_missing = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing", fLAPPDTS_PPSMissing); + if (!get_ts_pps_missing) { + Log("PrintDQ: No TS PPS Missing vector found! Did you run the LAPPDLoadStore tool?", v_debug, verbosity); + } + return true; } @@ -402,6 +432,10 @@ void PrintDQ::ResetVariables() { fNumClusterTracks.clear(); fDataStreams.clear(); + // LAPPD related metric + fLAPPDDataMap.clear(); + fLAPPD_TSPPSMissing.clear(); // This vector is to store output per LAPPD + fLAPPDTS_PPSMissing.clear(); // This vector is to load from ANNIEEvent store } @@ -466,7 +500,13 @@ bool PrintDQ::GrabVariables() { fNumClusterTracks.push_back(ThisMRDClusterTrackNum); } - + + for (std::map::iterator it = fLAPPDDataMap.begin(); it != fLAPPDDataMap.end(); ++it) + { + uint64_t key = it->first; + fLAPPD_TSPPSMissing.push_back(fLAPPDTS_PPSMissing[key]); + } + return true; } diff --git a/UserTools/PrintDQ/PrintDQ.h b/UserTools/PrintDQ/PrintDQ.h index a57c66fab..85e03de73 100644 --- a/UserTools/PrintDQ/PrintDQ.h +++ b/UserTools/PrintDQ/PrintDQ.h @@ -6,6 +6,7 @@ #include "Tool.h" #include "Hit.h" +#include "PsecData.h" /** @@ -45,7 +46,11 @@ class PrintDQ: public Tool { vector fGroupedTriggerWord; ///< corresponding trigger number for each trigger vector fClusterTime; ///< PMT cluster times std::vector fNumClusterTracks; ///< MRD Tracks corresponding to MRD clusters (NumClusterTracks) - + + std::map fLAPPDDataMap; + std::map fLAPPDTS_PPSMissing; + std::vector fLAPPD_TSPPSMissing; + int fRunNumber; ///< run number (tool assumes you're running over 1 run at a time) int fExtended; ///< extended window trigger (0 = none, 1 = charge-based, 2 = forced) ULong64_t fEventTimeTank; ///< ADC waveform timestamp @@ -73,7 +78,7 @@ class PrintDQ: public Tool { float_t totalhas_lappd; ///< total events with LAPPD data present in the data stream (% out of total events) float_t totalhas_BRF; ///< total events with a fit to the BRF waveform (% out of total events) float_t totaltimezero; ///< total events with no timestamp for the ADC waveforms (% out of total events) - + float_t totalPassPPS_check; /// \brief verbosity levels: if 'verbosity' < this level, the message type will be logged. @@ -87,4 +92,4 @@ class PrintDQ: public Tool { }; -#endif \ No newline at end of file +#endif From e427f9026f92b15c33ad43b2e43f78ed5f5c8360 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Sun, 20 Sep 2026 15:48:37 -0500 Subject: [PATCH 5/8] Update PrintDQ to support dual-ACDC data quality checks - Implemented OR-logic for the PPS missing check in dual-board configurations. - Dropped backward compatibility for legacy single-board data, as data quality checks are primarily run on new data acquisitions. --- UserTools/PrintDQ/PrintDQ.cpp | 32 +++++++++++++++++++++++--------- UserTools/PrintDQ/PrintDQ.h | 8 +++++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/UserTools/PrintDQ/PrintDQ.cpp b/UserTools/PrintDQ/PrintDQ.cpp index ee86ee73c..fdaff68bc 100644 --- a/UserTools/PrintDQ/PrintDQ.cpp +++ b/UserTools/PrintDQ/PrintDQ.cpp @@ -238,10 +238,16 @@ void PrintDQ::FindCounts() { // Check PPS quality for all LAPPDs in this event bool skip = false; - for (size_t k = 0; k < fLAPPD_TSPPSMissing.size(); k++) { - if (fLAPPD_TSPPSMissing[k] != 0) { + for (size_t k = 0; k < fLAPPD_TSPPSMissing_0.size(); k++) { + + bool missing_0 = (fLAPPD_TSPPSMissing_0[k] != 0); + bool missing_1 = (fLAPPD_TSPPSMissing_1[k] != 0); + + // OR logic: if both boards have missing ticks, skip the event. + // This is an event level check; its true essense is in per-LAPPD, but for quick DQ check, this is fine. + if (missing_0 && missing_1) { skip = true; - break; + break; } } if (!skip) { @@ -401,9 +407,14 @@ bool PrintDQ::LoadStores() Log("PrintDQ: No LAPPDDataMap found! Did you run the LAPPDLoadStore tool?", v_debug, verbosity); } - bool get_ts_pps_missing = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing", fLAPPDTS_PPSMissing); - if (!get_ts_pps_missing) { - Log("PrintDQ: No TS PPS Missing vector found! Did you run the LAPPDLoadStore tool?", v_debug, verbosity); + bool get_ts_pps_missing_0 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_0", fLAPPDTS_PPSMissing_0); + if (!get_ts_pps_missing_0) { + Log("PrintDQ: No TS PPS Missing_0 vector found! Did you run the LAPPDLoadStore tool?", v_debug, verbosity); + } + + bool get_ts_pps_missing_1 = m_data->Stores["ANNIEEvent"]->Get("LAPPDTS_PPSMissing_1", fLAPPDTS_PPSMissing_1); + if (!get_ts_pps_missing_1) { + Log("PrintDQ: No TS PPS Missing_1 vector found! Did you run the LAPPDLoadStore tool?", v_debug, verbosity); } return true; @@ -434,8 +445,10 @@ void PrintDQ::ResetVariables() { // LAPPD related metric fLAPPDDataMap.clear(); - fLAPPD_TSPPSMissing.clear(); // This vector is to store output per LAPPD - fLAPPDTS_PPSMissing.clear(); // This vector is to load from ANNIEEvent store + fLAPPD_TSPPSMissing_0.clear(); // This vector is to store output per LAPPD + fLAPPDTS_PPSMissing_0.clear(); // This vector is to load from ANNIEEvent store + fLAPPD_TSPPSMissing_1.clear(); + fLAPPDTS_PPSMissing_1.clear(); } @@ -504,7 +517,8 @@ bool PrintDQ::GrabVariables() { for (std::map::iterator it = fLAPPDDataMap.begin(); it != fLAPPDDataMap.end(); ++it) { uint64_t key = it->first; - fLAPPD_TSPPSMissing.push_back(fLAPPDTS_PPSMissing[key]); + fLAPPD_TSPPSMissing_0.push_back(fLAPPDTS_PPSMissing_0[key]); + fLAPPD_TSPPSMissing_1.push_back(fLAPPDTS_PPSMissing_1[key]); } return true; diff --git a/UserTools/PrintDQ/PrintDQ.h b/UserTools/PrintDQ/PrintDQ.h index 85e03de73..04db50ca6 100644 --- a/UserTools/PrintDQ/PrintDQ.h +++ b/UserTools/PrintDQ/PrintDQ.h @@ -48,9 +48,11 @@ class PrintDQ: public Tool { std::vector fNumClusterTracks; ///< MRD Tracks corresponding to MRD clusters (NumClusterTracks) std::map fLAPPDDataMap; - std::map fLAPPDTS_PPSMissing; - std::vector fLAPPD_TSPPSMissing; - + std::map fLAPPDTS_PPSMissing_0; + std::vector fLAPPD_TSPPSMissing_0; + std::map fLAPPDTS_PPSMissing_1; + std::vector fLAPPD_TSPPSMissing_1; + int fRunNumber; ///< run number (tool assumes you're running over 1 run at a time) int fExtended; ///< extended window trigger (0 = none, 1 = charge-based, 2 = forced) ULong64_t fEventTimeTank; ///< ADC waveform timestamp From e53cd2f0fd54ad5796a9dbc6c28d49045cc79582 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Fri, 2 Oct 2026 13:28:56 -0500 Subject: [PATCH 6/8] Add LAPPDloadStoreConfig in PrintDQ toolchain --- configfiles/PrintDQ/LAPPDLoadStoreConfig | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 configfiles/PrintDQ/LAPPDLoadStoreConfig diff --git a/configfiles/PrintDQ/LAPPDLoadStoreConfig b/configfiles/PrintDQ/LAPPDLoadStoreConfig new file mode 100644 index 000000000..e9f4c9a5c --- /dev/null +++ b/configfiles/PrintDQ/LAPPDLoadStoreConfig @@ -0,0 +1,32 @@ +LAPPDLoadStoreVerbosity 0 + +ReadStore 0 +loadFromStoreDirectly 0 + +num_vector_data 7795 +num_vector_pps 16 +SelectSingleLAPPD false +SelectedLAPPD 0 +loadPSEC 1 +loadPPS 0 +loadOffsets 0 +LoadBuiltPPSInfo 1 + +Nboards 6 #Number of pedestal files to read +PedinputfileTXT /pnfs/annie/persistent/processed/LAPPD_Pedestals_corrected/Pedestals/2025_LAPPD645839/P +DoPedSubtraction 1 + +mergingModeReadIn 0 + +MultiLAPPDMap 1 +PsecReceiveMode 0 +stopEntries 10000000000 + +# General Parameters +NChannels 30 +Nsamples 256 # Number of samples in a waveform +TrigChannel 5 # Specified channel for the trigger signal +SampleSize 100 # Sample size for baseline substraction +LAPPDchannelOffset 1000 + +ACCIDConfigFile ./configfiles/LAPPDProcessedAna/LAPPDIDConfig.csv From 3a8d2a8b17663582db5da59d6757263bcfe7e1a0 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Fri, 2 Oct 2026 14:52:46 -0500 Subject: [PATCH 7/8] Update ToolsConfig in PrintDQ ToolChain --- configfiles/PrintDQ/ToolsConfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configfiles/PrintDQ/ToolsConfig b/configfiles/PrintDQ/ToolsConfig index 87046c72d..eec6cdb6f 100644 --- a/configfiles/PrintDQ/ToolsConfig +++ b/configfiles/PrintDQ/ToolsConfig @@ -5,6 +5,7 @@ myFindMrdTracks FindMrdTracks configfiles/PrintDQ/FindMrdTracksConfig myClusterFinder ClusterFinder ./configfiles/PrintDQ/ClusterFinderConfig myClusterClassifiers ClusterClassifiers ./configfiles/PrintDQ/ClusterClassifiersConfig myEventSelector EventSelector ./configfiles/PrintDQ/EventSelectorConfig +myLAPPDLoadStore LAPPDLoadStore ./configfiles/PrintDQ/LAPPDLoadStoreConfig myFitRWMWaveform FitRWMWaveform ./configfiles/PrintDQ/FitRWMWaveformConfig myPrintDQ PrintDQ ./configfiles/PrintDQ/PrintDQConfig From 3917ce33f572f52f8bd46d2a3987dfa6ef3cd6ce Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Fri, 2 Oct 2026 14:56:11 -0500 Subject: [PATCH 8/8] Update Configs in LAPPD_EB ToolChain --- configfiles/LAPPD_EB/Configs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configfiles/LAPPD_EB/Configs b/configfiles/LAPPD_EB/Configs index 37356ae48..2a5e77d1d 100644 --- a/configfiles/LAPPD_EB/Configs +++ b/configfiles/LAPPD_EB/Configs @@ -1,4 +1,4 @@ - General Parameters +#General Parameters Nsamples 256 #Number of samples in a waveform SampleSize 100 #Sample size for baseline substraction TrigChannel 5 #Specified channel the trigger signal will be on @@ -8,7 +8,7 @@ NUM_VECTOR_METADATA 103 #Fixed META vector size LAPPDchannelOffset 1000 NChannels 30 -LAPPDStoreReadInVerbosity 0 +LAPPDLoadStoreVerbosity 0 mergingModeReadIn 0 RawDataInputWavLabel RawWaveform