Commit 6af0532f authored by Chad Lantz's avatar Chad Lantz
Browse files

Modified to work with the new behaivor of DataReader2021

parent a6d508e4
......@@ -22,10 +22,11 @@ class Detector{
public:
Detector( );
Detector( std::string _name );
Detector( std::vector< Channel* > _element ){ m_Element = _element;}
virtual ~Detector( );
virtual void LoadElements(std::vector< Channel* > _elements, int _runNumber){ std::cout << "It's using the mother class LoadElements()" << std::endl;}
virtual Channel* GetElement (int row, int column);
virtual Channel* GetElement (std::string _name);
virtual std::vector < Channel* > GetChannelsVector () { return m_Element; }
......@@ -44,6 +45,7 @@ class Detector{
virtual void SetWFAthresholds ( double _threshold, int _diffSmoothing ){ m_Threshold = _threshold; m_diffSmoothing = _diffSmoothing; }
virtual void SetFFTlowPass ( int _freq ){ m_LPFfreq = _freq; m_doLPF = true; }
virtual void SetMedianFilter ( int _window ){ m_medHW = _window; m_doMedianFilter = true; }
virtual void SetVerbosity ( int _level ){ m_verbose = _level; }
virtual void DoDRS4NLcomp ( ){ m_doDRS4NLcomp = true; }
virtual void DeclareHistograms( );
virtual void FillHistograms ( );
......@@ -53,10 +55,13 @@ class Detector{
virtual void PlotWFandDerivative( int eventNum, double _yMin1=0, double _yMax1=0, double _yMin2=0, double _yMax2=0 );
virtual void PlotWFandPWF ( int eventNum, double _yMin1=0, double _yMax1=0, double _yMin2=0, double _yMax2=0 );
bool WasFound(){ return (m_Element.size() > 0) ? true : false; }
void SetName ( std::string _name ) { m_name = _name; }
std::string GetName ( ) { return m_name; }
private:
/** Verbosity level */
int m_verbose = 0;
/** Name of the detector **/
std::string m_name;
/** Vector of channels associated to the dector **/
......@@ -91,6 +96,8 @@ class Detector{
bool m_doMedianFilter = false;
/** Number of samples per channel **/
int m_nSamp = 1024;
/** Run number being processed */
int m_runNumber;
/** Visualizer for plots **/
Visualizer* m_viz = 0;
/** Alignment of the 2018 Testbeam */
......
......@@ -17,12 +17,14 @@
class EM : public Detector{
public:
// using Detector::Detector; //Inherit constructors
EM( );
EM( std::vector< Channel* > _readOut, int _runNumber, std::string _name );
EM( std::string _name );
~EM( );
Channel* GetElement(int row, int column);
virtual void LoadElements(std::vector< Channel* > _elements, int _runNumber);
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 ; };
......
......@@ -17,12 +17,15 @@
class RPD : public Detector{
public:
//using Detector::Detector; //Inherit constructors
RPD( );
RPD( std::string _name );
RPD( std::vector< Channel* > _readOut, int _runNumber, std::string _name );
~RPD( );
Channel* GetElement(int row, int column);
virtual void LoadElements(std::vector< Channel* > _elements, int _runNumber);
void SetnRows(int _rows){m_nRows = _rows; nElements = m_nRows * m_nColumns; ResizeSortedElements(); };
void SetnCols(int _cols){m_nColumns= _cols; nElements = m_nRows * m_nColumns; ResizeSortedElements(); };
void ResizeSortedElements();
......
......@@ -23,10 +23,13 @@ LV = (1,1) LH = (1,2) SV = (2,1) SH = (2,2)
class Scintillators : public Detector{
public:
// using Detector::Detector; //Inherit constructors
Scintillators( );
Scintillators( std::string _name );
Scintillators(std::vector<Channel *> _readOut, int _runNumber, std::string _name );
virtual ~Scintillators( );
virtual void LoadElements(std::vector< Channel* > _elements, int _runNumber);
void PrintMap ( );
std::string FindPaddleType( Channel *c );
Channel* GetScintillator ( std::string _scintillatorID );
......
......@@ -16,10 +16,14 @@
class ZDC : public Detector{
public:
// using Detector::Detector; //Inherit constructors
ZDC( );
ZDC( std::string _name );
ZDC(std::vector<Channel *> _readOut, int _runNumber, int _zdcNumber);
ZDC(int);
virtual ~ZDC( );
virtual void LoadElements(std::vector< Channel* > _elements, int _runNumber);
virtual void PrintMap ( );
void SetNumber ( int _number ) { m_Number = _number; }
......
......@@ -26,6 +26,12 @@ Detector::Detector( ){
}
/** @brief Name Constructor for Detector.
*/
Detector::Detector( std::string _name ){
m_name = _name;
}
/** @brief Destructor for Detector.
*/
Detector::~Detector( ){
......
......@@ -24,22 +24,34 @@
#include <fstream>
#include <iomanip>
/** @brief Default Constructor for EM.
*/
EM::EM( ){
}
/** @brief Constructor that takes the whole vector of channels readout and selects and stores only the EM ones
* @param _readOut Vector of Channels with all detector configs
/** @brief Name Constructor for EM.
*/
EM::EM( std::string _name ){
SetName(_name);
}
/** @brief Destructor for EM.
*/
EM::~EM( ){
}
/** @brief Implementation of LoadElements for the EM class
* @param _elements Vector of Channels with all detector configs
* @param _runNumber Current run number being analyzed
*
* Creates a new EM type Detector and picks the relevant Channels from the input vector.
* Adds the EM channels to the channels vector
*
*/
EM::EM( std::vector < Channel* > _readOut, int _runNumber, std::string _name ){
*/
void EM::LoadElements( std::vector < Channel* > _elements, int _runNumber ){
SetName (_name );
// Set up the row translation if run number is from 2021 test beam
for(int i = 0; i < m_nRows; i++){
rowTranslation[i] = i+1;
......@@ -53,11 +65,11 @@ EM::EM( std::vector < Channel* > _readOut, int _runNumber, std::string _name ){
std::cout << std::endl << "EM MODULE SECTION-SIGNAL MAPPING" << std::endl << "---------------------------------" << std::endl;
for(int row = 0; row < m_nRows; row++){
for(int column = 0; column < m_nColumns; column++){
for(int i=0; i < (int)_readOut.size(); i++){
if(_readOut.at(i)->mapping_row == rowTranslation[row]
&& _readOut.at(i)->mapping_column == colTranslation[column]
&& ( _readOut.at(i)->detector == "EM" ) ){
m_SortedElements.at(row).push_back(_readOut.at(i));
for(int i=0; i < (int)_elements.size(); i++){
if(_elements.at(i)->mapping_row == rowTranslation[row]
&& _elements.at(i)->mapping_column == colTranslation[column]
&& ( _elements.at(i)->detector == "EM" ) ){
m_SortedElements.at(row).push_back(_elements.at(i));
std::cout << Form("Config: X_Col[%d], Y_Row[%d] -> Array: X_Col[%d], Y_Row[%d] -> Channel[%s] -> Det[%s]",
colTranslation[column], rowTranslation[row], column, row,
......@@ -65,7 +77,7 @@ EM::EM( std::vector < Channel* > _readOut, int _runNumber, std::string _name ){
m_SortedElements[row][column]->detector.c_str()) << std::endl;
SetElement(_readOut.at(i));
SetElement(_elements.at(i));
}
}
}
......@@ -75,12 +87,6 @@ EM::EM( std::vector < Channel* > _readOut, int _runNumber, std::string _name ){
PrintMap();
}
/** @brief Destructor for EM.
*/
EM::~EM( ){
}
/** @brief Get the properties of a detector element
* @param row Row of element to be accessed
* @param column Column of element to be accessed
......
......@@ -15,22 +15,80 @@
#include <string>
#include <stdio.h>
/** @brief Default Constructor for RPD.
*/
RPD::RPD( ){
}
/** @brief Constructor that takes the whole vector of channels readout and selects and stores only the RPD ones
* @param _readOut Vector of Channels with all detector configs
/** @brief Name Constructor for RPD.
*/
RPD::RPD( std::string _name ){
SetName(_name);
}
/** @brief Destructor for RPD.
*/
RPD::~RPD( ){
}
/** @brief Legacy Constructor for the RPD class that takes the whole vector of channels readout and selects and stores only the RPD ones
* @param _elements Vector of Channels with all detector configs
* @param _runNumber Current run number being analyzed
* @param _name Identifier for the name of the model of the prototype - that distinguish PF from Tile
* Creates a new RPD type Detector and picks the relevant Channels from the input vector.
*
*/
RPD::RPD( std::vector < Channel* > _elements, int _runNumber, std::string _name ){
SetName( _name );
//Set up the row translation if run number is from 2018 test beam
//TRPD is now the identifier for tile RPD prototypes
for(int i = 0; i < 4; i++){
if(_runNumber >=79 && _runNumber <= 413 && GetName() == "TRPD18" ){//UPDATE FOR 2021 IF NEEDED, ELSE DELETE
rowTranslation[i] = i+1;
colTranslation[i] = 4-i;
}else{
//Same column-row association for both tile and pan flute at the moment
//Expert in analysis should comment and eventually modify
rowTranslation[i] = i+1;//ARIC CHANGED
colTranslation[i] = i+1;
}
}
RPD::RPD( std::vector < Channel* > _readOut, int _runNumber, std::string _name ){
ResizeSortedElements();
//std::cout << std::endl << "PANFLUTE RPD TILE-SIGNAL MAPPING" << std::endl << "---------------------------------" << std::endl;
for(int row = 0; row < m_nRows; row++){
for(int column = 0; column < m_nColumns; column++){
for(int i=0; i < (int)_elements.size(); i++){
if(_elements.at(i)->mapping_row == rowTranslation[row] && _elements.at(i)->mapping_column == colTranslation[column]
&& _elements.at(i)->detector == "PFRPD"){
m_SortedElements[row][column] = _elements.at(i);
// std::cout << Form("Config: X_Col[%d], Y_Row[%d] -> Array: X_Col[%d], Y_Row[%d] -> Channel[%s] -> Det[%s]",
// colTranslation[column], rowTranslation[row], column, row,
// m_SortedElements[row][column]->name.c_str(),
// m_SortedElements[row][column]->detector.c_str()) << std::endl;
SetElement(_elements.at(i));
}
}
}
}
std::cout << std::endl << GetName() << " object created with " << m_nRows << " rows and " << m_nColumns << " columns" << std::endl;
PrintMap();
}
/** @brief Constructor that takes the whole vector of channels readout and selects and stores only the RPD ones
* @param _elements Vector of Channels with all detector configs
* @param _runNumber Current run number being analyzed
*
* Adds the RPD channels to the channels vector
*
*/
void RPD::LoadElements( std::vector < Channel* > _elements, int _runNumber){
SetName( _name );
//Set up the row translation if run number is from 2018 test beam
//TRPD is now the identifier for tile RPD prototypes
for(int i = 0; i < 4; i++){
......@@ -49,15 +107,15 @@ RPD::RPD( std::vector < Channel* > _readOut, int _runNumber, std::string _name )
//std::cout << std::endl << "PANFLUTE RPD TILE-SIGNAL MAPPING" << std::endl << "---------------------------------" << std::endl;
for(int row = 0; row < m_nRows; row++){
for(int column = 0; column < m_nColumns; column++){
for(int i=0; i < (int)_readOut.size(); i++){
if(_readOut.at(i)->mapping_row == rowTranslation[row] && _readOut.at(i)->mapping_column == colTranslation[column]
&& _readOut.at(i)->detector == "PFRPD"){
m_SortedElements[row][column] = _readOut.at(i);
for(int i=0; i < (int)_elements.size(); i++){
if(_elements.at(i)->mapping_row == rowTranslation[row] && _elements.at(i)->mapping_column == colTranslation[column]
&& _elements.at(i)->detector == "PFRPD"){
m_SortedElements[row][column] = _elements.at(i);
// std::cout << Form("Config: X_Col[%d], Y_Row[%d] -> Array: X_Col[%d], Y_Row[%d] -> Channel[%s] -> Det[%s]",
// colTranslation[column], rowTranslation[row], column, row,
// m_SortedElements[row][column]->name.c_str(),
// m_SortedElements[row][column]->detector.c_str()) << std::endl;
SetElement(_readOut.at(i));
SetElement(_elements.at(i));
}
}
}
......@@ -67,11 +125,6 @@ RPD::RPD( std::vector < Channel* > _readOut, int _runNumber, std::string _name )
PrintMap();
}
/** @brief Destructor for RPD.
*/
RPD::~RPD( ){
}
/** @brief Get the properties of a detector element
* @param row Row of element to be accessed
......
File mode changed from 100644 to 100755
......@@ -19,25 +19,10 @@ Scintillators::Scintillators( ){
}
/** @brief Constructor for Scintillators with vector of Channels and module number
* @param _readOut Vector of Channels with all detector configs
* @param _ScintillatorsNumber nameID of the Scintillators
*
* Creates a new Scintillators type Detector with an assigned number and picks the
* relevant Channel from the input vector.
*
/** @brief Name Constructor for Scintillators.
*/
Scintillators::Scintillators( std::vector < Channel* > _readOut, int _runNumber, std::string _name ){
SetName(_name);
m_runNumber = _runNumber;
for(int i = 0; i < (int)_readOut.size(); i++){
if((_readOut.at(i)->detector.find("TRIG") != std::string::npos)){
SetElement(_readOut.at(i));
}
}
if(GetChannelsVector().size() > 4) std::cout << "WARNING : more than one entry for one Scintillators module. Check the config.xml" << std::endl;
std::cout << "Scintillators object created with " << GetChannelsVector().size() << " channel entries " << std::endl;
Scintillators::Scintillators( std::string _name ){
SetName(_name);
}
/** @brief Destructor for Scintillators.
......@@ -46,6 +31,30 @@ Scintillators::~Scintillators( ){
}
/** @brief Implementation of LoadElements for the Scintillators class
* @param _elements Vector of Channels with all detector configs
* @param _runNumber Current run number being analyzed
*
* Adds the Scintillator channels to the channels vector
*
*/
void Scintillators::LoadElements( std::vector < Channel* > _elements, int _runNumber ){
m_runNumber = _runNumber;
for(int i = 0; i < (int)_elements.size(); i++){
if((_elements.at(i)->detector.find("TRIG") != std::string::npos)){
SetElement(_elements.at(i));
}
}
if(GetChannelsVector().size() > 4) std::cout << "WARNING : more than one entry for one Scintillators module. Check the config.xml" << std::endl;
std::cout << "Scintillators object created with " << GetChannelsVector().size() << " channel entries " << std::endl;
}
/** @brief Get specific scintillator paddle by reference ID
*
* @param _scintillatorID Reference string for the scintillator. Can be LV (Large Vertical), LH (Large Horizontal), SV (Small Vertical), or SH (Small Horizontal).
*
*/
Channel* Scintillators::GetScintillator( std::string _scintillatorID ){
for(int i = 0; i < 2; i++){
......
......@@ -72,7 +72,7 @@ void ScintillatorsAnalysis2021::Initialize( std::vector < Detector* > _vDet ){
*/
void ScintillatorsAnalysis2021::SetupHistograms( ){
hPeak = new TH2D("trig_peak","Trigger Peak",100,0,300,100,0,300);
hPeak = new TH2D("trig_peak","Trigger Peak",100,0,1000,100,0,1000);
}
......
......@@ -19,12 +19,18 @@ ZDC::ZDC( ){
}
/** @brief Constructor for ZDC with vector of Channels and module number
/** @brief Name Constructor for ZDC.
*/
ZDC::ZDC( std::string _name ){
SetName(_name);
}
/** @brief Legacy constructor for the ZDC class. Will be removed soon
* @param _readOut Vector of Channels with all detector configs
* @param _runNumber Current run number being analyzed
* @param _zdcNumber Number of the ZDC module
*
* Creates a new ZDC type Detector with an assigned number and picks the
* relevant Channel from the input vector.
* Adds the ZDC channel to the channels vector
*
*/
ZDC::ZDC( std::vector < Channel* > _readOut, int _runNumber, int _zdcNumber){
......@@ -43,12 +49,42 @@ ZDC::ZDC( std::vector < Channel* > _readOut, int _runNumber, int _zdcNumber){
std::cout << "ZDC object created with " << GetChannelsVector().size() << " channel entries " << std::endl;
}
/** @brief Number Constructor for ZDC.
*/
ZDC::ZDC(int _zdcNumber){
m_Number = _zdcNumber;
SetName ( Form ("HAD%d", m_Number) );
}
/** @brief Destructor for ZDC.
*/
ZDC::~ZDC( ){
}
/** @brief Implementation of LoadElements for the ZDC class
* @param _readOut Vector of Channels with all detector configs
* @param _runNumber Current run number being analyzed
*
* Adds the ZDC channel to the channels vector
*
*/
void ZDC::LoadElements( std::vector < Channel* > _elements, int _runNumber){
m_runNumber = _runNumber;
for(int i = 0; i < (int)_elements.size(); i++){
if((_elements.at(i)->detector.find_first_of("H") != std::string::npos) && (_elements.at(i)->mapping_column == m_Number)){
SetElement(_elements.at(i));
}
}
if(GetChannelsVector().size() > 1) std::cout << "WARNING : more than one entry for one ZDC module. Check the config.xml" << std::endl;
std::cout << "ZDC object created with " << GetChannelsVector().size() << " channel entries " << std::endl;
}
/** @brief Prints a map of the ZDC to the terminal
*
* Prints a "map" of the ZDC.
......
......@@ -129,53 +129,73 @@ int main(int argc, char *argv[]){
r->SetOutputDirectory( Form("%s/run%d/",output_dir.c_str(),runNum) );
gSystem->Exec( Form("mkdir -p %s/run%d/",output_dir.c_str(),runNum) );
}
//ADD DETECTORS AND WF ANALYSIS VARIABLES
ZDC *zdc1 = new ZDC(1);
zdc1->SetWFAthresholds( 5, 30 );
zdc1->SetMedianFilter( 4 );
r->AddDetector( zdc1 );
ZDC *zdc2 = new ZDC(2);
zdc2->SetWFAthresholds( 5, 30 );
zdc2->SetMedianFilter( 4 );
r->AddDetector( zdc2 );
ZDC *zdc3 = new ZDC(3);
zdc3->SetWFAthresholds( 5, 30 );
zdc3->SetMedianFilter( 4 );
r->AddDetector( zdc3 );
RPD *rpd = new RPD("PFRPD");
rpd->SetWFAthresholds( 3.2, 28 );
rpd->SetMedianFilter( 4 );
r->AddDetector( rpd );
// RPD *rpd = new RPD("TRPD");
// rpd->SetWFAthresholds( 3.2, 28 );
// rpd->SetMedianFilter( 4 );
// r->AddDetector( rpd );
EM *em = new EM("UEM");
em->SetWFAthresholds( 4, 25 );
em->SetMedianFilter( 4 );
r->AddDetector( em );
Scintillators *trig = new Scintillators("TRIGGER");
trig->SetWFAthresholds( 4, 25 );
trig->SetMedianFilter( 4 );
r->AddDetector( trig );
//ADD DETECTORS FOR WF ANALYSIS (PROCESSING OF RAW SIGNALS)
r->SelectDetectorForAnalysis(true,true,false,true,true); //(_useUEM, _usePFRPD, _useTRPD, _useZDCs)
std::cout << std::endl << "============ LoadConfigurationFile ============" << std::endl << std::endl;
r->LoadConfigurationFile( config_file );
r->GetDetector("PFRPD")->SetWFAthresholds( 3.2, 28 );
// r->GetDetector("TRPD")->SetWFAthresholds( 30, 4 );
r->GetDetector("HAD1")->SetWFAthresholds( 5, 30 );
r->GetDetector("HAD2")->SetWFAthresholds( 5, 30 );
r->GetDetector("HAD3")->SetWFAthresholds( 5, 30 );
r->GetDetector("UEM")->SetWFAthresholds( 4, 25 );
r->GetDetector("Trigger")->SetWFAthresholds( 4, 25 );
r->GetDetector("PFRPD")->SetMedianFilter( 6 );
// r->GetDetector("TRPD")->SetMedianFilter( 4 );
r->GetDetector("HAD1")->SetMedianFilter( 4 );
r->GetDetector("HAD2")->SetMedianFilter( 4 );
r->GetDetector("HAD3")->SetMedianFilter( 4 );
r->GetDetector("UEM")->SetMedianFilter( 4 );
r->GetDetector("Trigger")->SetMedianFilter( 4 );
//Add pre analysis
r->AddPreAnalysis( new WFAnalysis() );
//ADD DETECTORS FOR ANALYSIS (PLOTTING/OUTPUT)
r->AddDetectorAnalysis( new ZDCAnalysis2021() );
r->AddDetectorAnalysis( new RPDAnalysis2021() );
r->AddDetectorAnalysis( new EMAnalysis() );
r->AddDetectorAnalysis( new ScintillatorsAnalysis2021() );
if( zdc1->WasFound() && zdc2->WasFound() && zdc3->WasFound() ) r->AddDetectorAnalysis( new ZDCAnalysis2021() );
if( rpd->WasFound() ) r->AddDetectorAnalysis( new RPDAnalysis2021() );
if( em->WasFound() ) r->AddDetectorAnalysis( new EMAnalysis() );
if( trig->WasFound() ) r->AddDetectorAnalysis( new ScintillatorsAnalysis2021() );
std::cout << std::endl << "============ LoadAlignmentFile ============" << std::endl << std::endl;
r->LoadAlignmentFile( alignment_file );
std::cout << std::endl << "============ LoadTimingFile ============" << std::endl << std::endl;
r->LoadTimingFile( timing_file );
std::cout << "~=~=~=~=~=~ Run Start" << std::endl;
r->EnablePlotLabel();
if( maxEvents != 0 )r->SetMaxEvents( maxEvents );
EventTimer timer(1000, r, kFALSE);
if(verbosity > 0) timer.TurnOn();
std::cout << "~=~=~=~=~=~ Run Start" << std::endl;
r->Run();
if(verbosity > 0) timer.TurnOff();
std::cout << std::endl << "~=~=~=~=~=~ Run Stop" << std::endl;
if(verbosity > 0) timer.TurnOff();
delete r;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment