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
12#include "Stepper.h"
13
15#include "DetectorsBase/Stack.h"
17#include "TGeoManager.h"
18#include "TVirtualMC.h"
19#include "TVirtualMCStack.h"
20#include "TMCProcess.h"
21#include <iomanip>
22#include "TArrayI.h"
23
24#include "FairRootManager.h"
25
26namespace o2
27{
28namespace mch
29{
30
31Stepper::Stepper() : mHits{o2::utils::createSimVector<o2::mch::Hit>()} {}
36
38{
39
40 if (!(vmc.TrackCharge())) {
41 // Only charged particles
42 return;
43 }
44
45 o2::SimTrackStatus t{vmc};
46
47 int detElemId;
48 vmc.CurrentVolOffID(2, detElemId); // go up 2 levels in the hierarchy to get the DE
49
50 auto stack = static_cast<o2::data::Stack*>(vmc.GetStack());
51
52 if (t.isEntering() || t.isExiting()) {
53 // generate a track referenced
55 tr.setUserId(detElemId);
56 stack->addTrackReference(tr);
57 }
58
59 if (t.isEntering()) {
60 float x, y, z;
61 vmc.TrackPosition(x, y, z);
62 mTof = (float)vmc.TrackTime();
63 mEntrancePoint.SetXYZ(x, y, z);
64 resetStep();
65 }
66
67 mTrackEloss += vmc.Edep();
68 mTrackLength += vmc.TrackStep();
69
70 if (t.isExiting() || t.isStopped()) {
71 float x, y, z;
72 float etot;
73 vmc.TrackPosition(x, y, z);
74 etot = (float)vmc.Etot();
75 mHits->emplace_back(stack->GetCurrentTrackNumber(), detElemId, mEntrancePoint,
76 math_utils::Point3D<float>{x, y, z}, mTrackEloss, mTrackLength, mTof, etot);
77 resetStep();
78 }
79}
80
81void Stepper::registerHits(const char* branchName)
82{
83 if (FairRootManager::Instance()) {
84 FairRootManager::Instance()->RegisterAny(branchName, mHits, kTRUE);
85 }
86}
87
88void Stepper::resetStep()
89{
90 mTrackEloss = 0.0;
91 mTrackLength = 0.0;
92}
93
95{
96 if (!o2::utils::ShmManager::Instance().isOperational()) {
97 mHits->clear();
98 }
99}
100
101} // namespace mch
102} // namespace o2
Definition of the Stack class.
uint32_t stack
Definition RawData.h:1
static constexpr ID MCH
Definition DetID.h:72
void registerHits(const char *branchName)
Definition Stepper.cxx:81
void process(const TVirtualMC &vmc)
Definition Stepper.cxx:37
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.