Skip to content

Commit

Permalink
EventBuilderV2 tools
Browse files Browse the repository at this point in the history
Tools for Event Builder version 2, contains EB tools, and two tools for LAPPD_EB tool chain, and one script for LAPPD timestamp fitting
  • Loading branch information
fengyvoid committed Oct 11, 2024
1 parent ce2334e commit 4119f18
Show file tree
Hide file tree
Showing 27 changed files with 9,294 additions and 0 deletions.
381 changes: 381 additions & 0 deletions UserTools/EBLAPPD/EBLAPPD.cpp

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions UserTools/EBLAPPD/EBLAPPD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#ifndef EBLAPPD_H
#define EBLAPPD_H

#include <string>
#include <iostream>

#include "Tool.h"
#include "PsecData.h"
#include "BoostStore.h"

/**
* \class EBPMT
*
* $Author: Yue Feng $
* $Date: 2024/04 $
* Contact: yuef@iaistate.edu
*
*/

class EBLAPPD : public Tool
{

public:
EBLAPPD(); ///< 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 Execute(); ///< Execute function used to perform Tool purpose.
bool Finalise(); ///< Finalise function used to clean up resources.
bool LoadLAPPDData();
bool CleanData();
bool Matching(int targetTrigger, int matchToTrack);

private:
int thisRunNum;
bool matchToAllTriggers;
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<uint64_t> MatchBuffer_LAPPDTimestamp_ns; // used to indexing data for unmatched

// TODO, maybe make a new "LAPPDBuildData" class?
vector<uint64_t> Buffer_LAPPDTimestamp_ns; // used to indexing the data
vector<PsecData> Buffer_LAPPDData;
vector<uint64_t> Buffer_LAPPDBeamgate_ns;
vector<uint64_t> Buffer_LAPPDOffset;
vector<unsigned long> Buffer_LAPPDBeamgate_Raw;
vector<unsigned long> Buffer_LAPPDTimestamp_Raw;
vector<int> Buffer_LAPPDBGCorrection;
vector<int> Buffer_LAPPDTSCorrection;
vector<int> Buffer_LAPPDOffset_minus_ps;
vector<int> Buffer_RunCode;
vector<uint64_t> Buffer_LAPPDBG_PPSBefore;
vector<uint64_t> Buffer_LAPPDBG_PPSAfter;
vector<uint64_t> Buffer_LAPPDBG_PPSDiff;
vector<int> Buffer_LAPPDBG_PPSMissing;
vector<uint64_t> Buffer_LAPPDTS_PPSBefore;
vector<uint64_t> Buffer_LAPPDTS_PPSAfter;
vector<uint64_t> Buffer_LAPPDTS_PPSDiff;
vector<int> Buffer_LAPPDTS_PPSMissing;

std::map<int, vector<uint64_t>> PairedCTCTimeStamps;
std::map<int, vector<int>> PairedLAPPD_TriggerIndex;
std::map<int, vector<uint64_t>> PairedLAPPDTimeStamps;

int matchTargetTrigger;
uint64_t matchTolerance_ns;
int verbosityEBLAPPD;

int matchedLAPPDNumber = 0;
int exeNum = 0;
int currentRunCode;

int v_message = 1;
int v_warning = 2;
int v_error = 3;
int v_debug = 4;
};

#endif
35 changes: 35 additions & 0 deletions UserTools/EBLAPPD/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# EBLAPPD

EBLAPPD tool is a part of Event Building version 2 tool chain.
For reference slides, see:
https://annie-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=5633

EBLAPPD match the LAPPD beamgate + LAPPD offset to grouped trigger, and save the matching results to CStore for EBSaver.

## Data

**PairedCTCTimeStamps**
After matching, the matched trigger timestamp will be saved here. The key is the main trigger word for each run type.
Saved as PairedLAPPDTriggerTimestamp in CStore.

**PairedLAPPDTimeStamps**
After matching, the matched LAPPD beamgate + offset will be saved here. The key is the main trigger word for each run type.
This and PairedCTCTimeStamps have the same index. A little bit dangerous, but overall works well.
Saved as PairedLAPPDTimeStamps in CStore


## Configuration

**matchTargetTrigger**
This gives which trigger word that the LAPPD beamgate + offset should be matched to.

**matchTolerance_ns**
This gives the maximum allowed time tolerance between the LAPPD beamgate + offset and the target trigger timestamp.

**exePerMatch**
This gives how many loops need to be past for one matching between MLAPPD beamgate + offset and target trigger timestamps.
500 is generally fine with beam runs.

**matchToAllTriggers**
1 or 0. 1 means match to all possible triggers, 0 means only match to the target trigger.

Loading

0 comments on commit 4119f18

Please sign in to comment.