BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
ExtractZ2.h
Go to the documentation of this file.
1#ifndef EXTRACTZ2_H
2#define EXTRACTZ2_H 1
3
4#include "BmnTrigWaveDigit.h"
5#include "TClonesArray.h"
6
7// Define some constants for analysis
8const double pedBC1 = 69.2885;
9const double pedBC2 = -11.7212;
10const double pedBC3 = -25.4808;
11const double pedBC4 = 126.067;
12const double a_out = 0.00173144;
13const double b_out = 0.0384856;
14const double c_out = 0.000015362;
15const double a_in = 0.020542;
16const double b_in = 0.0305108;
17const double c_in = 0.0000114953;
18
19// Define constants for PID
20const double meanBC1_Cin = 1095;
21const double meanBC2_Cin = 795;
22const double sigmaBC1_Cin = 130;
23const double sigmaBC2_Cin = 130;
24const double sigmaMultiBC1_Cin = 2;
25const double sigmaMultiBC2_Cin = 2;
26
27void findIdx(TClonesArray* data, int& index, double refT)
28{
29 // Function to find the waveform that is closest in time to T0 waveform
30 // and returns the index where the closest waveform is in the data array.
31 double minT = 1e4;
32 for (int m = 0; m < data->GetEntriesFast(); m++) {
33 BmnTrigWaveDigit* signal = (BmnTrigWaveDigit*)data->At(m);
34 double time = fabs(signal->GetTime() - refT);
35 if (time < minT) {
36 minT = time;
37 index = m;
38 }
39 }
40}
41
42void grabZ2(TClonesArray* TQDC_BC1,
43 TClonesArray* bc2Data,
44 double t0Time,
45 double& z2,
46 double& x,
47 double BC1calib,
48 double BC2calib,
49 short& Z,
50 bool isIncoming)
51{
52 double adcBC1, adcBC2;
53 int bc1Idx, bc2Idx;
54
55 // Require that BC1 and T0 had TQDC digits
56 if (TQDC_BC1->GetEntriesFast() && bc2Data->GetEntriesFast()) {
57 // Find the waveform closest in time to T0 time
58 findIdx(TQDC_BC1, bc1Idx, t0Time);
59 BmnTrigWaveDigit* signal1 = (BmnTrigWaveDigit*)TQDC_BC1->At(bc1Idx);
60 if (isIncoming)
61 adcBC1 = signal1->GetPeak() - pedBC1 + BC1calib;
62 else {
63 adcBC1 = signal1->GetPeak() - pedBC3;
64 }
65
66 // Find the waveform closest in time to T0 time
67 findIdx(bc2Data, bc2Idx, t0Time);
68 BmnTrigWaveDigit* signal2 = (BmnTrigWaveDigit*)bc2Data->At(bc2Idx);
69 if (isIncoming)
70 adcBC2 = signal2->GetPeak() - pedBC2 + BC2calib;
71 else {
72 adcBC2 = signal2->GetPeak() - pedBC4;
73 }
74
75 // Take geometric mean adc
76 x = sqrt(adcBC1 * adcBC2);
77
78 // Convert to Z2:
79 // Ask if this is for before target or after target
80 // because the calibration constants are different for the
81 // different PMTs
82 if (isIncoming) {
83 z2 = a_in + b_in * x + c_in * x * x;
84 // Ellipse sigmaMulti cut for Carbon on adcBC2(adcBC1) plot
85 if (adcBC2 > meanBC2_Cin
87 * sqrt(1
88 - (adcBC1 - meanBC1_Cin) * (adcBC1 - meanBC1_Cin)
90 && adcBC2 < meanBC2_Cin
92 * sqrt(1
93 - (adcBC1 - meanBC1_Cin) * (adcBC1 - meanBC1_Cin)
95 * sigmaBC1_Cin)))
96 Z = 6;
97 } else
98 z2 = a_out + b_out * x + c_out * x * x;
99 }
100}
101
102void grabZ2OR(TClonesArray* TQDC_BC1,
103 TClonesArray* bc2Data,
104 double t0Time,
105 double& z2A,
106 double& z2B,
107 double& x,
108 double& y,
109 bool isIncoming)
110{
111 double adcBC1, adcBC2;
112 int bc1Idx, bc2Idx;
113
114 // Require that BC1 and T0 had TQDC digits
115 x = -100.0;
116 y = -100.0;
117 z2A = -100.0;
118 z2B = -100.0;
119 if (TQDC_BC1->GetEntriesFast()) {
120 // Find the waveform closest in time to T0 time
121 findIdx(TQDC_BC1, bc1Idx, t0Time);
122 BmnTrigWaveDigit* signal1 = (BmnTrigWaveDigit*)TQDC_BC1->At(bc1Idx);
123 if (isIncoming)
124 adcBC1 = signal1->GetPeak() - pedBC1;
125 else {
126 adcBC1 = signal1->GetPeak() - pedBC3;
127 }
128 x = adcBC1;
129 if (isIncoming)
130 z2A = a_in + b_in * x + c_in * x * x;
131 else
132 z2A = a_out + b_out * x + c_out * x * x;
133 }
134 if (bc2Data->GetEntriesFast()) {
135 findIdx(bc2Data, bc2Idx, t0Time);
136 BmnTrigWaveDigit* signal2 = (BmnTrigWaveDigit*)bc2Data->At(bc2Idx);
137 if (isIncoming)
138 adcBC2 = signal2->GetPeak() - pedBC2;
139 else {
140 adcBC2 = signal2->GetPeak() - pedBC4;
141 }
142 y = adcBC2;
143 if (isIncoming)
144 z2B = a_in + b_in * y + c_in * y * y;
145 else
146 z2B = a_out + b_out * y + c_out * y * y;
147 }
148}
149
150#endif
const double c_out
Definition ExtractZ2.h:14
const double a_in
Definition ExtractZ2.h:15
const double sigmaBC2_Cin
Definition ExtractZ2.h:23
const double meanBC1_Cin
Definition ExtractZ2.h:20
void findIdx(TClonesArray *data, int &index, double refT)
Definition ExtractZ2.h:27
const double b_in
Definition ExtractZ2.h:16
const double c_in
Definition ExtractZ2.h:17
void grabZ2(TClonesArray *TQDC_BC1, TClonesArray *bc2Data, double t0Time, double &z2, double &x, double BC1calib, double BC2calib, short &Z, bool isIncoming)
Definition ExtractZ2.h:42
const double sigmaMultiBC2_Cin
Definition ExtractZ2.h:25
const double b_out
Definition ExtractZ2.h:13
const double pedBC2
Definition ExtractZ2.h:9
const double pedBC4
Definition ExtractZ2.h:11
const double sigmaMultiBC1_Cin
Definition ExtractZ2.h:24
const double sigmaBC1_Cin
Definition ExtractZ2.h:22
const double meanBC2_Cin
Definition ExtractZ2.h:21
const double pedBC3
Definition ExtractZ2.h:10
const double pedBC1
Definition ExtractZ2.h:8
void grabZ2OR(TClonesArray *TQDC_BC1, TClonesArray *bc2Data, double t0Time, double &z2A, double &z2B, double &x, double &y, bool isIncoming)
Definition ExtractZ2.h:102
const double a_out
Definition ExtractZ2.h:12
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
__m128 m
Definition P4_F32vec4.h:27
class for TQDC data including waveform can be initialized both from an std::vector and raw pointer to...
int16_t GetPeak(size_t start=0, size_t stop=SIZE_MAX) const
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
RVec< PromoteType< T > > sqrt(const RVec< T > &v)