Project
Loading...
Searching...
No Matches
Stepper.cxx
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
13
16#include "DetectorsBase/Stack.h"
18#include "TVirtualMC.h"
19#include "FairRootManager.h"
20
21namespace o2
22{
23namespace mid
24{
25
26Stepper::Stepper() : mHits{o2::utils::createSimVector<o2::mid::Hit>()} {}
31
33{
34
35 if (!(vmc.TrackCharge())) {
36 // Only charged particles
37 return false;
38 }
39
40 // TODO: Update basing on AliRoot
41
42 o2::SimTrackStatus ts{vmc};
43
44 int detElemId;
45 vmc.CurrentVolOffID(1, detElemId); // go up 1 level in the hierarchy to get the DE
46
47 auto stack = static_cast<o2::data::Stack*>(vmc.GetStack());
48
49 if (ts.isEntering() || ts.isExiting()) {
50 // generate a track referenced
52 tr.setUserId(detElemId);
53 stack->addTrackReference(tr);
54 }
55
56 if (ts.isEntering()) {
57 float x, y, z;
58 vmc.TrackPosition(x, y, z);
59 mEntrancePoint.SetXYZ(x, y, z);
60 resetStep();
61 }
62
63 mTrackEloss += vmc.Edep();
64 mTrackLength += vmc.TrackStep();
65
66 if (ts.isExiting() || ts.isStopped()) {
67 float x, y, z;
68 vmc.TrackPosition(x, y, z);
69 mHits->emplace_back(stack->GetCurrentTrackNumber(), detElemId, mEntrancePoint,
70 math_utils::Point3D<float>{x, y, z}, mTrackEloss, mTrackLength);
71 resetStep();
72 }
73
74 return true;
75}
76
77void Stepper::registerHits(const char* branchName)
78{
79 if (FairRootManager::Instance()) {
80 FairRootManager::Instance()->RegisterAny(branchName, mHits, kTRUE);
81 }
82}
83
84void Stepper::resetStep()
85{
86 mTrackEloss = 0.0;
87 mTrackLength = 0.0;
88}
89
91{
92 if (!o2::utils::ShmManager::Instance().isOperational()) {
93 mHits->clear();
94 }
95}
96
97} // namespace mid
98} // namespace o2
Definition of the Stack class.
uint32_t stack
Definition RawData.h:1
static constexpr ID MID
Definition DetID.h:73
void registerHits(const char *branchName)
Definition Stepper.cxx:77
bool process(const TVirtualMC &vmc)
Definition Stepper.cxx:32
static ShmManager & Instance()
Definition ShmManager.h:61
GLint GLenum GLint x
Definition glcorearb.h:403
GLint y
Definition glcorearb.h:270
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
void freeSimVector(std::vector< T > *ptr)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Common utility functions.