9 #include "ERTektronixSource.h" 11 #include "FairRootManager.h" 17 Int_t ERTektronixSource::fEvent = 0;
19 ERTektronixSource::ERTektronixSource():
31 ERTektronixSource::~ERTektronixSource(){
35 Bool_t ERTektronixSource::Init(){
37 ifstream* f =
new ifstream();
38 for (std::map<
int,vector<TString> >::iterator it=fPaths.begin(); it!=fPaths.end(); ++it){
39 Int_t chanel = it->first;
40 vector<TString> chanelFiles = it->second;
41 for (Int_t iFile = 0; iFile < chanelFiles.size(); iFile++ ){
42 f->open(chanelFiles[iFile]);
44 cerr <<
"Couldn`t open file " << chanelFiles[iFile] << endl;
54 Int_t eventNb = fPaths.begin()->second.size();
55 for (std::map<
int,vector<TString> >::iterator it=fPaths.begin(); it!=fPaths.end(); ++it){
56 if (it->second.size() != eventNb){
57 cerr <<
"Differen event count in chanels" << endl;
64 FairRootManager* ioman = FairRootManager::Instance();
65 for (Int_t iChanel = 0; iChanel < fNChanels; iChanel++){
68 bName.Form(
"ch%d.",iChanel+1);
69 ioman->Register(bName,
"Tektronix", fRawEvents[iChanel], kTRUE);
75 Int_t ERTektronixSource::ReadEvent(UInt_t
id){
78 if (fPaths.begin()->second.size()+1 == fEvent)
85 ifstream* f =
new ifstream();
87 for (std::map<
int,vector<TString> >::iterator it=fPaths.begin(); it!=fPaths.end(); ++it){
88 Int_t chanel = it->first;
89 vector<TString> chanelFiles= it->second;
90 f->open(chanelFiles[fEvent-1]);
91 for (Int_t iPoint = 0; iPoint < fNPoints; iPoint++){
94 cout <<
"Not enough points in file " << chanelFiles[fEvent-1] <<
" for " << chanel <<
" chanel!" <<endl;
98 fRawEvents[chanel-1]->SetAmp(amplitude,iPoint);
99 Double_t time = 5e-04+iPoint*1e-01;
100 fRawEvents[chanel-1]->SetTime(time,iPoint);
102 cout <<
"File " << chanelFiles[fEvent-1] <<
" for " << chanel <<
" chanel finished" <<endl;
109 void ERTektronixSource::Close(){
112 void ERTektronixSource::Reset(){
113 for (Int_t iChanel = 0; iChanel < fNChanels; iChanel++){
114 fRawEvents[iChanel]->Reset();
118 void ERTektronixSource::AddFile(Int_t chanel, TString path){
119 fPaths[chanel].push_back(path);
120 cout <<
"Input file " << path <<
" added to " << chanel <<
"chanel" << endl;
task for reading raw data from text files
class for raw data obtained from measurements or simulations