BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TofDataSet Class Reference

#include <TofDataSet.h>

Public Member Functions

 TofDataSet ()
 ~TofDataSet ()
RecordSetgetBarrelData (unsigned int i) const
RecordSetgetEndcapData (unsigned int i) const
RecordSetgetEtfData (unsigned int i) const
void setData (TTree *, unsigned int)
void setBarrelDataFiles (std::vector< std::string > &)
void setEndcapDataFiles (std::vector< std::string > &)
void setEtfDataFiles (std::vector< std::string > &)
void setBarrelData (RecBTofCalHitCol &)
void setEndcapData (RecETofCalHitCol &)
void setEtfData (RecBTofCalHitCol &)

Detailed Description

Definition at line 99 of file TofDataSet.h.

Constructor & Destructor Documentation

◆ TofDataSet()

TofDataSet::TofDataSet ( )

Definition at line 172 of file TofDataSet.cxx.

172 {
173 for ( unsigned int i = 0; i < NBarrel; i++ ) { barrelData[i] = new RecordSet; }
174 for ( unsigned int i = 0; i < NEndcap; i++ ) { endcapData[i] = new RecordSet; }
175 for ( unsigned int i = 0; i < NEtf * NStrip; i++ ) { etfData[i] = new RecordSet; }
176 return;
177}
std::vector< Record * > RecordSet
Definition TofDataSet.h:97
const unsigned int NStrip
Definition TofDataSet.h:15
const unsigned int NEtf
Definition TofDataSet.h:14
const unsigned int NBarrel
Definition TofDataSet.h:12
const unsigned int NEndcap
Definition TofDataSet.h:13

◆ ~TofDataSet()

TofDataSet::~TofDataSet ( )

Definition at line 179 of file TofDataSet.cxx.

179 {
180 for ( unsigned int i = 0; i < NBarrel; i++ )
181 {
182 barrelData[i]->clear();
183 delete barrelData[i];
184 }
185 for ( unsigned int i = 0; i < NEndcap; i++ )
186 {
187 endcapData[i]->clear();
188 delete endcapData[i];
189 }
190 for ( unsigned int i = 0; i < NEtf * NStrip; i++ )
191 {
192 etfData[i]->clear();
193 delete etfData[i];
194 }
195 return;
196}

Member Function Documentation

◆ getBarrelData()

RecordSet * TofDataSet::getBarrelData ( unsigned int i) const
inline

Definition at line 105 of file TofDataSet.h.

105{ return barrelData[i]; }

◆ getEndcapData()

RecordSet * TofDataSet::getEndcapData ( unsigned int i) const
inline

Definition at line 106 of file TofDataSet.h.

106{ return endcapData[i]; }

◆ getEtfData()

RecordSet * TofDataSet::getEtfData ( unsigned int i) const
inline

Definition at line 107 of file TofDataSet.h.

107{ return etfData[i]; }

◆ setBarrelData()

void TofDataSet::setBarrelData ( RecBTofCalHitCol & bhitcol)

Definition at line 285 of file TofDataSet.cxx.

285 {
286 RecBTofCalHitCol::iterator iter = bhitcol.begin();
287 for ( ; iter != bhitcol.end(); iter++ )
288 {
289 int tofid = ( *iter )->mod();
290 if ( tofid < 0 || tofid > 175 ) continue;
291 if ( fabs( ( *iter )->dzHit() - 1.0 ) > 1.0e-6 ) continue;
292
293 Record* r = new Record( ( *iter ) );
294 if ( r->cutBarrel() ) { barrelData[tofid]->push_back( r ); }
295 else { delete r; }
296 }
297 return;
298}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
bool cutBarrel()
Definition cut.cxx:3

Referenced by tofcalgsec::execute().

◆ setBarrelDataFiles()

void TofDataSet::setBarrelDataFiles ( std::vector< std::string > & barrelFiles)

Definition at line 198 of file TofDataSet.cxx.

198 {
199 TChain* data_barrel = new TChain( "btrk" );
200 if ( !data_barrel )
201 {
202 std::cerr << " tofcalgsec Error Msg: creating a tree[barrel] fails in TofDataSet()"
203 << std::endl;
204 throw "Error Msg: creating a tree fails in TofDataSet() ";
205 }
206 std::cout << "begin reading barrel data file ... " << std::endl;
207 try
208 {
209 for ( std::vector<std::string>::iterator it = barrelFiles.begin(); it != barrelFiles.end();
210 it++ )
211 {
212 std::cout << " Add file : " << ( *it ) << std::endl;
213 data_barrel->Add( ( *it ).c_str() );
214 }
215 } catch ( ... )
216 {
217 std::cerr
218 << "tofcalgsec Error Msg : in TofDataSet::setDataFiles(std::vector<std::string>&) "
219 << std::endl;
220 return;
221 }
222 setData( data_barrel, 1 );
223 delete data_barrel;
224 return;
225}
void setData(TTree *, unsigned int)

Referenced by tofcalgsec::finalize().

◆ setData()

void TofDataSet::setData ( TTree * t,
unsigned int isBarrel )

Definition at line 104 of file TofDataSet.cxx.

104 {
105 if ( t && t->GetEntries() > 0 )
106 {
107 rootRecord item;
108 t->SetBranchAddress( "run", &item.run );
109 t->SetBranchAddress( "event", &item.event );
110 t->SetBranchAddress( "tofid", &item.tofid );
111 if ( NULL != t->FindBranch( "strip" ) ) { t->SetBranchAddress( "strip", &item.strip ); }
112 t->SetBranchAddress( "qleft", &item.qleft );
113 t->SetBranchAddress( "qright", &item.qright );
114 t->SetBranchAddress( "tleft", &item.tleft );
115 t->SetBranchAddress( "tright", &item.tright );
116 t->SetBranchAddress( "zrhit", &item.zrhit );
117 if ( NULL != t->FindBranch( "dt" ) ) { t->SetBranchAddress( "dt", &item.dt ); }
118 t->SetBranchAddress( "texp", &item.texp );
119 t->SetBranchAddress( "path", &item.path );
120 t->SetBranchAddress( "phi", &item.phi );
121 t->SetBranchAddress( "theta", &item.theta );
122 t->SetBranchAddress( "p", &item.p );
123 t->SetBranchAddress( "hitcase", &item.hitcase );
124
125 for ( unsigned int i = 0; i < t->GetEntries(); i++ )
126 {
127 t->GetEntry( i );
128 if ( isBarrel == 1 && item.hitcase >= 0 && item.hitcase <= 2 )
129 {
130 Record* r = new Record( item );
131 if ( r->cutBarrel() )
132 {
133 unsigned int tofID = item.tofid;
134 barrelData[tofID]->push_back( r );
135 }
136 else { delete r; }
137 }
138 else if ( isBarrel == 0 && ( item.hitcase == 3 || item.hitcase == 4 ) )
139 {
140 Record* r = new Record( item );
141 if ( r->cutEndcap() )
142 {
143 unsigned int tofID = item.tofid;
144 endcapData[tofID]->push_back( r );
145 }
146 else { delete r; }
147 }
148 else if ( isBarrel == 2 && item.hitcase >= 5 && item.hitcase <= 6 )
149 {
150 Record* r = new Record( item );
151 if ( r->cutEtf() )
152 {
153 unsigned int tofID = item.tofid;
154 unsigned int strip = item.strip;
155 unsigned int id = tofID * 12 + strip;
156 etfData[id]->push_back( r );
157 }
158 else { delete r; }
159 }
160 }
161 }
162 else
163 {
164 std::cerr
165 << "Error: a invalid tree or a blank tree, When converting a tree to TofDataSet,exit"
166 << std::endl;
167 }
168
169 return;
170}
struct tagItem rootRecord
bool cutEtf()
Definition cut.cxx:355
bool cutEndcap()
Definition cut.cxx:259
Int_t run
Definition TofDataSet.h:18
Double_t tright
Definition TofDataSet.h:25
Int_t tofid
Definition TofDataSet.h:20
Double_t qright
Definition TofDataSet.h:23
Double_t path
Definition TofDataSet.h:29
Double_t texp
Definition TofDataSet.h:28
Double_t phi
Definition TofDataSet.h:30
Int_t event
Definition TofDataSet.h:19
Double_t dt
Definition TofDataSet.h:27
Int_t hitcase
Definition TofDataSet.h:35
Int_t strip
Definition TofDataSet.h:21
Double_t zrhit
Definition TofDataSet.h:26
Double_t tleft
Definition TofDataSet.h:24
Double_t theta
Definition TofDataSet.h:31
Double_t p
Definition TofDataSet.h:32
Double_t qleft
Definition TofDataSet.h:22
int t()
Definition t.c:1

Referenced by setBarrelDataFiles(), setEndcapDataFiles(), and setEtfDataFiles().

◆ setEndcapData()

void TofDataSet::setEndcapData ( RecETofCalHitCol & ehitcol)

Definition at line 300 of file TofDataSet.cxx.

300 {
301 RecETofCalHitCol::iterator iter = ehitcol.begin();
302 for ( ; iter != ehitcol.end(); iter++ )
303 {
304 int tofid = ( *iter )->mod();
305 if ( tofid < 0 || tofid > 95 ) continue;
306
307 Record* r = new Record( ( *iter ) );
308 if ( r->cutEndcap() ) { endcapData[tofid]->push_back( r ); }
309 else { delete r; }
310 }
311 return;
312}

Referenced by tofcalgsec::execute().

◆ setEndcapDataFiles()

void TofDataSet::setEndcapDataFiles ( std::vector< std::string > & endcapFiles)

Definition at line 227 of file TofDataSet.cxx.

227 {
228 TChain* data_endcap = new TChain( "etrk" );
229 if ( !data_endcap )
230 {
231 std::cerr << " tofcalgsec Error Msg: creating a tree[endcap] fails in TofDataSet()"
232 << std::endl;
233 throw "Error Msg: creating a tree fails in TofDataSet() ";
234 }
235 std::cout << "begin reading endcap data file ... " << std::endl;
236 try
237 {
238 for ( std::vector<std::string>::iterator it = endcapFiles.begin(); it != endcapFiles.end();
239 it++ )
240 {
241 std::cout << " Add file : " << ( *it ) << std::endl;
242 data_endcap->Add( ( *it ).c_str() );
243 }
244 } catch ( ... )
245 {
246 std::cerr
247 << "tofcalgsec Error Msg : in TofDataSet::setDataFiles(std::vector<std::string>&) "
248 << std::endl;
249 return;
250 }
251 setData( data_endcap, 0 );
252 delete data_endcap;
253 return;
254}

Referenced by tofcalgsec::finalize().

◆ setEtfData()

void TofDataSet::setEtfData ( RecBTofCalHitCol & bhitcol)

Definition at line 314 of file TofDataSet.cxx.

314 {
315 RecBTofCalHitCol::iterator iter = bhitcol.begin();
316 for ( ; iter != bhitcol.end(); iter++ )
317 {
318 int tofid = ( *iter )->mod();
319 int strip = int( ( *iter )->sinTheta() );
320 if ( tofid < 0 || tofid > 71 ) continue;
321 if ( strip < 0 || strip > 11 ) continue;
322 if ( fabs( ( *iter )->dzHit() ) > 1.0e-6 ) continue;
323 unsigned int id = tofid * 12 + strip;
324 Record* r = new Record( ( *iter ) );
325 if ( r->cutEtf() ) { etfData[id]->push_back( r ); }
326 else { delete r; }
327 }
328 return;
329}

Referenced by tofcalgsec::execute().

◆ setEtfDataFiles()

void TofDataSet::setEtfDataFiles ( std::vector< std::string > & etfFiles)

Definition at line 256 of file TofDataSet.cxx.

256 {
257 TChain* data_etf = new TChain( "etf" );
258 if ( !data_etf )
259 {
260 std::cerr << " tofcalgsec Error Msg: creating a tree[etf] fails in TofDataSet()"
261 << std::endl;
262 throw "Error Msg: creating a tree fails in TofDataSet() ";
263 }
264 std::cout << "begin reading etf data file ... " << std::endl;
265 try
266 {
267 for ( std::vector<std::string>::iterator it = etfFiles.begin(); it != etfFiles.end();
268 it++ )
269 {
270 std::cout << " Add file : " << ( *it ) << std::endl;
271 data_etf->Add( ( *it ).c_str() );
272 }
273 } catch ( ... )
274 {
275 std::cerr
276 << "tofcalgsec Error Msg : in TofDataSet::setDataFiles(std::vector<std::string>&) "
277 << std::endl;
278 return;
279 }
280 setData( data_etf, 2 );
281 delete data_etf;
282 return;
283}

Referenced by tofcalgsec::finalize().


The documentation for this class was generated from the following files: