CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2019TimeWinEventBuilderTask.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
6
7#include "CbmEvent.h"
8
9#include "FairRootManager.h"
10#include "FairRunOnline.h"
11#include <Logger.h>
12
13#include "TClonesArray.h"
14#include "TH1.h"
15#include "TH2.h"
16#include "THttpServer.h"
17#include <TDirectory.h>
18#include <TFile.h>
19
20// ---- Default constructor -------------------------------------------
22 : FairTask("CbmMcbm2019TimeWinEventBuilderTask")
23{
26}
27
28// ---- Destructor ----------------------------------------------------
30
31// ---- Initialisation ----------------------------------------------
36
37// ---- Init ----------------------------------------------------------
39{
41 FairRootManager* ioman = FairRootManager::Instance();
42
44 fEvents = new TClonesArray("CbmEvent", 100);
45 ioman->Register("CbmEvent", "Cbm_Event", fEvents, IsOutputBranchPersistent("CbmEvent"));
46
47 if (!fEvents) LOG(fatal) << "Output branch was not created";
48
50 if (kTRUE == fpAlgo->InitAlgo()) return kSUCCESS;
51 else
52 return kFATAL;
53}
54
55// ---- ReInit -------------------------------------------------------
56InitStatus CbmMcbm2019TimeWinEventBuilderTask::ReInit() { return kSUCCESS; }
57
58// ---- Exec ----------------------------------------------------------
60{
61 LOG(debug2) << "CbmMcbm2019TimeWinEventBuilderTask::Exec => Starting sequence";
64
66 FillOutput();
67 LOG(debug2) << "CbmMcbm2019TimeWinEventBuilderTask::Exec => Done";
68}
69
70
71// ---- Finish --------------------------------------------------------
73{
74 if (fbFillHistos) { SaveHistos(); } // if( fbFillHistos )
75
77 fpAlgo->Finish();
78}
79
80//----------------------------------------------------------------------
82{
84 fEvents->Delete();
85
87 std::vector<CbmEvent*> vEvents = fpAlgo->GetEventVector();
88
90 for (CbmEvent* event : vEvents) {
91 LOG(debug) << "Vector: " << event->ToString();
92 new ((*fEvents)[fEvents->GetEntriesFast()]) CbmEvent(std::move(*event));
93 LOG(debug) << "TClonesArray: " << static_cast<CbmEvent*>(fEvents->At(fEvents->GetEntriesFast() - 1))->ToString();
94 } // for( CbmEvent* event: vEvents )
95
98}
99//----------------------------------------------------------------------
101{
103 std::vector<std::pair<TNamed*, std::string>> vHistos = fpAlgo->GetHistoVector();
104
106 TFile* oldFile = gFile;
107 TDirectory* oldDir = gDirectory;
108
109 TFile* histoFile = nullptr;
110
112 histoFile = new TFile(fsOutFileName, "RECREATE");
113 histoFile->cd();
114
116 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
118 TString sFolder = vHistos[uHisto].second.data();
119 if (nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
120 gDirectory->cd(sFolder);
121
123 vHistos[uHisto].first->Write();
124
125 histoFile->cd();
126 } // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
127
128 histoFile->Close();
129
131 gFile = oldFile;
132 gDirectory = oldDir;
133}
134//----------------------------------------------------------------------
136{
137 fbFillHistos = bFlag;
138 if (nullptr != fpAlgo) fpAlgo->SetFillHistos(fbFillHistos);
139}
141
154
156{
157 if (nullptr != fpAlgo) fpAlgo->SetTriggerMinNumber(selDet, uVal);
158}
160{
161 if (nullptr != fpAlgo) fpAlgo->SetTriggerMaxNumber(selDet, iVal);
162}
163
164void CbmMcbm2019TimeWinEventBuilderTask::SetTriggerWindow(ECbmModuleId det, Double_t dWinBeg, Double_t dWinEnd)
165{
166 if (nullptr != fpAlgo) fpAlgo->SetTriggerWindow(det, dWinBeg, dWinEnd);
167}
168
169
171 Double_t dTsOverLength)
172{
173 if (nullptr != fpAlgo) fpAlgo->SetTsParameters(dTsStartTime, dTsLength, dTsOverLength);
174}
175
181{
182 if (nullptr != fpAlgo) fpAlgo->SetIgnoreTsOverlap(bFlagIn);
183}
188
189//----------------------------------------------------------------------
190
ClassImp(CbmConverterManager)
ECbmModuleId
Definition CbmDefs.h:39
static double dTsStartTime
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
std::string ToString() const
Definition CbmEvent.cxx:101
void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
void SetTriggerWindow(ECbmModuleId selDet, Double_t dWinBeg, Double_t dWinEnd)
void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal)
void SetReferenceDetector(ECbmModuleId refDet, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn=0, Int_t iTriggerMaxDigisIn=-1, Double_t fdTimeWinBegIn=-100, Double_t fdTimeWinEndIn=100)
void AddDetector(ECbmModuleId selDet, ECbmDataType dataTypeIn, std::string sNameIn, UInt_t uTriggerMinDigisIn=0, Int_t iTriggerMaxDigisIn=-1, Double_t fdTimeWinBegIn=-100, Double_t fdTimeWinEndIn=100)
std::vector< std::pair< TNamed *, std::string > > GetHistoVector()
void SetEventOverlapMode(EOverlapMode mode)
Control flags.
std::vector< CbmEvent * > & GetEventVector()
Data output access.
void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal)
void SetTsParameters(Double_t dTsStartTime, Double_t dTsLength, Double_t dTsOverLength)
TString fsOutFileName
Switch ON/OFF filling of histograms.
void SetTriggerWindow(ECbmModuleId det, Double_t dWinBeg, Double_t dWinEnd)
void SetTriggerMaxNumber(ECbmModuleId selDet, Int_t iVal)
void SetTriggerMinNumber(ECbmModuleId selDet, UInt_t uVal)
Bool_t fbFillHistos
output container of CbmEvents
CbmMcbm2019TimeWinEventBuilderAlgo * fpAlgo