SND@LHC Software
Loading...
Searching...
No Matches
MuFilterHit.cxx
Go to the documentation of this file.
1#include "MuFilterHit.h"
2#include "MuFilter.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
11Double_t speedOfLight = TMath::C() *100./1000000000.0 ; // from m/sec to cm/ns
12// ----- Default constructor -------------------------------------------
14 : SndlhcHit()
15{
16 flag = true;
17 for (Int_t i=0;i<16;i++){fMasked[i]=kFALSE;}
18}
19// ----- Standard constructor ------------------------------------------
21 : SndlhcHit(detID)
22{
23 flag = true;
24 for (Int_t i=0;i<16;i++){fMasked[i]=kFALSE;}
25}
26MuFilterHit::MuFilterHit(Int_t detID,Int_t nP,Int_t nS)
27 : SndlhcHit(detID,nP,nS)
28{
29 flag = true;
30 for (Int_t i=0;i<16;i++){
31 fMasked[i]=kFALSE;
32 signals[i] = -999;
33 times[i] = -999;
34 fDaqID[i] = -1;
35 }
36}
37
38
39// ----- constructor from MuFilterPoint ------------------------------------------
40MuFilterHit::MuFilterHit(Int_t detID, std::vector<MuFilterPoint*> V)
41 : SndlhcHit()
42{
43 MuFilter* MuFilterDet = dynamic_cast<MuFilter*> (gROOT->GetListOfGlobals()->FindObject("MuFilter"));
44 // get parameters from the MuFilter detector for simulating the digitized information
45 nSiPMs = MuFilterDet->GetnSiPMs(detID);
46 nSides = MuFilterDet->GetnSides(detID);
47
48 Float_t timeResol = MuFilterDet->GetConfParF("MuFilter/timeResol");
49
50 Float_t attLength=0;
51 Float_t siPMcalibration=0;
52 Float_t siPMcalibrationS=0;
53 Float_t propspeed =0;
54 if (floor(detID/10000)==3) {
55 if (nSides==2){attLength = MuFilterDet->GetConfParF("MuFilter/DsAttenuationLength");}
56 else {attLength = MuFilterDet->GetConfParF("MuFilter/DsTAttenuationLength");}
57 siPMcalibration = MuFilterDet->GetConfParF("MuFilter/DsSiPMcalibration");
58 propspeed = MuFilterDet->GetConfParF("MuFilter/DsPropSpeed");
59 }
60 else {
61 if (floor(detID/10000)==1 && nSides==1){
62 // top readout with mirror on bottom
63 attLength = 2*MuFilterDet->GetConfParF("MuFilter/VandUpAttenuationLength");
64 }
65 else {attLength = MuFilterDet->GetConfParF("MuFilter/VandUpAttenuationLength");}
66 siPMcalibration = MuFilterDet->GetConfParF("MuFilter/VandUpSiPMcalibration");
67 siPMcalibrationS = MuFilterDet->GetConfParF("MuFilter/VandUpSiPMcalibrationS");
68 propspeed = MuFilterDet->GetConfParF("MuFilter/VandUpPropSpeed");
69 }
70
71 for (unsigned int j=0; j<16; ++j){
72 signals[j] = -1;
73 times[j] =-1;
74 }
75 LOG(DEBUG) << "detid "<<detID<< " size "<<nSiPMs<< " side "<<nSides;
76
77 fDetectorID = detID;
78 Float_t signalLeft = 0;
79 Float_t signalRight = 0;
80 Float_t earliestToAL = 1E20;
81 Float_t earliestToAR = 1E20;
82 for(auto p = std::begin(V); p!= std::end(V); ++p) {
83
84 Double_t signal = (*p)->GetEnergyLoss();
85
86 // Find distances from MCPoint centre to ends of bar
87 TVector3 vLeft,vRight;
88 TVector3 impact((*p)->GetX(),(*p)->GetY() ,(*p)->GetZ() );
89 MuFilterDet->GetPosition(fDetectorID,vLeft, vRight);
90 Double_t distance_Left = (vLeft-impact).Mag();
91 Double_t distance_Right = (vRight-impact).Mag();
92 // Simple model: divide signal between nSides
93 signalLeft+=signal/nSides*TMath::Exp(-distance_Left/attLength);
94 signalRight+=signal/nSides*TMath::Exp(-distance_Right/attLength);
95
96 // for the timing, find earliest particle and smear with time resolution
97 Double_t ptime = (*p)->GetTime();
98 Double_t t_Left = ptime + distance_Left/propspeed;
99 Double_t t_Right = ptime + distance_Right/propspeed;
100 if ( t_Left <earliestToAL){earliestToAL = t_Left ;}
101 if ( t_Right <earliestToAR){earliestToAR = t_Right ;}
102 }
103 // shortSiPM = {3,6,11,14,19,22,27,30,35,38,43,46,51,54,59,62,67,70,75,78}; - counting from 1!
104 // In the SndlhcHit class the 'signals' array starts from 0.
105 for (unsigned int j=0; j<nSiPMs; ++j){
106 if ( floor(detID/10000)==2 && (j==2 or j==5)){ // only US has small SiPMs
107 signals[j] = signalLeft/float(nSiPMs) * siPMcalibrationS; // most simplest model, divide signal individually. Small SiPMS special
108 times[j] = gRandom->Gaus(earliestToAL, timeResol);
109 }else{
110 signals[j] = signalLeft/float(nSiPMs) * siPMcalibration; // most simplest model, divide signal individually.
111 times[j] = gRandom->Gaus(earliestToAL, timeResol);
112 }
113 if (nSides>1){
114 signals[j+nSiPMs] = signalRight/float(nSiPMs) * siPMcalibration; // most simplest model, divide signal individually.
115 times[j+nSiPMs] = gRandom->Gaus(earliestToAR, timeResol);
116 }
117 }
118 flag = true;
119 for (Int_t i=0;i<16;i++){fMasked[i]=kFALSE;}
120 LOG(DEBUG) << "signal created";
121}
122
123// ----- Destructor ----------------------------------------------------
125// -------------------------------------------------------------------------
126
127// ----- Public method GetEnergy -------------------------------------------
129{
130 // to be calculated from digis and calibration constants, missing!
131 Float_t E = 0;
132 for (unsigned int j=0; j<nSiPMs; ++j){
133 E+=signals[j];
134 if (nSides>1){ E+=signals[j+nSiPMs];}
135 }
136 return E;
137}
138
140 if ( (floor(fDetectorID/10000)==3&&fDetectorID%1000>59) ||
141 (floor(fDetectorID/10000)==1&&int(fDetectorID/1000)%10==2) ) {
142 return kTRUE;
143 }
144 else{return kFALSE;}
145}
146
148 if (i%8==2 || i%8==5) {return kTRUE;}
149 else{return kFALSE;}
150}
151
152// ----- Public method Get List of signals -------------------------------------------
153std::map<Int_t,Float_t> MuFilterHit::GetAllSignals(Bool_t mask,Bool_t positive)
154{
155 std::map<Int_t,Float_t> allSignals;
156 for (unsigned int s=0; s<nSides; ++s){
157 for (unsigned int j=0; j<nSiPMs; ++j){
158 unsigned int channel = j+s*nSiPMs;
159 if (signals[channel]<-900){continue;}
160 if (signals[channel]> 0 || !positive){
161 if (!fMasked[channel] || !mask){
162 allSignals[channel] = signals[channel];
163 }
164 }
165 }
166 }
167 return allSignals;
168}
169
170// ----- Public method Get List of time measurements -------------------------------------------
171std::map<Int_t,Float_t> MuFilterHit::GetAllTimes(Bool_t mask)
172{
173 std::map<Int_t,Float_t> allTimes;
174 for (unsigned int s=0; s<nSides; ++s){
175 for (unsigned int j=0; j<nSiPMs; ++j){
176 unsigned int channel = j+s*nSiPMs;
177 if (signals[channel]> 0){
178 if (!fMasked[channel] || !mask){
179 allTimes[channel] = times[channel];
180 }
181 }
182 }
183 }
184 return allTimes;
185}
186
187// ----- Public method Get time difference mean Left - mean Right -----------------
188Float_t MuFilterHit::GetDeltaT(Bool_t mask)
189// based on mean TDC measured on Left and Right
190{
191 Float_t mean[] = {0,0};
192 Int_t count[] = {0,0};
193 Float_t dT = -999.;
194 for (unsigned int s=0; s<nSides; ++s){
195 for (unsigned int j=0; j<nSiPMs; ++j){
196 unsigned int channel = j+s*nSiPMs;
197 if (signals[channel]> 0){
198 if (!fMasked[channel] || !mask){
199 mean[s] += times[channel];
200 count[s] += 1;
201 }
202 }
203 }
204 }
205 if (count[0]>0 && count[1]>0) {
206 dT = mean[0]/count[0] - mean[1]/count[1];
207 }
208 return dT;
209}
210Float_t MuFilterHit::GetFastDeltaT(Bool_t mask)
211// based on fastest (earliest) TDC measured on Left and Right
212{
213 Float_t first[] = {1E20,1E20};
214 Float_t dT = -999.;
215 for (unsigned int s=0; s<nSides; ++s){
216 for (unsigned int j=0; j<nSiPMs; ++j){
217 unsigned int channel = j+s*nSiPMs;
218 if (signals[channel]> 0){
219 if (!fMasked[channel] || !mask){
220 if (times[channel]<first[s]) {first[s] = times[channel];}
221 }
222 }
223 }
224 }
225 if (first[0]<1E10 && first[1]<1E10) {
226 dT = first[0] - first[1];
227 }
228 return dT;
229}
230
231
232// ----- Public method Get mean time -----------------
233Float_t MuFilterHit::GetImpactT(Bool_t mask)
234{
235 Float_t mean[] = {0,0};
236 Int_t count[] = {0,0};
237 Float_t dT = -999.;
238 Float_t dL;
239 MuFilter* MuFilterDet = dynamic_cast<MuFilter*> (gROOT->GetListOfGlobals()->FindObject("MuFilter"));
240 if (floor(fDetectorID/10000==3)) {
241 dL = MuFilterDet->GetConfParF("MuFilterDet/DownstreamBarX") / MuFilterDet->GetConfParF("MuFilter/DsPropSpeed");}
242 else if (floor(fDetectorID/10000==2)) {
243 dL = MuFilterDet->GetConfParF("MuFilterDet/UpstreamBarX") / MuFilterDet->GetConfParF("MuFilter/VandUpPropSpeed");}
244 else {
245 dL = MuFilterDet->GetConfParF("MuFilterDet/VetoBarX") / MuFilterDet->GetConfParF("MuFilter/VandUpPropSpeed");}
246
247 for (unsigned int s=0; s<nSides; ++s){
248 for (unsigned int j=0; j<nSiPMs; ++j){
249 unsigned int channel = j+s*nSiPMs;
250 if (signals[channel]> 0){
251 if (!fMasked[channel] || !mask){
252 mean[s] += times[channel];
253 count[s] += 1;
254 }
255 }
256 }
257 }
258 if (count[0]>0 && count[1]>0) {
259 dT = (mean[0]/count[0] + mean[1]/count[1])/2.*6.25 - dL/2.; // TDC to ns = 6.25
260 }
261 return dT;
262}
263
264std::map<TString,Float_t> MuFilterHit::SumOfSignals(Bool_t mask)
265{
266/* use cases, for Veto and DS small/large ignored
267 sum of signals left large SiPM: LL
268 sum of signals right large SiPM: RL
269 sum of signals left small SiPM: LS
270 sum of signals right small SiPM: RS
271 sum of signals left and right:
272*/
273 Float_t theSumL = 0;
274 Float_t theSumR = 0;
275 Float_t theSumLS = 0;
276 Float_t theSumRS = 0;
277 for (unsigned int s=0; s<nSides; ++s){
278 for (unsigned int j=0; j<nSiPMs; ++j){
279 unsigned int channel = j+s*nSiPMs;
280 if (signals[channel]> 0){
281 if (!fMasked[channel] || !mask){
282 if (s==0 and !isShort(j)){theSumL+= signals[channel];}
283 if (s==0 and isShort(j)){theSumLS+= signals[channel];}
284 if (s==1 and !isShort(j)){theSumR+= signals[channel];}
285 if (s==1 and isShort(j)){theSumRS+= signals[channel];}
286 }
287 }
288 }
289 }
290 std::map<TString,Float_t> sumSignals;
291 sumSignals["SumL"]=theSumL;
292 sumSignals["SumR"]=theSumR;
293 sumSignals["SumLS"]=theSumLS;
294 sumSignals["SumRS"]=theSumRS;
295 sumSignals["Sum"]=theSumL+theSumR;
296 sumSignals["SumS"]=theSumLS+theSumRS;
297 return sumSignals;
298}
299
300// ----- Public method Print -------------------------------------------
302{
303 std::cout << "-I- MuFilterHit: MuFilter hit " << " in detector " << fDetectorID;
304
305 if ( floor(fDetectorID/10000)==3&&fDetectorID%1000>59) {
306 std::cout << " with vertical bars"<<std::endl;
307 std::cout << "top digis:";
308 for (unsigned int j=0; j<nSiPMs; ++j){
309 std::cout << signals[j] <<" ";
310 }
311 }else{
312 std::cout << " with horizontal bars"<<std::endl;
313 for (unsigned int s=0; s<nSides; ++s){
314 if (s==0) {std::cout << "left digis:";}
315 else {std::cout << "right digis:";}
316 for (unsigned int j=0; j<nSiPMs; ++j){
317 std::cout << signals[j] <<" ";
318 }
319 }
320 }
321std::cout << std::endl;
322}
323// -------------------------------------------------------------------------
324
326
Double_t speedOfLight
Float_t SumOfSignals(char *opt, Bool_t mask=kTRUE)
Float_t GetEnergy()
std::map< Int_t, Float_t > GetAllTimes(Bool_t mask=kTRUE)
Float_t GetDeltaT(Bool_t mask=kTRUE)
virtual ~MuFilterHit()
Float_t fMasked[16]
Definition MuFilterHit.h:48
bool isShort(Int_t)
bool isVertical()
Float_t flag
flag
Definition MuFilterHit.h:47
std::map< Int_t, Float_t > GetAllSignals(Bool_t mask=kTRUE, Bool_t positive=kTRUE)
void Print() const
Float_t GetFastDeltaT(Bool_t mask=kTRUE)
Float_t GetImpactT(Bool_t mask=kTRUE)
Int_t GetnSides(Int_t detID)
Definition MuFilter.cxx:715
void GetPosition(Int_t id, TVector3 &vLeft, TVector3 &vRight)
Definition MuFilter.cxx:639
Int_t GetnSiPMs(Int_t detID)
Definition MuFilter.cxx:708
Float_t GetConfParF(TString name)
Definition MuFilter.h:46
Int_t nSiPMs
Definition SndlhcHit.h:73
Float_t times[16]
SiPM signal.
Definition SndlhcHit.h:76
Int_t fDetectorID
Detector unique identifier.
Definition SndlhcHit.h:72
Int_t fDaqID[16]
SiPM time.
Definition SndlhcHit.h:77
Int_t nSides
number of SiPMs per side
Definition SndlhcHit.h:74
Float_t signals[16]
number of sides
Definition SndlhcHit.h:75
ClassImp(ecalContFact) ecalContFact