BmnRoot
Loading...
Searching...
No Matches
BmnScWallDigitizer.h
Go to the documentation of this file.
1/*
2 * File: BmnScWallDigitizer.h
3 * Author: Sergey Morozov
4 *
5 * Created on 16.09.2021, 12:00
6 */
7
8#ifndef BMNSCWALLDIGITIZER_H
9#define BMNSCWALLDIGITIZER_H
10
11#include "BmnScWallDigit.h"
12#include "BmnScWallGeoPar.h"
13#include "BmnScWallPoint.h"
14#include "FairLogger.h"
15#include "TRandom3.h"
16
17#include <FairTask.h>
18#include <TClonesArray.h>
19#include <fstream>
20#include <iostream>
21
22class BmnScWallDigitizer : public FairTask
23{
24 public:
25 struct SiPM
26 {
27 int Npixels; // Total number of pixels in SiPM (for saturation)
28 int pixPerMIP; // MIP to N SiPM pixels with PDE taken into account
29 double noiseMIP; // MIP noise level
30 double gevPerMIP; // MIP to GeV conversion factor
31
32 SiPM() = default;
33
34 SiPM(int Npixels_, int pixPerMIP_, double noiseMIP_, double gevPerMIP_)
35 : Npixels(Npixels_)
36 , pixPerMIP(pixPerMIP_)
37 , noiseMIP(noiseMIP_)
38 , gevPerMIP(gevPerMIP_)
39 {}
40
41 ~SiPM() = default;
42
43 ULong64_t ModelNpixels(double meanPixels) { return gRandom->Poisson(meanPixels); }
44
45 ULong64_t ModelSaturation(ULong64_t firedPixels)
46 {
47 return static_cast<ULong64_t>(
48 std::round(Npixels * (1.0 - std::exp(-static_cast<double>(firedPixels) / Npixels))));
49 }
50
51 double ModelNoise(double meanMIP) { return gRandom->Gaus(meanMIP, noiseMIP); }
52
53 double ModelResponse(double pfELoss)
54 {
55 auto meanPixels = (pfELoss / gevPerMIP) * pixPerMIP;
56 auto firedPixels = ModelNpixels(meanPixels);
57 firedPixels = ModelSaturation(firedPixels);
58 return gevPerMIP * ModelNoise(static_cast<double>(firedPixels) / pixPerMIP);
59 }
60 };
61
62 // Constructor and Destructor
63 BmnScWallDigitizer(const int period);
64 BmnScWallDigitizer(const char* config = nullptr);
65 virtual ~BmnScWallDigitizer();
66
67 // Overridden FairTask methods
68 virtual InitStatus Init();
69 virtual void Exec(Option_t* opt);
70 virtual void Finish();
71
72 // Setter methods
73 InitStatus LoadConfig(const char* config);
74 void SetScale(double scale) { fScale = scale; }
75 void SetThreshold(double setValue) { fThreshold = setValue; }
76 void SetTimeCut(double setValue) { fTimeCut = setValue; }
77 void SetSiPM(int Npixels, int pixPerMIP, double noiseMIP, double gevPerMIP)
78 {
79 fSiPM.Npixels = Npixels;
80 fSiPM.pixPerMIP = pixPerMIP;
81 fSiPM.noiseMIP = noiseMIP;
82 fSiPM.gevPerMIP = gevPerMIP;
83 }
84
85 private:
86 double fScale; // Scale factor
87 double fThreshold; // Noise threshold level
88 double fTimeCut; // Cut times above this
89 SiPM fSiPM; // SiPM properties and methods
90
91 TClonesArray* fPointArray; // Input array of BmnScWallPoints
92 TClonesArray* fDigiArray; // Output array of BmnScWallDigits
93
94 std::unordered_map<uint32_t, std::vector<BmnScWallPoint*>>
95 fuoHitMap; // Physical address (w/o scint) to point vector map
96 void FillHitMap();
97
98 float fworkTime; // Accumulated work time for the digitizer
99 ClassDef(BmnScWallDigitizer, 2);
100};
101
102#endif /* BMNSCWALLDIGITIZER_H */
void SetThreshold(double setValue)
void SetScale(double scale)
virtual void Exec(Option_t *opt)
InitStatus LoadConfig(const char *config)
void SetTimeCut(double setValue)
virtual InitStatus Init()
void SetSiPM(int Npixels, int pixPerMIP, double noiseMIP, double gevPerMIP)
SiPM(int Npixels_, int pixPerMIP_, double noiseMIP_, double gevPerMIP_)
double ModelNoise(double meanMIP)
ULong64_t ModelSaturation(ULong64_t firedPixels)
double ModelResponse(double pfELoss)
ULong64_t ModelNpixels(double meanPixels)