-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTXPConfig.h
More file actions
136 lines (116 loc) · 4.64 KB
/
TXPConfig.h
File metadata and controls
136 lines (116 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include <string>
#include <sstream>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include <TVector3.h>
#include <TTreeReaderArray.h>
#include "TRandom.h"
#include "TObject.h"
// Event packet definitions for events processed with TXPConfig
namespace EvntPacket {
// Singles events are events with the charge transformed into
// a calibrated energy from XPConfig.
struct Singles {
std::vector<double_t> Energy;
std::vector<int16_t> index;
std::vector<int> detectorNum;
std::vector<int> crystNum;
std::vector<int16_t> timeStamp;
int multiplicity; // number of events in packet
};
// Addback events are events where calibrated coincident events in the same
// detector between crystals are added together. This recovers
// information about the full energy peak from compton scattered
// events.
struct Addback {
std::vector<double_t> Energy;
std::vector<int16_t> detectorNum;
std::vector<int16_t> timeStamp; // timestamp of the first event
std::vector<int16_t> groupedHitsNum;
std::vector<bool> isCompton; // true if BGO shield triggers
int multiplicity;
};
} //end EvntPacket
// Class to load in the experimental configuration and process events into
// event packets
class TXPConfig : public TObject {
ClassDef(TXPConfig, 2);
// Initialize from a XPConfig
public:
/* == Constructors and Initalizors == */
TXPConfig();
// %% Load experimenal configuration from config files %%
TXPConfig(std::string XPConfig);
TXPConfig(std::string XPConfig, std::string XPGeometry);
int loadCal(std::string XPConfig);
void exportCal(std::string XPConfig);
/* == Geometry Functions == */
int loadGeometry(std::string XPGeometry);
void exportGeometry(std::string XPGeometry);
double_t GetAngleIndex( int index1, int index2 );
double_t GetAngleDetec( int nDet1, int nDet2 );
int getDetNum( int index );
int getCrystNum( int index );
/* == Energy calibration functions == */
double_t GetEnergy(int32_t &Q, short &index);
double_t GetCal( int nCoeff, int index );
void SetCal( int nCoeff, int index , double_t Coeff);
/* == Gain Matching Functions == */
int loadGainMatch( std::string GainMatchFileLoc );
void exportGainMatch( std::string GainMatchFileLoc );
void SetGainMatchForIndex( int index, double_t offset, double_t slope );
void deleteGainMatchForIndex( int index );
void deleteGainMatch( );
/* == Functions for vetoing detector events == */
// The following detectors should be vitoed:
// * BGO shields
// * Detectors with Tr set to 0 (ie, bad channels)
bool isVito(int index); // returns true if index is bad
bool isHPGe( int index)
{ if( fDetTypeVec[index] == 1 ) return true; return false; }
bool isBGO(int index)
{ if( fDetTypeVec[index] == -1) return true; return false; }
// Set the state of the detector
void setVitoDet(int index, bool state);
/* == Processing functions == */
// The returned objects must be deleted
EvntPacket::Singles* Leaf2Singles( TTreeReaderArray<int32_t> &Q,
TTreeReaderArray<int16_t> &adc, TTreeReaderArray<int16_t> &timeStamp,
int multiplicity);
EvntPacket::Addback* Leaf2Addback( TTreeReaderArray<int32_t> &Q,
TTreeReaderArray<int16_t> &adc, TTreeReaderArray<int16_t> &timeStamp,
int multiplicity);
/*
EventPacket::Addback* Singles2Addback( EvntPacket::Singles* Singles );
*/
/* == Misc functions == */
// Return the number of channels loaded
int NChan();
private:
// Calibration coefficents for
// Cal0 + Cal1*Q = E
bool fhasEngCalibration = false;
std::vector<double_t> fCal0Vec;
std::vector<double_t> fCal1Vec;
std::vector<double_t> fCal2Vec;
// Vito list
std::vector<bool> fvitoVec;
std::vector<int> fisTrVec;
// Gain Match Information
bool fhasGainMatch = false;
std::vector<double_t> fGainMatchOffsetVec;
std::vector<double_t> fGainMatchSlopeVec;
void CreateEmptyGainMatch();
// Detector type
std::vector<int> fDetTypeVec;
// Geometry
bool fhasGeometry = false;
std::vector<int> fIndex2Clover;
std::vector<int> fIndex2Cryst;
TVector3 fDetPositions[16];
};