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 <TGeoManager.h>
16#include <TGeoVolume.h>
17#include "FairVolume.h"
18
20
21namespace o2
22{
23namespace mid
24{
25
26Detector::Detector(bool active) : o2::base::DetImpl<Detector>("MID", active),
27 mStepper()
28{
29}
30
32 : o2::base::DetImpl<Detector>(rhs), mStepper()
33{
34}
35
36void Detector::defineSensitiveVolumes()
37{
38 for (auto* vol : getSensitiveVolumes()) {
39 AddSensitiveVolume(vol);
40 }
41}
42
44{
45 defineSensitiveVolumes();
46}
47
48bool Detector::ProcessHits(FairVolume* vol)
49{
50 auto hit = mStepper.process(*fMC);
51 if (hit) {
52 (static_cast<o2::data::Stack*>(fMC->GetStack()))->addHit(GetDetId());
53 }
54 return hit;
55}
56
57std::vector<Hit>* Detector::getHits(int iColl)
58{
59 if (iColl == 0) {
60 return mStepper.getHits();
61 }
62 return nullptr;
63}
64
65bool Detector::setHits(int iColl, std::vector<Hit>* ptr)
66{
67 if (iColl == 0) {
68 mStepper.setHits(ptr);
69 }
70 return false;
71}
72
74{
76
77 mStepper.registerHits(addNameTo("Hit").c_str());
78}
79
80void Detector::EndOfEvent() { mStepper.resetHits(); }
81
83{
84
85 auto motherVolume = gGeoManager->GetVolume("YOUT2");
86
87 auto top = (motherVolume) ? motherVolume : gGeoManager->GetTopVolume();
88
89 if (!top) {
90 throw std::runtime_error("Cannot create MID geometry without a top volume");
91 }
92
94}
95
96} // namespace mid
97} // namespace o2
Definition of the Stack class.
ClassImp(o2::hmpid::Detector)
Implementation of the trigger-stations geometry.
TBranch * ptr
Detector()
Default Constructor.
Definition Detector.cxx:36
std::string addNameTo(const char *ext) const
Definition Detector.h:150
void ConstructGeometry() override
Definition Detector.cxx:82
void Register() override
Definition Detector.cxx:73
bool ProcessHits(FairVolume *vol=nullptr) override
Definition Detector.cxx:48
void EndOfEvent() override
Definition Detector.cxx:80
std::vector< o2::mid::Hit > * getHits(int iColl)
Definition Detector.cxx:57
void InitializeO2Detector() override
Definition Detector.cxx:43
std::vector< o2::mid::Hit > * getHits()
Definition Stepper.h:31
void setHits(std::vector< o2::mid::Hit > *ptr)
Definition Stepper.h:32
void registerHits(const char *branchName)
Definition Stepper.cxx:77
bool process(const TVirtualMC &vmc)
Definition Stepper.cxx:32
GLdouble GLdouble GLdouble GLdouble top
Definition glcorearb.h:4077
std::vector< TGeoVolume * > getSensitiveVolumes()
get a list of MID sensitive volumes
Definition Geometry.cxx:359
void createGeometry(TGeoVolume &topVolume)
create MID geometry and attach it to existing topVolume
Definition Geometry.cxx:347
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...