Project
Loading...
Searching...
No Matches
TriggerMap.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
12#include "PHOSBase/Geometry.h"
14
15#include <fairlogger/Logger.h>
16
17#include <TH2.h>
18#include <TRandom.h>
19
20#include <iostream>
21
22using namespace o2::phos;
23
25{
26 // create default object
27 // empty (all channels good) bad maps and
28 // uniform turn-on curves for DDLs
29 mParamDescr.emplace_back("TestDefault");
30 std::array<std::array<float, NMAXPAR>, NDDL> a;
31 for (int iDDL = 0; iDDL < NDDL; iDDL++) {
32 a[iDDL].fill(0);
33 a[iDDL][0] = 1.; // only one step
34 a[iDDL][1] = 4.; // threshold
35 a[iDDL][2] = 0.5; // width
36 }
37 mParamSets.emplace_back(a);
38 mCurrentSet = mParamSets[0];
39 mVersion = 0;
40}
41
42void TriggerMap::addTurnOnCurvesParams(std::string_view versionName, std::array<std::array<float, 10>, 14>& params)
43{
44 mParamDescr.emplace_back(versionName);
45 mParamSets.emplace_back(params);
46}
47
49{
50 if (static_cast<std::size_t>(v) >= mParamDescr.size()) {
51 LOG(error) << "impossible parameterization " << v;
52 LOG(error) << "Available are:";
53 for (std::size_t i = 0; i < mParamDescr.size(); i++) {
54 LOG(error) << i << " : " << mParamDescr[i];
55 }
56 LOG(error) << " keep current " << mParamDescr[mVersion];
57 return;
58 }
59 mVersion = v;
60 LOG(info) << "Will use parameterization " << mParamDescr[mVersion];
61 mCurrentSet = mParamSets[mVersion];
62}
63
64bool TriggerMap::selectTurnOnCurvesParams(std::string_view versionName)
65{
66 mVersion = 0;
67 while (static_cast<std::size_t>(mVersion) < mParamDescr.size()) {
68 if (versionName.compare(mParamDescr[mVersion]) == 0.) {
69 return true;
70 }
71 mVersion++;
72 }
73 mVersion = 0;
74 LOG(error) << "Can not fine parameterization " << versionName;
75 LOG(error) << "Available are:";
76 for (std::size_t i = 0; i < mParamDescr.size(); i++) {
77 LOG(error) << i << " : " << mParamDescr[i];
78 }
79 return false;
80}
81
82float TriggerMap::L0triggerProbability(float e, short ddl) const
83{
84
85 if (mCurrentSet.size() == 0) {
86 LOG(error) << "Parameteriztion not chosen";
87 return 0;
88 }
89 if (mVersion == 0) {
90 return mCurrentSet[ddl][0] / (TMath::Exp((mCurrentSet[ddl][1] - e) / mCurrentSet[ddl][2]) + 1.) +
91 (1. - mCurrentSet[ddl][0]) / (TMath::Exp((mCurrentSet[ddl][3] - e) / mCurrentSet[ddl][4]) + 1.);
92 } else {
93 return 0;
94 }
95}
96bool TriggerMap::isFiredMC2x2(float a, short module, short ix, short iz) const
97{
98 char truRelId[3] = {char(module), char(ix), char(iz)};
99 short tileId = Geometry::truRelToAbsNumbering(truRelId, 0); // 0 for 2x2 TriggerMap
100 short iTRU = module * 4 + ix / 16 - 6;
101 return isGood2x2(tileId) && try2x2(a, iTRU);
102}
103
104bool TriggerMap::isFiredMC4x4(float a, short module, short ix, short iz) const
105{
106 char truRelId[3] = {char(module), char(ix), char(iz)};
107 short tileId = Geometry::truRelToAbsNumbering(truRelId, 1);
108 short iTRU = module * 4 + ix / 16 - 6;
109 return isGood4x4(tileId) && try4x4(a, iTRU);
110}
111bool TriggerMap::try2x2(float a, short iTRU) const
112{
113 return gRandom->Uniform() < L0triggerProbability(a, iTRU);
114}
115bool TriggerMap::try4x4(float a, short iTRU) const
116{
117 return gRandom->Uniform() < L0triggerProbability(a, iTRU);
118}
int32_t i
static short truRelToAbsNumbering(const char *relId, short trigType)
Definition Geometry.cxx:118
float L0triggerProbability(float e, short ddl) const
void setTurnOnCurvesVestion(int v=0)
bool isFiredMC2x2(float a, short iTRU, short ix, short iz) const
random return true with probability to fire trigger
bool isFiredMC4x4(float a, short iTRU, short ix, short iz) const
random return true with probability to fire trigger
bool isGood2x2(short cellID) const
tests if cell is in active trigger region
Definition TriggerMap.h:51
void addTurnOnCurvesParams(std::string_view versionName, std::array< std::array< float, 10 >, 14 > &params)
bool try2x2(float a, short iTRU) const
bool selectTurnOnCurvesParams(std::string_view versionName)
bool try4x4(float a, short iTRU) const
TriggerMap()=default
Constructor.
bool isGood4x4(short cellID) const
tests if cell is in active trigger region
Definition TriggerMap.h:64
const GLdouble * v
Definition glcorearb.h:832
GLenum const GLfloat * params
Definition glcorearb.h:272
GLenum GLfloat param
Definition glcorearb.h:271
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"