Difference between revisions of "PhotoFis.C (ROOT program to analyse data)"

From New IAC Wiki
Jump to navigation Jump to search
 
Line 2: Line 2:
  
 
   struct evt_t {
 
   struct evt_t {
 
 
   Int_t event, ADCnum, ADCval, Lastevent, LastADCnum,LastADCval;
 
   Int_t event, ADCnum, ADCval, Lastevent, LastADCnum,LastADCval;
 
 
  };
 
  };
 
 
  ifstream in;
 
  ifstream in;
 
 
  in.open("189.txt");
 
  in.open("189.txt");
 
 
  evt_t evt;
 
  evt_t evt;
 
 
  Int_t nlines=0;
 
  Int_t nlines=0;
 
 
  TFile *f = new TFile("PhotoFis.root","RECREATE");
 
  TFile *f = new TFile("PhotoFis.root","RECREATE");
 
 
  TTree *tree = new TTree("PhotoFis","PhototFis data from ascii file");
 
  TTree *tree = new TTree("PhotoFis","PhototFis data from ascii file");
 
 
  tree->Branch("evt",&evt.event,"event/I:ADCnum/I:ADCval/I:Lastevent/I:LastADCnum/I:LastADCval");
 
  tree->Branch("evt",&evt.event,"event/I:ADCnum/I:ADCval/I:Lastevent/I:LastADCnum/I:LastADCval");
 
 
  evt.LastADCnum=0;
 
  evt.LastADCnum=0;
 
 
  evt.LastADCval=0;
 
  evt.LastADCval=0;
 
 
  evt.Lastevent=0;
 
  evt.Lastevent=0;
 
 
  while(in.good()){
 
  while(in.good()){
 
 
   //evt.event=nlines;
 
   //evt.event=nlines;
 
 
   in >> evt.ADCnum >> evt.ADCval >> evt.event ;
 
   in >> evt.ADCnum >> evt.ADCval >> evt.event ;
 
 
if(evt.event < 10) printf( " %0d  %d %d \n", evt.event, evt.ADCnum, evt.ADCval );
 
if(evt.event < 10) printf( " %0d  %d %d \n", evt.event, evt.ADCnum, evt.ADCval );
 
 
 
 
 
   nlines++;
 
   nlines++;
 
 
   tree->Fill();
 
   tree->Fill();
 
 
   evt.LastADCnum=evt.ADCnum;
 
   evt.LastADCnum=evt.ADCnum;
 
 
   evt.LastADCval=evt.ADCval;
 
   evt.LastADCval=evt.ADCval;
 
 
   evt.Lastevent=evt.event;
 
   evt.Lastevent=evt.event;
 
 
   in >> evt.LastADCnum >> evt.LastADCval >> evt.Lastevent ;
 
   in >> evt.LastADCnum >> evt.LastADCval >> evt.Lastevent ;
 
 
// printf( " %0d  %d %d \n", evt.LastADCnum, evt.LastADCval, evt.Lastevent );
 
// printf( " %0d  %d %d \n", evt.LastADCnum, evt.LastADCval, evt.Lastevent );
 
 
 
 
 
  }
 
  }
 
 
  tree->Print();
 
  tree->Print();
 
 
  tree->Write();   
 
  tree->Write();   
 
 
  in.close();
 
  in.close();
 
 
  delete tree;
 
  delete tree;
 
 
  delete f;
 
  delete f;
 
 
}
 
}

Revision as of 23:44, 22 October 2008

void PhotoFis() {

  struct evt_t {
  Int_t event, ADCnum, ADCval, Lastevent, LastADCnum,LastADCval;
};
ifstream in;
in.open("189.txt");
evt_t evt;
Int_t nlines=0;
TFile *f = new TFile("PhotoFis.root","RECREATE");
TTree *tree = new TTree("PhotoFis","PhototFis data from ascii file");
tree->Branch("evt",&evt.event,"event/I:ADCnum/I:ADCval/I:Lastevent/I:LastADCnum/I:LastADCval");
evt.LastADCnum=0;
evt.LastADCval=0;
evt.Lastevent=0;
while(in.good()){
  //evt.event=nlines;
  in >> evt.ADCnum >> evt.ADCval >> evt.event ;

if(evt.event < 10) printf( " %0d %d %d \n", evt.event, evt.ADCnum, evt.ADCval );

  nlines++;
  tree->Fill();
  evt.LastADCnum=evt.ADCnum;
  evt.LastADCval=evt.ADCval;
  evt.Lastevent=evt.event;
  in >> evt.LastADCnum >> evt.LastADCval >> evt.Lastevent ;

// printf( " %0d %d %d \n", evt.LastADCnum, evt.LastADCval, evt.Lastevent );

}
tree->Print();
tree->Write();  
in.close();
delete tree;
delete f;

}