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

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

8
	const Int_t noBranches = 4;
9 10
	const Double_t cfRatio = 0.5;
	const Int_t cfTD = 5;
11 12

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

//	tr->SetMakeClass(1);

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

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

35
//----event loop in tr input tree
36
	Long64_t nentries = tr->GetEntries();
37

38 39 40
	for(Long64_t i = 0; i < nentries; i++) {
		tr->GetEntry(i);

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

46
		if ( !(i%100) ) { printf("Found event #%d\n", i); }
47 48
		tw->Fill();
	}
49
//----end of event loop
50
	printf("%d events are processed\n", nentries);
51 52 53 54 55 56

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

	return;
}