-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathTriggerMap.cxx
More file actions
118 lines (106 loc) · 3.65 KB
/
TriggerMap.cxx
File metadata and controls
118 lines (106 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "PHOSBase/Geometry.h"
#include "DataFormatsPHOS/TriggerMap.h"
#include <fairlogger/Logger.h>
#include <TH2.h>
#include <TRandom.h>
#include <iostream>
using namespace o2::phos;
TriggerMap::TriggerMap(int param) : mVersion(param)
{
// create default object
// empty (all channels good) bad maps and
// uniform turn-on curves for DDLs
mParamDescr.emplace_back("TestDefault");
std::array<std::array<float, NMAXPAR>, NDDL> a;
for (int iDDL = 0; iDDL < NDDL; iDDL++) {
a[iDDL].fill(0);
a[iDDL][0] = 1.; // only one step
a[iDDL][1] = 4.; // threshold
a[iDDL][2] = 0.5; // width
}
mParamSets.emplace_back(a);
mCurrentSet = mParamSets[0];
mVersion = 0;
}
void TriggerMap::addTurnOnCurvesParams(std::string_view versionName, std::array<std::array<float, 10>, 14>& params)
{
mParamDescr.emplace_back(versionName);
mParamSets.emplace_back(params);
}
void TriggerMap::setTurnOnCurvesVestion(int v)
{
if (static_cast<std::size_t>(v) >= mParamDescr.size()) {
LOG(error) << "impossible parameterization " << v;
LOG(error) << "Available are:";
for (std::size_t i = 0; i < mParamDescr.size(); i++) {
LOG(error) << i << " : " << mParamDescr[i];
}
LOG(error) << " keep current " << mParamDescr[mVersion];
return;
}
mVersion = v;
LOG(info) << "Will use parameterization " << mParamDescr[mVersion];
mCurrentSet = mParamSets[mVersion];
}
bool TriggerMap::selectTurnOnCurvesParams(std::string_view versionName)
{
mVersion = 0;
while (static_cast<std::size_t>(mVersion) < mParamDescr.size()) {
if (versionName.compare(mParamDescr[mVersion]) == 0.) {
return true;
}
mVersion++;
}
mVersion = 0;
LOG(error) << "Can not fine parameterization " << versionName;
LOG(error) << "Available are:";
for (std::size_t i = 0; i < mParamDescr.size(); i++) {
LOG(error) << i << " : " << mParamDescr[i];
}
return false;
}
float TriggerMap::L0triggerProbability(float e, short ddl) const
{
if (mCurrentSet.size() == 0) {
LOG(error) << "Parameteriztion not chosen";
return 0;
}
if (mVersion == 0) {
return mCurrentSet[ddl][0] / (TMath::Exp((mCurrentSet[ddl][1] - e) / mCurrentSet[ddl][2]) + 1.) +
(1. - mCurrentSet[ddl][0]) / (TMath::Exp((mCurrentSet[ddl][3] - e) / mCurrentSet[ddl][4]) + 1.);
} else {
return 0;
}
}
bool TriggerMap::isFiredMC2x2(float a, short module, short ix, short iz) const
{
char truRelId[3] = {char(module), char(ix), char(iz)};
short tileId = Geometry::truRelToAbsNumbering(truRelId, 0); // 0 for 2x2 TriggerMap
short iTRU = module * 4 + ix / 16 - 6;
return isGood2x2(tileId) && try2x2(a, iTRU);
}
bool TriggerMap::isFiredMC4x4(float a, short module, short ix, short iz) const
{
char truRelId[3] = {char(module), char(ix), char(iz)};
short tileId = Geometry::truRelToAbsNumbering(truRelId, 1);
short iTRU = module * 4 + ix / 16 - 6;
return isGood4x4(tileId) && try4x4(a, iTRU);
}
bool TriggerMap::try2x2(float a, short iTRU) const
{
return gRandom->Uniform() < L0triggerProbability(a, iTRU);
}
bool TriggerMap::try4x4(float a, short iTRU) const
{
return gRandom->Uniform() < L0triggerProbability(a, iTRU);
}