BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnSiMDDigitizer.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- BmnSiMDDigitizer source file -----
3// ----- Created 23/12/20 by I. Kozlov (SPSU) -----
4// -------------------------------------------------------------------------
5
6#include "BmnSiMDDigitizer.h"
7
8#include "BmnSiMDPoint.h"
9#include "BmnTrigDigit.h"
10#include "FairRootManager.h"
11#include "TClonesArray.h"
12#include "TMath.h"
13
14#include <iostream>
15
16static Double_t workTime = 0.0;
17
18using namespace std;
19using namespace TMath;
20
21// ----- Default constructor -------------------------------------------
23 : FairTask("Bmn SiMD Digitizer")
24 , fPointArray(nullptr)
25 , fDigitArray()
26 , fNMod(64)
27{}
28// -------------------------------------------------------------------------
29
30// ----- Destructor ----------------------------------------------------
32// -------------------------------------------------------------------------
33
34// ----- Public method Init --------------------------------------------
36{
37
38 if (fVerbose)
39 cout << "BmnSiMDDigitizer::Init() started\n ";
40
41 // Get RootManager
42 FairRootManager* ioman = FairRootManager::Instance();
43 if (!ioman) {
44 cout << "-E- BmnSiMDDigitizer::Init: " << "RootManager not instantiated!" << endl;
45 return kFATAL;
46 }
47
48 // Get input array
49 fPointArray = (TClonesArray*)ioman->GetObject("SiMDPoint");
50 if (!fPointArray) {
51 cout << "BmnSiMDDigitizer::Init(): branch SiMDPoint not found! Task will be deactivated" << endl;
52 SetActive(kFALSE);
53 return kERROR;
54 }
55
56 // Create and register output array
57 fDigitArray = new TClonesArray("BmnTrigDigit");
58 ioman->Register("SiMDDigit", "SiMD", fDigitArray, kTRUE);
59
61 for (Int_t i = 0; i < fNMod; i++) {
62 fModsAngles[i] = i * 5.625;
63 }
64
65 if (fVerbose)
66 cout << "BmnSiMDDigitizer::Init() finished\n";
67 return kSUCCESS;
68}
69// -------------------------------------------------------------------------
70
71// -------------------------------------------------------------------------
72// ----- Public method Exec --------------------------------------------
74{
75
76 if (!IsActive())
77 return;
78
79 TStopwatch sw;
80 sw.Start();
81
82 if (fVerbose)
83 cout << " BmnSiMDDigitizer::Exec() started\n";
84
85 // Reset output array
86 if (!fDigitArray)
87 Fatal("Exec", "No SiMDDigit array");
88
89 fDigitArray->Delete();
90
91 // map for storage energies at modules
92 map<Int_t, Double_t> ampMap;
93
94 // Loop over MCPoints
95 for (Int_t iPoint = 0; iPoint < fPointArray->GetEntriesFast(); iPoint++) {
96 BmnSiMDPoint* point = (BmnSiMDPoint*)fPointArray->At(iPoint);
97 if (!point)
98 continue;
99
100 Int_t mod = ModByPoint(point->GetXOut(), point->GetYOut());
101
102 auto it = ampMap.find(mod);
103 if (it != ampMap.end()) {
104 ampMap[mod] += point->GetEnergyLoss();
105 } else {
106 ampMap[mod] = point->GetEnergyLoss();
107 }
108 }
109
110 // for (map<Int_t, Double_t>::iterator mit = ampMap.begin(); mit != ampMap.end(); ++mit) {
111 for (auto mit : ampMap) {
112 BmnTrigDigit digi;
113 digi.SetMod((Short_t)mit.first);
114 digi.SetAmp(mit.second);
115 new ((*fDigitArray)[fDigitArray->GetEntriesFast()]) BmnTrigDigit(digi);
116 }
117
118 if (fVerbose) {
119 printf(" Number of BmnSiMDPoints = %d\n", fPointArray->GetEntriesFast());
120 printf(" Number of BmnSiMDDigits = %d\n", fDigitArray->GetEntriesFast());
121 cout << " BmnSiMDDigitizer::Exec() finished\n";
122 }
123
124 sw.Stop();
125 workTime += sw.RealTime();
126}
127
129{
130
131 // Double_t XPOS = 0.5;
132 // Double_t YPOS = -4.6;
133
134 Double_t newX = x; // -XPOS;
135 Double_t newY = y; // -YPOS;
136 // Double_t pAngle = GetPointAngle(newX, newY);
137 Double_t pAngle = TVector2(newX, newY).Phi() * RadToDeg();
138 for (Int_t i = 0; i < fNMod; i++) {
139 if (pAngle >= fModsAngles[i] && pAngle <= (fModsAngles[i] + 5.6))
140 return i;
141 }
142 return -1;
143}
144
146{
147 printf("Work time of the SiMD digitizer: %4.4f sec.\n", workTime);
148}
static Double_t workTime
int i
Definition P4_F32vec4.h:22
int Int_t
short Short_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
void Fatal(const char *location, const char *msgfmt,...)
Int_t ModByPoint(Double_t x, Double_t y)
TClonesArray * fDigitArray
Output array of BmnSiMDDigits.
virtual void Exec(Option_t *opt)
Virtual method Exec.
BmnSiMDDigitizer()
Default constructor.
virtual InitStatus Init()
Virtual method Init.
~BmnSiMDDigitizer()
Destructor.
virtual void Finish()
TClonesArray * fPointArray
Input array of BmnSiMDPoints.
Double_t GetYOut() const
Double_t GetXOut() const
void SetMod(Short_t mod)
void SetAmp(Double_t amp)
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
void Stop()
Double_t Phi() const
constexpr Double_t RadToDeg()
Definition json.hpp:4446