Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "DynamicTTree"]
path = DynamicTTree
url = https://github.com/simonepigazzini/DynamicTTree.git
url = https://github.com/pmeridian/DynamicTTree.git
[submodule "CfgManager"]
path = CfgManager
url = https://github.com/simonepigazzini/CfgManager.git
url = https://github.com/pmeridian/CfgManager.git
2 changes: 1 addition & 1 deletion DynamicTTree
4 changes: 3 additions & 1 deletion cfg/ECAL_H4_Oct2021/ECAL_H4_Phase1_base.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<h4reco>
outNameSuffix /eos/cms/store/group/dpg_ecal/comm_ecal/upgrade/testbeam/ECALTB_H4_Oct2021/Reco/
outNameSuffix /tmp/meridian/
path2data /eos/cms/store/group/dpg_ecal/comm_ecal/upgrade/testbeam/ECALTB_H4_Oct2021/DataTree/
pluginList H4Hodo DigiReco WFReco
run 10467
maxEvents 1000
maxFiles -1
dataType H4Tree
preProcessorType H4DAQPreProcessor
</h4reco>

VFEs B1 B2 B3 B4 B5 \
Expand Down
105 changes: 105 additions & 0 deletions cfg/MTDTB_FNAL_Mar2023/SCOPE_reco_base.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<h4reco>
outNameSuffix ntuples/
path2data /eos/cms/store/group/dpg_mtd/comm_mtd/TB/MTDTB_FNAL_Mar2023/KeySightScope/TimingDAQRECO/RecoWithTracks/v1/
run 66353
maxEvents 100
maxFiles -1
dataType scopeFNALTree
preProcessorType ScopeFNALPreProcessor
pluginList DigiReco WFReco
</h4reco>

SCOPE TOFCLK_P TOFCLK_P_1 TOFCLK_P_2 TOFCLK_M TOFCLK_M_1 TOFCLK_M_2 MCP

#---VFE config
<DigiReco>
pluginType DigitizerReco
channelsNames= SCOPE
</DigiReco>

#---WF reconstruction for VFEs
<WFReco>
pluginType WFAnalyzer
srcInstanceName DigiReco
channelsNames= DigiReco.channelsNames
timeRecoTypes LED CFD CLK
fillWFtree 1
WFtreePrescale 10
</WFReco>

#---Scope channels
<TOFCLK_P>
digiBoard 0
digiGroup 0
digiChannel 0
type Clock
polarity 1
nSamples 800
tUnit 0.05
#CFD
CLK -0.8 0.8
LED 0 2 2 100 400
baselineFit 1
baselineWin 150 600
baselineInt 150 600
signalWin 100 700 5 pol2
signalInt 100 700
<templateFit>
file data/tmpl_CLK_FNAL_Mar2023_large.root tmpl_TOFCLK_large
fitWin 0. 15 45
</templateFit>
</TOFCLK_P>

<TOFCLK_P_1= TOFCLK_P>
copyChannel TOFCLK_P 0 400
nSamples 400
CLK -0.8 0.8 50 350
LED 0 2 2 10 350
baselineWin 50 350
baselineInt 50 350
signalWin 50 350 5 pol2
signalInt 50 350
</TOFCLK_P_1>

<TOFCLK_P_2= TOFCLK_P_1>
copyChannel TOFCLK_P 400 800
</TOFCLK_P_2>

<TOFCLK_M= TOFCLK_P>
polarity -1
<templateFit>
file data/tmpl_CLK_M_FNAL_Mar2023_large.root tmpl_TOFCLK_M_large
fitWin 0. 15 45
</templateFit>
</TOFCLK_M>

<TOFCLK_M_1= TOFCLK_P_1>
copyChannel TOFCLK_M 0 400
<templateFit>
file data/tmpl_CLK_M_FNAL_Mar2023_large.root tmpl_TOFCLK_M_large
fitWin 0. 15 45
</templateFit>
</TOFCLK_M_1>

<TOFCLK_M_2= TOFCLK_M_1>
copyChannel TOFCLK_M 400 800
</TOFCLK_M_2>

<MCP>
digiBoard 0
digiGroup 0
digiChannel 3
polarity -1
nSamples 800
tUnit 0.05
baselineWin 1 100
baselineInt 10 90
signalWin 50 700 5 gaus
signalInt 40 40
CFD 0.5 5
LED 20 2 2
<templateFit>
file data/tmpl_MCP_FNAL_Mar2023.root tmpl_MCP
fitWin 0. 10 21
</templateFit>
</MCP>
9 changes: 5 additions & 4 deletions interface/DataLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#include <vector>

#include "CfgManager/interface/CfgManager.h"
#include "DynamicTTree/interface/DynamicTTreeBase.h"

#include "interface/H4Tree.h"
using namespace std;

class DataLoader
{
Expand All @@ -21,7 +22,7 @@ class DataLoader
~DataLoader() {};

//----getters---
inline H4Tree& GetTree() {return *inTree_;};
inline DynamicTTreeBase* GetTree() {return inTree_;};
inline int GetNFiles() {return fileList_.size();};
inline int GetNFilesProcessed() {return iFile_;};
inline long int GetCurrentEntry() {return inTree_->GetCurrentEntry();};
Expand All @@ -39,9 +40,9 @@ class DataLoader
vector<string> fileList_;
int iFile_;
TFile* currentFile_;
H4Tree* inTree_;
DynamicTTreeBase* inTree_;
bool firstEventInSpill_;

string dataType_;
};

#endif
54 changes: 35 additions & 19 deletions interface/H4Tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
using namespace std;

#define MAX_ADC_CHANNELS 500000
#define MAX_DIGI_SAMPLES 100000
#define MAX_TDC_CHANNELS 200
#define MAX_SCALER_WORDS 16
#define MAX_PATTERNS 16
#define MAX_PATTERNS_SHODO 16
#define SMALL_HODO_X_NFIBERS 8
#define SMALL_HODO_Y_NFIBERS 8
#define MAX_TRIG_WORDS 32
#define MAX_RO 100


typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef unsigned long long uint64;

//****************************************************************************************
//----------Helper functions--------------------------------------------------------------
Expand Down Expand Up @@ -63,35 +72,42 @@ typedef std::unordered_map<const bgc_key_t, int, key_hash, key_equal> bgc_map_t;
DATA(unsigned int, nTriggerWords)

#define DATA_VECT_TABLE \
DATA(unsigned int, evtTimeBoard, nEvtTimes) \
DATA(uint64, evtTime, nEvtTimes) \
DATA(unsigned int, adcBoard, MAX_ADC_CHANNELS) \
DATA(unsigned int, adcChannel, MAX_ADC_CHANNELS) \
DATA(unsigned int, adcData, MAX_ADC_CHANNELS) \
DATA(unsigned int, tdcChannel, MAX_TDC_CHANNELS) \
DATA(unsigned int, tdcData, MAX_TDC_CHANNELS) \
DATA(unsigned int, pattern, nPatterns) \
DATA(unsigned int, patternBoard, nPatterns) \
DATA(unsigned int, patternChannel, nPatterns) \
DATA(unsigned int, triggerWords, nTriggerWords) \
DATA(unsigned int, triggerWordsBoard, nTriggerWords) \
DATA(int, digiBoard, nDigiSamples) \
DATA(unsigned int, digiGroup, nDigiSamples) \
DATA(unsigned int, digiChannel, nDigiSamples) \
DATA(unsigned int, digiStartIndexCell, nDigiSamples) \
DATA(float, digiSampleValue, nDigiSamples) \
DATA(float, digiSampleGain, nDigiSamples)
DATA(unsigned int, evtTimeBoard, nEvtTimes, MAX_RO) \
DATA(unsigned long long, evtTime, nEvtTimes, MAX_RO) \
DATA(unsigned int, adcBoard, nAdcChannels, MAX_ADC_CHANNELS) \
DATA(unsigned int, adcChannel, nAdcChannels, MAX_ADC_CHANNELS) \
DATA(unsigned int, adcData, nAdcChannels, MAX_ADC_CHANNELS) \
DATA(unsigned int, tdcChannel, nTdcChannels, MAX_TDC_CHANNELS) \
DATA(unsigned int, tdcData, nTdcChannels, MAX_TDC_CHANNELS) \
DATA(unsigned int, pattern, nPatterns, MAX_PATTERNS) \
DATA(unsigned int, patternBoard, nPatterns, MAX_PATTERNS) \
DATA(unsigned int, patternChannel, nPatterns, MAX_PATTERNS) \
DATA(unsigned int, triggerWords, nTriggerWords, MAX_TRIG_WORDS) \
DATA(unsigned int, triggerWordsBoard, nTriggerWords, MAX_TRIG_WORDS) \
DATA(int, digiBoard, nDigiSamples, MAX_DIGI_SAMPLES) \
DATA(unsigned int, digiGroup, nDigiSamples, MAX_DIGI_SAMPLES) \
DATA(unsigned int, digiChannel, nDigiSamples, MAX_DIGI_SAMPLES) \
DATA(unsigned int, digiStartIndexCell, nDigiSamples, MAX_DIGI_SAMPLES) \
DATA(float, digiSampleValue, nDigiSamples, MAX_DIGI_SAMPLES) \
DATA(float, digiSampleTime, nDigiSamples, MAX_DIGI_SAMPLES) \
DATA(float, digiSampleGain, nDigiSamples, MAX_DIGI_SAMPLES)

#include "DynamicTTree/interface/DynamicTTreeInterface.h"

#undef DYNAMIC_TREE_NAME
#undef DATA_TABLE
#undef DATA_VECT_TABLE


class H4Tree : public H4TreeBase
{
public:
//---ctors
H4Tree(const char* name="", const char* title=""):
H4TreeBase(name,title)
{
}

H4Tree(TChain* t):
H4TreeBase(t)
{
Expand Down
3 changes: 3 additions & 0 deletions interface/PluginLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ template<class P> inline PluginLoader<P>::PluginLoader(string plugin_name)
cout << ">>> PluginLoader: " << dlerror() << endl;
exit(1);
}

pluginCreator = (P* (*)(void))dlsym(pluginHandle, "create");
std::cout << "Loaded " << plugin_name << ": " << pluginCreator << std::endl;

if((error = dlerror()) != NULL)
{
cout << ">>> PluginLoader: " << error << endl;
Expand Down
71 changes: 71 additions & 0 deletions interface/PreProcessorBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef __PREPROCESSOR_BASE__
#define __PREPROCESSOR_BASE__

#include <string>
#include <map>

#include "CfgManager/interface/CfgManager.h"
#include "CfgManager/interface/CfgManagerT.h"
#include "interface/H4Tree.h"

//**********Helper macros*****************************************************************
//---Helper macro to keep track of the preProcessor running: must be inserted at the
// beginning of each method
#define CHECKPOINT() \
SetCurrentMethod(__FUNCTION__);


//**********PREPROCESSOR BASE CLASS*************************************************************
class PreProcessorBase
{
public:

//**********LOGGER LEVELS*****************************************************************
enum LoggerLevel {
INFO = 0,
WARN = 1,
ERR = 2
};

//---ctors---
PreProcessorBase(){};

//---dtor---
virtual ~PreProcessorBase(){};

//---setters---
void SetPluginType(const std::string& preProcessor) { preProcessorType_ = preProcessor; };
void SetInstanceName(const std::string& instance) { instanceName_ = instance; };
void SetCurrentMethod(std::string method) { currentMethod_ = method; };

//---getters---
std::string GetPluginType() { return preProcessorType_; };
std::string GetInstanceName() { return instanceName_; };
std::string GetCurrentMethod() { return currentMethod_; };

//---utils---
virtual bool Begin(CfgManager& opts)
{ CHECKPOINT(); return true; };
virtual H4Tree* ProcessEvent(DynamicTTreeBase* event, CfgManager& opts)
{ CHECKPOINT(); return 0; };

void Log(std::string message, LoggerLevel lv=INFO);

protected:
//---keep track of the preProcessor type as defined in the cfg
std::string preProcessorType_;
//---keep track of the preProcessor name as defined in the cfg
std::string instanceName_;
//---keep track of the current running preProcessor method. Must be called manually in each function;
std::string currentMethod_;
};

#undef CHECKPOINT

//---To be inserted at the end of each preProcessor definition
#define DEFINE_PREPROCESSOR(NAME) \
extern "C" PreProcessorBase* create() { return new NAME; } \
extern "C" void destroy(PreProcessorBase* preProcessor) { delete preProcessor; }

#endif

11 changes: 8 additions & 3 deletions interface/WFClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class WFClass : public TObject
//---dtor---
~WFClass() {};

//crop method
void CropWF(WFClass& WF, int firstSample=-1, int lastSample=-1);

//---getters---
inline const vector<double>* GetSamples() {return &samples_;};
inline const vector<double>* GetTimes() {return &times_;};
Expand Down Expand Up @@ -151,15 +154,17 @@ class WFClass : public TObject
void SetSignalIntegralWindow(int min, int max);
void SetBaselineWindow(int min, int max);
void SetBaselineIntegralWindow(int min, int max);
void SetTemplate(TH1* templateWF=NULL);
virtual void SetTemplate(TH1* templateWF=NULL);

//---utils---
virtual void Reset();
bool ApplyCalibration();
virtual void AddSample(float sample);
virtual void AddSample(float sample, float gain) {AddSample(sample);};
virtual void AddSampleTime(float sample, float time);
virtual void AddSampleGain(float sample, float gain) {AddSample(sample);};
WFBaseline SubtractBaseline(int min=-1, int max=-1);
WFBaseline SubtractBaseline(float baseline);
virtual WFBaseline SubtractBaselineFit(int min=-1, int max=-1) {};

virtual WFFitResults TemplateFit(float amp_threshold=0., float offset=0., int lW=0, int hW=0);

Expand All @@ -178,7 +183,7 @@ class WFClass : public TObject
//---utils---
float BaselineRMS();
float LinearInterpolation(float& A, float& B, const int& min, const int& max, const int& skipSample=-1);
double TemplateChi2(const double* par=NULL);
virtual double TemplateChi2(const double* par=NULL);
double AnalyticChi2(const double* par=NULL);

protected:
Expand Down
12 changes: 9 additions & 3 deletions interface/WFClassClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ class WFClassClock : public WFClass
public:
//---ctors---
WFClassClock() {};
WFClassClock(float tUnit);
WFClassClock(int polarity, float tUnit);

WFBaseline SubtractBaselineFit(int min=-1, int max=-1) override;
void SetTemplate(TH1* templateWF=NULL) override;

//---getters---
void AddSample(float sample) override;
WFFitResults GetTime(string method, vector<float>& params) override;
WFFitResults GetTimeLE(float thr = 0, int nmFitSamples=2, int npFitSamples=2, int min=-1, int max=-1) override;
WFFitResults GetTimeCLK(float wleft=-1.3, float wright=1.3, int min=130, int max=900);
WFFitResults GetTimeCLK(float wleft=-1.3, float wright=1.3, int min=100, int max=700);
WFFitResults TemplateFit(float ampl_threshold=0, float offset=0., int lW=0, int hW=0) override;
float GetPeriod() override { return clkPeriod_; };
float GetTemplateFitPeriod() override { return clkPeriod_; };
float GetTemplateFitPeriod() override { return tmplFitPeriod_; };

protected:
double TemplateChi2(const double* par=NULL) override;

private:
float clkPeriod_;
Expand Down
Loading