Project
Loading...
Searching...
No Matches
HMPIDDigitizer.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
15
16#include "Framework/Logger.h"
17
18using namespace o2::hmpid;
19
21
22float HMPIDDigitizer::getThreshold(o2::hmpid::Digit const& digiti) const
23{
24 // TODO: implement like in AliRoot some thresholding depending on conditions ...
25 return 4.;
26}
27
28// applies threshold to digits; removes the ones below a certain charge threshold
29void HMPIDDigitizer::zeroSuppress(std::vector<o2::hmpid::Digit> const& digits, std::vector<o2::hmpid::Digit>& newdigits,
32{
33 int index = 0;
34 for (auto& digit : digits) {
35 if (digit.getCharge() >= getThreshold(digit)) {
36 // if(digit.getPx() < 80 && digit.getPy() < 48) {
37 newdigits.push_back(digit);
38 if (newlabels) {
39 // copy the labels to the new place with the right new index
40 newlabels->addElements(newdigits.size() - 1, labels.getLabels(index));
41 }
42 // }
43 }
44 index++;
45 }
46}
47
48void HMPIDDigitizer::flush(std::vector<o2::hmpid::Digit>& digits)
49{
50 // flushing and finalizing digits in the workspace
51 zeroSuppress(mDigits, digits, mTmpLabelContainer, mRegisteredLabelContainer);
52 reset();
53}
54
56{
57 mIndexForPad.clear();
58 mInvolvedPads.clear();
59 mDigits.clear();
60 mTmpLabelContainer.clear();
61}
62
63// this will process hits and fill the digit vector with digits which are finalized
64void HMPIDDigitizer::process(std::vector<o2::hmpid::HitType> const& hits, std::vector<o2::hmpid::Digit>& digits)
65{
66 LOG(info) << "Starting HMPPID digitizer process function";
67
68 for (auto& hit : hits) {
69 int chamber, pc, px, py;
70 float totalQ;
71 // retrieves center pad and the total charge
72 o2::hmpid::Digit::getPadAndTotalCharge(hit, chamber, pc, px, py, totalQ);
73
74 if (px < 0 || py < 0) {
75 continue;
76 }
77
78 // determine which pads to loop over
79 std::array<uint32_t, 9> allpads;
80 int counter = 0;
81 for (int nx = -1; nx <= 1; ++nx) {
82 for (int ny = -1; ny <= 1; ++ny) {
83 if ((px + nx) < 0 || (px + nx) > 79 || (py + ny) < 0 || (py + ny) > 47) {
84 // LOG(info) << ">> Pad out the PhotoCathod boundary. Excluded :" << px << " " << py << " :" << nx << "," << ny;
85 continue;
86 }
87 allpads[counter] = o2::hmpid::Digit::abs(chamber, pc, px + nx, py + ny);
88 counter++;
89 }
90 }
91 // LOG(info) << "." << px << " " << py ;
92 for (auto& pad : allpads) {
93 auto iter = mIndexForPad.find(pad);
94 int index = -1;
95 if (iter != mIndexForPad.end()) {
96 index = iter->second;
97 }
98 // auto index = mIndexForPad[pad];
99 float fraction = o2::hmpid::Digit::getFractionalContributionForPad(hit, (int)pad);
100 // LOG(info) << "FRACTION ON PAD " << pad << " IS " << fraction;
101 if (index != -1) {
102 // digit exists ... reuse
103 auto& digit = mDigits[index];
104 digit.addCharge(totalQ * fraction);
105
106 if (mRegisteredLabelContainer) {
107 auto labels = mTmpLabelContainer.getLabels(index);
108 o2::MCCompLabel newlabel(hit.GetTrackID(), mEventID, mSrcID, false);
109 bool newlabelneeded = true;
110 for (auto& l : labels) {
111 if (l == newlabel) {
112 newlabelneeded = false;
113 break;
114 }
115 }
116 if (newlabelneeded) {
117 mTmpLabelContainer.addElementRandomAccess(index, newlabel);
118 }
119 }
120 } else {
121 // create digit ... and register
122 // mDigits.emplace_back(mCurrentTriggerTime, pad, totalQ * fraction);
123 mDigits.emplace_back(pad, totalQ * fraction);
124 mIndexForPad[pad] = mDigits.size() - 1;
125 mInvolvedPads.emplace_back(pad);
126
127 if (mRegisteredLabelContainer) {
128 // add label for this digit
129 mTmpLabelContainer.addElement(mDigits.size() - 1, o2::MCCompLabel(hit.GetTrackID(), mEventID, mSrcID, false));
130 }
131 }
132 }
133 }
134}
ClassImp(HMPIDDigitizer)
A container to hold and manage MC truth information/labels.
gsl::span< TruthElement > getLabels(uint32_t dataindex)
void addElements(uint32_t dataindex, gsl::span< CompatibleLabel > elements)
void addElement(uint32_t dataindex, TruthElement const &element, bool noElement=false)
void addElementRandomAccess(uint32_t dataindex, TruthElement const &element)
HMPID Digit declaration.
Definition Digit.h:36
static float getFractionalContributionForPad(o2::hmpid::HitType const &hit, int somepad)
Definition Digit.cxx:263
static void getPadAndTotalCharge(o2::hmpid::HitType const &hit, int &chamber, int &pc, int &px, int &py, float &totalcharge)
Definition Digit.cxx:245
static uint32_t abs(int ch, int pc, int x, int y)
Definition Digit.h:39
void process(std::vector< o2::hmpid::HitType > const &, std::vector< o2::hmpid::Digit > &digit)
void flush(std::vector< o2::hmpid::Digit > &digit)
GLuint index
Definition glcorearb.h:781
GLuint counter
Definition glcorearb.h:3987
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits