Project
Loading...
Searching...
No Matches
TrackGenerator.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
16
18
19namespace o2
20{
21namespace mid
22{
23
24//______________________________________________________________________________
25std::vector<Track> TrackGenerator::generate()
26{
28 std::poisson_distribution<> distTracks(mMeanTracksPerEvent);
29 int nTracks = distTracks(mGenerator);
30 return generate(nTracks);
31}
32
33//______________________________________________________________________________
34std::vector<Track> TrackGenerator::generate(int nTracks)
35{
38 std::vector<Track> tracks;
39 Track track;
40 std::array<float, 3> pos;
41 std::array<float, 2> dir;
42 for (int itrack = 0; itrack < nTracks; ++itrack) {
43 for (int ipos = 0; ipos < 3; ++ipos) {
44 pos[ipos] =
45 std::uniform_real_distribution<float>{mPositionLimits[2 * ipos], mPositionLimits[2 * ipos + 1]}(mGenerator);
46 }
47 track.setPosition(pos[0], pos[1], pos[2]);
48
49 std::array<float, 4> limits = getLimitsForAcceptance(pos);
50
51 for (int idir = 0; idir < 2; ++idir) {
52 dir[idir] = std::uniform_real_distribution<float>{limits[2 * idir], limits[2 * idir + 1]}(mGenerator);
53 }
54 track.setDirection(dir[0], dir[1], 1.);
55 tracks.push_back(track);
56 }
57 return tracks;
58}
59
60//______________________________________________________________________________
61std::array<float, 4> TrackGenerator::getLimitsForAcceptance(std::array<float, 3> pos)
62{
65 std::array<float, 4> limits = mSlopeLimits;
66 float dZ = -1600. - pos[2];
67 if (dZ == 0.) {
68 dZ = 0.0001;
69 }
70
71 // These are the maximum x and y position of MT11 with the standard alignment
72 std::array<float, 2> maxValues{{257., 306.7}};
73 for (int icoor = 0; icoor < 2; ++icoor) {
74 int imin = 2 * icoor;
75 int imax = 2 * icoor + 1;
76 float minSlope = (pos[icoor] - maxValues[icoor]) / dZ;
77 float maxSlope = (maxValues[icoor] - pos[icoor]) / dZ;
78 if (minSlope > limits[imin]) {
79 limits[imin] = minSlope;
80 }
81 if (maxSlope < limits[imax]) {
82 limits[imax] = maxSlope;
83 }
84 }
85 return limits;
86}
87} // namespace mid
88} // namespace o2
uint16_t pos
Definition RawData.h:3
Fast track generator for MID.
std::vector< Track > generate()
This class defines the MID track.
Definition Track.h:30
void setDirection(float xDir, float yDir, float zDir)
Definition Track.cxx:37
void setPosition(float xPos, float yPos, float zPos)
Definition Track.cxx:42
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...