BOSS 6.6.4.p03
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
 
void setData (TTree *, bool)
 
void setBarrelDataFiles (std::vector< std::string > &)
 
void setEndcapDataFiles (std::vector< std::string > &)
 
void setBarrelData (RecBTofCalHitCol &)
 
void setEndcapData (RecETofCalHitCol &)
 

Detailed Description

Definition at line 92 of file TofDataSet.h.

Constructor & Destructor Documentation

◆ TofDataSet()

TofDataSet::TofDataSet ( )

Definition at line 149 of file TofDataSet.cxx.

149 {
150 for( unsigned int i=0; i<NBarrel; i++ ) {
151 barrelData[i] = new RecordSet;
152 }
153 for( unsigned int i=0; i<NEndcap; i++ ) {
154 endcapData[i] = new RecordSet;
155 }
156 return;
157}
std::vector< Record * > RecordSet
Definition: TofDataSet.h:89
const unsigned int NBarrel
Definition: TofDataSet.h:12
const unsigned int NEndcap
Definition: TofDataSet.h:13

◆ ~TofDataSet()

TofDataSet::~TofDataSet ( )

Definition at line 160 of file TofDataSet.cxx.

160 {
161 for( unsigned int i=0; i<NBarrel; i++ ) {
162 barrelData[i]->clear();
163 delete barrelData[i];
164 }
165 for( unsigned int i=0; i<NEndcap; i++ ) {
166 endcapData[i]->clear();
167 delete endcapData[i];
168 }
169 return;
170}

Member Function Documentation

◆ getBarrelData()

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

Definition at line 98 of file TofDataSet.h.

98{ return barrelData[i]; }

Referenced by TofCalibManager::doCalibration(), and TofCalibManager::fillRoot().

◆ getEndcapData()

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

Definition at line 99 of file TofDataSet.h.

99{ return endcapData[i]; }

Referenced by TofCalibManager::doCalibration(), and TofCalibManager::fillRoot().

◆ setBarrelData()

void TofDataSet::setBarrelData ( RecBTofCalHitCol bhitcol)

Definition at line 219 of file TofDataSet.cxx.

219 {
220 RecBTofCalHitCol::iterator iter = bhitcol.begin();
221 for( ; iter!=bhitcol.end(); iter++ ) {
222 int tofid = (*iter)->mod();
223 if( tofid<0 || tofid>175 ) continue;
224
225 Record *r = new Record( (*iter) );
226 if( r->cutBarrel() ) {
227 barrelData[tofid]->push_back(r);
228 }
229 else {
230 delete r;
231 }
232 }
233 return;
234}
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 173 of file TofDataSet.cxx.

173 {
174 TChain* data_barrel = new TChain("btrk");
175 if( !data_barrel ) {
176 std::cerr << " tofcalgsec Error Msg: creating a tree[barrel] fails in TofDataSet()"<<std::endl;
177 throw "Error Msg: creating a tree fails in TofDataSet() ";
178 }
179 std::cout<<"begin reading barrel data file ... "<<std::endl;
180 try{
181 for( std::vector<std::string>::iterator it=barrelFiles.begin(); it!=barrelFiles.end(); it++ ) {
182 std::cout << " Add file : " << (*it) << std::endl;
183 data_barrel->Add( (*it).c_str() );
184 }
185 }
186 catch(...){
187 std::cerr << "tofcalgsec Error Msg : in TofDataSet::setDataFiles(std::vector<std::string>&) " << std::endl;
188 return;
189 }
190 setData( data_barrel, true );
191 delete data_barrel;
192 return;
193}
void setData(TTree *, bool)
Definition: TofDataSet.cxx:99

Referenced by tofcalgsec::finalize().

◆ setData()

void TofDataSet::setData ( TTree *  t,
bool  isBarrel 
)

Definition at line 99 of file TofDataSet.cxx.

99 {
100 if( t && t->GetEntries()>0 ) {
101 rootRecord item;
102 t->SetBranchAddress( "run", &item.run );
103 t->SetBranchAddress( "event", &item.event );
104 t->SetBranchAddress( "tofid", &item.tofid );
105 t->SetBranchAddress( "qleft", &item.qleft );
106 t->SetBranchAddress( "qright", &item.qright );
107 t->SetBranchAddress( "tleft", &item.tleft );
108 t->SetBranchAddress( "tright", &item.tright );
109 t->SetBranchAddress( "zrhit", &item.zrhit );
110 t->SetBranchAddress( "texp", &item.texp );
111 t->SetBranchAddress( "path", &item.path );
112 t->SetBranchAddress( "phi", &item.phi );
113 t->SetBranchAddress( "theta", &item.theta );
114 t->SetBranchAddress( "p", &item.p );
115 t->SetBranchAddress( "hitcase", &item.hitcase );
116
117 for( unsigned int i=0; i<t->GetEntries(); i++ ) {
118 t->GetEntry(i);
119 if( isBarrel && item.hitcase>=0 && item.hitcase<=2 ) {
120 Record *r = new Record( item );
121 if( r->cutBarrel() ) {
122 unsigned int tofID = item.tofid;
123 barrelData[tofID]->push_back(r);
124 }
125 else {
126 delete r;
127 }
128 }
129 else if( !isBarrel && ( item.hitcase==3 || item.hitcase==4 ) ) {
130 Record *r = new Record( item );
131 if( r->cutEndcap() ) {
132 unsigned int tofID = item.tofid;
133 endcapData[tofID]->push_back(r);
134 }
135 else {
136 delete r;
137 }
138 }
139 }
140 }
141 else {
142 std::cerr << "Error: a invalid tree or a blank tree, When converting a tree to TofDataSet,exit" << std::endl;
143 }
144
145 return;
146}
bool cutEndcap()
Definition: cut.cxx:88
Int_t run
Definition: TofDataSet.h:16
Double_t tright
Definition: TofDataSet.h:22
Int_t tofid
Definition: TofDataSet.h:18
Double_t qright
Definition: TofDataSet.h:20
Double_t path
Definition: TofDataSet.h:25
Double_t texp
Definition: TofDataSet.h:24
Double_t phi
Definition: TofDataSet.h:26
Int_t event
Definition: TofDataSet.h:17
Int_t hitcase
Definition: TofDataSet.h:31
Double_t zrhit
Definition: TofDataSet.h:23
Double_t tleft
Definition: TofDataSet.h:21
Double_t theta
Definition: TofDataSet.h:27
Double_t p
Definition: TofDataSet.h:28
Double_t qleft
Definition: TofDataSet.h:19
int t()
Definition: t.c:1

Referenced by setBarrelDataFiles(), and setEndcapDataFiles().

◆ setEndcapData()

void TofDataSet::setEndcapData ( RecETofCalHitCol ehitcol)

Definition at line 237 of file TofDataSet.cxx.

237 {
238 RecETofCalHitCol::iterator iter = ehitcol.begin();
239 for( ; iter!=ehitcol.end(); iter++ ) {
240 int tofid = (*iter)->mod();
241 if( tofid<0 || tofid>95 ) continue;
242
243 Record *r = new Record( (*iter) );
244 if( r->cutEndcap() ) {
245 endcapData[tofid]->push_back(r);
246 }
247 else {
248 delete r;
249 }
250 }
251 return;
252}

Referenced by tofcalgsec::execute().

◆ setEndcapDataFiles()

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

Definition at line 196 of file TofDataSet.cxx.

196 {
197 TChain* data_endcap = new TChain("etrk");
198 if( !data_endcap ) {
199 std::cerr << " tofcalgsec Error Msg: creating a tree[endcap] fails in TofDataSet()"<<std::endl;
200 throw "Error Msg: creating a tree fails in TofDataSet() ";
201 }
202 std::cout<<"begin reading endcap data file ... "<<std::endl;
203 try{
204 for( std::vector<std::string>::iterator it=endcapFiles.begin(); it!=endcapFiles.end(); it++ ) {
205 std::cout << " Add file : " << (*it) << std::endl;
206 data_endcap->Add( (*it).c_str() );
207 }
208 }
209 catch(...){
210 std::cerr << "tofcalgsec Error Msg : in TofDataSet::setDataFiles(std::vector<std::string>&) " << std::endl;
211 return;
212 }
213 setData( data_endcap, false );
214 delete data_endcap;
215 return;
216}

Referenced by tofcalgsec::finalize().


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