-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathTriggerMap.cxx
More file actions
95 lines (84 loc) · 2.83 KB
/
TriggerMap.cxx
File metadata and controls
95 lines (84 loc) · 2.83 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
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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.h"
#include <TH2.h>
#include <TRandom.h>
#include <iostream>
using namespace o2::phos;
TriggerMap::TriggerMap(int param) : mVersion(param)
{
if (mVersion >= mParamDescr.size()) {
LOG(ERROR) << "impossible parameterization " << mVersion;
LOG(ERROR) << "Available are:";
for (int i = 0; i < mParamDescr.size(); i++) {
LOG(ERROR) << i << " : " << mParamDescr[i];
}
return;
}
LOG(INFO) << "Will use parameterization " << mParamDescr[mVersion];
mCurrentSet = mParamSets[mVersion];
}
void TriggerMap::addTurnOnCurvesParams(std::string_view versionName, std::array<std::array<float, 10>, 14>& params)
{
mParamDescr.emplace_back(versionName);
mParamSets.emplace_back(params);
}
bool TriggerMap::selectTurnOnCurvesParams(std::string_view versionName)
{
mVersion = 0;
while (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 (int 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 iTRU, short ix, short iz) const
{
char truRelId[3] = {char(iTRU), char(ix), char(iz)};
short tileId = Geometry::truRelToAbsNumbering(truRelId);
return isGood2x2(tileId) && try2x2(a, iTRU);
}
bool TriggerMap::isFiredMC4x4(float a, short iTRU, short ix, short iz) const
{
char truRelId[3] = {char(iTRU), char(ix), char(iz)};
short tileId = Geometry::truRelToAbsNumbering(truRelId);
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);
}