Commit 3751e268 authored by Riccardo Longo's avatar Riccardo Longo
Browse files

Restyling of ProcessEvent finished (+ side modifications needed)

parent 4a4a1f41
Pipeline #128002 canceled with stages
......@@ -14,6 +14,8 @@
#include <string>
#include <vector>
#include "Containers.h"
class TFile;
class TH1;
class TH2;
......@@ -30,6 +32,7 @@ class Analysis{
virtual void SetupHistograms( ) = 0;
virtual void AnalyzeEvent ( const std::vector< TH1* >& ) = 0;
virtual void AnalyzeEvent ( const std::vector< std::vector< float > >& ) = 0;
virtual void AnalyzeEvent ( const std::vector< Channel* > ) = 0;
virtual void Finalize ( ) = 0;
};
......
......@@ -27,7 +27,7 @@ class Detector{
virtual Channel* GetElement (int row, int column);
virtual Channel* GetElement (std::string _name);
virtual std::vector < Channel* >* GetChannelsVector () { return &m_Element; }
virtual std::vector < Channel* > GetChannelsVector () { return m_Element; }
virtual double* GetPosition ( ) { return m_Position; }
virtual double* GetAngle ( ) { return m_Angle; }
......
......@@ -12,6 +12,7 @@
#define WFANALYSIS_H
#include "Analysis.h"
#include "Containers.h"
class WFAnalysis : public Analysis{
......@@ -23,6 +24,7 @@ class WFAnalysis : public Analysis{
virtual void SetupHistograms( );
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 Finalize ( );
};
......
......@@ -339,12 +339,13 @@ void DataReader::ProcessEvents(){
for( int ev = 0; ev < tree->GetEntries(); ev++ ){
tree->GetEntry( ev );
// Fill the waveforms
for( uint detID = 0; detID < (int) m_detectors.size(); detID++ ) m_detectors.at(detID)->FillHistograms();
// Fill the raw waveforms
for( uint detID = 0; detID < (int) m_detectors.size(); detID++ )
m_detectors.at(detID)->FillHistograms();
//Here if you're interested in already processed waveform
for( uint ch = 0; ch < m_nCh; ch++ ) {
// Loop over samples in each channel
// Loop over samples in each channel
for( uint samp = 0; samp < m_nSamp; samp++ ){
vWFH[ ch ]->SetBinContent( samp + 1, vWF[ ch ][ samp ] );
} // End loop over samples in each channel
......@@ -353,7 +354,13 @@ void DataReader::ProcessEvents(){
// Now call all analysis and run their AnalyzeEvent.
// Can either send a vector of histos, or a 2D vector
// Of all the data, depending on what you want to do.
// Note that at the moment none of this methods is doing anything
for( auto& ana : m_ana ){
//raw data analysis
ana->AnalyzeEvent( zdc1->GetChannelsVector() );
ana->AnalyzeEvent( zdc2->GetChannelsVector() );
ana->AnalyzeEvent( rpd->GetChannelsVector() );
//already processed wf analysis
ana->AnalyzeEvent( vWFH );
ana->AnalyzeEvent( vWF );
}
......
......@@ -54,9 +54,9 @@ Channel* RPD::GetElement(int row, int column){
if((int)m_SortedElements.size()==nElements){ return m_SortedElements[row][column];
}else{
for(int i=0; i < (int)GetChannelsVector()->size(); i++){
if(row == GetChannelsVector()->at(i)->mapping_row && column == GetChannelsVector()->at(i)->mapping_column){
return GetChannelsVector()->at(i);
for(int i=0; i < (int)GetChannelsVector().size(); i++){
if(row == GetChannelsVector().at(i)->mapping_row && column == GetChannelsVector().at(i)->mapping_column){
return GetChannelsVector().at(i);
}
}
}
......
......@@ -101,6 +101,26 @@ void WFAnalysis::AnalyzeEvent( const std::vector< std::vector< float > >& vWF ){
}
}
/**
* @brief Analyze Event method for WF analysis
* A const vector of channels is received. Can be either the vector coming from a single detector or formed using all the channels.
* Example of how to retrieve raw data and associated histograms are provided
* @param vCh
*/
void WFAnalysis::AnalyzeEvent( const std::vector<Channel *> vCh ){
for( unsigned int ch = 0; ch < vCh.size(); ch++ ){
//retrieving information for each channel
TH1* h = vCh.at(ch)->WF_histo;
std::vector < float > chEntries = vCh.at(ch)->WF;
for( unsigned int samp = 0; samp < h->GetNbinsX(); samp++ ){
// will print what each sample in each channel equals
// std::cout << ch << " " << samp << " = " << h->GetBinContent( samp + 1 ) << std::endl;
}
}
}
/** @brief Finalize method for WFAnalysis
*
* Write histograms, TTree if it exists.
......
......@@ -27,8 +27,8 @@ ZDC::ZDC( std::vector < Channel* > _readOut, int _zdcNumber){
SetElement(_readOut.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;
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 Destructor for ZDC.
......
Supports Markdown
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