forked from JeffersonLab/SBS-offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SBSGEMStand.cxx
178 lines (133 loc) · 4.06 KB
/
SBSGEMStand.cxx
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <iostream>
#include <string>
#include "THaTrackingDetector.h"
#include "THaRunBase.h"
#include "THaCrateMap.h"
#include "THaAnalysisObject.h"
#include "SBSGEMStand.h"
#include "SBSGEMPlane.h"
#include "Textvars.h"
using namespace Podd;
SBSGEMStand::SBSGEMStand( const char* name, const char* desc, THaApparatus* app ):
THaTrackingDetector(name,desc,app) {
fPlanes.clear();
fIsMC = false;//by default!
fCrateMap = 0;
}
SBSGEMStand::~SBSGEMStand(){
return;
}
THaAnalysisObject::EStatus SBSGEMStand::Init( const TDatime& date ){
assert( fCrateMap == 0 );
// Why THaTrackingDetector::Init() here? THaTrackingDetector doesn't implement its own Init() method
THaAnalysisObject::EStatus status = THaTrackingDetector::Init(date);
if( status == kOK ){
for (std::vector<SBSGEMPlane *>::iterator it = fPlanes.begin() ; it != fPlanes.end(); ++it){
status = (*it)->Init(date);
if( status != kOK ){
return status;
}
}
} else {
return kInitError;
}
return kOK;
}
Int_t SBSGEMStand::ReadDatabase( const TDatime& date ){
std::cout << "[Reading SBSGEMStand database]" << std::endl;
fIsInit = kFALSE;
FILE* file = OpenFile( date );
if( !file ) return kFileError;
//As far as I can tell, this doesn't do anything yet (AJRP):
Int_t err = ReadGeometry( file, date );
if( err ) {
fclose(file);
return err;
}
std::string planeconfig;
std::vector<Int_t> *cmap = new std::vector<Int_t>;
//it appears that cmap is not actually used yet in any way. TBD
DBRequest request[] = {
{ "planeconfig", &planeconfig, kString },
{ "cratemap", cmap, kIntV },
{ "is_mc", &fIsMC, kInt, 0, 1},
{0}
};
err = LoadDB( file, date, request, fPrefix );
fclose(file);
if(err)
return err;
//vsplit is a Podd function that "tokenizes" a string into a vector<string> by whitespace:
std::vector<std::string> planes = vsplit(planeconfig);
if( planes.empty()) {
Error("", "[SBSGEMStand::ReadDatabase] No planes defined");
}
for (const auto& name : planes ) {
fPlanes.push_back(new SBSGEMPlane( name.c_str(), name.c_str(), this, fIsMC));
}
fIsInit = kTRUE;
return kOK;
}
Int_t SBSGEMStand::Begin( THaRunBase* run ){
for (std::vector<SBSGEMPlane *>::iterator it = fPlanes.begin() ; it != fPlanes.end(); ++it){
(*it)->Begin(run);
}
return 0;
}
void SBSGEMStand::Clear( Option_t *opt ){
THaTrackingDetector::Clear(opt);
for (auto* plane : fPlanes ){
plane->Clear(opt);
}
return;
}
Int_t SBSGEMStand::Decode(const THaEvData& evdata ){
//return 0;
//std::cout << "[SBSGEMStand::Decode]" << std::endl;
for (auto* plane : fPlanes ) {
plane->Decode(evdata);
}
return 0;
}
Int_t SBSGEMStand::End( THaRunBase* run ){
for (auto* plane : fPlanes ) {
plane->End(run);
}
return 0;
}
void SBSGEMStand::Print(const Option_t* opt) const {
std::cout << "GEM Stand " << fName << " with " << fPlanes.size() << " planes defined:" << std::endl;
/*
for (std::vector<SBSGEMPlane *>::iterator it = fPlanes.begin() ; it != fPlanes.end(); ++it){
std::cout << "\t"
(*it)->Print(opt);
}
*/
for( auto* plane : fPlanes.size() ){
plane->Print(opt);
}
return;
}
void SBSGEMStand::SetDebug( Int_t level ){
THaTrackingDetector::SetDebug( level );
for (auto* plane : fPlanes ) {
plane->SetDebug(level);
}
return;
}
Int_t SBSGEMStand::DefineVariables( EMode mode ){
if( mode == kDefine and fIsSetup ) return kOK;
fIsSetup = ( mode == kDefine );
RVarDef vars[] = {
// { "trkstat", "Track reconstruction status", "fTrkStat" },
{ 0 },
};
DefineVarsFromList( vars, mode );
return 0;
}
Int_t SBSGEMStand::CoarseTrack( TClonesArray& tracks ){
return 0;
}
Int_t SBSGEMStand::FineTrack( TClonesArray& tracks ){
return 0;
}