Skip to content
Snippets Groups Projects
Commit 4939bc58 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Pierre-Alain Loizeau
Browse files

mCBM: add classes for generic Timing Checker Algo and Task

parent d0f2a773
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,9 @@ Set(SRCS
tasks/CbmMcbm2019CheckTimingPairs.cxx
tasks/CbmMcbm2019TimeWinEventBuilderAlgo.cxx
tasks/CbmMcbm2019TimeWinEventBuilderTask.cxx
tasks/CbmMcbmCheckTimingAlgo.cxx
tasks/CbmMcbmCheckTimingTask.cxx
)
If(_UINT8_T_EXIST)
......
......@@ -73,4 +73,7 @@
#pragma link C++ class CbmMcbm2019TimeWinEventBuilderAlgo + ;
#pragma link C++ class CbmMcbm2019TimeWinEventBuilderTask + ;
#pragma link C++ class CbmMcbmCheckTimingAlgo+;
#pragma link C++ class CbmMcbmCheckTimingTask+;
#endif
This diff is collapsed.
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef CBMMCBMCHECKTIMINGALGO_H
#define CBMMCBMCHECKTIMINGALGO_H
#include "TString.h"
#include "CbmModuleList.h"
#include <vector>
#include "CbmTofDigi.h"
class TH1;
class TH2;
class CbmDigiManager;
class CheckTimingDetector
{
public:
CheckTimingDetector() {;}
CheckTimingDetector( ECbmModuleId detIdIn, std::string sNameIn ) { detId = detIdIn; sName = sNameIn; }
/// Settings
ECbmModuleId detId = ECbmModuleId::kNotExist;
std::string sName = "Invalid";
Double_t dTimeRangeBeg = -1000.0;
Double_t dTimeRangeEnd = 1000.0;
UInt_t uRangeNbBins = 320;
UInt_t uChargeCutMin = 0; /// Charge cut used for example to reject/select pulser, no effect if equal, select if min < max, reject if max < min
UInt_t uChargeCutMax = 0; /// Charge cut used for example to reject/select pulser, no effect if equal, select if min < max, reject if max < min
/// Book-keeping variables
Double_t dPrevTime = 0.;
Int_t iPrevRefFirstDigi = 0;
};
class CbmMcbmCheckTimingAlgo
{
public:
CbmMcbmCheckTimingAlgo();
CbmMcbmCheckTimingAlgo(const CbmMcbmCheckTimingAlgo&) = delete;
CbmMcbmCheckTimingAlgo operator=(const CbmMcbmCheckTimingAlgo&) = delete;
/** Constructor with parameters (Optional) **/
// CbmMcbmCheckTimingAlgo(Int_t verbose);
/** Destructor **/
~CbmMcbmCheckTimingAlgo();
/** Initiliazation of task at the beginning of a run **/
Bool_t Init();
/** ReInitiliazation of task when the runID changes **/
Bool_t ReInit();
/** Executed for each event. **/
void ProcessTs();
/** Load the parameter container from the runtime database **/
void SetParContainers();
/** Finish task called at the end of the run **/
void Finish();
inline void SetOutFilename( TString sNameIn ) { fOutFileName = sNameIn; }
void WriteHistos();
void SetReferenceDetector( ECbmModuleId refDetIn, std::string sNameIn,
Double_t dTimeRangeBegIn = -1000.0, Double_t dTimeRangeEndIn = 1000.0,
UInt_t uRangeNbBinsIn = 320,
UInt_t uChargeCutMinIn = 0, UInt_t uChargeCutMaxIn = 0 );
void AddCheckDetector( ECbmModuleId detIn, std::string sNameIn,
Double_t dTimeRangeBegIn = -1000.0, Double_t dTimeRangeEndIn = 1000.0,
UInt_t uRangeNbBinsIn = 320,
UInt_t uChargeCutMinIn = 0, UInt_t uChargeCutMaxIn = 0 );
void RemoveCheckDetector( ECbmModuleId detIn );
private:
void CheckDataPresence( CheckTimingDetector detToCheck );
void CreateHistos();
template <class DigiRef> void CheckInterSystemOffset();
template <class Digi> void FillTimeOffsetHistos( const Double_t dRefTime,
const Double_t dRefCharge,
UInt_t uDetIdx );
/** Input array from previous already existing data level **/
CbmDigiManager* fDigiMan = nullptr; //!
/** T0 is not included in CbmDigiManager, so add it explicitly here **/
const std::vector< CbmTofDigi > * fpT0DigiVec = nullptr; //!
//
UInt_t fuNbTs = 0;
CheckTimingDetector fRefDet{ CheckTimingDetector( ECbmModuleId::kT0, "T0" ) };
std::vector< CheckTimingDetector > fvDets{ CheckTimingDetector( ECbmModuleId::kSts, "Sts" ),
CheckTimingDetector( ECbmModuleId::kMuch, "Much" ),
CheckTimingDetector( ECbmModuleId::kTrd, "Trd" ),
CheckTimingDetector( ECbmModuleId::kTof, "Tof" ),
CheckTimingDetector( ECbmModuleId::kRich, "Rich" ),
CheckTimingDetector( ECbmModuleId::kPsd, "Psd" ) };
/// vectors storing histograms for each detector under investigation
std::vector< TH1 * > fvhDetSelfDiff = {};
std::vector< TH1 * > fvhDetToRefDiff = {};
std::vector< TH2 * > fvhDetToRefDiffRefCharge = {};
std::vector< TH2 * > fvhDetToRefDiffDetCharge = {};
std::vector< TH2 * > fvhDetToRefDiffEvo = {};
std::vector< TH2 * > fvhDetToRefDiffEvoLong = {};
/** Name of the histogram output file **/
TString fOutFileName = "data/HistosCheckTiming.root";
ClassDef(CbmMcbmCheckTimingAlgo,1);
};
#endif
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "CbmMcbmCheckTimingTask.h"
/// CBM headers
/// FAIRROOT headers
#include "FairLogger.h"
/// FAIRSOFT headers (geant, boost, ...)
#include "TH2.h"
#include "TH1.h"
#include "THttpServer.h"
#include <TFile.h>
/// C/C++ headers
// ---- Default constructor -------------------------------------------
CbmMcbmCheckTimingTask::CbmMcbmCheckTimingTask()
: FairTask("CbmMcbmCheckTimingTask")
{
/// Create Algo. To be made generic/switchable when more event building algo are available!
fpAlgo = new CbmMcbmCheckTimingAlgo();
}
// ---- Destructor ----------------------------------------------------
CbmMcbmCheckTimingTask::~CbmMcbmCheckTimingTask()
{
}
// ---- Initialisation ----------------------------------------------
void CbmMcbmCheckTimingTask::SetParContainers()
{
/// Nothing to do
}
// ---- Init ----------------------------------------------------------
InitStatus CbmMcbmCheckTimingTask::Init()
{
/// Call Algo Init method
if( kTRUE == fpAlgo->Init() )
return kSUCCESS;
else return kFATAL;
}
// ---- ReInit -------------------------------------------------------
InitStatus CbmMcbmCheckTimingTask::ReInit()
{
return kSUCCESS;
}
// ---- Exec ----------------------------------------------------------
void CbmMcbmCheckTimingTask::Exec(Option_t* /*option*/)
{
LOG(debug2) << "CbmMcbmCheckTimingTask::Exec => Starting sequence";
/// Call Algo ProcessTs method
fpAlgo->ProcessTs();
LOG(debug2) << "CbmMcbmCheckTimingTask::Exec => Done";
}
// ---- Finish --------------------------------------------------------
void CbmMcbmCheckTimingTask::Finish()
{
// SaveHistos();
/// Call Algo finish method
fpAlgo->Finish();
}
//----------------------------------------------------------------------
void CbmMcbmCheckTimingTask::SaveHistos()
{
fpAlgo->WriteHistos();
/*
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector< std::pair< TNamed *, std::string > > vHistos = fpAlgo->GetHistoVector();
/// (Re-)Create ROOT file to store the histos
TDirectory * oldDir = NULL;
TFile * histoFile = NULL;
/// Store current directory position to allow restore later
oldDir = gDirectory;
/// open separate histo file in recreate mode
histoFile = new TFile( fsOutFileName , "RECREATE");
histoFile->cd();
/// Save all plots and create folders if needed
for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
{
/// Make sure we end up in chosen folder
TString sFolder = vHistos[ uHisto ].second.data();
if( nullptr == gDirectory->Get( sFolder ) )
gDirectory->mkdir( sFolder );
gDirectory->cd( sFolder );
/// Write plot
vHistos[ uHisto ].first->Write();
histoFile->cd();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Restore original directory position
oldDir->cd();
histoFile->Close();
*/
}
//----------------------------------------------------------------------
void CbmMcbmCheckTimingTask::SetOutFilename( TString sNameIn )
{
fsOutFileName = sNameIn;
fpAlgo->SetOutFilename( fsOutFileName );
}
//----------------------------------------------------------------------
void CbmMcbmCheckTimingTask::SetReferenceDetector( ECbmModuleId refDetIn, std::string sNameIn,
Double_t dTimeRangeBegIn, Double_t dTimeRangeEndIn,
UInt_t uRangeNbBinsIn,
UInt_t uChargeCutMinIn, UInt_t uChargeCutMaxIn )
{
fpAlgo->SetReferenceDetector( refDetIn, sNameIn,
dTimeRangeBegIn, dTimeRangeEndIn,
uRangeNbBinsIn,
uChargeCutMinIn, uChargeCutMaxIn );
}
void CbmMcbmCheckTimingTask::AddCheckDetector( ECbmModuleId detIn, std::string sNameIn,
Double_t dTimeRangeBegIn, Double_t dTimeRangeEndIn,
UInt_t uRangeNbBinsIn,
UInt_t uChargeCutMinIn, UInt_t uChargeCutMaxIn )
{
fpAlgo->AddCheckDetector( detIn, sNameIn,
dTimeRangeBegIn, dTimeRangeEndIn,
uRangeNbBinsIn,
uChargeCutMinIn, uChargeCutMaxIn );
}
void CbmMcbmCheckTimingTask::RemoveCheckDetector( ECbmModuleId detIn )
{
fpAlgo->RemoveCheckDetector( detIn );
}
//----------------------------------------------------------------------
ClassImp(CbmMcbmCheckTimingTask)
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef CBMMCBMCHECKTIMINGTASK_H
#define CBMMCBMCHECKTIMINGTASK_H
/// CBM headers
#include "CbmMcbmCheckTimingAlgo.h"
/// FAIRROOT headers
#include "FairTask.h"
/// FAIRSOFT headers (geant, boost, ...)
/// C/C++ headers
class TClonesArray;
class CbmMcbmCheckTimingTask : public FairTask
{
public:
/** Default constructor **/
CbmMcbmCheckTimingTask();
CbmMcbmCheckTimingTask(const CbmMcbmCheckTimingTask&) = delete;
CbmMcbmCheckTimingTask operator=(const CbmMcbmCheckTimingTask&) = delete;
/** Constructor with parameters (Optional) **/
// CbmMcbmCheckTimingTask(Int_t verbose);
/** Destructor **/
~CbmMcbmCheckTimingTask();
/** Initiliazation of task at the beginning of a run **/
virtual InitStatus Init();
/** ReInitiliazation of task when the runID changes **/
virtual InitStatus ReInit();
/** Executed for each event. **/
virtual void Exec(Option_t*);
/** Load the parameter container from the runtime database **/
virtual void SetParContainers();
/** Finish task called at the end of the run **/
virtual void Finish();
void SetOutFilename( TString sNameIn );
void SetReferenceDetector( ECbmModuleId refDetIn, std::string sNameIn,
Double_t dTimeRangeBegIn = -1000.0, Double_t dTimeRangeEndIn = 1000.0,
UInt_t uRangeNbBinsIn = 320,
UInt_t uChargeCutMinIn = 0, UInt_t uChargeCutMaxIn = 0 );
void AddCheckDetector( ECbmModuleId detIn, std::string sNameIn,
Double_t dTimeRangeBegIn = -1000.0, Double_t dTimeRangeEndIn = 1000.0,
UInt_t uRangeNbBinsIn = 320,
UInt_t uChargeCutMinIn = 0, UInt_t uChargeCutMaxIn = 0 );
void RemoveCheckDetector( ECbmModuleId detIn );
private:
void SaveHistos();
CbmMcbmCheckTimingAlgo * fpAlgo = nullptr;
/** Name of the histogram output file **/
TString fsOutFileName = "data/HistosCheckTiming.root";
ClassDef(CbmMcbmCheckTimingTask,1);
};
#endif // CBMMCBM2019TIMEWINEVENTBUILDERTASK_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment