CbmRoot
Loading...
Searching...
No Matches
CbmFindPrimaryVertexEvents.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Florian Uhlig */
4
12
13#include "CbmEvent.h"
15#include "CbmVertex.h"
16#include "FairRootManager.h"
17#include "TClonesArray.h"
18
19#include <Logger.h>
20
21#include <cassert>
22#include <iomanip>
23#include <iostream>
24
25using namespace std;
26
27
28// ----- Default constructor -------------------------------------------
30 : FairTask()
31 , fTimer()
32 , fFinder(NULL)
33 , fEvents(NULL)
34 , fTracks(NULL)
35 , fPrimVert(NULL)
36 , fNofEvents(0)
37 , fTimeTot(0.)
38{
39 fName = "FindPrimaryVertex";
40}
41// -------------------------------------------------------------------------
42
43
44// ----- Standard constructor ------------------------------------------
46 : FairTask()
47 , fTimer()
48 , fFinder(pvFinder)
49 , fEvents(NULL)
50 , fTracks(NULL)
51 , fPrimVert(NULL)
52 , fNofEvents(0)
53 , fTimeTot(0.)
54{
55 fName = "FindPrimaryVertex";
56}
57// -------------------------------------------------------------------------
58
59
60// ----- Constructor with name and title ---------------------------------
62 : FairTask(name)
63 , fTimer()
64 , fFinder(finder)
65 , fEvents(NULL)
66 , fTracks(NULL)
67 , fPrimVert(NULL)
68 , fNofEvents(0)
69 , fTimeTot(0.)
70{
71}
72// -------------------------------------------------------------------------
73
74
75// ----- Destructor ----------------------------------------------------
77// -------------------------------------------------------------------------
78
79
80// ----- Initialisation --------------------------------------------------
82{
83
84 assert(fFinder);
85
86 // Get FairRootManager
87 FairRootManager* ioman = FairRootManager::Instance();
88 assert(ioman);
89
90 // Get event array
91 fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent"));
92 if (nullptr == fEvents) {
93 LOG(fatal) << GetName() << "No CbmEvent TClonesArray found!";
94 }
95
96 // Get CbmStsTrack array
97 fTracks = (TClonesArray*) ioman->GetObject("StsTrack");
98 assert(fTracks);
99
100 // Create and register CbmVertex object
101 fPrimVert = new CbmVertex("Primary Vertex", "Global");
102 ioman->Register("PrimaryVertex.", "Global", fPrimVert, IsOutputBranchPersistent("PrimaryVertex"));
103
104
105 // Initialise vertex finder
106 fFinder->Init();
107
108 return kSUCCESS;
109}
110// -------------------------------------------------------------------------
111
112
113// ----- Task execution ------------------------------------------------
115{
116
117 // --- Event loop
118 Int_t nEvents = fEvents->GetEntriesFast();
119 LOG(debug) << GetName() << ": reading time slice with " << nEvents << " events ";
120 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
121
122 fTimer.Start();
123 CbmEvent* event = static_cast<CbmEvent*>(fEvents->At(iEvent));
124
125 // --- Call find method of vertex finder
126 // Int_t status = fFinder->FindEventVertex(event, fTracks);
128
129 // --- Event log
130 LOG(info) << "+ " << setw(20) << GetName() << ": Event " << setw(6) << right << event->GetNumber() << ", real time "
131 << fixed << setprecision(6) << fTimer.RealTime()
132 << " s, tracks used: " << event->GetVertex()->GetNTracks();
133 LOG(debug) << fPrimVert->ToString();
134
135 // --- Counters
136 fNofEvents++;
137 fTimeTot += fTimer.RealTime();
138
139 } //# events
140}
141// -------------------------------------------------------------------------
142
143
144// ----- End-of-run action ---------------------------------------------
146{
147
148 std::cout << std::endl;
149 LOG(info) << "=====================================";
150 LOG(info) << GetName() << ": Run summary";
151 LOG(info) << "Events processed : " << fNofEvents;
152 LOG(info) << "Time per event : " << fTimeTot / Double_t(fNofEvents) << " s ";
153 LOG(info) << "=====================================";
154}
155// -------------------------------------------------------------------------
156
157
ClassImp(CbmConverterManager)
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
CbmPrimaryVertexFinder * fFinder
Concrete finder instance.
TClonesArray * fTracks
event array
Double_t fTimeTot
Total execution time [s].
Int_t fNofEvents
Total number of events processed.
virtual Int_t FindEventVertex(CbmEvent *event, TClonesArray *tracks)=0
virtual std::string ToString() const
Hash for CbmL1LinkKey.