SND@LHC Software
Loading...
Searching...
No Matches
sndScifiHit.cxx
Go to the documentation of this file.
1#include "sndScifiHit.h"
2#include "Scifi.h"
3#include "TROOT.h"
4#include "FairRunSim.h"
5#include "TGeoNavigator.h"
6#include "TGeoManager.h"
7#include "TGeoBBox.h"
8#include <TRandom.h>
9#include <iomanip>
10
11namespace {
12 //parameters for simulating the digitized information
13 const Float_t ly_loss_params[4] = {20., 300.}; //x_0, lambda
14 const Float_t npix_to_qdc_params[4] = {0.172, -1.31, 0.006, 0.33}; // A, B, sigma_A, sigma_B
15}
16
17// ----- Default constructor -------------------------------------------
19 : SndlhcHit()
20{
21 flag = true;
22}
23// ----- Standard constructor ------------------------------------------
25 : SndlhcHit(detID)
26{
27 flag = true;
28}
29// ----- constructor from point class ------------------------------------------
30sndScifiHit::sndScifiHit (int SiPMChan, std::vector<ScifiPoint*> V, std::vector<Float_t> W)
31{
32 Scifi* ScifiDet = dynamic_cast<Scifi*> (gROOT->GetListOfGlobals()->FindObject("Scifi") );
33 Float_t nphe_min = ScifiDet->GetConfParF("Scifi/nphe_min");
34 Float_t nphe_max = ScifiDet->GetConfParF("Scifi/nphe_max");
35 Float_t timeResol = ScifiDet->GetConfParF("Scifi/timeResol");
36 Float_t signalSpeed = ScifiDet->GetConfParF("Scifi/signalSpeed");
37
38 nSides = 1;
39 nSiPMs = 1;
40 for (unsigned int j=0; j<16; ++j){
41 signals[j] = -1;
42 times[j] =-1;
43 }
44
45 fDetectorID = SiPMChan;
46 Float_t ly_total = 0;
47 Float_t earliestToA = 1E20;
48 for( int i = 0; i <V.size();i++) {
49
50 Double_t signal = V[i]->GetEnergyLoss()*W[i];
51
52 // Find distances from MCPoint centre to ends of fibre
53 TVector3 a, b;
54 TVector3 impact(V[i]->GetX(),V[i]->GetY() ,V[i]->GetZ() );
55 ScifiDet->GetSiPMPosition(V[i]->GetDetectorID(),a, b);
56
57 Double_t distance;
58
59 bool verticalHit = int(fDetectorID/100000)%10 == 1;
60
61 // Calculate distance from energy deposit to SiPM.
62 // Vertical
63 if (verticalHit) {
64 distance = (b - impact).Mag();
65 // Horizontal
66 } else {
67 distance = (impact - a).Mag();
68 }
69
70 // convert energy deposit to light yield (here Np.e. == avg. N fired pixels)
71 Float_t ly = signal*1E+6*0.16; //0.16 p.e per 1 keV
72 // account for the light attenuation in the fibers
73 ly*= ly_loss(distance);
74 ly_total+= ly;
75
76 // for the timing, find earliest light to arrive at SiPM and smear with time resolution
77 Float_t arrival_time = V[i]->GetTime() + distance/signalSpeed;
78 if (arrival_time < earliestToA){earliestToA = arrival_time;}
79
80 }
81 // smear the total light yield using Poisson distribution
82 ly_total= gRandom->Poisson(ly_total);
83
84 // account for limited SiPM dyn. range
85 Float_t Npix = sipm_saturation(ly_total,nphe_max);
86 // convert Npix to QDC
87 signals[0] = npix_to_qdc(Npix);
88
89 if (ly_total > nphe_min){ // nominal threshold at 3.5 p.e.
90 flag=true;
91 }else{
92 flag=false;
93 }
94 times[0] = gRandom->Gaus(earliestToA, timeResol);
95
96 LOG(DEBUG) << "signal created";
97}
98
99// ----- Destructor ----------------------------------------------------
101// -------------------------------------------------------------------------
102
103// ----- Public method GetEnergy -------------------------------------------
105{
106 // to be calculated from digis and calibration constants, missing!
107 return signals[0];
108}
109
110Float_t sndScifiHit::ly_loss(Float_t distance){
111// It returns the light yield attenuation depending on the distance to SiPM
112 return TMath::Exp(-(distance-ly_loss_params[0])/ly_loss_params[1]);
113}
114
115Float_t sndScifiHit::sipm_saturation(Float_t ly, Float_t nphe_max){
116// It returns the number of fired pixels per channel
117 Float_t factor = 1 - TMath::Exp(-ly/nphe_max);
118 return nphe_max*factor;
119}
120
121Float_t sndScifiHit::npix_to_qdc(Float_t npix){
122// It returns QDC per channel after Gaussian smearing of the parameters
123 Float_t A = gRandom->Gaus(npix_to_qdc_params[0], npix_to_qdc_params[2]);
124 Float_t B = gRandom->Gaus(npix_to_qdc_params[1], npix_to_qdc_params[3]);
125 return A*npix + B;
126}
127
128// ----- Public method Print -------------------------------------------
130{
131 std::cout << "-I- sndScifiHit: Scifi hit " << " in station " << GetStation();
132 if ( isVertical()) { std::cout << " vertical plane ";}
133 else { std::cout << " horizontal plane ";}
134 std::cout << "SiPM nr "<<GetSiPM()<< " SiPM channel "<<GetSiPMChan()<<std::endl;
135}
136// -------------------------------------------------------------------------
137
139
Definition Scifi.h:20
void GetSiPMPosition(Int_t SiPMChan, TVector3 &A, TVector3 &B)
Definition Scifi.cxx:625
Float_t GetConfParF(TString name)
Definition Scifi.h:49
Int_t nSiPMs
Definition SndlhcHit.h:73
Float_t times[16]
SiPM signal.
Definition SndlhcHit.h:76
Int_t GetDetectorID() const
Definition SndlhcHit.h:36
Int_t fDetectorID
Detector unique identifier.
Definition SndlhcHit.h:72
Int_t nSides
number of SiPMs per side
Definition SndlhcHit.h:74
Float_t signals[16]
number of sides
Definition SndlhcHit.h:75
Int_t GetStation()
Definition sndScifiHit.h:31
Float_t ly_loss(Float_t distance)
Int_t GetSiPMChan()
Definition sndScifiHit.h:38
Int_t GetSiPM()
Definition sndScifiHit.h:37
virtual ~sndScifiHit()
Float_t flag
flag
Definition sndScifiHit.h:48
Float_t GetEnergy()
Float_t npix_to_qdc(Float_t npix)
bool isVertical()
Definition sndScifiHit.h:32
Float_t sipm_saturation(Float_t ly, Float_t nphe_max)
ClassImp(ecalContFact) ecalContFact
float ly_loss_params