Commit 1d088ad6 authored by Riccardo Longo's avatar Riccardo Longo
Browse files

Start of 2021 Test Beam implementation. Framework not yet optimized and not yet tested.

parent cb1acc60
...@@ -52,6 +52,8 @@ class Analysis{ ...@@ -52,6 +52,8 @@ class Analysis{
Visualizer* m_viz = 0; Visualizer* m_viz = 0;
/** Alignment information for the given run */ /** Alignment information for the given run */
Alignment* m_alignment; Alignment* m_alignment;
/** Alignment information for the given run */
Alignment2021* m_alignment2021;
}; };
#endif #endif
...@@ -47,6 +47,8 @@ class Channel { ...@@ -47,6 +47,8 @@ class Channel {
bool is_on; bool is_on;
/** Operating voltage of the channel*/ /** Operating voltage of the channel*/
int Vop; int Vop;
/** PMT reference code **/
std::string PMTcode;
/** Raw waveform for a particular event */ /** Raw waveform for a particular event */
std::vector < float > WF; std::vector < float > WF;
/** Pointer to the WF vector */ /** Pointer to the WF vector */
...@@ -117,5 +119,38 @@ class Alignment { ...@@ -117,5 +119,38 @@ class Alignment {
}; };
class Alignment2021 {
public:
/** Run number being analyzed **/
int runNumber;
/** Beam type - can be p or e in H2 2021 **/
std::string beam_type;
/** Beam energy **/
double beam_energy;
/** X position of the NIKHEF Table **/
double x_det_table;
/** Y position of the NIKHEF Table **/
double y_det_table;
/** X position of the Trigger Table **/
double x_trig_table;
/** Y position of the Trigger Table **/
double y_trig_table;
/** First detector met by the beam **/
std::string Det1;
/** Second detector met by the beam **/
std::string Det2;
/** Third detector met by the beam **/
std::string Det3;
/** Fourth detector met by the beam **/
std::string Det4;
/** Fifth detector met by the beam **/
std::string Det5;
/** Sixth detector met by the beam **/
std::string Det6;
/** GOLIATH magnet status **/
};
#endif #endif
/** @file DataReader2021
* @brief Function prototypes for DataReader2021
*
* This contains the prototypes and members
* for DataReader2021
*
* @author Yakov Kulinich
* @bug No known bugs.
*/
#ifndef DataReader2021_H
#define DataReader2021_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include "XMLSettingsReader.h"
#include "Containers.h"
#include "Detector.h"
#include "ZDC.h"
#include "RPD.h"
#include <TChain.h>
#include <TSystem.h>
class TFile;
class Analysis;
class DataReader2021{
public:
DataReader2021( );
DataReader2021( const unsigned int = 0, const unsigned int = 0 );
DataReader2021( const unsigned int = 0, const unsigned int = 0,
const std::string& = "" );
DataReader2021( const unsigned int = 0, const unsigned int = 0,
const std::string& = "", const unsigned int = 0 );
virtual ~DataReader2021();
void AddPreAnalysis ( Analysis* );
void AddDetectorAnalysis ( Analysis* );
void SelectDetectorForAnalysis ( bool _useUEM, bool _usePFRPD, bool _useTRPD, bool _useZDCs );
void ReadListOfFiles( std::string listname );
void LoadAlignmentFile (std::string _inFile = std::getenv("JZCaPA") + std::string("/Utils/Alignment_2018.xml"));
void LoadConfigurationFile (std::string _inFile = std::getenv("JZCaPA") + std::string("/Utils/ConfigFile2018.xml"));
void LoadTimingFile (std::string _inFile = "" );
void SetDebugMode ( ) { m_debug = true; }
void SetVerbosity ( int _level ){ m_verbose = _level; }
void SetOutputDirectory ( std::string _dir ){ m_outputDir = _dir; }
void UpdateConsole ( Long_t _updateRate);
void EnablePlotLabel ( ) { m_useLabel = true; }
Detector* GetDetector( std::string _detName );
Alignment2021* GetAlignment(){ return m_alignment; }
void Run();
void Initialize ( );
void ProcessEvents( );
void Finalize ( );
private:
// output file
TFile* m_fOut;
// Output TTree
TTree* m_tOut;
// Output directory
std::string m_outputDir = "";
// vector of pre-detector analysis
std::vector< Analysis* > m_ana;
// vector of detector analysis
std::vector< Analysis* > m_det_ana;
// Vector of time vectors for DRS4 modules
std::vector< std::vector< float >* > m_time;
//Number of channels to be read
unsigned int m_nCh;
//Number of samples per channel
unsigned int m_nSamp;
//Input file name
std::string m_fNameIn;
//Input list of files
std::string m_fListOfFiles;
//Run number
unsigned int m_runNumber;
//Boolean switch to enable the reading of a list of files
bool m_readListOfFiles;
//Input file (in case of a single processing)
TFile* m_fIn;
//TChain to accomodate many files (in case of a list of files)
TChain* m_fileChain;
//Vector of detectors placed in the 2018 setup (2 ZDCs, 1 RPD)
std::vector < Detector* > m_detectors;
//Vectors of
//Alignment information for the given run
Alignment2021* m_alignment;
//XML parser
XMLSettingsReader *m_XMLparser;
//Current event
int m_event;
//Event number of last update
int m_event_old = 0;
//Booleans for analysis selection
bool m_useZDCs, m_usePFRPD, m_useTRPD, m_useUEM;
//Boolean to enable plot labelling
bool m_useLabel = false;
//DebugVariable
bool m_debug = false;
//Verbosity level
int m_verbose = 0;
//Memory info container for UpdateConsole
MemInfo_t m_memInfo;
//CPU info container for UpdateConsole
CpuInfo_t m_cpuInfo;
//Process info container for UpdateConsole
ProcInfo_t m_procInfo;
};
#endif
...@@ -31,6 +31,7 @@ class Detector{ ...@@ -31,6 +31,7 @@ class Detector{
virtual double* GetPosition ( ) { return m_Position; } virtual double* GetPosition ( ) { return m_Position; }
virtual double* GetAngle ( ) { return m_Angle; } virtual double* GetAngle ( ) { return m_Angle; }
virtual Alignment* GetAlignment( ) { return m_Alignment; } virtual Alignment* GetAlignment( ) { return m_Alignment; }
virtual Alignment2021* GetAlignment2021( ) { return m_Alignment2021; }
virtual void SetNSamples ( int _nSamples ) { m_nSamp = _nSamples; } virtual void SetNSamples ( int _nSamples ) { m_nSamp = _nSamples; }
virtual void SetElement ( Channel* _entry) { m_Element.push_back(_entry); } virtual void SetElement ( Channel* _entry) { m_Element.push_back(_entry); }
...@@ -38,12 +39,18 @@ class Detector{ ...@@ -38,12 +39,18 @@ class Detector{
virtual void SetAngle (double _cosx = 0, double _cosy = 0, double _cosz = 0) { m_Angle[0] = _cosx; m_Angle[1] = _cosy; m_Angle[2] = _cosz; } virtual void SetAngle (double _cosx = 0, double _cosy = 0, double _cosz = 0) { m_Angle[0] = _cosx; m_Angle[1] = _cosy; m_Angle[2] = _cosz; }
virtual void SetBranches ( TTree* _dataTree ); virtual void SetBranches ( TTree* _dataTree );
virtual void SetAlignment( Alignment* _alignment ){ m_Alignment = _alignment; } virtual void SetAlignment( Alignment* _alignment ){ m_Alignment = _alignment; }
virtual void SetAlignment2021( Alignment2021* _alignment ){ m_Alignment2021 = _alignment; }
virtual void DeclareHistograms ( ); virtual void DeclareHistograms ( );
virtual void FillHistograms ( ); virtual void FillHistograms ( );
virtual void PrintMap ( ) = 0; virtual void PrintMap ( ) = 0;
void SetName ( std::string _name ) { m_name = _name; }
std::string GetName ( ) { return m_name; }
private: private:
/** Name of the detector **/
std::string m_name;
/** Vector of channels associated to the dector **/ /** Vector of channels associated to the dector **/
std::vector< Channel* > m_Element; std::vector< Channel* > m_Element;
/** Three element array with x, y, and z of some pre-defined point on the detector **/ /** Three element array with x, y, and z of some pre-defined point on the detector **/
...@@ -52,9 +59,10 @@ class Detector{ ...@@ -52,9 +59,10 @@ class Detector{
double m_Angle[3]; double m_Angle[3];
/** Number of samples per channel **/ /** Number of samples per channel **/
int m_nSamp = 1024; int m_nSamp = 1024;
/** Alignment of the Testbeam */ /** Alignment of the 2018 Testbeam */
Alignment* m_Alignment = 0; Alignment* m_Alignment = 0;
/** Alignment of the 2021 Testbeam */
Alignment2021* m_Alignment2021 = 0;
}; };
#endif #endif
/** @file EM
* @brief Function prototypes for EM
*
* This contains the prototypes and members
* for EM
*
* @author Aric Tate
* @bug No known bugs.
*/
#ifndef EM_H
#define EM_H
#include "Containers.h"
#include "Detector.h"
class EM : public Detector{
public:
EM( );
EM( std::vector< Channel* > _readOut, int _runNumber, std::string _name );
~EM( );
Channel* GetElement(int row, int column);
void SetnRows(int rows){ m_nRows=rows; m_nElements = m_nRows * m_nColumns; ResizeSortedElements(); };
void SetnCols(int cols){ m_nColumns=cols; m_nElements = m_nRows * m_nColumns; ResizeSortedElements(); };
int GetnRows() { return m_nRows ; };
int GetnCols() { return m_nColumns ; };
void ResizeSortedElements();
virtual void PrintMap( );
private:
/** Number of rows **/
int m_nRows = 3;
/** Number of columns **/
int m_nColumns = 3;
/** Total elements **/
int m_nElements = m_nRows * m_nColumns;
/** 2D vector of channels sorted in a [row][column] format **/
std::vector< std::vector< Channel* > > m_SortedElements;
/** Translation of row elements for 2021 testbeam
Converts the tile mapping (row,col)
(1,4) (1,3) (1,2) (0,0) (0,1) (0,2) (0,3)
from (2,4) (2,3) (2,2) to (1,0) (1,1) (1,2) (1,3)
(3,4) (3,3) (3,2) (2,0) (2,1) (2,2) (2,3)
As viewed from the beam souce
**/
int rowTranslation [5];
/** Translation of column elements for 2018 testbeam
Converts the tile mapping (row,col)
(1,4) (1,3) (1,2) (0,0) (0,1) (0,2)
from (2,4) (2,3) (2,2) to (1,0) (1,1) (1,2)
(3,4) (3,3) (3,2) (2,0) (2,1) (2,2)
As viewed from the beam source**/
int colTranslation [5];
};
#endif
/** @file EMAnalysis
* @brief Function prototypes for EMAnalysis
*
* This contains the prototypes and members
* for EMAnalysis
*
* @author Aric Tate
* @bug No known bugs.
*/
#ifndef EMANALYSIS_H
#define EMANALYSIS_H
#include "Analysis.h"
#include "TH2D.h"
#include "Containers.h"
#include "EM.h"
#include <vector>
class EMAnalysis : public Analysis{
public :
EMAnalysis( );
virtual ~EMAnalysis( );
virtual void Initialize ( ){};
virtual void Initialize ( std::vector < Detector* > _vDet );
virtual void SetupHistograms( );
virtual void AnalyzeEvent ( );
virtual void AnalyzeEvent ( const std::vector< TH1* >& ){};
virtual void AnalyzeEvent ( const std::vector< std::vector< float > >& ){};
virtual void AnalyzeEvent ( const std::vector< Channel* > ){};
virtual void SetBranches ( TTree* _tree );
virtual void Finalize ( );
/** Running average of charges */
double m_charge[5][5];
/** Running average of charges */
double m_peak[5][5];
/** Center of mass x */
double m_xCoM;
/** Center of mass y */
double m_zCoM;
/** Sum of all channel charges */
double ChargeSum;
/** Sum of all channel peak heights */
double PeakSum;
/** Sum of all channel differential peak heights */
double DiffPeakSum;
/** Average charge per tile */
TH2D *hCharge;
/** Average peak height per tile */
TH2D *hPeak;
/** Calculated center of mass */
TH2D *hCenter;
/** Charge vs peak height */
TH2D *hChgVsPk;
/** Peak height vs differential peak height */
TH2D *hPkVsDiffPk;
/** Charge sum histogram */
TH1D *hChargeSum;
/** Peak height sum histogram */
TH1D *hPeakSum;
/** Differential peak height sum histogram */
TH1D *hDiffPeakSum;
/** Array of charge histograms. One per tile */
std::vector< std::vector < TH1D* > > hChargeArr;
/** Array of peak height histograms. One per tile */
std::vector< std::vector < TH1D* > > hPeakArr;
/** Array of differential peak histograms. One per tile */
std::vector< std::vector < TH1D* > > hDPeakArr;
/** Center of tiles in X mm */
double xPos[5] = {-10.0,0.0,10.0, 0, 0 }; //CHECK FOR 2021!
/** Gap between tiles in Z mm */
double zPos[5] = {10.0,20.0,30.0, 0, 0}; //CHECK FOR 2021!
/** Estimated position of the beam calculated form table position */
double m_beamPosX, m_beamPosY;
/** Number of rows and columns in the EM module */
int m_numRows, m_numCols;
int m_counter;
private :
/** Pointer to the EM */
EM *m_EM = 0;
/** Array of pointers to the EM channels to avoid repeated GetElement() calls */
Channel* em[5][5];
};
#endif
...@@ -18,22 +18,23 @@ class RPD : public Detector{ ...@@ -18,22 +18,23 @@ class RPD : public Detector{
public: public:
RPD( ); RPD( );
RPD( std::vector< Channel* > _readOut, int _runNumber ); RPD( std::vector< Channel* > _readOut, int _runNumber, std::string m_name );
~RPD( ); ~RPD( );
Channel* GetElement(int row, int column); Channel* GetElement(int row, int column);
void SetnRows(int rows){nRows=rows; nElements = nRows * nColumns; ResizeSortedElements(); }; void SetnRows(int _rows){m_nRows = _rows; nElements = m_nRows * m_nColumns; ResizeSortedElements(); };
void SetnCols(int cols){nColumns=cols; nElements = nRows * nColumns; ResizeSortedElements(); }; void SetnCols(int _cols){m_nColumns= _cols; nElements = m_nRows * m_nColumns; ResizeSortedElements(); };
void ResizeSortedElements(); void ResizeSortedElements();
virtual void PrintMap( ); virtual void PrintMap( );
private: private:
/** Number of rows **/ /** Number of rows **/
int nRows = 4; int m_nRows = 4;
/** Number of columns **/ /** Number of columns **/
int nColumns = 4; int m_nColumns = 4;
/** Translation of row elements for 2018 testbeam /** Translation of row elements for 2018 testbeam
Converts the tile mapping (row,col) Converts the tile mapping (row,col)
(1,4) (1,3) (1,2) (1,1) (0,0) (0,1) (0,2) (0,3) (1,4) (1,3) (1,2) (1,1) (0,0) (0,1) (0,2) (0,3)
...@@ -54,7 +55,7 @@ class RPD : public Detector{ ...@@ -54,7 +55,7 @@ class RPD : public Detector{
As viewed from the beam souce**/ As viewed from the beam souce**/
int colTranslation [4]; int colTranslation [4];
/** Total elements **/ /** Total elements **/
int nElements = nRows * nColumns; int nElements = m_nRows * m_nColumns;
/** 2D vector of channels sorted in a [row][column] format **/ /** 2D vector of channels sorted in a [row][column] format **/
std::vector< std::vector< Channel* > > m_SortedElements; std::vector< std::vector< Channel* > > m_SortedElements;
......
...@@ -35,8 +35,9 @@ class Visualizer { ...@@ -35,8 +35,9 @@ class Visualizer {
void SetAtlasStyle(); void SetAtlasStyle();
/** @brief Sets the label to be printed on each plot **/ /** @brief Sets the label to be printed on each plot **/
void SetTestBeamLabel(std::string _category, std::string _year, std::string _beam) { category = _category; year = _year; beam = _beam; } void SetTestBeamLabel(std::string _category, std::string _year, std::string _beam) { m_category = _category; m_year = _year; m_beam = _beam; }
void SetTestBeamLabel( int runNo, Alignment* alignment ); void SetTestBeamLabel( int runNo, Alignment* alignment );
void SetTestBeamLabel( int runNo, Alignment2021* alignment );
/** @brief allow the user to define the extension of the plots once they're printed. ".pdf" by default */ /** @brief allow the user to define the extension of the plots once they're printed. ".pdf" by default */
void SetPlotExtension( std::string _extension ) { m_extension = _extension; } void SetPlotExtension( std::string _extension ) { m_extension = _extension; }
...@@ -61,9 +62,9 @@ class Visualizer { ...@@ -61,9 +62,9 @@ class Visualizer {
/** String identifying the style to be applied */ /** String identifying the style to be applied */
std::string m_style; std::string m_style;
/** Strings encoding the year of the test and the beam **/ /** Strings encoding the year of the test and the beam **/
std::string category = "NO"; std::string m_category = "NO";
std::string year = "NO"; std::string m_year = "NO";
std::string beam = "NO"; std::string m_beam = "NO";
/** Output folder for plots. Defaults to $JZCaPA/results/ */ /** Output folder for plots. Defaults to $JZCaPA/results/ */
std::string m_oFolder = "${JZCaPA}/results/"; std::string m_oFolder = "${JZCaPA}/results/";
/** Debug flag */ /** Debug flag */
......
...@@ -25,6 +25,8 @@ class ZDC : public Detector{ ...@@ -25,6 +25,8 @@ class ZDC : public Detector{
private: private:
int m_Number; int m_Number;
int m_runNumber;
}; };
#endif #endif
...@@ -252,7 +252,7 @@ void DataReader::LoadConfigurationFile(std::string _inFile ){ ...@@ -252,7 +252,7 @@ void DataReader::LoadConfigurationFile(std::string _inFile ){
if( channelEntries.size() < 18 ) std::cout << "WARNING!!!! Number of Channels < 18. Seems that some entry is missed for this run in the config.xml. BE CAREFUL!" << std::endl; if( channelEntries.size() < 18 ) std::cout << "WARNING!!!! Number of Channels < 18. Seems that some entry is missed for this run in the config.xml. BE CAREFUL!" << std::endl;
ZDC* zdc1 = new ZDC(channelEntries,m_runNumber,1); ZDC* zdc1 = new ZDC(channelEntries,m_runNumber,1);
ZDC* zdc2 = new ZDC(channelEntries,m_runNumber,2); ZDC* zdc2 = new ZDC(channelEntries,m_runNumber,2);
RPD* rpd = new RPD(channelEntries,m_runNumber); RPD* rpd = new RPD(channelEntries,m_runNumber, "TRPD18");
m_detectors.push_back(zdc1); //Position 0 goes for ZDC1 m_detectors.push_back(zdc1); //Position 0 goes for ZDC1
m_detectors.push_back(zdc2); //Position 1 goes for ZDC2 m_detectors.push_back(zdc2); //Position 1 goes for ZDC2
...@@ -418,12 +418,15 @@ void DataReader::UpdateConsole( Long_t _updateRate){ ...@@ -418,12 +418,15 @@ void DataReader::UpdateConsole( Long_t _updateRate){
*/ */
void DataReader::Run(){ void DataReader::Run(){
std::cout << "Initializing " << std::endl;
Initialize(); Initialize();
std::cout << "Initialization done " << std::endl;
if( !m_fIn ){ if( !m_fIn ){
std::cerr << "Input file didn't open... exiting" << std::endl; std::cerr << "Input file didn't open... exiting" << std::endl;
return; return;
} }
ProcessEvents(); ProcessEvents();
std::cout << "Events done " << std::endl;
Finalize(); Finalize();
} }
...@@ -483,6 +486,7 @@ void DataReader::Initialize(){ ...@@ -483,6 +486,7 @@ void DataReader::Initialize(){
ana->Initialize(); ana->Initialize();
ana->SetupHistograms(); ana->SetupHistograms();
} }
std::cout << "After loop suspect " << std::endl;
for( auto& det_ana : m_det_ana ){ for( auto& det_ana : m_det_ana ){
det_ana->Initialize( m_detectors ); det_ana->Initialize( m_detectors );
det_ana->SetupHistograms(); det_ana->SetupHistograms();
...@@ -511,13 +515,15 @@ void DataReader::ProcessEvents(){ ...@@ -511,13 +515,15 @@ void DataReader::ProcessEvents(){
/** TODO : add reading for list of files /** TODO : add reading for list of files
* Please note that many of the implementations are now for a single-file treatment * Please note that many of the implementations are now for a single-file treatment
*/ */
std::cout << "Before retrieving pointers " << std::endl;
TTree* tree = static_cast< TTree* >( m_fIn->Get( "tree" ) ); TTree* tree = static_cast< TTree* >( m_fIn->Get( "tree" ) );
//Specific pointers to each detector, if needed afterwards //Specific pointers to each detector, if needed afterwards
ZDC* zdc1 = static_cast< ZDC* >( GetDetector("ZDC1") ); ZDC* zdc1 = static_cast< ZDC* >( GetDetector("ZDC1") );
ZDC* zdc2 = static_cast< ZDC* >( GetDetector("ZDC2") ); ZDC* zdc2 = static_cast< ZDC* >( GetDetector("ZDC2") );
RPD* rpd = static_cast< RPD* >( GetDetector("RPD") ); RPD* rpd = static_cast< RPD* >( GetDetector("TRPD") );
std::cout << "Before looping on detectors " << std::endl;
//All the raw channels addresses set for read-out //All the raw channels addresses set for read-out
for( uint detID = 0; detID < (