BmnRoot
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 // Function to find the waveform that is closest in time to T0 waveform
29 // and returns the index where the closest waveform is in the data array.
30 double minT = 1e4;
31 for (int m = 0; m < data->GetEntriesFast(); m++) {
32 BmnTrigWaveDigit *signal = (BmnTrigWaveDigit *)data->At(m);
33 double time = fabs(signal->GetTime() - refT);
34 if (time < minT) {
35 minT = time;
36 index = m;
37 }
38 }
39}
40
41void grabZ2(TClonesArray *TQDC_BC1, TClonesArray *bc2Data, double t0Time, double &z2, double &x, double BC1calib, double BC2calib, short &Z, bool isIncoming) {
42 double adcBC1, adcBC2;
43 int bc1Idx, bc2Idx;
44
45 // Require that BC1 and T0 had TQDC digits
46 if (TQDC_BC1->GetEntriesFast() && bc2Data->GetEntriesFast()) {
47 // Find the waveform closest in time to T0 time
48 findIdx(TQDC_BC1, bc1Idx, t0Time);
49 BmnTrigWaveDigit *signal1 = (BmnTrigWaveDigit *)TQDC_BC1->At(bc1Idx);
50 if (isIncoming)
51 adcBC1 = signal1->GetPeak() - pedBC1 + BC1calib;
52 else {
53 adcBC1 = signal1->GetPeak() - pedBC3;
54 }
55
56 // Find the waveform closest in time to T0 time
57 findIdx(bc2Data, bc2Idx, t0Time);
58 BmnTrigWaveDigit *signal2 = (BmnTrigWaveDigit *)bc2Data->At(bc2Idx);
59 if (isIncoming)
60 adcBC2 = signal2->GetPeak() - pedBC2 + BC2calib;
61 else {
62 adcBC2 = signal2->GetPeak() - pedBC4;
63 }
64
65 // Take geometric mean adc
66 x = sqrt(adcBC1 * adcBC2);
67
68 // Convert to Z2:
69 // Ask if this is for before target or after target
70 // because the calibration constants are different for the
71 // different PMTs
72 if (isIncoming) {
73 z2 = a_in + b_in * x + c_in * x * x;
74 // Ellipse sigmaMulti cut for Carbon on adcBC2(adcBC1) plot
76 Z = 6;
77 } else
78 z2 = a_out + b_out * x + c_out * x * x;
79 }
80}
81
82void grabZ2OR(TClonesArray *TQDC_BC1, TClonesArray *bc2Data, double t0Time, double &z2A, double &z2B, double &x, double &y, bool isIncoming) {
83 double adcBC1, adcBC2;
84 int bc1Idx, bc2Idx;
85
86 // Require that BC1 and T0 had TQDC digits
87 x = -100.0;
88 y = -100.0;
89 z2A = -100.0;
90 z2B = -100.0;
91 if (TQDC_BC1->GetEntriesFast()) {
92 // Find the waveform closest in time to T0 time
93 findIdx(TQDC_BC1, bc1Idx, t0Time);
94 BmnTrigWaveDigit *signal1 = (BmnTrigWaveDigit *)TQDC_BC1->At(bc1Idx);
95 if (isIncoming)
96 adcBC1 = signal1->GetPeak() - pedBC1;
97 else {
98 adcBC1 = signal1->GetPeak() - pedBC3;
99 }
100 x = adcBC1;
101 if (isIncoming)
102 z2A = a_in + b_in * x + c_in * x * x;
103 else
104 z2A = a_out + b_out * x + c_out * x * x;
105 }
106 if (bc2Data->GetEntriesFast()) {
107 findIdx(bc2Data, bc2Idx, t0Time);
108 BmnTrigWaveDigit *signal2 = (BmnTrigWaveDigit *)bc2Data->At(bc2Idx);
109 if (isIncoming)
110 adcBC2 = signal2->GetPeak() - pedBC2;
111 else {
112 adcBC2 = signal2->GetPeak() - pedBC4;
113 }
114 y = adcBC2;
115 if (isIncoming)
116 z2B = a_in + b_in * y + c_in * y * y;
117 else
118 z2B = a_out + b_out * y + c_out * y * y;
119 }
120}
121
122#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:41
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:82
const double a_out
Definition ExtractZ2.h:12
friend F32vec4 sqrt(const F32vec4 &a)
Definition P4_F32vec4.h:34
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
__m128 m
Definition P4_F32vec4.h:27
int GetPeak(UInt_t start=0, UInt_t stop=1e9) const
Double_t GetTime() const