Project
Loading...
Searching...
No Matches
Detector.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
14#include "DetectorsBase/Stack.h"
15#include "Stepper.h"
16#include "TGeoManager.h"
17#include <sstream>
18#include <iostream>
19#include <array>
20#include "TGeoManager.h"
21
23
24namespace o2
25{
26namespace mch
27{
28
30 : o2::base::DetImpl<Detector>("MCH", active), mStepper{new o2::mch::Stepper}
31{
32}
33
35 : o2::base::DetImpl<Detector>(rhs), mStepper{new o2::mch::Stepper}
36{
37}
38
40{
41 delete mStepper;
42}
43
44void Detector::defineSensitiveVolumes()
45{
46 for (auto* vol : geo::getSensitiveVolumes()) {
47 AddSensitiveVolume(vol);
48 }
49}
50
52{
53 defineSensitiveVolumes();
54}
55
57{
58 TGeoVolume* top = gGeoManager->GetTopVolume();
59 if (!top) {
60 throw std::runtime_error("Cannot create MCH geometry without a top volume");
61 }
62 geo::createGeometry(*gGeoManager, *top);
63}
64
66{
67 if (!gGeoManager) {
68 throw std::runtime_error("Cannot add alignable volumes without TGeoManager");
69 }
70 geo::addAlignableVolumes(*gGeoManager);
71}
72
73Bool_t Detector::ProcessHits(FairVolume* v)
74{
75 mStepper->process(*fMC);
76 (static_cast<o2::data::Stack*>(fMC->GetStack()))->addHit(GetDetId());
77 return kTRUE;
78}
79
80std::vector<o2::mch::Hit>* Detector::getHits(int i)
81{
82 if (i == 0) {
83 return mStepper->getHits();
84 }
85 return nullptr;
86}
87
88bool Detector::setHits(int i, std::vector<o2::mch::Hit>* ptr)
89{
90 if (i == 0) {
91 mStepper->setHits(ptr);
92 }
93 return false;
94}
95
97{
98 // TODO : get another way to do I/O (i.e. separate concerns)
99
100 mStepper->registerHits(addNameTo("Hit").c_str());
101}
102
103void Detector::EndOfEvent() { mStepper->resetHits(); }
104
105} // namespace mch
106} // namespace o2
Definition of the Stack class.
int32_t i
ClassImp(o2::hmpid::Detector)
Interface for MCH geometry creation.
TBranch * ptr
Detector()
Default Constructor.
Definition Detector.cxx:36
std::string addNameTo(const char *ext) const
Definition Detector.h:150
Bool_t ProcessHits(FairVolume *v=nullptr) override
Definition Detector.cxx:73
void InitializeO2Detector() override
Definition Detector.cxx:51
void ConstructGeometry() override
Definition Detector.cxx:56
void Register() override
Definition Detector.cxx:96
void EndOfEvent() override
Definition Detector.cxx:103
void addAlignableVolumes() const override
Add alignable top volumes.
Definition Detector.cxx:65
~Detector() override
Definition Detector.cxx:39
std::vector< o2::mch::Hit > * getHits(int)
Definition Detector.cxx:80
void registerHits(const char *branchName)
Definition Stepper.cxx:81
std::vector< o2::mch::Hit > * getHits()
Definition Stepper.h:33
void setHits(std::vector< o2::mch::Hit > *ptr)
Definition Stepper.h:34
void process(const TVirtualMC &vmc)
Definition Stepper.cxx:37
const GLdouble * v
Definition glcorearb.h:832
GLdouble GLdouble GLdouble GLdouble top
Definition glcorearb.h:4077
void addAlignableVolumes(TGeoManager &geom)
Definition Geometry.cxx:99
void createGeometry(TGeoManager &geom, TGeoVolume &topVolume)
Definition Geometry.cxx:74
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...