Commit 9379096d authored by aricct2's avatar aricct2
Browse files

fixed merge conflict in CMakeLists.txt

parents 83bc6074 2c5d41dd
doxygen/html
doxygen/latex
\ No newline at end of file
......@@ -34,8 +34,13 @@ class Analysis{
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 AnalyzeEvent ( const std::vector< Channel* > vCh, TVirtualPad* pad ) = 0;
virtual void AnalyzeEvent ( const std::vector< Channel* >, std::string ) = 0;
virtual void SetVerbosity ( int _level ){ m_verbose = _level; }
virtual void Finalize ( ) = 0;
protected:
/** Verbosity level */
int m_verbose = 0;
};
#endif
......@@ -14,6 +14,7 @@
#include <iostream>
#include <vector>
#include <utility>
class Channel {
......@@ -52,6 +53,32 @@ class Channel {
std::vector < float > *pWF = &WF;
/** Histrogram for visualization and analysis of the waveform */
TH1D* WF_histo;
/** Histogram of the processed waveform */
TH1D* PWF_histo;
/** Histogram with first derivative **/
TH1D* FirstDerivative;
/** RMS value of the first derrivative of the waveform **/
double FirstDerivativeRMS;
/** Bin number of the peak center*/
int Peak_center;
/** Height of the peak */
double Peak_max;
/** Max value of the derivative */
double Diff_max;
/** Bin number of 1/3 peak value on the rising edge*/
int DiscriminatorTime;
/** Start and end of the hit window*/
std::pair< int, int > hit_window;
/** Flag if the channel was hit */
bool was_hit;
/** Pedestal of raw waveform */
double PedMean;
/** Pedestal RMS of raw waveform */
double PedRMS;
/** Integral of PWF_histo in the hit window */
double Charge;
/** Crossing zero points - dummy - to be checked by Sheng **/
std::vector < int > CrossZeroPoints;
};
......@@ -78,12 +105,5 @@ class Alignment {
};
class ProcessedWF {
/** Histogram with first derivative **/
TH1D* FirstDerivative;
/** Crossing zero points - dummy - to be checked by Sheng **/
std::vector < int > CrossZeroPoints;
};
#endif
......@@ -23,6 +23,7 @@
#include "Containers.h"
#include "Detector.h"
#include <TChain.h>
class TFile;
......@@ -34,18 +35,20 @@ class DataReader{
DataReader( );
DataReader( const unsigned int = 0, const unsigned int = 0 );
DataReader( const unsigned int = 0, const unsigned int = 0,
const std::string& = "" );
const std::string& = "" );
DataReader( const unsigned int = 0, const unsigned int = 0,
const std::string& = "", const unsigned int = 0 );
const std::string& = "", const unsigned int = 0 );
virtual ~DataReader();
void AddAnalysis ( Analysis* );
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 SetDebugMode() { m_debug = true; }
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 SetDebugMode ( ) { m_debug = true; }
void SetVerbosity ( int _level ){ m_verbose = _level; }
void UpdateConsole ( Long_t _updateRate);
Detector* GetDetector( std::string _detName );
......@@ -91,9 +94,16 @@ class DataReader{
//XML parser
XMLSettingsReader *m_XMLparser;
//Current event
int m_event;
//Event number of last update
int m_event_old = 0;
//DebugVariable
bool m_debug = false;
//Verbosity level
int m_verbose = 0;
};
#endif
/** @file EventTimer
* @brief Reimplementation of TTimer
*
* This contains the prototypes and members
* for EventTimer
*
* @author Chad Lantz
* @bug No known bugs.
*/
#ifndef EVENTTIMER_H
#define EVENTTIMER_H
#include "TTimer.h"
#include "DataReader.h"
class EventTimer : public TTimer {
public:
EventTimer( );
EventTimer(Long_t milliSec = 0, DataReader* obj = 0, Bool_t mode = kTRUE);
~EventTimer();
virtual Bool_t Notify();
DataReader* m_object;
Long_t m_rate;
};
#endif
\ No newline at end of file
/** @file Visualizer.h
* @brief Class to have a simple visualization of plots through JZCaPA. If you want to plot something, just define here a child method and use it recursively, w/o filling the code with canvases et al.
*
* @author Riccardo Longo
* @bug No known bugs.
*/
#ifndef VISUALIZER_H
#define VISUALIZER_H
#include "TH1.h"
#include "TStyle.h"
#include "TVector.h"
#include "TGraph.h"
#include <iostream>
#include <vector>
class Visualizer {
public :
Visualizer();
Visualizer( std::string _style );
//Styles (so far only ATLAS)
TStyle* AtlasStyle();
//Methods to set a given style
void SetAtlasStyle();
/** @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; }
/** @brief make the argument true to activate the debug mode. False to deactivate it*/
void SetDebugMode ( bool _isDebugon ) { m_debug = _isDebugon; }
//Special plot treatments
void OverlayHistos ( TH1 *h1, TH1 *h2 , TVirtualPad* pad, double _line = 0);
void ScatterPlot ( std::vector< double > _v1, std::vector< double > _v2, TVirtualPad* pad);
//Main visualization methods
void ManyPadsPlot ( std::vector< TH1* > _first_form, std::vector< TH1* > _second_form, int _ncol, int _nrow, std::string _out_name, std::string _treatment );
void SinglePlot ( std::vector< double > _v1, std::vector< double > _v2, std::string _out_name, std::string _treatment, double _line = 0);
private :
/** String identifying the style to be applied */
std::string m_style;
/** Debug flag */
bool m_debug = false;
/** String defining the extension used to print the plots */
std::string m_extension = ".pdf";
};
#endif
......@@ -13,6 +13,8 @@
#include "Analysis.h"
#include "Containers.h"
#include "TVirtualFFT.h"
#include "TF1.h"
#include "TStyle.h"
#include "TGaxis.h"
#include "TF1.h"
......@@ -23,20 +25,32 @@ class WFAnalysis : public Analysis{
public :
WFAnalysis( );
WFAnalysis( int _sensitivity, double _threshold ){ m_diffSens = _sensitivity; m_Tmultiple = _threshold; }
virtual ~WFAnalysis( );
virtual void Initialize ( );
virtual void SetupHistograms( );
virtual TH1 *GetDifferential( TH1D *h, int window, bool debug = false );
virtual double GetRMS ( TH1D *h, int diff_window, bool save = false) ;
virtual void OverlayHistos ( TH1D *h1, TH1D *h2 , TVirtualPad* pad, bool save = false );
virtual void OverlayHistos ( TH1D *h1, TH1D *h2 , bool save = true );
virtual void GetDifferential( TH1D *hIN, TH1D *hOUT );
virtual double GetRMS ( TH1D *h, bool debug = false) ;
virtual void GetPedestal ( Channel* ch, TH1D* hRef = 0 );
virtual void FindHitWindow ( Channel* ch );
virtual void ZeroSuppress ( Channel* ch );
virtual void LowPassFilter ( Channel* ch, TH1D* hIn = 0 );
virtual void AnalyzeEvent ( const std::vector< TH1* >& );
virtual void AnalyzeEvent ( const std::vector< std::vector< float > >& );
virtual void AnalyzeEvent ( const std::vector< Channel* > vCh );
virtual void AnalyzeEvent ( const std::vector< Channel* > vCh, TVirtualPad* pad );
virtual void AnalyzeEvent ( const std::vector< Channel* > vCh, std::string detector );
virtual void Finalize ( );
private :
/** Sensitivity level to hits (differentiation window) */
int m_diffSens = 25;
/** Hit threshold multiplier */
double m_Tmultiple = 3.5;
/** Frequency threshold for low pass filter */
int fCutoff = 50;
/** Flag for inverting PMT signals */
bool invert = false;
};
#endif
......@@ -12,9 +12,7 @@
#include <TFile.h>
#include <TTree.h>
#include <TH1.h>
#include <TCanvas.h>
#include <TChain.h>
#include <TSystem.h>
#include <iostream>
......@@ -23,6 +21,8 @@
#include "Containers.h"
#include "RPD.h"
#include "ZDC.h"
#include "Visualizer.h"
/** @brief Default Constructor for DataReader.
*/
......@@ -32,8 +32,8 @@ DataReader::DataReader() : DataReader( 0, 0, "", 0 ){
/** @brief Constructor for DataReader.
*
* @param1 Number of channels being read
* @param2 Number of samples per channel
* @param nCh Number of channels being read
* @param nSamp Number of samples per channel
*/
DataReader::DataReader( const unsigned int nCh, const unsigned int nSamp )
: DataReader( nCh, nSamp, "", 0 ){
......@@ -45,9 +45,9 @@ DataReader::DataReader( const unsigned int nCh, const unsigned int nSamp )
/** @brief Constructor for DataReader.
*
* @param1 Number of channels being read
* @param2 Number of samples per channel
* @param3 Input filename.
* @param nCh Number of channels being read
* @param nSamp Number of samples per channel
* @param fNameIn Input filename.
*/
DataReader::DataReader( const uint nCh, const uint nSamp,
const std::string& fNameIn )
......@@ -58,10 +58,10 @@ DataReader::DataReader( const uint nCh, const uint nSamp,
/** @brief Constructor for DataReader.
*
* @param1 Number of channels being read
* @param2 Number of samples per channel
* @param4 Output file name (custom)
* @param3 Run number being used.
* @param nCh Number of channels being read
* @param nSamp Number of samples per channel
* @param4 fNameIn Output file name (custom)
* @param3 runNum Run number being used.
*/
DataReader::DataReader( const uint nCh, const uint nSamp,
......@@ -83,18 +83,19 @@ DataReader::~DataReader(){
/** @brief Adds an analysis to vector of analysis
*
* @param1 Pointer to an Analysis.
* @param ana Pointer to an Analysis.
*
* @return none
*/
void DataReader::AddAnalysis( Analysis* ana ){
ana->SetVerbosity( m_verbose );
m_ana.push_back( ana );
}
/** @brief Enables the read from list of files option for DataReader
*
* @param1 name of the list of files to be processed (with the full path if it's not in the execution folder)
* @param listname name of the list of files to be processed (with the full path if it's not in the execution folder)
*
* @return none
*/
......@@ -170,7 +171,6 @@ void DataReader::LoadConfigurationFile(std::string _inFile ){
//Discard entries for any channel that does not apply to our run
if(m_runNumber < first_run || m_runNumber > last_run) continue;
//If the entry applies, we store it in the vector
m_XMLparser->getChildValue("channel",i,"detector",buffer_ch->detector);
m_XMLparser->getChildValue("channel",i,"name",buffer_ch->name);
......@@ -182,7 +182,14 @@ void DataReader::LoadConfigurationFile(std::string _inFile ){
m_XMLparser->getChildValue("channel",i,"is_on",buffer_ch->is_on);
m_XMLparser->getChildValue("channel",i,"Vop",buffer_ch->Vop);
channelEntries.push_back(buffer_ch);
bool isNew(true);
for( int k = 0; k < channelEntries.size(); k++){
if(buffer_ch->name == channelEntries.at(k)->name){
std::cout << "WARNING!!! Redundancy in your settings file for " << buffer_ch->name << ". Check it carefully. The second entry found will be skipped..." << std::endl;
isNew = false;
}
}
if(isNew) channelEntries.push_back(buffer_ch);
}
std::cout << "Loaded " << channelEntries.size() << " configuration entries " << std::endl;
......@@ -221,12 +228,43 @@ Detector* DataReader::GetDetector( std::string _detName ){
}
/** @brief Console output update
* @return none
*
* Called by the TTimer in ProcessEvents
* Updates the console with CPU and RAM usage,
* number of events processed and events/second
* if verbosity is not zero
*/
void DataReader::UpdateConsole( Long_t _updateRate){
if( m_verbose == 0 ){ return; }
if(m_event!=0){
MemInfo_t memInfo;
CpuInfo_t cpuInfo;
// Get CPU information
gSystem->GetCpuInfo(&cpuInfo, 100);
// Get Memory information
gSystem->GetMemInfo(&memInfo);
// Get events/second
double rate = 1000*(m_event-m_event_old)/_updateRate;
m_event_old = m_event;
std::cout << "\r" << std::left << Form("Processed %d events, ", m_event);
std::cout << Form( "%4.1f ev/s, ", rate);
std::cout << Form( "CPU: %d", (int)cpuInfo.fTotal) << "%, ";
std::cout << Form( "RAM:%4.1f/%4.1fGB ", (double)memInfo.fMemUsed/1024, (double)memInfo.fMemTotal/1024);
std::cout << std::flush;
}
}
/** @brief Run method for DataReader
* @return none
*
* Call Initialize, ProcessEvents, and Finalize
* Made so the driver class only has to call one method.
*
* @return none
*/
void DataReader::Run(){
......@@ -294,24 +332,6 @@ void DataReader::Initialize(){
* @return none
*/
void DataReader::ProcessEvents(){
TCanvas *canvas = new TCanvas( "Diff Demo", "Diff Demo", 200, 10, 1000, 600);
TPad *pad = new TPad("pad", "pad",0.15,0.11,0.85,0.79);
canvas->Divide(4,2);
// Processed Raw data to read in as vector of vectors size NxM
// Where N = nCh and M = nSamples per channel.
std::vector< std::vector< float > > vWF;
std::vector< std::vector< float >* > pvWF;
// Histograms (N of them) for the raw waveforms from each event.
// They will go to AnalyzeEvent for processing
std::vector< TH1* > vWFH;
// Resize these to be of size nCh.
vWF .resize( m_nCh );
pvWF.resize( m_nCh );
vWFH.resize( m_nCh );
/** TODO : add reading for list of files
* Please note that many of the implementations are now for a single-file treatment
......@@ -330,63 +350,31 @@ void DataReader::ProcessEvents(){
m_detectors.at(detID)->DeclareHistograms();
}
// Connect raw data to tree. For the moment, the only reading implemented is the raw data from each channel.
// Other items should be implemented in the same way if needed.
// Also create the histograms to fill
for( uint ch = 0; ch < m_nCh; ch++ ){
//Example - here we retrieve the already processed waveform (M.Phipps approach during the data production)
pvWF[ ch ] = &vWF[ ch ];
tree->SetBranchAddress( Form( "C%d", ch ), &pvWF[ ch ] );
vWFH[ ch ] = new TH1D( Form( "hWF%d", ch ), Form( "hWF%d;samp;amp", ch ), m_nSamp, 0, m_nSamp );
}
std::cout << "File: " << m_fIn->GetName() << " has " << tree->GetEntries() << " events." << std::endl;
// !! EVENT LOOP
for( int ev = 0; ev < tree->GetEntries(); ev++ ){
m_event = ev;
// Uncomment to run a few events at a time
if(ev==8) break;
// Uncomment to run a single event
//if(ev!=8) continue;
tree->GetEntry( ev );
// 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
for( uint samp = 0; samp < m_nSamp; samp++ ){
vWFH[ ch ]->SetBinContent( samp + 1, vWF[ ch ][ samp ] );
} // End loop over samples in each channel
} // End loop over channels
// 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(), canvas->cd() );
//ana->AnalyzeEvent( rpd->GetChannelsVector() );
ana->AnalyzeEvent( rpd->GetChannelsVector(), canvas->cd(ev+1) );
//already processed wf analysis
//ana->AnalyzeEvent( vWFH );
//ana->AnalyzeEvent( vWF );
ana->AnalyzeEvent( zdc1->GetChannelsVector(), zdc1->GetChannelsVector().at(0)->detector );
ana->AnalyzeEvent( zdc2->GetChannelsVector(), zdc1->GetChannelsVector().at(0)->detector );
ana->AnalyzeEvent( rpd->GetChannelsVector(), rpd->GetChannelsVector().at(0)->detector );
}
} // End event loop
pad->Update();
canvas->Draw();
canvas->Print( "Output.pdf" );
for( auto& h : vWFH ){ delete h; }
}
/** @brief Finalize method for DataReader
......
......@@ -27,6 +27,9 @@ Detector::~Detector( ){
}
/** @brief Get the properties of a detector element
* @param row Row of element to be accessed
* @param column Column of element to be accessed
* @return Pointer to the Channel of the requested element
*
* Returns a pointer to the Channel stored in m_Elements with the
* requested row and column.
......@@ -80,7 +83,9 @@ void Detector::SetBranches( TTree *_dataTree ){
void Detector::DeclareHistograms(){
for( uint ch = 0; ch < m_Element.size(); ch++ ){
m_Element.at(ch)->WF_histo = new TH1D(m_Element.at(ch)->name.c_str(), (m_Element.at(ch)->name + ", " + m_Element.at(ch)->detector).c_str(), m_nSamp, 0, m_nSamp);
m_Element.at(ch)->WF_histo = new TH1D( m_Element.at(ch)->name.c_str(), (m_Element.at(ch)->name + ", " + m_Element.at(ch)->detector).c_str(), m_nSamp, 0, m_nSamp);
m_Element.at(ch)->PWF_histo = new TH1D((m_Element.at(ch)->name + " Processed").c_str(), (m_Element.at(ch)->name + ", " + m_Element.at(ch)->detector + " Processed").c_str() , m_nSamp, 0, m_nSamp);
m_Element.at(ch)->FirstDerivative = new TH1D((m_Element.at(ch)->name + " Derivative").c_str(), (m_Element.at(ch)->name + ", " + m_Element.at(ch)->detector + " Derivative").c_str(), m_nSamp, 0, m_nSamp);
}
}
......@@ -91,6 +96,10 @@ void Detector::DeclareHistograms(){
void Detector::FillHistograms(){
for( uint ch = 0; ch < m_Element.size(); ch++ ){
m_Element.at(ch)->WF_histo->Reset();
m_Element.at(ch)->PWF_histo->Reset();
m_Element.at(ch)->FirstDerivative->Reset();
m_Element.at(ch)->FirstDerivativeRMS = 0;
m_Element.at(ch)->CrossZeroPoints.clear();
// Loop over samples in each channel
for( uint samp = 0; samp < m_nSamp; samp++ ){
m_Element.at(ch)->WF_histo->SetBinContent( samp + 1, m_Element.at(ch)->WF[ samp ] );
......
/** @file EventTimer.cxx
* @brief Implementation of EventTimer.
*
* Function definitions for EventTimer are provided.
* This class is a reimplementation of TTimer with
* a new notify method for JZCaPA
*
* @author Chad Lantz
* @bug No known bugs.
*/
#include "EventTimer.h"
/** @brief Default constructor for EventTimer
*
*/
EventTimer::EventTimer( ) : TTimer( ){
}
/** @brief Custom constructor for EventTimer
*
* Makes a TTimer and sets the object member of EventTimer
*/
EventTimer::EventTimer(Long_t milliSec, DataReader* obj, Bool_t mode)
: TTimer(milliSec, mode){
m_object = obj;
m_rate = milliSec;
}
/** @brief Default destructor for EventTimer
*
*/
EventTimer::~EventTimer(){
}
/** @brief Notify when timer times out.
*
* Calls the update method from the object pointer
* The timer is always reset. To stop the timer
* call TurnOff().
*/
Bool_t EventTimer::Notify(){
Timeout(); // emit Timeout() signal
if (m_object) m_object->UpdateConsole( m_rate );
Reset();
return kTRUE;
}
\ No newline at end of file
......@@ -21,6 +21,10 @@ 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
*
* Creates a new RPD type Detector and picks the relevant Channels from the input vector.
*
*/
RPD::RPD( std::vector < Channel* > _readOut){
......@@ -47,6 +51,9 @@ RPD::~RPD( ){
}
/** @brief Get the properties of a detector element
* @param row Row of element to be accessed
* @param column Column of element to be accessed
* @return Pointer to the Channel of the requested element
*
* If m_SortedElements is populated, return the element in
* m_SortedElements[row][column].
......
/** @file Visualizer.cpp
* @brief Implementation of Visualizer class.
*
*
* @author Riccardo Longo
* @bug No known bugs.
*/
#include <TH1.h>
#include <TH2.h>
#include <TROOT.h>