analyse.C 1.92 KB
Newer Older
1 2 3 4 5
// now raw .root to analyzed .root conversion 
// is taking place in 
// ./convertRawToAnalyzed/analyse.cpp
// it is compiled within makefile

6 7 8 9
void analyse()
{
	gSystem->Load("../libData.so");

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

13
	const Int_t noBranches = 4;
14 15
	const Double_t cfRatio = 0.5;
	const Int_t cfTD = 5;
16 17

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

//	tr->SetMakeClass(1);

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

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

40
//----event loop in tr input tree
41
	Long64_t nentries = tr->GetEntries();
42

43 44 45
	for(Long64_t i = 0; i < nentries; i++) {
		tr->GetEntry(i);

46 47
		for (Int_t j = 0; j<noBranches; j++) {
			wevent[j]->Reset();
48
			wevent[j]->ProcessEvent();	//here all the analysis is going on so far
49
		}
50

51
		if ( !(i%100) ) { printf("Found event #%d\n", i); }
52 53
		tw->Fill();
	}
54
//----end of event loop
55
	printf("%d events are processed\n", nentries);
56 57 58 59 60 61

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

	return;
}