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

From New IAC Wiki
Jump to navigation Jump to search
Line 17: Line 17:
 
   //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();
Line 31: Line 31:
 
  delete tree;
 
  delete tree;
 
  delete f;
 
  delete f;
}
+
}

Revision as of 23:45, 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;
}