analyse.C 1.56 KB
Newer Older
1 2 3 4 5 6 7
void analyse()
{
	gSystem->Load("../libData.so");

	TFile *f = new TFile("../data/rawDataDSR4/NeuRad_test_07_1.root");
	TTree *tr = (TTree*)f->Get("rtree");

8 9 10
	const Int_t noBranches = 4;

	TString bName;
11
	RawEvent *revent[noBranches];	// pointer to the array (of RawEvent class) in which raw data for each channel will be put
12
	for (Int_t j = 0; j<noBranches; j++) {
13
		revent[j] = new RawEvent();	//each raw event element is of class RawEvent()
14
		bName.Form("ch%d", j);
15
		tr->SetBranchAddress(bName.Data(), &revent[j]);	//read the tree tr with raw data and fill array revent with raw data
16
	}
17 18 19

//	tr->SetMakeClass(1);

20 21
	TFile *fw = new TFile("../data/dataDSR4/analysis_07_1.root", "RECREATE");	//create .root file with somehow analyzed data
	TTree *tw = new TTree("atree", "title of drs4 analysis tree");	//create analysis tree atree in it
22

23
	AEvent *wevent[noBranches];	// pointer to the array (of AEvent class) in which analyzed data for each channel will be put
24 25 26
	for (Int_t j = 0; j<noBranches; j++) {
		wevent[j] = new AEvent();
		bName.Form("Ach%d.", j);
27 28
		wevent[j]->SetInputEvent(&revent[j]);	//takes raw event from RawEvent
		tw->Bronch(bName.Data(), "AEvent", &wevent[j]);	// create branches in atree to hold analyzed data
29
	}
30

31
//----event loop in tr input tree
32
	Long64_t nentries = tr->GetEntries();
33

34 35 36
	for(Long64_t i = 0; i < nentries; i++) {
		tr->GetEntry(i);

37 38
		for (Int_t j = 0; j<noBranches; j++) {
			wevent[j]->Reset();
39
			wevent[j]->ProcessEvent();	//here all the analysis is going on so far
40
		}
41 42 43 44

		tw->Fill();
	}

45
//----end of event loop
46 47 48 49 50 51

	tw->Write();
	fw->Close();

	return;
}