Project
Loading...
Searching...
No Matches
CosmicProcessor.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 <algorithm>
15#include <fairlogger/Logger.h> // for LOG
17#include <TStopwatch.h>
19
20using namespace o2::tof;
21
22//__________________________________________________
24{
25 mCosmicInfo.clear();
26 mCosmicInfo.reserve(5200);
27 mCosmicTrack.clear();
28 mCosmicTrack.reserve(1200);
29 mSizeTrack.clear();
30 mSizeTrack.reserve(1200);
31
32 mCosmicTrackTemp.reserve(200);
33
34 memset(mCounters, 0, sizeof(int) * Geo::NCHANNELS);
35}
36//__________________________________________________
38{
39 if (mCosmicTrack.size() > 1000) {
40 return;
41 }
42
43 // fit the track and check if is good
44 mSizeTrack.push_back(int(mCosmicTrackTemp.size()));
45 mCosmicTrack.insert(mCosmicTrack.end(), mCosmicTrackTemp.begin(), mCosmicTrackTemp.end());
46}
47//__________________________________________________
49{
50 if (mCosmicInfo.size() > 5000) {
51 return;
52 }
53
54 TStopwatch timerProcess;
55 timerProcess.Start();
56
57 reader.init();
59
60 auto array = reader.getDigitArray();
61 int ndig = array->size();
62 int ndig2 = ndig * fill;
63
64 int npair = 0;
65
66 int bcdist = 200;
67 float thr = 5000000; // in ps
68
69 int volID1[5], volID2[5];
70 float pos1[3], pos2[3], pos2or[3];
71
72 std::vector<int> mIcandClus;
73 mIcandClus.reserve(200);
74
75 bool trackFound = false;
76
77 for (int i = 0; i < ndig; i++) {
78 if (npair >= 150) {
79 break;
80 }
81 auto& dig1 = (*array)[i];
82 int ch1 = dig1.getChannel();
83 mCounters[ch1]++;
84 if (mCounters[ch1] > 3) {
85 continue;
86 }
87 auto ir0 = hbfutils.getFirstIRofTF(dig1.getIR());
88
89 int64_t bc1 = int64_t(dig1.getBC());
90 int tdc1 = int(dig1.getTDC());
91 float tot1 = dig1.getTOT() * 48.8E-3;
92 Geo::getVolumeIndices(ch1, volID1);
93 Geo::getPos(volID1, pos1);
94
95 float tm1 = (dig1.getIR().differenceInBC(ir0) * 1024 + tdc1) * Geo::TDCBIN; // in ps
96
97 mIcandClus.clear();
98 if (!trackFound) {
99 mCosmicTrackTemp.clear();
100 mCosmicTrackTemp.emplace_back(ch1, pos1[0], pos1[1], pos1[2], 0.0, tot1);
101 }
102
103 for (int j = i + 1; j < ndig2; j++) {
104 auto& dig2 = (*array)[j];
105 int64_t bc2 = int64_t(dig2.getBC()) - bc1;
106 if (std::abs(bc2) > bcdist) {
107 continue;
108 }
109
110 int ch2 = dig2.getChannel();
111 if (mCounters[ch2] > 3) {
112 continue;
113 }
114 float tm2 = (dig2.getIR().differenceInBC(ir0) * 1024 + int(dig2.getTDC())) * Geo::TDCBIN; // in ps
115
116 int tdc2 = int(dig2.getTDC()) - tdc1;
117 float tot2 = dig2.getTOT() * 48.8E-3;
118 Geo::getVolumeIndices(ch2, volID2);
119 Geo::getPos(volID2, pos2or);
120 pos2[0] = pos2or[0] - pos1[0];
121 pos2[1] = pos2or[1] - pos1[1];
122 pos2[2] = pos2or[2] - pos1[2];
123
124 float dtime = (bc2 * 1024 + tdc2) * Geo::TDCBIN; // in ps
125
126 float lt2 = pos2[0] * pos2[0] + pos2[1] * pos2[1];
127 float l = sqrt(lt2 + pos2[2] * pos2[2]);
128
129 if (!trackFound && lt2 < 40000 && std::abs(dtime) < 10000) {
130 mCosmicTrackTemp.emplace_back(ch2, pos2or[0], pos2or[1], pos2or[2], dtime, tot2);
131 }
132
133 if (l < 500) {
134 continue;
135 }
136 if (pos2[1] > 0) {
137 l = -l;
138 }
139
140 dtime -= l * 33.356409; // corrected for pad distance assuiming muonn downward
141
142 if (std::abs(dtime) > thr) {
143 continue;
144 }
145
146 npair++;
147 mCosmicInfo.emplace_back(ch1, ch2, dtime, tot1, tot2, l, tm1, tm2);
148 }
149 if (!trackFound && ndig < 1000 && mCosmicTrackTemp.size() > 4) {
150 trackFound = true;
151 }
152 }
153
154 if (trackFound) {
155 processTrack();
156 }
157
158 LOG(debug) << "We had " << ndig << " digits in this event";
159 timerProcess.Stop();
160}
Managing digitsi in a RO window to provide cosmics candidates.
int32_t i
uint32_t j
Definition RawData.h:0
std::ostringstream debug
void process(DigitDataReader &r, bool fill=true)
DigitDataReader class for TOF. Feeds the MC digits to the Cluster Finder.
Definition DataReader.h:60
void init() override
Definition DataReader.h:70
const gsl::span< const o2::tof::Digit > * getDigitArray() const
Definition DataReader.h:78
static void getPos(Int_t *det, Float_t *pos)
Definition Geo.cxx:491
static void getVolumeIndices(Int_t index, Int_t *detId)
Definition Geo.cxx:543
static constexpr int NCHANNELS
Definition Geo.h:124
static constexpr Float_t TDCBIN
TDC bin width [ps].
Definition Geo.h:150
GLenum array
Definition glcorearb.h:4274
IR getFirstIRofTF(const IR &rec) const
get 1st IR of TF corresponding to the 1st sampled orbit (in MC)
Definition HBFUtils.h:71
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir0(3, 5)