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
12#include <FairVolume.h>
13
14#include <TVirtualMC.h>
15#include <TVirtualMCStack.h>
16#include <TGeoVolume.h>
17#include <TGeoTube.h>
18#include <TGeoManager.h>
19
20#include "DetectorsBase/Stack.h"
24
25using o2::itsmft::Hit;
26
27namespace o2
28{
29namespace ecal
30{
31
33 : o2::base::DetImpl<Detector>("ECL", true),
34 mTrackData(),
35 mHits(o2::utils::createSimVector<o2::itsmft::Hit>())
36{
37}
38
40 : o2::base::DetImpl<Detector>("ECL", true),
41 mTrackData(),
42 mHits(o2::utils::createSimVector<o2::itsmft::Hit>())
43{
44 auto& ecalPars = ECalBaseParam::Instance();
45 mInnerRadius = ecalPars.rMin;
46 mOuterRadius = ecalPars.rMax;
47 mLength = ecalPars.zLength;
48 mEnableEndcap = ecalPars.enableFwdEndcap;
49}
50
52{
53 if (mHits) {
55 }
56}
57
63
65{
66 int ifield = 2; // ?
67 float fieldm = 10.0; // ?
69
70 float tmaxfdLead = 0.1; // .10000E+01; // Degree
71 float stemaxLead = .10000E+01; // cm
72 float deemaxLead = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
73 float epsilLead = 1.0E-4; // .10000E+01;
74 float stminLead = 0.0; // cm "Default value used"
75
76 // First approximation is a detector full of lead
77 // Lead
78 Detector::Material(1, "LEAD", 207.19, 82., 11.35, .56, 18.5);
79 Detector::Medium(1, "LEAD", 1, 0, ifield, fieldm, tmaxfdLead, stemaxLead, deemaxLead, epsilLead, stminLead);
80}
81
83{
84 LOG(info) << "Initialize ECal O2Detector";
85 mGeometryTGeo = GeometryTGeo::Instance();
86 // defineSensitiveVolumes();
87}
88
89void Detector::defineSensitiveVolumes()
90{
91 LOGP(info, "Adding ECal Sensitive Volumes");
92}
93
95
97{
98 // This will create a branch in the output tree called Hit, setting the last
99 // parameter to kFALSE means that this collection will not be written to the file,
100 // it will exist only during the simulation
101
102 if (FairRootManager::Instance()) {
103 FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, true);
104 }
105}
106
108{
109 LOGP(info, "Creating ECal geometry");
110
111 TGeoManager* geoManager = gGeoManager;
112 TGeoVolume* vALIC = geoManager->GetVolume("barrel");
113 if (!vALIC) {
114 LOGP(fatal, "Could not find barrel volume while constructing ECal geometry");
115 }
116 new TGeoVolumeAssembly(GeometryTGeo::getECalVolPattern());
117 TGeoVolume* vECal = geoManager->GetVolume(GeometryTGeo::getECalVolPattern());
118 vALIC->AddNode(vECal, 2, new TGeoTranslation(0, 30., 0));
119
120 char vstrng[100] = "ECalVol";
121 vECal->SetTitle(vstrng);
122
123 // Build the ECal cylinder
125 TGeoMedium* medPb = matmgr.getTGeoMedium("ECL_LEAD");
126 TGeoTube* ecalShape = new TGeoTube("ECLsh", mInnerRadius, mOuterRadius, mLength);
127 TGeoVolume* ecalVol = new TGeoVolume("ECL", ecalShape, medPb);
128 ecalVol->SetLineColor(kAzure - 9);
129 ecalVol->SetTransparency(0);
130 vECal->AddNode(ecalVol, 1, nullptr);
131
132 if (mEnableEndcap) {
133 // Build the ecal endcap
134 TGeoTube* ecalEndcapShape = new TGeoTube("ECLECsh", 15.f, 160.f, 0.5 * (mOuterRadius - mInnerRadius));
135 TGeoVolume* ecalEndcapVol = new TGeoVolume("ECLEC", ecalEndcapShape, medPb);
136 ecalEndcapVol->SetLineColor(kAzure - 9);
137 ecalEndcapVol->SetTransparency(0);
138 vECal->AddNode(ecalEndcapVol, 1, new TGeoTranslation(0, 0, -450.f));
139 }
140}
141
143{
144 if (!o2::utils::ShmManager::Instance().isOperational()) {
145 mHits->clear();
146 }
147}
148
149bool Detector::ProcessHits(FairVolume* vol)
150{
151 // This method is called from the MC stepping
152 if (!(fMC->TrackCharge())) {
153 return false;
154 }
155
156 int lay = vol->getVolumeId();
157 int volID = vol->getMCid();
158
159 // Is it needed to keep a track reference when the outer ITS volume is encountered?
160 auto stack = (o2::data::Stack*)fMC->GetStack();
161 if (fMC->IsTrackExiting() && (lay == 0)) {
162 o2::TrackReference tr(*fMC, GetDetId());
163 tr.setTrackID(stack->GetCurrentTrackNumber());
164 tr.setUserId(lay);
165 stack->addTrackReference(tr);
166 }
167 bool startHit = false, stopHit = false;
168 unsigned char status = 0;
169 if (fMC->IsTrackEntering()) {
170 status |= Hit::kTrackEntering;
171 }
172 if (fMC->IsTrackInside()) {
173 status |= Hit::kTrackInside;
174 }
175 if (fMC->IsTrackExiting()) {
176 status |= Hit::kTrackExiting;
177 }
178 if (fMC->IsTrackOut()) {
179 status |= Hit::kTrackOut;
180 }
181 if (fMC->IsTrackStop()) {
182 status |= Hit::kTrackStopped;
183 }
184 if (fMC->IsTrackAlive()) {
185 status |= Hit::kTrackAlive;
186 }
187
188 // track is entering or created in the volume
189 if ((status & Hit::kTrackEntering) || (status & Hit::kTrackInside && !mTrackData.mHitStarted)) {
190 startHit = true;
191 } else if ((status & (Hit::kTrackExiting | Hit::kTrackOut | Hit::kTrackStopped))) {
192 stopHit = true;
193 }
194
195 // increment energy loss at all steps except entrance
196 if (!startHit) {
197 mTrackData.mEnergyLoss += fMC->Edep();
198 }
199 if (!(startHit | stopHit)) {
200 return false; // do noting
201 }
202
203 if (startHit) {
204 mTrackData.mEnergyLoss = 0.;
205 fMC->TrackMomentum(mTrackData.mMomentumStart);
206 fMC->TrackPosition(mTrackData.mPositionStart);
207 mTrackData.mTrkStatusStart = status;
208 mTrackData.mHitStarted = true;
209 }
210 if (stopHit) {
211 TLorentzVector positionStop;
212 fMC->TrackPosition(positionStop);
213 // Retrieve the indices with the volume path
214 int stave(0), halfstave(0), chipinmodule(0), module;
215 fMC->CurrentVolOffID(1, chipinmodule);
216 fMC->CurrentVolOffID(2, module);
217 fMC->CurrentVolOffID(3, halfstave);
218 fMC->CurrentVolOffID(4, stave);
219
220 Hit* p = addHit(stack->GetCurrentTrackNumber(), lay, mTrackData.mPositionStart.Vect(), positionStop.Vect(),
221 mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), positionStop.T(),
222 mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, status);
223 // p->SetTotalEnergy(vmc->Etot());
224
225 // RS: not sure this is needed
226 // Increment number of Detector det points in TParticle
227 stack->addHit(GetDetId());
228 }
229
230 return true;
231}
232
233o2::itsmft::Hit* Detector::addHit(int trackID, int detID, const TVector3& startPos, const TVector3& endPos,
234 const TVector3& startMom, double startE, double endTime, double eLoss, unsigned char startStatus,
235 unsigned char endStatus)
236{
237 mHits->emplace_back(trackID, detID, startPos, endPos, startMom, startE, endTime, eLoss, startStatus, endStatus);
238 return &(mHits->back());
239}
240
241} // namespace ecal
242} // namespace o2
243
Definition of the Stack class.
Definition of the ITSMFT Hit class.
uint32_t stack
Definition RawData.h:1
ClassImp(o2::ecal::Detector)
void setUserId(Int_t userId)
void setTrackID(Int_t track)
void Medium(Int_t numed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin, Float_t *ubuf=nullptr, Int_t nbuf=0)
Definition Detector.cxx:72
static void initFieldTrackingParams(int &mode, float &maxfield)
Definition Detector.cxx:143
void Material(Int_t imat, const char *name, Float_t a, Float_t z, Float_t dens, Float_t radl, Float_t absl, Float_t *buf=nullptr, Int_t nwbuf=0)
Definition Detector.cxx:59
std::string addNameTo(const char *ext) const
Definition Detector.h:150
static MaterialManager & Instance()
void Register() override
Definition Detector.cxx:96
bool ProcessHits(FairVolume *v=nullptr) override
Definition Detector.cxx:149
o2::itsmft::Hit * addHit(int trackID, int detID, const TVector3 &startPos, const TVector3 &endPos, const TVector3 &startMom, double startE, double endTime, double eLoss, unsigned char startStatus, unsigned char endStatus)
Definition Detector.cxx:233
void EndOfEvent() override
Definition Detector.cxx:94
void ConstructGeometry() override
Definition Detector.cxx:58
void InitializeO2Detector() override
Definition Detector.cxx:82
void Reset() override
Definition Detector.cxx:142
static GeometryTGeo * Instance()
static const char * getECalVolPattern()
static ShmManager & Instance()
Definition ShmManager.h:61
GLboolean * data
Definition glcorearb.h:298
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.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"