八千里路云和月

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 typedef 使用

比如, typedef G4THitsCollection<B2TrackerHit> B2TrackerHitsCollection;  将  G4THitsCollection<B2TrackerHit> 重命名为  B2TrackerHitsCollection 


 

文件流作为函数参数

1 void fitshape(std::ofstream &ffo, TString fitfunc, Int_t start, Int_t stop);
2 
3 std::ofstream ffo;
4 ffo.open("test.tt", std::fstream::app); 
5 TString sss("test"); 6 fd_tmp->fitshape(ffo, sss, 0, 4000);

注释 ifdef endif

1 #ifdef DRAW
2     TApplication the_app("app", &argc, argv);
3 #endif

strstr() 函数,实现字符串的截断

 1 /* strstr example */
 2 #include <stdio.h>
 3 #include <string.h>
 4 
 5 int main ()
 6 {
 7   char str[] ="This is a simple string";
 8   char * pch;
 9   pch = strstr (str,"simple");
10   puts (str);
11   return 0;
12 }

文件读取示例

 1 // read file and add to fit object   
 2 Double_t *x = new Double_t[133];   
 3 Double_t *y = new Double_t[133];   
 4 Double_t vX, vY;   
 5 Int_t vNData = 0;   
 6 ifstream vInput;   
 7 vInput.open(Form("%smotorcycle.dat",dir.Data()));   
 8 while (1) {
 9       vInput >> vX >> vY;
10       if (!vInput.good()) break;
11       x[vNData] = vX;
12       y[vNData] = vY;
13       vNData++;   }//while
14 vInput.close();
15 
16 delete [] x;   
17 delete [] y;

 

posted on 2022-02-11 08:55  hanX3  阅读(27)  评论(0编辑  收藏  举报