#include "TTree.h"
#include "TFile.h"
#include <assert.h>
#include <iostream>
#include <fstream>
Go to the source code of this file.
Functions | |
bool | barrel_conv2root () |
bool | endcap_conv2root () |
bool | sim_barrel_conv2root () |
bool | sim_endcap_conv2root () |
bool | join () |
bool | main () |
bool barrel_conv2root | ( | ) |
Definition at line 12 of file convElec2root.cxx.
References genRecEmupikp::i, ganga-rec::j, TrigConf::N, and num.
00012 { 00013 TTree* t1=new TTree("QElecBarParEast","barrel parameters of east end"); 00014 TTree* t2=new TTree("QElecBarParWest","barrel parameters of west end"); 00015 TTree* t3=new TTree("BarBoardNum","barrel electronics number"); 00016 double p1[11]={0.}; 00017 double p2[11]={0.}; 00018 char brname[50]; //branch name 00019 char ptname[50]; //pattern name 00020 for(int i=0;i<11;i++){ 00021 sprintf(brname,"P%d",i); 00022 sprintf(ptname,"p%d/D",i); 00023 t1->Branch(brname,&p1[i],ptname); 00024 t2->Branch(brname,&p2[i],ptname); 00025 } 00026 00027 double num[4]={0.}; 00028 sprintf(brname,"Board"); 00029 sprintf(ptname,"board/D"); 00030 t3->Branch(brname,&num[0],ptname); 00031 sprintf(brname,"Crate"); 00032 sprintf(ptname,"crate/D"); 00033 t3->Branch(brname,&num[1],ptname); 00034 sprintf(brname,"Fee"); 00035 sprintf(ptname,"fee/D"); 00036 t3->Branch(brname,&num[2],ptname); 00037 sprintf(brname,"Channel"); 00038 sprintf(ptname,"channel/D"); 00039 t3->Branch(brname,&num[3],ptname); 00040 00041 const unsigned int N = 2; 00042 bool is_open[N]={false}; 00043 ifstream infile[N]; 00044 char inTxtFile[N][500]={"ElecBarEast.txt","ElecBarWest.txt"}; 00045 for(int m=0;m<N;m++){ 00046 infile[m].open(inTxtFile[m],ios::in); 00047 if(infile[m].good()) 00048 is_open[m]=true; 00049 else 00050 std::cerr<<"file: "<<inTxtFile[N]<<" can't be found!"<<std::endl; 00051 } 00052 try{ 00053 for(int k=0;k<176;k++){ 00054 //------------set p------------------------- 00055 if(is_open[0]){ 00056 for( unsigned int j=0; j<4; j++ ) { 00057 infile[0] >> num[j]; 00058 } 00059 for( unsigned int j=0; j<9; j++ ) { 00060 infile[0] >> p1[j]; 00061 } 00062 } 00063 t1->Fill(); 00064 t3->Fill(); 00065 if(is_open[1]){ 00066 for( unsigned int j=0; j<4; j++ ) { 00067 infile[1] >> num[j]; 00068 } 00069 for( unsigned int j=0; j<9; j++ ) { 00070 infile[1] >> p2[j]; 00071 } 00072 } 00073 t2->Fill(); 00074 t3->Fill(); 00075 } 00076 } 00077 catch(...) { 00078 return false; 00079 } 00080 00081 TFile f("BarTofQElecPar.root","RECREATE"); 00082 t1->Write(); 00083 t2->Write(); 00084 t3->Write(); 00085 f.Close(); 00086 delete t1; 00087 delete t2; 00088 delete t3; 00089 t1=NULL; 00090 t2=NULL; 00091 t3=NULL; 00092 return true; 00093 }
bool endcap_conv2root | ( | ) |
Definition at line 95 of file convElec2root.cxx.
References genRecEmupikp::i, ganga-rec::j, and num.
00095 { 00096 TTree* t1=new TTree("QElecEndPar","endcap parameters of east end"); 00097 TTree* t2=new TTree("EndBoardNum","endcap electronics number"); 00098 double p[11]={0.}; 00099 char brname[50]; //branch name 00100 char ptname[50]; //pattern name 00101 for(int i=0;i<11;i++){ 00102 sprintf(brname,"P%d",i); 00103 sprintf(ptname,"p%d/D",i); 00104 t1->Branch(brname,&p[i],ptname); 00105 } 00106 00107 double num[4]={0.}; 00108 sprintf(brname,"Board"); 00109 sprintf(ptname,"board/D"); 00110 t2->Branch(brname,&num[0],ptname); 00111 sprintf(brname,"Crate"); 00112 sprintf(ptname,"crate/D"); 00113 t2->Branch(brname,&num[1],ptname); 00114 sprintf(brname,"Fee"); 00115 sprintf(ptname,"fee/D"); 00116 t2->Branch(brname,&num[2],ptname); 00117 sprintf(brname,"Channel"); 00118 sprintf(ptname,"channel/D"); 00119 t2->Branch(brname,&num[3],ptname); 00120 00121 bool is_open=false; 00122 ifstream infile; 00123 char inTxtFile[500]="ElecEndcap.txt"; 00124 infile.open(inTxtFile,ios::in); 00125 if(infile.good()) 00126 is_open=true; 00127 else 00128 std::cerr<<"file: "<<inTxtFile<<" can't be found!"<<std::endl; 00129 try{ 00130 for(int k=0;k<96;k++){ 00131 //------------set p------------------------- 00132 if(is_open){ 00133 for( unsigned int j=0; j<4; j++ ) { 00134 infile >> num[j]; 00135 } 00136 for( unsigned int j=0; j<9; j++ ) { 00137 infile >> p[j]; 00138 } 00139 } 00140 t1->Fill(); 00141 t2->Fill(); 00142 } 00143 } 00144 catch(...) { 00145 return false; 00146 } 00147 00148 TFile f("EndTofQElecPar.root","RECREATE"); 00149 t1->Write(); 00150 t2->Write(); 00151 f.Close(); 00152 delete t1; 00153 delete t2; 00154 t1=NULL; 00155 t2=NULL; 00156 return true; 00157 }
bool join | ( | ) |
Definition at line 260 of file convElec2root.cxx.
00260 { 00261 TFile f1("EndTofQElecPar.root"); 00262 TTree* t11=(TTree*)f1.Get("QElecEndPar"); 00263 if(0==t11) { std::cerr<<" can't get tree :QElecEndPar in file EndTofQElecPar.root"<<std::endl; return false;} 00264 TTree* t12=(TTree*)f1.Get("EndBoardNum"); 00265 if(0==t12) { std::cerr<<" can't get tree :EndBoardNum in file EndTofQElecPar.root"<<std::endl; return false;} 00266 00267 TFile f2("BarTofQElecPar.root"); 00268 TTree* t21=(TTree*)f2.Get("QElecBarParEast"); 00269 if(0==t21) { std::cerr<<" can't get tree :QElecBarParEast in file BarTofQElecPar.root"<<std::endl; return false;} 00270 TTree* t22=(TTree*)f2.Get("QElecBarParWest"); 00271 if(0==t22) { std::cerr<<" can't get tree :QElecBarParWest in file BarTofQElecPar.root"<<std::endl; return false;} 00272 TTree* t23=(TTree*)f2.Get("BarBoardNum"); 00273 if(0==t23) { std::cerr<<" can't get tree :BarBoardNum in file BarTofQElecPar.root"<<std::endl; return false;} 00274 00275 TFile f3("SimEndTofQElecPar.root"); 00276 TTree* t31=(TTree*)f3.Get("SimQElecEndPar"); 00277 if(0==t31) { std::cerr<<" can't get tree :SimQElecEndPar in file SimEndTofQElecPar.root"<<std::endl; return false;} 00278 00279 TFile f4("SimBarTofQElecPar.root"); 00280 TTree* t41=(TTree*)f4.Get("SimQElecBarParEast"); 00281 if(0==t41) { std::cerr<<" can't get tree :SimQElecBarParEast in file SimBarTofQElecPar.root"<<std::endl; return false;} 00282 TTree* t42=(TTree*)f4.Get("SimQElecBarParWest"); 00283 if(0==t42) { std::cerr<<" can't get tree :SimQElecBarParWest in file SimBarTofQElecPar.root"<<std::endl; return false;} 00284 00285 TFile fnew("TofQElecConst.root","RECREATE"); 00286 t11->Write(); 00287 t12->Write(); 00288 t21->Write(); 00289 t22->Write(); 00290 t23->Write(); 00291 t31->Write(); 00292 t41->Write(); 00293 t42->Write(); 00294 f1.Close(); 00295 f2.Close(); 00296 f3.Close(); 00297 f4.Close(); 00298 fnew.Close(); 00299 t11=NULL; 00300 t12=NULL; 00301 t21=NULL; 00302 t22=NULL; 00303 t23=NULL; 00304 t31=NULL; 00305 t41=NULL; 00306 t42=NULL; 00307 return true; 00308 }
bool main | ( | ) |
Definition at line 310 of file convElec2root.cxx.
References barrel_conv2root(), endcap_conv2root(), join(), sim_barrel_conv2root(), and sim_endcap_conv2root().
00310 { 00311 barrel_conv2root(); 00312 endcap_conv2root(); 00313 sim_barrel_conv2root(); 00314 sim_endcap_conv2root(); 00315 join(); 00316 }
bool sim_barrel_conv2root | ( | ) |
Definition at line 160 of file convElec2root.cxx.
References genRecEmupikp::i, ganga-rec::j, and TrigConf::N.
Referenced by main().
00160 { 00161 TTree* t1=new TTree("SimQElecBarParEast","barrel parameters of east end"); 00162 TTree* t2=new TTree("SimQElecBarParWest","barrel parameters of west end"); 00163 double p1[11]={0.}; 00164 double p2[11]={0.}; 00165 char brname[50]; //branch name 00166 char ptname[50]; //pattern name 00167 for(int i=0;i<11;i++){ 00168 sprintf(brname,"P%d",i); 00169 sprintf(ptname,"p%d/D",i); 00170 t1->Branch(brname,&p1[i],ptname); 00171 t2->Branch(brname,&p2[i],ptname); 00172 } 00173 00174 const unsigned int N = 2; 00175 bool is_open[N]={false}; 00176 ifstream infile[N]; 00177 char inTxtFile[N][500]={"ElecBarEast-Curve.txt","ElecBarWest-Curve.txt"}; 00178 for(int m=0;m<N;m++){ 00179 infile[m].open(inTxtFile[m],ios::in); 00180 if(infile[m].good()) 00181 is_open[m]=true; 00182 else 00183 std::cerr<<"file: "<<inTxtFile[N]<<" can't be found!"<<std::endl; 00184 } 00185 try{ 00186 for(int k=0;k<176;k++){ 00187 //------------set p------------------------- 00188 if(is_open[0]){ 00189 for( unsigned int j=0; j<11; j++ ) { 00190 infile[0] >> p1[j]; 00191 } 00192 } 00193 if(is_open[1]){ 00194 for( unsigned int j=0; j<11; j++ ) { 00195 infile[1] >> p2[j]; 00196 } 00197 } 00198 t1->Fill(); 00199 t2->Fill(); 00200 } 00201 } 00202 catch(...) { 00203 return false; 00204 } 00205 00206 TFile f("SimBarTofQElecPar.root","RECREATE"); 00207 t1->Write(); 00208 t2->Write(); 00209 f.Close(); 00210 delete t1; 00211 delete t2; 00212 t1=NULL; 00213 t2=NULL; 00214 return true; 00215 }
bool sim_endcap_conv2root | ( | ) |
Definition at line 217 of file convElec2root.cxx.
References genRecEmupikp::i, ganga-rec::j, and t().
Referenced by main().
00217 { 00218 TTree* t=new TTree("SimQElecEndPar","endcap parameters of east end"); 00219 double p[11]={0.}; 00220 char brname[50]; //branch name 00221 char ptname[50]; //pattern name 00222 for(int i=0;i<11;i++){ 00223 sprintf(brname,"P%d",i); 00224 sprintf(ptname,"p%d/D",i); 00225 t->Branch(brname,&p[i],ptname); 00226 } 00227 00228 bool is_open=false; 00229 ifstream infile; 00230 char inTxtFile[500]="ElecEndcap-Curve.txt"; 00231 infile.open(inTxtFile,ios::in); 00232 if(infile.good()) 00233 is_open=true; 00234 else 00235 std::cerr<<"file: "<<inTxtFile<<" can't be found!"<<std::endl; 00236 try{ 00237 for(int k=0;k<96;k++){ 00238 //------------set p------------------------- 00239 if(is_open){ 00240 for( unsigned int j=0; j<11; j++ ) { 00241 infile >> p[j]; 00242 } 00243 } 00244 t->Fill(); 00245 } 00246 } 00247 catch(...) { 00248 return false; 00249 } 00250 00251 TFile f("SimEndTofQElecPar.root","RECREATE"); 00252 t->Write(); 00253 f.Close(); 00254 delete t; 00255 t=NULL; 00256 return true; 00257 }