Project
Loading...
Searching...
No Matches
SDigitizer.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 "EMCALBase/Geometry.h"
16#include "EMCALBase/Hit.h"
17#include "MathUtils/Cartesian.h"
19
20#include <climits>
21#include <list>
22#include <chrono>
23#include <numeric>
24#include <fairlogger/Logger.h> // for LOG
25
27
29using o2::emcal::Hit;
30
31using namespace o2::emcal;
32
33//_______________________________________________________________________
34std::vector<o2::emcal::LabeledDigit> SDigitizer::process(const std::vector<Hit>& hits)
35{
36
37 std::map<int, std::map<int, std::vector<o2::emcal::Hit>>> hitsPerTowerPerParticleID;
38
39 // will be used to sort digits and labels by tower
40 std::unordered_map<Int_t, std::vector<LabeledDigit>> digitsPerTower;
41
42 for (auto hit : hits) {
43 hitsPerTowerPerParticleID[hit.GetDetectorID()][hit.GetTrackID()].push_back(hit);
44 }
45
46 std::vector<o2::emcal::Hit> SHits;
47 for (auto [towerID, hitsParticle] : hitsPerTowerPerParticleID) {
48 for (auto [partID, Hits] : hitsParticle) {
49 o2::emcal::Hit SHit = std::accumulate(std::next(Hits.begin()), Hits.end(), Hits.front());
50 SHits.push_back(SHit);
51 }
52 }
53
54 for (auto hit : SHits) {
55 try {
56
57 Int_t tower = hit.GetDetectorID();
58
59 if (tower < 0 || tower > mGeometry->GetNCells()) {
60 LOG(warning) << "tower index out of range: " << tower;
61 continue;
62 }
63
64 Double_t energy = hit.GetEnergyLoss();
65
66 //@TODO check if the summed digit time is set correctly
67 Digit digit(tower, energy, hit.GetTime());
68
69 MCLabel label(hit.GetTrackID(), mCurrEvID, mCurrSrcID, false, 1.0);
70 if (digit.getAmplitude() < __DBL_EPSILON__) {
71 label.setAmplitudeFraction(0);
72 }
73 LabeledDigit d(digit, label);
74
75 digitsPerTower[tower].push_back(d);
76
77 } catch (InvalidPositionException& e) {
78 LOG(error) << "Error in creating the digit: " << e.what();
79 }
80 }
81
82 std::vector<LabeledDigit> digitsVector;
83
84 // Sum all digits in one tower
85 for (auto [towerID, labeledDigits] : digitsPerTower) {
86
87 o2::emcal::LabeledDigit Sdigit = std::accumulate(std::next(labeledDigits.begin()), labeledDigits.end(), labeledDigits.front());
88
89 if (Sdigit.getAmplitude() < __DBL_EPSILON__) {
90 continue;
91 }
92
93 digitsVector.push_back(Sdigit);
94 }
95
96 digitsPerTower.clear();
97
98 return digitsVector;
99}
100
101//_______________________________________________________________________
103{
104 // set current MC source ID
105 if (v > MCCompLabel::maxSourceID()) {
106 LOG(fatal) << "MC source id " << v << " exceeds max storable in the label " << MCCompLabel::maxSourceID();
107 }
108 mCurrSrcID = v;
109}
110
111//_______________________________________________________________________
113{
114 // set current MC event ID
115 if (v > MCCompLabel::maxEventID()) {
116 LOG(fatal) << "MC event id " << v << " exceeds max storable in the label " << MCCompLabel::maxEventID();
117 }
118 mCurrEvID = v;
119}
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
char error[CURL_ERROR_SIZE]
ClassImp(o2::emcal::SDigitizer)
static constexpr int maxSourceID()
static constexpr int maxEventID()
EMCAL digit implementation.
Definition Digit.h:34
Double_t getAmplitude() const
Definition Digit.cxx:101
Int_t GetNCells() const
Definition Geometry.h:222
EMCAL simulation hit information.
Definition Hit.h:28
Exception handling errors due to positions not in the EMCAL area.
EMCAL labeled digit implementation.
Double_t getAmplitude() const
Monte-Carlo label for EMCAL clusters / digits.
Definition MCLabel.h:26
EMCAL summed digitizer.
Definition SDigitizer.h:43
std::vector< o2::emcal::LabeledDigit > process(const std::vector< Hit > &hits)
Steer conversion of hits to digits.
const GLdouble * v
Definition glcorearb.h:832
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"