1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rootのvector<TVector3>の扱い

Posted at

Rootファイルのツリー(vector)ブランチ(TVecotr3)の中にあるX,Y,Zの値をとりたい


vecotor<double> A なら A->at(i)

ででてくる、

veotor<TVector3> B は B->at(i).X() 

ででてくる。
MyClass関数は便利

TH2F *hist1 = new TH2F("hist1","posXYth2; Xa; Ya",1000, -18000., 18000., 1000, -18000., 18000.);
   TCanvas*c1=new TCanvas("c1");
   gStyle ->SetOptStat(1001110);

   Long64_t nentries = fChain->GetEntries();
   Long64_t nbytes = 0, nb = 0, an=0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;        
      nb = fChain->GetEntry(jentry);   nbytes += nb;
         std::size_t size  = WaveL->size(); //TVecotor3そのものの数
	     std::cout<<"size = "<<size<<std::endl;
      
         for(int a=0; a<size; a++){
            double Xa = 0;
            double Ya = 0;

            Xa = pos->at(a).X() ;// 
            Ya = pos->at(a).Y() ;//
            hist1 -> Fill(Xa,Ya);  
         }
         
   }      
   cout << "owari" <<endl;
   hist1->Draw("lego2z");
   
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?