Skip to content

Commit

Permalink
Add LAPPDLoadStore tool for EventBuildingV2 tool chain
Browse files Browse the repository at this point in the history
The LAPPDHit and LAPPDPulse.h are for LAPPD so they are included in this PR
  • Loading branch information
fengyvoid committed Jan 20, 2025
1 parent 5b3a549 commit d32a15d
Show file tree
Hide file tree
Showing 7 changed files with 1,971 additions and 61 deletions.
176 changes: 115 additions & 61 deletions DataModel/LAPPDHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,100 +2,154 @@
#ifndef LAPPDHITCLASS_H
#define LAPPDHITCLASS_H

#include<Hit.h>
#include<SerialisableObject.h>
#include <Hit.h>
#include "LAPPDPulse.h"
#include <SerialisableObject.h>

using std::cout;
using std::endl;

class LAPPDHit : public Hit{

class LAPPDHit : public Hit
{

friend class boost::serialization::access;

public:
LAPPDHit() : Hit(), Position(0), LocalPosition(0) {serialise=true;}
LAPPDHit(int thetubeid, double thetime, double thecharge, std::vector<double> theposition, std::vector<double> thelocalposition) : Hit(thetubeid,thetime,thecharge), Position(theposition), LocalPosition(thelocalposition) {serialise=true;}

public:
LAPPDHit() : Hit(), Position(0), LocalPosition(0) { serialise = true; }
LAPPDHit(int thetubeid, double thetime, double thecharge, std::vector<double> theposition, std::vector<double> thelocalposition) : Hit(thetubeid, thetime, thecharge), Position(theposition), LocalPosition(thelocalposition) { serialise = true; }
LAPPDHit(int thetubeid, double thetime, double thecharge, std::vector<double> theposition, std::vector<double> thelocalposition, double pulse1LastTime, double pulse2LastTime, double pulse1StartTime, double pulse2StartTime) : Hit(thetubeid, thetime, thecharge), Position(theposition), LocalPosition(thelocalposition)
{
serialise = true;
Pulse1LastTime = pulse1LastTime;
Pulse2LastTime = pulse2LastTime;
Pulse1StartTime = pulse1StartTime;
Pulse2StartTime = pulse2StartTime;
}
LAPPDHit(int thetubeid, double thetime, double thecharge, std::vector<double> theposition, std::vector<double> thelocalposition, double pulse1LastTime, double pulse2LastTime, double pulse1StartTime, double pulse2StartTime, LAPPDPulse p1, LAPPDPulse p2) : Hit(thetubeid, thetime, thecharge), Position(theposition), LocalPosition(thelocalposition)
{
serialise = true;
Pulse1LastTime = pulse1LastTime;
Pulse2LastTime = pulse2LastTime;
Pulse1StartTime = pulse1StartTime;
Pulse2StartTime = pulse2StartTime;
pulse1 = p1;
pulse2 = p2;
}

virtual ~LAPPDHit(){};

inline std::vector<double> GetPosition() const {return Position;}
inline std::vector<double> GetLocalPosition() const {return LocalPosition;}
inline void SetPosition(std::vector<double> pos){Position=pos;}
inline void SetLocalPosition(std::vector<double> locpos){LocalPosition=locpos;}

bool Print() {
cout<<"TubeId : "<<TubeId<<endl;
cout<<"Time : "<<Time<<endl;
cout<<"X Pos : "<<Position.at(0)<<endl;
cout<<"Y Pos : "<<Position.at(1)<<endl;
cout<<"Z Pos : "<<Position.at(2)<<endl;
cout<<"Parallel Pos : "<<LocalPosition.at(0)<<endl;
cout<<"Transverse Pos : "<<LocalPosition.at(1)<<endl;
cout<<"Charge : "<<Charge<<endl;

inline std::vector<double> GetPosition() const { return Position; }
inline std::vector<double> GetLocalPosition() const { return LocalPosition; }
inline void SetPosition(std::vector<double> pos) { Position = pos; }
inline void SetLocalPosition(std::vector<double> locpos) { LocalPosition = locpos; }
inline double GetPulse1LastTime() const { return Pulse1LastTime; }
inline double GetPulse2LastTime() const { return Pulse2LastTime; }
inline double GetPulse1StartTime() const { return Pulse1StartTime; }
inline double GetPulse2StartTime() const { return Pulse2StartTime; }
inline LAPPDPulse GetPulse1() const { return pulse1; }
inline LAPPDPulse GetPulse2() const { return pulse2; }

bool Print()
{
cout << "TubeId : " << TubeId << endl;
cout << "Time : " << Time << endl;
cout << "X Pos : " << Position.at(0) << endl;
cout << "Y Pos : " << Position.at(1) << endl;
cout << "Z Pos : " << Position.at(2) << endl;
cout << "Parallel Pos : " << LocalPosition.at(0) << endl;
cout << "Transverse Pos : " << LocalPosition.at(1) << endl;
cout << "Charge : " << Charge << endl;
return true;
}
protected:

protected:
std::vector<double> Position;
std::vector<double> LocalPosition;

template<class Archive> void serialize(Archive & ar, const unsigned int version){
if(serialise){
double Pulse1LastTime;
double Pulse2LastTime;
double Pulse1StartTime;
double Pulse2StartTime;
LAPPDPulse pulse1;
LAPPDPulse pulse2;

template <class Archive>
void serialize(Archive &ar, const unsigned int version)
{
if (serialise)
{
ar & TubeId;
ar & Time;
ar & Position;
ar & LocalPosition;
ar & Charge;

ar & Pulse1LastTime;
ar & Pulse2LastTime;
ar & Pulse1StartTime;
ar & Pulse2StartTime;
ar & pulse1;
ar & pulse2;
}
}
};

// Derived classes
class MCLAPPDHit : public LAPPDHit{

class MCLAPPDHit : public LAPPDHit
{

friend class boost::serialization::access;

public:
MCLAPPDHit() : LAPPDHit(), Parents(std::vector<int>{}) {serialise=true;}
MCLAPPDHit(int thetubeid, double thetime, double thecharge, std::vector<double> theposition, std::vector<double> thelocalposition, std::vector<int> theparents) : LAPPDHit(thetubeid, thetime, thecharge,theposition,thelocalposition), Parents(theparents) {serialise=true;}

const std::vector<int>* GetParents() const { return &Parents; }
void SetParents(std::vector<int> parentsin){ Parents = parentsin; }

bool Print() {
cout<<"TubeId : "<<TubeId<<endl;
cout<<"Time : "<<Time<<endl;
cout<<"X Pos : "<<Position.at(0)<<endl;
cout<<"Y Pos : "<<Position.at(1)<<endl;
cout<<"Z Pos : "<<Position.at(2)<<endl;
cout<<"Parallel Pos : "<<LocalPosition.at(0)<<endl;
cout<<"Transverse Pos : "<<LocalPosition.at(1)<<endl;
cout<<"Charge : "<<Charge<<endl;
if(Parents.size()){
cout<<"Parent MCPartice indices: {";
for(int parenti=0; parenti<(int)Parents.size(); ++parenti){
cout<<Parents.at(parenti);
if((parenti+1)<(int)Parents.size()) cout<<", ";

public:
MCLAPPDHit() : LAPPDHit(), Parents(std::vector<int>{}) { serialise = true; }
MCLAPPDHit(int thetubeid, double thetime, double thecharge, std::vector<double> theposition, std::vector<double> thelocalposition, std::vector<int> theparents) : LAPPDHit(thetubeid, thetime, thecharge, theposition, thelocalposition), Parents(theparents) { serialise = true; }

const std::vector<int> *GetParents() const { return &Parents; }
void SetParents(std::vector<int> parentsin) { Parents = parentsin; }

bool Print()
{
cout << "TubeId : " << TubeId << endl;
cout << "Time : " << Time << endl;
cout << "X Pos : " << Position.at(0) << endl;
cout << "Y Pos : " << Position.at(1) << endl;
cout << "Z Pos : " << Position.at(2) << endl;
cout << "Parallel Pos : " << LocalPosition.at(0) << endl;
cout << "Transverse Pos : " << LocalPosition.at(1) << endl;
cout << "Charge : " << Charge << endl;
if (Parents.size())
{
cout << "Parent MCPartice indices: {";
for (int parenti = 0; parenti < (int)Parents.size(); ++parenti)
{
cout << Parents.at(parenti);
if ((parenti + 1) < (int)Parents.size())
cout << ", ";
}
cout<<"}"<<endl;
} else {
cout<<"No recorded parents"<<endl;
cout << "}" << endl;
}
else
{
cout << "No recorded parents" << endl;
}
return true;
}

template<class Archive> void serialize(Archive & ar, const unsigned int version){
if(serialise){

template <class Archive>
void serialize(Archive &ar, const unsigned int version)
{
if (serialise)
{
ar & TubeId;
ar & Time;
ar & Position;
ar & LocalPosition;
ar & Charge;
// n.b. at time of writing MCHit stores no additional persistent members
// - it only adds parent MCParticle indices, and these aren't saved...
// - it only adds parent MCParticle indices, and these aren't saved...
}
}
protected:

protected:
std::vector<int> Parents;
};

Expand Down
15 changes: 15 additions & 0 deletions DataModel/LAPPDPulse.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ class LAPPDPulse : public Hit{
inline void SetChannelID(int channelid){ChannelID=channelid;}
inline void SetPeak(double peak){Peak=peak;}
inline void SetRange(double low, double hi){LowRange=low; HiRange=hi;}
inline void SetHalfHeightTime(double half){halfHeightTime=half;}
inline double GetHalfHeightTime(){return halfHeightTime;}
inline void SetHalfEndTime(double half){halfEndTime=half;}
inline double GetHalfEndTime(){return halfEndTime;}
inline void SetBaseline(double base){baseline=base;}
inline double GetBaseline(){return baseline;}

bool Print() {
cout<<"TubeId : "<<TubeId<<endl;
cout<<"ChannelID : "<<ChannelID<<endl;
cout<<"Time : "<<Time<<endl;
cout<<"Charge : "<<Charge<<endl;
cout<<"HalfHeightTime : "<<halfHeightTime<<endl;
cout<<"Baseline : "<<baseline<<endl;
return true;
}

Expand All @@ -36,6 +44,10 @@ class LAPPDPulse : public Hit{
double Peak;
double LowRange;
double HiRange;
double halfHeightTime;
double halfEndTime;
double baseline;



template<class Archive> void serialize(Archive & ar, const unsigned int version){
Expand All @@ -47,6 +59,9 @@ class LAPPDPulse : public Hit{
ar & Peak;
ar & LowRange;
ar & HiRange;
ar & halfHeightTime;
ar & halfEndTime;
ar & baseline;
}
}
};
Expand Down
1 change: 1 addition & 0 deletions UserTools/Factory/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@ if (tool=="BackTracker") ret=new BackTracker;
if (tool=="PrintDQ") ret=new PrintDQ;
if (tool=="AssignBunchTimingMC") ret=new AssignBunchTimingMC;
if (tool=="FitRWMWaveform") ret=new FitRWMWaveform;
if (tool=="LAPPDLoadStore") ret=new LAPPDLoadStore;
return ret;
}
Loading

0 comments on commit d32a15d

Please sign in to comment.