Commit b734dd89 authored by Riccardo Longo's avatar Riccardo Longo
Browse files

Pushing work on Scintillators - not completed - to be picked up

parent 1d886740
/** @file ZDCAnalysis2021
* @brief Function prototypes for ZDCAnalysis2021
*
* This contains the prototypes and members
* for ScintillatorsAnalysis in 2021 test beam
*
* @author Riccardo Longo
* @bug No known bugs.
*/
#ifndef SCINTILLATORSANALYSIS2021_H
#define SCINTILLATORSANALYSIS2021_H
#include "Analysis.h"
#include "TH2D.h"
#include "Containers.h"
#include "Detector.h"
class ScintillatorsAnalysis2021 : public Analysis{
public :
ScintillatorsAnalysis2021( );
virtual ~ScintillatorsAnalysis2021( );
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 ( );
//Histograms
private :
/** Pointer to the Large Horizontal Scintillator (Trigger) */
Detector *m_scintillatorLH = 0;
/** Pointer to the second Scintillators module */
Detector *m_scintillatorLV = 0;
/** Pointer to the third Scintillators module */
Detector *m_scintillatorSH = 0;
/** Pointer to the third Scintillators module */
Detector *m_scintillatorSV = 0;
/** Pointer to the LV channel */
Channel* m_sciLV = 0;
/** Pointer to the LH channel */
Channel* m_sciLH = 0;
/** Pointer to the SV channel */
Channel* m_sciSV = 0;
/** Pointer to the SH channel */
Channel* m_sciSH = 0;
};
#endif
/** @ingroup ana
* @file Scintillators.cpp
* @brief Implementation of Scintillators.
*
* Function definitions for Scintillators are provided.
* This is a daughter class of Detector.
* Methods specific to Scintillatorss are implemented here.
*
* @author Riccardo Longo
* @bug No known bugs.
*/
#include "Scintillators.h"
/** @brief Default Constructor for Scintillators.
*/
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.
*
*/
Scintillators::Scintillators( std::vector < Channel* > _readOut, int _runNumber ){
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;
}
/** @brief Destructor for Scintillators.
*/
Scintillators::~Scintillators( ){
}
Channel* Scintillators::GetScintillator( std::string _scintillatorID ){
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
Channel *c = GetElement(i, j);
if( FindPaddleType( c ) == _scintillatorID)
return c;
}
}
std::cout << "ERROR! Scintillator " << _scintillatorID << " not found " << std::endl;
}
/** @brief From channel returns the Scintillator ID **/
std::string Scintillators::FindPaddleType( Channel *c ){
if(c->mapping_row == 1 && c->mapping_column == 1)
return "LV";
if(c->mapping_row == 1 && c->mapping_column == 2)
return "LH";
if(c->mapping_row == 2 && c->mapping_column == 1)
return "SV";
if(c->mapping_row == 2 && c->mapping_column == 2)
return "SH";
}
/** @brief Prints a map of the Scintillators to the terminal
*
* Prints a "map" of the Scintillators.
* Displays one element with Scintillators number on the top line, DRS4
* Channel on the second line, and if the element is functioning on the
* third line.
*
*/
void Scintillators::PrintMap(){
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
Channel *c = GetElement(i, j);
std::cout<<"| " << FindPaddleType(c) <<" |"<<std::endl;
std::cout<<"| " << c->name <<" |"<<std::endl;
std::cout<<"| |"<< std::endl;
std::cout<<"|_______|"<< std::endl;
}
}
}
/** @ingroup ana
* @file ScintillatorsAnalysis2021.cpp
* @brief Implementation of ScintillatorsAnalysis2021.
*
*
* Function definitions for ScintillatorsAnalysis2021 are provided.
* This class is the main class for the trigger scintillator analysis in 2021 test beam.
* Four scintillators in total are readout. The two large scintillators (LV and LH) provides trigger with their coincidence.
* The two smaller scintillators (SH and SV)
* @author Riccardo Longo
* @bug No known bugs.
*/
#include "ScintillatorsAnalysis2021.h"
#include "Scintillators.h"
#include "Containers.h"
#include "TH2D.h"
#include "TH1.h"
#include "TCanvas.h"
#include "Visualizer.h"
/** @brief Default Constructor for ScintillatorsAnalysis2021.
*/
ScintillatorsAnalysis2021::ScintillatorsAnalysis2021( ){
}
/** @brief Destructor for ScintillatorsAnalysis2021.
*/
ScintillatorsAnalysis2021::~ScintillatorsAnalysis2021( ){
}
/** @brief Initialization method for ScintillatorsAnalysis2021
*
* Can add other things here that you would
* perhaps not put into the constructor.
* I.e. a TTree, some tools. Etc.
*
*/
void ScintillatorsAnalysis2021::Initialize( ){
}
/** @brief Initialization method for ScintillatorsAnalysis2021
*
* Takes a vector of detectors, picks out the Scintillatorss
* and assigns them to member pointers
*
*/
void ScintillatorsAnalysis2021::Initialize( std::vector < Detector* > _vDet ){
std::cout << "======================= Beginning of ScintillatorsAnalysis2021 =======================" << std::endl;
for( auto& det : _vDet ){
if( det->GetChannelsVector().at(0)->detector == "TRIGGER"
&& det->GetChannelsVector()[0]->mapping_row == 1
&& det->GetChannelsVector()[0]->mapping_column == 1){
m_scintillatorLV = (Scintillators*)det;
m_sciLV = det->GetElement(1,1);
}
if( det->GetChannelsVector().at(0)->detector == "TRIGGER"
&& det->GetChannelsVector()[0]->mapping_row == 1
&& det->GetChannelsVector()[0]->mapping_column == 2){
m_scintillatorLH = (Scintillators*)det;
m_sciLH = det->GetElement(1,2);
}
if( det->GetChannelsVector().at(0)->detector == "TRIGGER"
&& det->GetChannelsVector()[0]->mapping_row == 2
&& det->GetChannelsVector()[0]->mapping_column == 1){
m_scintillatorSV = (Scintillators*)det;
m_sciSV = det->GetElement(2,1);
}
if( det->GetChannelsVector().at(0)->detector == "TRIGGER"
&& det->GetChannelsVector()[0]->mapping_row == 2
&& det->GetChannelsVector()[0]->mapping_column == 2){
m_scintillatorSH = (Scintillators*)det;
m_sciSH = det->GetElement(2,2);
}
}
m_alignment = m_scintillatorLH->GetAlignment();
}
/** @brief Historgam Setup method for ScintillatorsAnalysis2021
*
* Should instantiate any histograms you wish to output here.
*
* @return none
*/
void ScintillatorsAnalysis2021::SetupHistograms( ){
}
/** @brief Branch setup method for ScintillatorsAnalysis2021
*
* Adds branches with data created by the analysis
*
*/
void ScintillatorsAnalysis2021::SetBranches( TTree* _tree ){
m_AnalysisTree = _tree;
//The tree output in this class is set to be equal to the one of the ZDC channels.
//Large Vertical scintillator
m_AnalysisTree->Branch("LV_Charge", &m_sciLV->Charge, "LV_Charge/D" );
m_AnalysisTree->Branch("LV_Peak_max", &m_sciLV->Peak_max, "LV_Peak_max/D" );
m_AnalysisTree->Branch("LV_Diff_max", &m_sciLV->Diff_max, "LV_Diff_max/D" );
m_AnalysisTree->Branch("LV_Peak_center", &m_sciLV->Peak_center, "LV_Peak_center/I" );
m_AnalysisTree->Branch("LV_Peak_time", &m_sciLV->Peak_time, "LV_Peak_time/D" );
m_AnalysisTree->Branch("LV_Diff_Peak_center", &m_sciLV->Diff_Peak_center, "LV_Diff_Peak_center/I" );
m_AnalysisTree->Branch("LV_Diff_Peak_time", &m_sciLV->Diff_Peak_time, "LV_Diff_Peak_time/D" );
m_AnalysisTree->Branch("LV_Ped_mean", &m_sciLV->PedMean, "LV_Ped_mean/D" );
//Large Horizontal Scintillator
m_AnalysisTree->Branch("LH_Charge", &m_sciLH->Charge, "LH_Charge/D" );
m_AnalysisTree->Branch("LH_Peak_max", &m_sciLH->Peak_max, "LH_Peak_max/D" );
m_AnalysisTree->Branch("LH_Diff_max", &m_sciLH->Diff_max, "LH_Diff_max/D" );
m_AnalysisTree->Branch("LH_Peak_center", &m_sciLH->Peak_center, "LH_Peak_center/I" );
m_AnalysisTree->Branch("LH_Peak_time", &m_sciLH->Peak_time, "LH_Peak_time/D" );
m_AnalysisTree->Branch("LH_Diff_Peak_center", &m_sciLH->Diff_Peak_center, "LH_Diff_Peak_center/I" );
m_AnalysisTree->Branch("LH_Diff_Peak_time", &m_sciLH->Diff_Peak_time, "LH_Diff_Peak_time/D" );
m_AnalysisTree->Branch("LH_Ped_mean", &m_sciLH->PedMean, "LH_Ped_mean/D" );
//Small Vertical Scintillator
m_AnalysisTree->Branch("SV_Charge", &m_sciSV->Charge, "SV_Charge/D" );
m_AnalysisTree->Branch("SV_Peak_max", &m_sciSV->Peak_max, "SV_Peak_max/D" );
m_AnalysisTree->Branch("SV_Diff_max", &m_sciSV->Diff_max, "SV_Diff_max/D" );
m_AnalysisTree->Branch("SV_Peak_center", &m_sciSV->Peak_center, "SV_Peak_center/I" );
m_AnalysisTree->Branch("SV_Peak_time", &m_sciSV->Peak_time, "SV_Peak_time/D" );
m_AnalysisTree->Branch("SV_Diff_Peak_center", &m_sciSV->Diff_Peak_center, "SV_Diff_Peak_center/I" );
m_AnalysisTree->Branch("SV_Diff_Peak_time", &m_sciSV->Diff_Peak_time, "SV_Diff_Peak_time/D" );
m_AnalysisTree->Branch("SV_Ped_mean", &m_sciSV->PedMean, "SV_Ped_mean/D" );
//Small Horizontal Scintillator
m_AnalysisTree->Branch("SH_Charge", &m_sciSH->Charge, "SH_Charge/D" );
m_AnalysisTree->Branch("SH_Peak_max", &m_sciSH->Peak_max, "SH_Peak_max/D" );
m_AnalysisTree->Branch("SH_Diff_max", &m_sciSH->Diff_max, "SH_Diff_max/D" );
m_AnalysisTree->Branch("SH_Peak_center", &m_sciSH->Peak_center, "SH_Peak_center/I" );
m_AnalysisTree->Branch("SH_Peak_time", &m_sciSH->Peak_time, "SH_Peak_time/D" );
m_AnalysisTree->Branch("SH_Diff_Peak_center", &m_sciSH->Diff_Peak_center, "SH_Diff_Peak_center/I" );
m_AnalysisTree->Branch("SH_Diff_Peak_time", &m_sciSH->Diff_Peak_time, "SH_Diff_Peak_time/D" );
m_AnalysisTree->Branch("SH_Ped_mean", &m_sciSH->PedMean, "SH_Ped_mean/D" );
}
/** @brief Analyze Events method for ScintillatorsAnalysis2021
*
*
*/
void ScintillatorsAnalysis2021::AnalyzeEvent( ){
}
/** @brief Finalize method for ScintillatorsAnalysis2021
*
*
*/
void ScintillatorsAnalysis2021::Finalize( ){
std::string output = std::getenv("JZCaPA");
output += "/results/";
TCanvas *c = new TCanvas("ScintillatorsAnalysis2021","ScintillatorsAnalysis2021",800,600);
if(m_viz == NULL) m_viz = new Visualizer( "ATLAS" );
/*
std::vector<TH1*> hist1D_vec;
std::vector<TH1*> hist2D_vec;
hist1D_vec.push_back(hCharge1); hist1D_vec.push_back(hCharge2); hist1D_vec.push_back(hCharge3);
m_viz->SimplePadsPlot( hist1D_vec, 3, 1, "Q_{ZDC} (pC)","Counts", "HAD[1-3]_Charge1D.png", "HAD", ""); hist1D_vec.clear();
c->cd();
m_viz->DrawPlot(hCharge,"Q_{m_sciLV} (pC)","Q_{ZDC2} (pC)","ZDC_charge.png","COLZ");//OUTDATED
*/
delete c;
}
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