Commit a6d508e4 authored by Chad Lantz's avatar Chad Lantz
Browse files

Removed the use of daughter types of the Detector mother class allowing new...

Removed the use of daughter types of the Detector mother class allowing new detector types to be created without modifying DataReader
parent a20c0484
......@@ -22,17 +22,13 @@
#include "XMLSettingsReader.h"
#include "Containers.h"
#include "Detector.h"
#include "ZDC.h"
#include "EM.h"
#include "RPD.h"
#include "Scintillators.h"
#include "Analysis.h"
#include "Visualizer.h"
#include <TChain.h>
#include <TSystem.h>
class TFile;
class Analysis;
class DataReader2021{
......@@ -45,9 +41,9 @@ class DataReader2021{
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, bool _useScint );
void AddPreAnalysis ( Analysis* );
void AddDetectorAnalysis ( Analysis* );
void AddDetector ( Detector* );
void ReadListOfFiles( std::string listname );
......@@ -130,15 +126,6 @@ class DataReader2021{
//Event number of last update
int m_event_old = 0;
//Booleans for analysis selection
bool m_useZDCs, m_usePFRPD, m_useTRPD, m_useUEM, m_useScint;
//Pointers for each detector, to be assigned using booleans.
ZDC *zdc1, *zdc2, *zdc3;
RPD *pfrpd, *trpd;
EM *uem;
Scintillators *scint;
//Boolean to enable plot labelling
bool m_useLabel = false;
......
......@@ -20,12 +20,6 @@
#include <iomanip>
#include "DataReader2021.h"
#include "Analysis.h"
#include "Containers.h"
#include "RPD.h"
#include "ZDC.h"
#include "EM.h"
#include "Visualizer.h"
/** @brief Default Constructor for DataReader2021.
......@@ -125,33 +119,15 @@ void DataReader2021::AddDetectorAnalysis( Analysis* det_ana ){
m_det_ana.push_back( det_ana );
}
/**
* @brief Allows the user to select which detectors will enter the waveform analysis and the detector analysis s
* @param _useZDC/1/2/3 set it true to look to ATLAS HAD ZDC modules
* @param _usePFRPD set it true to look to the PFRPD
* @param _useTRPD set it true to look to the TRPD
* @param _useUEM set it true to look to the upgraded EM module
/** @brief Adds an detector to vector of detectors (e.g. ZDC, RPD ...)
*
* @param ana Pointer to a Detector.
*
* @return none
*/
void DataReader2021::SelectDetectorForAnalysis(bool _useUEM, bool _usePFRPD, bool _useTRPD, bool _useZDCs, bool _useScint){
m_useUEM = _useUEM;
m_useZDCs = _useZDCs;
m_usePFRPD = _usePFRPD;
m_useTRPD = _useTRPD;
m_useScint = _useScint;
std::string enableDet;
enableDet = "Detectors Selected for Analysis: ";
if (m_useUEM) enableDet += " Upg.EM ";
if (m_usePFRPD) enableDet += " PanFlute-RPD " ;
if (m_useTRPD) enableDet += " Tile-RPD " ;
if (m_useZDCs) enableDet += " HAD1 HAD2 HAD3 " ;
if (m_useScint) enableDet += " Trigger " ;
enableDet += ";";
std::cout << enableDet << std::endl << std::endl;
void DataReader2021::AddDetector( Detector* det ){
det->SetVerbosity( m_verbose );
m_detectors.push_back( det );
}
/** @brief Enables the read from list of files option for DataReader2021
......@@ -264,27 +240,21 @@ void DataReader2021::LoadConfigurationFile(std::string _inFile ){
std::cout << "Loaded " << channelEntries.size() << " configuration entries " << 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;
if (m_useZDCs){
zdc1 = new ZDC(channelEntries,m_runNumber,1);
zdc2 = new ZDC(channelEntries,m_runNumber,2);
zdc3 = new ZDC(channelEntries,m_runNumber,3);
}
if (m_usePFRPD) pfrpd = new RPD(channelEntries,m_runNumber, "PFRPD");
if (m_useTRPD) trpd = new RPD(channelEntries,m_runNumber, "TRPD");
if (m_useUEM) uem = new EM(channelEntries,m_runNumber, "UEM");
if (m_useScint) scint = new Scintillators(channelEntries,m_runNumber, "Trigger");
if (m_useZDCs) {
m_detectors.push_back(zdc1);
m_detectors.push_back(zdc2);
m_detectors.push_back(zdc3);
std::string names = "";
//Hand the channels to the detectors so they can pick theirs from the list
//If a detector doesn't find its channels, remove it from the vector (and analysis)
//If it does find its channels, add its name to the list to print for the user
for(int det = 0; det < m_detectors.size(); det++){
m_detectors.at(det)->LoadElements(channelEntries, m_runNumber);
if( m_detectors.at(det)->GetChannelsVector().size() == 0 ){
std::cout << "No entries found for " << m_detectors.at(det)->GetName() << ". Removing detector from analysis." << std::endl;
m_detectors.erase(m_detectors.begin() + det);
}else{
names+= m_detectors.at(det)->GetName() + "; ";
}
}
if (m_usePFRPD) m_detectors.push_back(pfrpd);
if (m_useTRPD) m_detectors.push_back(trpd);
if (m_useUEM) m_detectors.push_back(uem);
if (m_useScint) m_detectors.push_back(scint);
std::cout << "Detectors found in config file: " << names << std::endl << std::endl;
delete m_XMLparser; m_XMLparser = NULL;
return;
......@@ -513,15 +483,6 @@ void DataReader2021::Initialize(){
m_tIn = static_cast< TTree* >( m_fIn->Get( "tree" ) );
if(m_useZDCs){
zdc1 = static_cast< ZDC* >( GetDetector("HAD1") );
zdc2 = static_cast< ZDC* >( GetDetector("HAD2") );
zdc3 = static_cast< ZDC* >( GetDetector("HAD3") );
}
if(m_usePFRPD) pfrpd = static_cast< RPD* >( GetDetector("PFRPD") );
if(m_useTRPD) trpd = static_cast< RPD* >( GetDetector("TRPD") );
if(m_useUEM) uem = static_cast< EM* > ( GetDetector("UEM") );
if(m_useScint) scint = static_cast< Scintillators* > ( GetDetector("Trigger") );
//All the raw channels addresses set for read-out
for( uint detID = 0; detID < (int) m_detectors.size(); detID++ ){
m_detectors.at(detID)->SetBranches(m_tIn);
......@@ -567,7 +528,6 @@ void DataReader2021::ProcessEvents(){
* Please note that many of the implementations are now for a single-file treatment
*/
// !! EVENT LOOP
int nEventsToProcess;
if( m_maxEvents == -1 ){
......@@ -595,16 +555,10 @@ void DataReader2021::ProcessEvents(){
// Of all the data, depending on what you want to do.
for( auto& ana : m_ana ){
//raw data analysis
if(m_useZDCs){
ana->AnalyzeEvent( zdc1->GetChannelsVector() );
ana->AnalyzeEvent( zdc2->GetChannelsVector() );
ana->AnalyzeEvent( zdc3->GetChannelsVector() );
}
if(m_usePFRPD) ana->AnalyzeEvent( pfrpd->GetChannelsVector() );
if(m_useTRPD) ana->AnalyzeEvent( trpd->GetChannelsVector() );
if(m_useUEM) ana->AnalyzeEvent( uem->GetChannelsVector() );
if(m_useScint) ana->AnalyzeEvent( scint->GetChannelsVector() );
for( auto& det : m_detectors ){
ana->AnalyzeEvent( det->GetChannelsVector() );
}
}
for( auto& det_ana : m_det_ana ){
//Detector level analysis
det_ana->AnalyzeEvent();
......
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