PhotoFis.C (ROOT program to analyse data)

From New IAC Wiki
Revision as of 23:44, 22 October 2008 by Oborn (talk | contribs)
Jump to navigation Jump to search

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;

}