Commit 28715fc7 authored by Dominik Smith's avatar Dominik Smith
Browse files

Cleanup.

parent 51dc916c
......@@ -221,9 +221,6 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice =
<< "building using ``Real2019'' option. Terminating macro." << std::endl;
return;
}
// Remove STS as it will be our reference
evBuildRaw->RemoveDetector(kEventBuilderDetSts);
// Set STS as reference detector
evBuildRaw->SetReferenceDetector(kEventBuilderDetSts);
evBuildRaw->SetTsParameters(0.0, 1.e7, 0.0);
......@@ -256,9 +253,6 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice =
<< "building using ``Real2019'' option. Terminating macro." << std::endl;
return;
}
// Remove STS as it will be our reference
evBuildRaw->RemoveDetector(kRawEventBuilderDetSts);
// Set STS as reference detector
evBuildRaw->SetReferenceDetector(kRawEventBuilderDetSts);
evBuildRaw->SetTsParameters(0.0, 1.e7, 0.0);
......
......@@ -49,22 +49,23 @@ enum class EOverlapModeRaw
class RawEventBuilderDetector {
public:
RawEventBuilderDetector() { ; }
RawEventBuilderDetector() = default;
RawEventBuilderDetector(ECbmModuleId detIdIn, ECbmDataType dataTypeIn, std::string sNameIn)
: detId {detIdIn}
, dataType {dataTypeIn}
, sName {sNameIn}
{
detId = detIdIn;
dataType = dataTypeIn;
sName = sNameIn;
}
RawEventBuilderDetector(ECbmModuleId detIdIn, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn,
Int_t iTriggerMaxDigisIn, Double_t fdTimeWinBegIn, Double_t fdTimeWinEndIn)
: RawEventBuilderDetector(detIdIn, dataTypeIn, sNameIn)
{
fuTriggerMinDigis = uTriggerMinDigisIn;
fiTriggerMaxDigis = iTriggerMaxDigisIn;
fdTimeWinBeg = fdTimeWinBegIn;
fdTimeWinEnd = fdTimeWinEndIn;
fdTimeWinBeg = fdTimeWinBegIn;
fdTimeWinEnd = fdTimeWinEndIn;
}
bool operator==(const RawEventBuilderDetector& other) const { return (other.detId == this->detId); }
......@@ -83,7 +84,6 @@ public:
/// Selection Window
Double_t fdTimeWinBeg = -100;
Double_t fdTimeWinEnd = 100;
/// Book-keeping variables
UInt_t fuStartIndex = 0;
UInt_t fuEndIndex = 0;
......@@ -110,13 +110,13 @@ static const RawEventBuilderDetector kRawEventBuilderDetUndef = RawEventBuilderD
class CbmAlgoBuildRawEvents {
public:
/** Default constructor **/
CbmAlgoBuildRawEvents();
CbmAlgoBuildRawEvents() = default;
CbmAlgoBuildRawEvents(const CbmAlgoBuildRawEvents&) = delete;
CbmAlgoBuildRawEvents operator=(const CbmAlgoBuildRawEvents&) = delete;
/** Destructor **/
~CbmAlgoBuildRawEvents();
~CbmAlgoBuildRawEvents() {};
/** Initiliazation at the beginning of a run **/
Bool_t InitAlgo();
......@@ -142,7 +142,6 @@ public:
void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal);
void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal);
void SetTriggerWindow(ECbmModuleId selDet, Double_t dWinBeg, Double_t dWinEnd);
void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
......@@ -191,6 +190,7 @@ private:
/// Internal methods
Bool_t CheckDataAvailable(RawEventBuilderDetector& det);
void InitTs();
void InitSeedWindow();
void BuildEvents();
void CreateHistograms();
......@@ -199,8 +199,11 @@ private:
template<class DigiSeed>
void LoopOnSeeds();
void CheckSeed(Double_t dSeedTime, UInt_t uSeedDigiIdx);
void CheckTriggerCondition(Double_t dSeedTime);
template<class DigiCheck>
void SearchMatches(Double_t dSeedTime, RawEventBuilderDetector& detMatch);
void SearchMatches(Double_t dSeedTime, RawEventBuilderDetector& detMatch);
void AddDigiToEvent(RawEventBuilderDetector& det, Int_t uIdx);
Bool_t HasTrigger(CbmEvent*);
Bool_t CheckTriggerConditions(CbmEvent* event, RawEventBuilderDetector& det);
......@@ -232,6 +235,9 @@ private:
Double_t fdEarliestTimeWinBeg = kdDefaultTimeWinBeg;
Double_t fdLatestTimeWinEnd = kdDefaultTimeWinEnd;
Double_t fdWidestTimeWinRange = kdDefaultTimeWinEnd - kdDefaultTimeWinBeg;
///Seed window
Double_t fdSeedWindowBeg = 0;
Double_t fdSeedWindowEnd = 0;
Double_t fdTsStartTime = -1;
Double_t fdTsLength = -1;
......
......@@ -7,7 +7,6 @@
********************************************************************************/
#include "CbmTaskBuildRawEvents.h"
#include "CbmAlgoBuildRawEvents.h"
#include "CbmDigiManager.h"
#include "CbmEvent.h"
......@@ -21,23 +20,16 @@
#include "THttpServer.h"
#include <TFile.h>
// ---- Default constructor -------------------------------------------
CbmTaskBuildRawEvents::CbmTaskBuildRawEvents() : FairTask("CbmTaskBuildRawEvents")
{
/// Create Algo. To be made generic/switchable when more event building algo are available!
fpAlgo = new CbmAlgoBuildRawEvents();
}
// ---- Destructor ----------------------------------------------------
CbmTaskBuildRawEvents::~CbmTaskBuildRawEvents() {}
// ---- Initialisation ----------------------------------------------
void CbmTaskBuildRawEvents::SetParContainers()
{
/// Nothing to do
}
void CbmTaskBuildRawEvents::SetParContainers() {}
// ---- Init ----------------------------------------------------------
InitStatus CbmTaskBuildRawEvents::Init()
{
/// Get a handle from the IO manager
......@@ -113,7 +105,6 @@ InitStatus CbmTaskBuildRawEvents::Init()
/// Register output array (CbmEvent)
fEvents = new TClonesArray("CbmEvent", 100);
ioman->Register("CbmEvent", "Cbm_Event", fEvents, IsOutputBranchPersistent("CbmEvent"));
if (!fEvents) LOG(fatal) << "Output branch was not created";
/// Call Algo Init method
......@@ -122,10 +113,8 @@ InitStatus CbmTaskBuildRawEvents::Init()
return kFATAL;
}
// ---- ReInit -------------------------------------------------------
InitStatus CbmTaskBuildRawEvents::ReInit() { return kSUCCESS; }
// ---- Exec ----------------------------------------------------------
void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
{
LOG(debug2) << "CbmTaskBuildRawEvents::Exec => Starting sequence";
......@@ -135,7 +124,7 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fStsDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kSts); i++) {
const CbmStsDigi* Digi = fDigiMan->Get<CbmStsDigi>(i);
fStsDigis->insert(fStsDigis->begin() + i, *Digi);
fStsDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fStsDigis->size() << " STS digis.";
LOG(debug) << "In DigiManager: " << fDigiMan->GetNofDigis(ECbmModuleId::kSts) << " STS digis.";
......@@ -147,7 +136,7 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fMuchBeamTimeDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kMuch); i++) {
const CbmMuchBeamTimeDigi* Digi = fDigiMan->Get<CbmMuchBeamTimeDigi>(i);
fMuchBeamTimeDigis->insert(fMuchBeamTimeDigis->begin() + i, *Digi);
fMuchBeamTimeDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fDigiMan->GetNofDigis(ECbmModuleId::kMuch) << " MUCH digis.";
LOG(debug) << "In DigiManager: " << fMuchBeamTimeDigis->size() << " MUCH digis.";
......@@ -156,7 +145,7 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fMuchDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kMuch); i++) {
const CbmMuchDigi* Digi = fDigiMan->Get<CbmMuchDigi>(i);
fMuchDigis->insert(fMuchDigis->begin() + i, *Digi);
fMuchDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fDigiMan->GetNofDigis(ECbmModuleId::kMuch) << " MUCH digis.";
LOG(debug) << "In DigiManager: " << fMuchDigis->size() << " MUCH digis.";
......@@ -168,7 +157,7 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fTrdDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kTrd); i++) {
const CbmTrdDigi* Digi = fDigiMan->Get<CbmTrdDigi>(i);
fTrdDigis->insert(fTrdDigis->begin() + i, *Digi);
fTrdDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fDigiMan->GetNofDigis(ECbmModuleId::kTrd) << " TRD digis.";
LOG(debug) << "In DigiManager: " << fTrdDigis->size() << " TRD digis.";
......@@ -179,7 +168,7 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fTofDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kTof); i++) {
const CbmTofDigi* Digi = fDigiMan->Get<CbmTofDigi>(i);
fTofDigis->insert(fTofDigis->begin() + i, *Digi);
fTofDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fDigiMan->GetNofDigis(ECbmModuleId::kTof) << " TOF digis.";
LOG(debug) << "In DigiManager: " << fTofDigis->size() << " TOF digis.";
......@@ -190,7 +179,7 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fRichDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kRich); i++) {
const CbmRichDigi* Digi = fDigiMan->Get<CbmRichDigi>(i);
fRichDigis->insert(fRichDigis->begin() + i, *Digi);
fRichDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fDigiMan->GetNofDigis(ECbmModuleId::kRich) << " RICH digis.";
LOG(debug) << "In DigiManager: " << fRichDigis->size() << " RICH digis.";
......@@ -201,12 +190,11 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
fPsdDigis->clear();
for (Int_t i = 0; i < fDigiMan->GetNofDigis(ECbmModuleId::kPsd); i++) {
const CbmPsdDigi* Digi = fDigiMan->Get<CbmPsdDigi>(i);
fPsdDigis->insert(fPsdDigis->begin() + i, *Digi);
fPsdDigis->push_back(*Digi);
}
LOG(debug) << "Read: " << fDigiMan->GetNofDigis(ECbmModuleId::kPsd) << " PSD digis.";
LOG(debug) << "In DigiManager: " << fPsdDigis->size() << " PSD digis.";
}
/// Call Algo ProcessTs method
fpAlgo->ProcessTs();
......@@ -215,17 +203,13 @@ void CbmTaskBuildRawEvents::Exec(Option_t* /*option*/)
LOG(debug2) << "CbmTaskBuildRawEvents::Exec => Done";
}
// ---- Finish --------------------------------------------------------
void CbmTaskBuildRawEvents::Finish()
{
if (fbFillHistos) { SaveHistos(); } // if( fbFillHistos )
/// Call Algo finish method
fpAlgo->Finish();
if (fbFillHistos) { SaveHistos(); }
}
//----------------------------------------------------------------------
void CbmTaskBuildRawEvents::FillOutput()
{
/// Clear TClonesArray before usage.
......@@ -239,12 +223,11 @@ void CbmTaskBuildRawEvents::FillOutput()
LOG(debug) << "Vector: " << event->ToString();
new ((*fEvents)[fEvents->GetEntriesFast()]) CbmEvent(std::move(*event));
LOG(debug) << "TClonesArray: " << static_cast<CbmEvent*>(fEvents->At(fEvents->GetEntriesFast() - 1))->ToString();
} // for( CbmEvent* event: vEvents )
}
/// Clear event vector after usage
fpAlgo->ClearEventVector();
}
//----------------------------------------------------------------------
void CbmTaskBuildRawEvents::SaveHistos()
{
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
......@@ -262,75 +245,19 @@ void CbmTaskBuildRawEvents::SaveHistos()
/// 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();
const 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 CbmTaskBuildRawEvents::SetFillHistos(Bool_t bFlag)
{
fbFillHistos = bFlag;
if (nullptr != fpAlgo) fpAlgo->SetFillHistos(fbFillHistos);
}
void CbmTaskBuildRawEvents::SetOutFilename(TString sNameIn) { fsOutFileName = sNameIn; }
void CbmTaskBuildRawEvents::SetReferenceDetector(RawEventBuilderDetector refDet)
{
if (nullptr != fpAlgo) fpAlgo->SetReferenceDetector(refDet);
}
void CbmTaskBuildRawEvents::AddDetector(RawEventBuilderDetector selDet)
{
if (nullptr != fpAlgo) fpAlgo->AddDetector(selDet);
}
void CbmTaskBuildRawEvents::RemoveDetector(RawEventBuilderDetector selDet)
{
if (nullptr != fpAlgo) fpAlgo->RemoveDetector(selDet);
}
void CbmTaskBuildRawEvents::SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal)
{
if (nullptr != fpAlgo) fpAlgo->SetTriggerMinNumber(selDet, uVal);
}
void CbmTaskBuildRawEvents::SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal)
{
if (nullptr != fpAlgo) fpAlgo->SetTriggerMaxNumber(selDet, iVal);
}
void CbmTaskBuildRawEvents::SetTriggerWindow(ECbmModuleId det, Double_t dWinBeg, Double_t dWinEnd)
{
if (nullptr != fpAlgo) fpAlgo->SetTriggerWindow(det, dWinBeg, dWinEnd);
}
void CbmTaskBuildRawEvents::SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
{
if (nullptr != fpAlgo) fpAlgo->SetTsParameters(dTsStartTime, dTsLength, dTsOverLength);
}
void CbmTaskBuildRawEvents::SetEventOverlapMode(EOverlapModeRaw mode)
{
if (nullptr != fpAlgo) fpAlgo->SetEventOverlapMode(mode);
}
void CbmTaskBuildRawEvents::SetIgnoreTsOverlap(Bool_t bFlagIn)
{
if (nullptr != fpAlgo) fpAlgo->SetIgnoreTsOverlap(bFlagIn);
}
void CbmTaskBuildRawEvents::ChangeMuchBeamtimeDigiFlag(Bool_t bFlagIn)
{
if (nullptr != fpAlgo) fpAlgo->ChangeMuchBeamtimeDigiFlag(bFlagIn);
fbUseMuchBeamtimeDigi = bFlagIn;
}
//----------------------------------------------------------------------
ClassImp(CbmTaskBuildRawEvents)
......@@ -14,6 +14,7 @@
/// FAIRSOFT headers (geant, boost, ...)
/// C/C++ headers
#include "CbmAlgoBuildRawEvents.h"
#include "CbmMuchBeamTimeDigi.h"
#include "CbmMuchDigi.h"
#include "CbmPsdDigi.h"
......@@ -30,7 +31,6 @@
#include <vector>
class CbmDigiManager;
class CbmAlgoBuildRawEvents;
class RawEventBuilderDetector;
class TClonesArray;
......@@ -47,18 +47,15 @@ public:
/** Constructor with parameters (Optional) **/
// CbmTaskBuildRawEvents(Int_t verbose);
/** Destructor **/
~CbmTaskBuildRawEvents();
/** 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*);
......@@ -68,24 +65,55 @@ public:
/** Finish task called at the end of the run **/
virtual void Finish();
void SetFillHistos(Bool_t bFlag = kTRUE);
void SetOutFilename(TString sNameIn);
void SetReferenceDetector(RawEventBuilderDetector refDet);
void AddDetector(RawEventBuilderDetector selDet);
void RemoveDetector(RawEventBuilderDetector selDet);
void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal);
void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal);
void SetTriggerWindow(ECbmModuleId det, Double_t dWinBeg, Double_t dWinEnd);
void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength);
void SetEventOverlapMode(EOverlapModeRaw mode);
void SetIgnoreTsOverlap(Bool_t bFlagIn);
void ChangeMuchBeamtimeDigiFlag(Bool_t bFlagIn = kFALSE);
/** Setters **/
void SetOutFilename(TString sNameIn) { fsOutFileName = sNameIn; }
void SetFillHistos(Bool_t bFlag = kTRUE)
{
fbFillHistos = bFlag;
if (nullptr != fpAlgo) fpAlgo->SetFillHistos(fbFillHistos);
}
void SetReferenceDetector(RawEventBuilderDetector refDet)
{
if (nullptr != fpAlgo) fpAlgo->SetReferenceDetector(refDet);
}
void AddDetector(RawEventBuilderDetector selDet)
{
if (nullptr != fpAlgo) fpAlgo->AddDetector(selDet);
}
void RemoveDetector(RawEventBuilderDetector selDet)
{
if (nullptr != fpAlgo) fpAlgo->RemoveDetector(selDet);
}
void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal)
{
if (nullptr != fpAlgo) fpAlgo->SetTriggerMinNumber(selDet, uVal);
}
void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal)
{
if (nullptr != fpAlgo) fpAlgo->SetTriggerMaxNumber(selDet, iVal);
}
void SetTriggerWindow(ECbmModuleId det, Double_t dWinBeg, Double_t dWinEnd)
{
if (nullptr != fpAlgo) fpAlgo->SetTriggerWindow(det, dWinBeg, dWinEnd);
}
void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
{
if (nullptr != fpAlgo) fpAlgo->SetTsParameters(dTsStartTime, dTsLength, dTsOverLength);
}
void SetEventOverlapMode(EOverlapModeRaw mode)
{
if (nullptr != fpAlgo) fpAlgo->SetEventOverlapMode(mode);
}
void SetIgnoreTsOverlap(Bool_t bFlagIn)
{
if (nullptr != fpAlgo) fpAlgo->SetIgnoreTsOverlap(bFlagIn);
}
void ChangeMuchBeamtimeDigiFlag(Bool_t bFlagIn = kFALSE)
{
if (nullptr != fpAlgo) fpAlgo->ChangeMuchBeamtimeDigiFlag(bFlagIn);
fbUseMuchBeamtimeDigi = bFlagIn;
}
private:
void FillOutput();
......
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