Project
Loading...
Searching...
No Matches
O2MCApplication.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_MC_APPLICATION_H
13#define O2_MC_APPLICATION_H
14
15#include "FairMCApplication.h"
17#include "Rtypes.h" // for Int_t, Bool_t, Double_t, etc
18#include <iostream>
19#include <TParticle.h>
20#include <vector>
21#include <DetectorsBase/Stack.h>
23#include <FairRootManager.h>
24#include <FairDetector.h>
25
26#include <fairmq/FwdDecls.h>
27
28namespace o2
29{
30namespace steer
31{
32
33// O2 specific changes/overrides to FairMCApplication
34// (like for device based processing in which we
35// forward the data instead of using FairRootManager::Fill())
37{
38 public:
40 ~O2MCApplication() override = default;
41
42 // triggers data sending/io
43 void SendData();
44
45 void initLate();
46
48 void FinishEvent() override
49 {
50 // update the stack
51 fStack->FillTrackArray();
52 fStack->UpdateTrackIndex(fActiveDetectors);
53
55
56 // detectors finalize their hits (e.g. sorting, summing duplicates) before these are sent
57 for (auto det : listActiveDetectors) {
58 det->FinishEvent();
59 }
60
61 // This special finish event version does not fill the output tree of FairRootManager
62 // but forwards the data to the HitMerger
63 SendData();
64
65 // call end of event on active detectors
66 for (auto det : listActiveDetectors) {
67 det->EndOfEvent();
68 }
69 fStack->Reset();
70 }
71
73 void FinishRun();
74
75 void attachSubEventInfo(fair::mq::Parts&, o2::data::SubEventInfo const& info) const;
76
78 void GeneratePrimaries() override
79 {
80 // ordinarily we would call the event generator ...
81 LOG(debug) << "O2MCApplication: Init primaries from external buffer " << mPrimaries.size();
82 GetStack()->Reset();
83 // but here we init the stack from
84 // a vector of particles that someone sets externally
85 static_cast<o2::data::Stack*>(GetStack())->initFromPrimaries(mPrimaries);
86 }
87
88 void setPrimaries(std::vector<TParticle> const& p)
89 {
90 mPrimaries = p;
91 }
92
93 void setSimDataChannel(fair::mq::Channel* channel) { mSimDataChannel = channel; }
95
96 std::vector<TParticle> mPrimaries;
97
98 fair::mq::Channel* mSimDataChannel;
100 std::vector<o2::base::Detector*> mActiveO2Detectors;
101
102 ClassDefOverride(O2MCApplication, 1); //Interface to MonteCarlo application
103};
104
105} // end namespace steer
106} // end namespace o2
107
108#endif
Definition of the Stack class.
std::ostringstream debug
int32_t i
void finishEventCommon()
some common parts of finishEvent
o2::data::SubEventInfo * mSubEventInfo
generic channel on which to send sim data
fair::mq::Channel * mSimDataChannel
std::vector< o2::base::Detector * > mActiveO2Detectors
what are we currently processing?
void setSimDataChannel(fair::mq::Channel *channel)
void GeneratePrimaries() override
void attachSubEventInfo(fair::mq::Parts &, o2::data::SubEventInfo const &info) const
~O2MCApplication() override=default
void setPrimaries(std::vector< TParticle > const &p)
std::vector< TParticle > mPrimaries
ClassDefOverride(O2MCApplication, 1)
active (data taking) o2 detectors
void setSubEventInfo(o2::data::SubEventInfo *i)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"