AculCalibScint.cpp 2.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
#include "AculCalibScint.h"
#include "AculCalParsScint.h"

ClassImp(AculCalibScint);

AculCalibScint::AculCalibScint() {

	printf("AculCalibScint::Default constructor called.\n");
	fInFiles = 0;
	fTrees = 0;
	fCutFile = 0;


}

AculCalibScint::AculCalibScint(const char* parfile) {
	printf("AculCalibScint::Constructor called.\n");

	SetParFile(parfile);
	Init();
//	cout << "nofiles: " << nofiles << endl;
//	OpenTrees();
//	LoadCuts();

//	fr.Print();
//	fr.At(0);
	

}

AculCalibScint::~AculCalibScint() {

	printf("AculCalibScint::Destructor called.\n");

}

void AculCalibScint::Init() {
	fPars = new AculCalParsScint(fParFileName.Data());
	OpenFiles();
	LoadTrees();
//	SetPars();
}

void AculCalibScint::PrintTrees() {

	if (!fTrees) {
		cerr << "\"AculCalibScint::PrintTrees\" Probably no tree was open." << endl;
		return;
	}

//	TTree *curTree = 0;
	cout << " AculCalibScint::PrintTrees:" << endl;
	for (Int_t i = 0; i < fPars->GetNoRawFiles(); i++) {
//		curTree = fTrees[i];
		if (fTrees[i]) {
			printf("\tTree No. %d; File: %s; Name: %s\n", i, fTrees[i]->GetDirectory()->GetName(), fTrees[i]->GetName());
		} else {
			printf("\tTree No. %d was not loaded. Maximal number of trees is %d\n", i, NOCALFILES);
		}
	}

	return;
}

void AculCalibScint::OpenFiles() {

	if (!fPars) {
		cerr << "\"AculCalibScint::OpenFiles\" parameters were not initialized." << endl;
		return;
	}

	fPars->GetNoRawFiles();
	fInFiles = new TFile* [fPars->GetNoRawFiles()];
	for (Int_t i = 0; i < fPars->GetNoRawFiles(); i++) {
		fInFiles[i] = new TFile(fPars->GetFileName(i), "READ");
//		cout << "\"AculCalibScint::OpenFiles\" File \"" << fInFiles[i]->GetName() << "\" was opened." << endl;
	}

}

void AculCalibScint::LoadTrees() {

	if (!fInFiles) {
		cerr << "\"AculCalibScint::LoadTrees\" Input files were not open." << endl;
		return;
	}

	fTrees = new TTree* [fPars->GetNoRawFiles()];
	for (Int_t i = 0; i < fPars->GetNoRawFiles(); i++) {
		fTrees[i] = (TTree*)fInFiles[i]->Get("AnalysisxTree");
//		cout << "\"AculCalibScint::LoadTrees\" Tree \"" << fTrees[i]->GetName()
//				<< "\" from file \"" << fInFiles[i]->GetName() << "\" was loaded." << endl;
	}

}

void AculCalibScint::DrawVariable(const char* variable, Int_t tree, TCanvas *canvas, Int_t lowRange, Int_t upRange) {

//	if (!canvas) TCanvas *c = new TCanvas();
	if (!canvas) return;

	canvas->Clear();
	canvas->Divide(4,4);

	TString canvasTitle;
	TString var;
	TString con;

	TTree *curTree = 0;
	curTree = fTrees[tree];
	if (!curTree) {
		printf("AculCalibScint::DrawVariable: Tree No. %d was not found.\n", tree);
		return;
	}

	canvasTitle.Form("variable: %s; tree: %d", variable, tree);
	canvas->SetTitle(canvasTitle.Data());

	for (Int_t i = 0; i < 16; i++) {
		var.Form("%s[%d]", variable, i);
		con.Form("%s[%d]>%d && %s[%d]<%d", variable, i, lowRange, variable, i, upRange);
		canvas->cd(i+1);
		curTree->Draw(var.Data(), con.Data());
		canvas->Update();
	}

}