BeAnalysis.cpp 37.3 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * BeAnalysis.cpp
 *
 *  Created on: Jul 19, 2017
 *      Author: vratik
 */

#include "BeAnalysis.h"
9

10
#include "BeWork.h"
11
#include "TCanvas.h"
12
#include "TGaxis.h"
13

14
BeAnalysis::BeAnalysis() : che(0), lowExpFile(0), upExpFile(0), spectra(0) {
15 16
	// TODO Auto-generated constructor stub

17 18 19 20 21 22 23 24
	for (Int_t i = 0; i < 6; i++) {
		chs[i] = NULL;
		ti[i] = NULL;
	}

	SetCuts();
	SetChainsToDraw();

25
	SetNoBinsSpectra();
26 27 28
	SetNoBinsCorrelations();

	InitHistos();
29

30
	noIntervals = 5;
31

32
	epsilonT = 0;
33 34 35 36
	cosThetaT = 0;
	epsilonY = 0;
	cosThetaY = 0;
	thetaAT = 0;
37

38 39 40
	kVerbose = 1;
	kRangeProportionIn = 2.0;

41 42 43 44
	kSaveFigures = 0;
	figurePath = "";
	figureFormat = "";

45 46 47 48 49 50 51 52
}

BeAnalysis::~BeAnalysis() {
	// TODO Auto-generated destructor stub
}

void BeAnalysis::OpenSimChains() {

53 54 55 56 57 58
	for (Int_t i = 0; i < 6; i++) {
		chs[i] = BeWork::OpenChain(simFiles[i].Data(),
				lowSimFile[i], upSimFile[i], "simbe", 4, "sbeam");
		Info("statesRatioFitting.cxx", "%lld events in chain \"%s\" containing simulated data", chs[i]->GetEntries(), chs[i]->GetName());
		ti[i] = BeWork::OpenTree(inputFiles[i].Data(), "sbeam", 2);
	}
59
	printf("\n");
60

61 62 63 64 65
}

void BeAnalysis::OpenExpChain() {

	//experimental chain
66 67
	che = BeWork::OpenChain(expFiles.Data(), lowExpFile, upExpFile, "beonly");										//original file
	Info("BeAnalysis::OpenExpChain", "%lld events in chain \"%s\" containing experimental data",
68 69 70
			che->GetEntries(), che->GetName());

}
71 72

void BeAnalysis::SetCuts() {
73 74
//	cBe20 = "fBeIM>0 && fBeIM<20";
//	cBe3 = "fBeIM>0 && fBeIM<3";
75 76
	cBeWork = "fBeIM>0 && fBeIM<10";

77
	TCut cBe0_14 = "fBeIM>0 && fBeIM<1.4";
78 79
	//cBe0_14 = "fBeIM>0 && fBeIM<1.6";
	//cBe0_14 = "fBeIM>0 && fBeIM<1.20";
80 81 82 83 84
	TCut cBe14_19 = "fBeIM>1.4 && fBeIM<1.9";
//	cBe14_19 = "fBeIM>1.4 && fBeIM<2.0";
	TCut cBe19_25 = "fBeIM>1.9 && fBeIM<2.5";
	TCut cBe25_31 = "fBeIM>2.5 && fBeIM<3.1";
	TCut cBe31_37 = "fBeIM>3.1 && fBeIM<3.7";
85 86 87 88 89 90 91 92
	//array:
	cBeE[0] = cBe0_14;
	cBeE[1] = cBe14_19;
	cBeE[2] = cBe19_25;
	cBeE[3] = cBe25_31;
	cBeE[4] = cBe31_37;

	cEpsilonT = "fTpp/fBeIM<0.2";
93 94
	//cEpsilonT = "fTpp/fBeIM<1.";
	//cEpsilonY = "fTap/fBeIM<0.5";
95 96 97 98
	cEpsilonY = "fTap/fBeIM>0.7";

	//raw files
	//energy cuts
99 100
//	crBe20 = "f6BeIM>0 && f6BeIM<20";
//	crBe3 = "f6BeIM>0 && f6BeIM<3";
101 102
	crBeWork = "f6BeIM>0 && f6BeIM<10";

103
	TCut crBe0_14 = "f6BeIM>0 && f6BeIM<1.4";
104 105
	//crBe0_14 = "f6BeIM>0 && f6BeIM<1.6";
	//crBe0_14 = "f6BeIM>0.5 && f6BeIM<1.20";
106 107 108 109 110
	TCut crBe14_19 = "f6BeIM>1.4 && f6BeIM<1.9";
//	TCut crBe14_19 = "f6BeIM>1.6 && f6BeIM<2.1";
	TCut crBe19_25 = "f6BeIM>1.9 && f6BeIM<2.5";
	TCut crBe25_31 = "f6BeIM>2.5 && f6BeIM<3.1";
	TCut crBe31_37 = "f6BeIM>3.1 && f6BeIM<3.7";
111 112 113 114 115 116 117 118 119
	//array:
	crBeE[0] = crBe0_14;
	crBeE[1] = crBe14_19;
	crBeE[2] = crBe19_25;
	crBeE[3] = crBe25_31;
	crBeE[4] = crBe31_37;
	//angular cuts


120
	//crEpsilonT = "fTpp/f6BeIM>0.8";
121
	crEpsilonT = "fTpp/f6BeIM<0.2";
122 123
	//crEpsilonT = "fTpp/f6BeIM<1.";
	//crEpsilonY = "fTap/f6BeIM<0.5";
124 125 126
	crEpsilonY = "fTap/f6BeIM>0.7";

	//simulation input
127 128 129 130 131 132 133
	TCut ciBe0_14 = "E_IM>0 && E_IM<1.4";
	//ciBe0_14 = "E_IM>0 && E_IM<1.6";
	//ciBe0_14 = "E_IM>0.5 && E_IM<1.20";
	TCut ciBe14_19 = "E_IM>1.4 && E_IM<1.9";
	TCut ciBe19_25 = "E_IM>1.9 && E_IM<2.5";
	TCut ciBe25_31 = "E_IM>2.5 && E_IM<3.1";
	TCut ciBe31_37 = "E_IM>3.1 && E_IM<3.7";
134
	//array:
135 136 137 138 139
	ciBeE[0] = ciBe0_14;
	ciBeE[1] = ciBe14_19;
	ciBeE[2] = ciBe19_25;
	ciBeE[3] = ciBe25_31;
	ciBeE[4] = ciBe31_37;
140 141

	ciEpsilon = "sTpp/E_IM<0.2";
142 143
	//ciEpsilon = "sTpp/E_IM<1.";
	//ciEpsilonY = "sTap/E_IM<0.5";
144
//	ciEpsilonY = "sTap/E_IM>0.7";
145 146 147

	cQ = "TMath::Abs(fQLiP)<10";
	cProtons = "fP1Lab.fE-938.272<50 && fP2Lab.fE-938.272<50";
148
	//cProtons = "fP1Lab.fE-938.272<34 && fP2Lab.fE-938.272<34 && fP1Lab.fE-938.272>1 && fP2Lab.fE-938.272>1";
149 150 151 152 153
}

void BeAnalysis::SetCMAngularRange(Int_t minAngle, Int_t maxAngle) {
	kMinAngle = minAngle;
	kMaxAngle = maxAngle;
154
	SetCMAngularCuts();
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
}

void BeAnalysis::SetChainsToDraw(Bool_t ch0, Bool_t ch1, Bool_t ch2, Bool_t ch3, Bool_t ch4,
		Bool_t ch5) {

	kChains[0] = ch0;
	kChains[1] = ch1;
	kChains[2] = ch2;
	kChains[3] = ch3;
	kChains[4] = ch4;
	kChains[5] = ch5;

}

void BeAnalysis::SetRangeProportion(Float_t rangeProportion, Bool_t autoRange) {
	kRangeProportion = rangeProportion;
	kAutoRange = autoRange;
}

174
void BeAnalysis::SetNoExpEvents(Long64_t *noExpEvents) {
175 176 177

	eMaxEvents = 5000000;

178 179 180 181 182 183 184
	if (!noExpEvents) {
		for (Int_t i = 0; i < 6; i++) {
			eEvents[i] = eMaxEvents;
		}
		Warning("BeAnalysis::SetNoExpEvents", "Default numbers of experimental events were set.");
		return;
	}
185

186 187 188
	for (Int_t i = 0; i < 6; i++) {
		eEvents[i] = noExpEvents[i];
	}
189

190
	return;
191 192 193

}

194
void BeAnalysis::SetNoSimEvents(Long64_t *noSimEvents) {
195 196 197

	sMaxEvents = 3000000;

198 199 200 201 202 203 204 205
	if (!noSimEvents) {
		for (Int_t i = 0; i < 6; i++) {
			sEvents[i] = sMaxEvents;
			cout << sEvents[i] << endl;
		}
		Warning("BeAnalysis::SetNoSimEvents", "Default numbers of simulated events were set.");
		return;
	}
206

207 208 209 210 211 212
	for (Int_t i = 0; i < 6; i++) {
		sEvents[i] = noSimEvents[i];
		cout << sEvents[i] << endl;
	}
	return;

213 214
}

215 216 217
void BeAnalysis::SetRatiosGStoEX(TString sRatioAl0, TString sRatioNoAl0,
		TString sRatioAl180, TString sRatioNoAl180,
		TString sRatioAl90, TString sRatioNoAl90) {
218 219 220 221 222 223 224 225 226 227

	sRatio[0] = sRatioAl0;
	sRatio[1] = sRatioNoAl0;
	sRatio[2] = sRatioAl180;
	sRatio[3] = sRatioNoAl180;
	sRatio[4] = sRatioAl90;
	sRatio[5] = sRatioNoAl90;

}

228 229 230 231 232 233 234 235 236 237 238 239 240
void BeAnalysis::InitHistos() {

	for (Int_t i = 0; i < 6; i++) {
		hsSpectra[i] = 0;
		heSpectra[i] = 0;
		hSdiff[i] = 0;
	}

	for (Int_t i = 0; i < 5; i++) {
		for (Int_t j = 0; j < 6; j++) {
			hseT[i][j] = 0;
			heeT[i][j] = 0;
			hieT[i][j] = 0;
241 242 243 244 245 246 247 248

			hscoskT[i][j] = 0;
			hecoskT[i][j] = 0;
			hicoskT[i][j] = 0;

			hseY[i][j] = 0;
			heeY[i][j] = 0;
			hieY[i][j] = 0;
249 250 251 252 253 254
		}
	}


}

255
void BeAnalysis::SaveSpectrumHist(Int_t chain) {
256 257

	TFile fw("figures/spectra.root", "UPDATE");
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272

	TString hName;

	if (heSpectra[chain] != 0) {
		hName.Form("heSpectrum%d%d", kMinAngle, kMaxAngle);
		heSpectra[chain]->SetName(hName.Data());
		heSpectra[chain]->Write();
		Info("BeAnalysis::SaveSpectrumHist", "Histogram saved.");
	}
	if (hsSpectra[chain] != 0) {
		hName.Form("hsSpectrum%d%d", kMinAngle, kMaxAngle);
		hsSpectra[chain]->SetName(hName.Data());
		hsSpectra[chain]->Write();
		Info("BeAnalysis::SaveSpectrumHist", "Histogram saved.");
	}
273 274 275 276 277 278 279
	fw.Close();

}

void BeAnalysis::SaveEpsilonTHist(Int_t interval, Int_t chain) {

	TFile fw("figures/epsilonT.root", "UPDATE");
280

Vratislav Chudoba's avatar
Vratislav Chudoba committed
281 282
	TString hName;

283
	if (heeT[interval][chain] != 0) {
Vratislav Chudoba's avatar
Vratislav Chudoba committed
284 285
		hName.Form("heeT%d_%d_%d%d", interval, chain, kMinAngle, kMaxAngle);
		heeT[interval][chain]->SetName(hName.Data());
286 287 288 289
		heeT[interval][chain]->Write();
		Info("BeAnalysis::SaveEpsilonTHist", "Histogram saved.");
	}
	if (hseT[interval][chain] != 0) {
Vratislav Chudoba's avatar
Vratislav Chudoba committed
290 291
		hName.Form("hseT%d_%d_%d%d", interval, chain, kMinAngle, kMaxAngle);
		hseT[interval][chain]->SetName(hName.Data());
292
		hseT[interval][chain]->Write();
Vratislav Chudoba's avatar
Vratislav Chudoba committed
293
		Info("BeAnalysis::SaveEpsilonTHist", "Histogram saved.");
294 295
	}
	if (hieT[interval][chain] != 0) {
Vratislav Chudoba's avatar
Vratislav Chudoba committed
296 297
		hName.Form("hieT%d_%d_%d%d", interval, chain, kMinAngle, kMaxAngle);
		hieT[interval][chain]->SetName(hName.Data());
298
		hieT[interval][chain]->Write();
Vratislav Chudoba's avatar
Vratislav Chudoba committed
299
		Info("BeAnalysis::SaveEpsilonTHist", "Histogram saved.");
300 301 302 303 304
	}
	fw.Close();

}

305 306 307 308
void BeAnalysis::SaveCosThetaTHist(Int_t interval, Int_t chain) {

	TFile fw("figures/cosThetaT.root", "UPDATE");

Vratislav Chudoba's avatar
Vratislav Chudoba committed
309 310
	TString hName;

311
	if (hecoskT[interval][chain] != 0) {
Vratislav Chudoba's avatar
Vratislav Chudoba committed
312 313
		hName.Form("hecoskT%d_%d_%d%d", interval, chain, kMinAngle, kMaxAngle);
		hecoskT[interval][chain]->SetName(hName.Data());
314 315 316 317
		hecoskT[interval][chain]->Write();
		Info("BeAnalysis::SaveCosThetaTHist", "Histogram saved.");
	}
	if (hscoskT[interval][chain] != 0) {
Vratislav Chudoba's avatar
Vratislav Chudoba committed
318 319
		hName.Form("hscoskT%d_%d_%d%d", interval, chain, kMinAngle, kMaxAngle);
		hscoskT[interval][chain]->SetName(hName.Data());
320
		hscoskT[interval][chain]->Write();
Vratislav Chudoba's avatar
Vratislav Chudoba committed
321
		Info("BeAnalysis::SaveCosThetaTHist", "Histogram saved.");
322 323
	}
	if (hicoskT[interval][chain] != 0) {
Vratislav Chudoba's avatar
Vratislav Chudoba committed
324 325
		hName.Form("hicoskT%d_%d_%d%d", interval, chain, kMinAngle, kMaxAngle);
		hicoskT[interval][chain]->SetName(hName.Data());
326
		hicoskT[interval][chain]->Write();
Vratislav Chudoba's avatar
Vratislav Chudoba committed
327
		Info("BeAnalysis::SaveCosThetaTHist", "Histogram saved.");
328 329 330 331 332 333
	}

	fw.Close();

}

334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
void BeAnalysis::SaveEpsilonYHist(Int_t interval, Int_t chain) {

	TFile fw("figures/epsilonY.root", "UPDATE");

	if (heeY[interval][chain] != 0) {
		heeY[interval][chain]->Write();
		Info("BeAnalysis::SaveEpsilonYHist", "Histogram saved.");
	}
	if (hseY[interval][chain] != 0) {
		hseY[interval][chain]->Write();
		Info("BeAnalysis::SaveEpsilonYHist", "Histogram saved.");
	}
	if (hieY[interval][chain] != 0) {
		hieY[interval][chain]->Write();
		Info("BeAnalysis::SaveEpsilonYHist", "Histogram saved.");
	}
	fw.Close();

}

354
void BeAnalysis::SetCMAngularCuts() {
355 356 357 358 359 360 361 362

	TString sAngles, srAngles;

	sAngles.Form("fBeThetaCM1>%d*TMath::DegToRad() && fBeThetaCM1<%d*TMath::DegToRad()", kMinAngle, kMaxAngle);
	srAngles.Form("f6BeThetaCM1>%d*TMath::DegToRad() && f6BeThetaCM1<%d*TMath::DegToRad()", kMinAngle, kMaxAngle);

	cAngles = sAngles.Data();
	crAngles = srAngles.Data();
363 364 365 366 367
}

void BeAnalysis::Spectra() {

	if (!spectra) {
368
		Error("BeAnalysis::Spectra", "kSpectra was to zero.");
369 370 371
		return;
	}

372 373 374 375 376 377 378 379 380 381 382
	if (!che) {
		Error("BeAnalysis::Spectra", "Chain with experimental data was not initialized.");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
			if (!chs[i]) {
				Error("BeAnalysis::Spectra", "Chain No. %d with simulated data was not initialized.", i);
				return;
			}
	}
383 384 385

	TCanvas *cSpectra = new TCanvas();

386 387 388
//	TH1F *hsSpectra[6];
//	TH1F *heSpectra[6];
//	TH1F *hSdiff[6];
389 390 391

	canvasTitle.Form("energy spectra fitting;\t(%d,%d) degrees", kMinAngle, kMaxAngle);
	cSpectra->SetTitle(canvasTitle.Data());
392 393
//	cSpectra->Divide(2, 3);
	CanvasDivision(cSpectra);
394 395 396 397 398

	che->SetLineColor(kGreen);

	for (Int_t j = 0; j < 6; j++) {	//different files
		if (!kChains[j]) continue;
399
//		cout << kChains[j] << endl;
400
		cSpectra->cd(j+1);
401 402
//		chs[j]->SetLineColor(kBlue);
//		chs[j]->SetFillColor(kWhite);
403
		hsName.Form("hsSpectra%d", j);
404
		hsSpectra[j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsSpectra, 0, 10);
405 406
//		drawCommand.Form("f6BeIM>>%s(200,0,10)", hsName.Data());
		drawCommand.Form("f6BeIM>>%s", hsName.Data());
407 408
		//			chs[j]->Draw(drawCommand.Data(), cQ && crBeWork && crAngles && sRatio[j], "", sEvents[j]);
		chs[j]->Draw(drawCommand.Data(), cProtons && cQ && crBeWork && crAngles && sRatio[j], "", sEvents[j]);
409
//		hsSpectra[j] = (TH1F*)gPad->FindObject(hsName.Data());
410
		heName.Form("heSpectra%d", j);
411
		heSpectra[j] = new TH1F(heName.Data(), cAngles.GetTitle(), noBinsSpectra, 0, 10);
412 413
//		drawCommand.Form("fBeIM>>%s(200,0,10)", heName.Data());
		drawCommand.Form("fBeIM>>%s", heName.Data());
414
		//			che->Draw(drawCommand.Data(), cQ && cBeWork && cAngles, "same", eEvents[j]);
415

416
		che->Draw(drawCommand.Data(), cProtons && cQ && cBeWork && cAngles, "", eEvents[j]);
417 418 419
//		TString histTitle;
//		histTitle.Form("%s", cAngles.GetTitle());
//		heSpectra[j]->SetTitle(cAngles.GetTitle());
420 421 422 423 424

////		cout << drawCommand << "\t" << eEvents[j] << endl;
////		che->Draw(drawCommand.Data(), cProtons && cQ && cBeWork && cAngles, "", eEvents[j]);
//		che->Draw("fBeIM", "", "");
//		continue;
425
//		heSpectra[j] = (TH1F*)gPad->FindObject(heName.Data());
426 427 428 429

		//			heSpectra[j]->Draw("");
		heSpectra[j]->Draw("E");
		heSpectra[j]->SetLineColor(1);
430
//		heSpectra[j]->SetTitle("");
431 432
		heSpectra[j]->SetXTitle("E_{T} (MeV)");
//		heSpectra[j]->GetXaxis()->SetTitleOffset(0.95);
433 434
		heSpectra[j]->GetXaxis()->CenterTitle();
		heSpectra[j]->SetYTitle("counts");
435
//		heSpectra[j]->GetYaxis()->SetTitleOffset(0.7);
436
		heSpectra[j]->GetYaxis()->CenterTitle();
437

438 439 440
		hsSpectra[j]->SetLineColor(kGray+1);
		hsSpectra[j]->SetFillColor(kGray+1);
		hsSpectra[j]->Draw("same");
441

442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
		heSpectra[j]->Draw("same E");

		if (kAutoRange) {
			Float_t leftMaxMC = kRangeProportion*hsSpectra[j]->GetMaximum();
			Float_t leftMaxE = kRangeProportion*heSpectra[j]->GetMaximum();
			leftMaxMC > leftMaxE ? heSpectra[j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : heSpectra[j]->GetYaxis()->SetRangeUser(0, leftMaxE);
		}


		hSdiff[j] = new TH1F(*heSpectra[j]);
		hSdiff[j]->Add(hsSpectra[j], -1);
		hSdiff[j]->SetLineColor(kRed);

		cSpectra->Update();

457 458 459
		Int_t intLowLimit, IntHighLimit;
		const Double_t binToMeV = 10./(Double_t)noBinsSpectra;

460
		Info("statesRatioFitting", "MC %d", j+1);
461 462 463 464 465 466 467 468 469 470 471
		intLowLimit = (Int_t)0./binToMeV;
		IntHighLimit = (Int_t)2./binToMeV;
		Info("statesRatioFitting", "ground state: %3.1f (sim)/ %3.1f (exp) = %3.3f",
				hsSpectra[j]->Integral(intLowLimit, IntHighLimit), heSpectra[j]->Integral(intLowLimit, IntHighLimit),
				hsSpectra[j]->Integral(intLowLimit, IntHighLimit)/heSpectra[j]->Integral(intLowLimit, IntHighLimit) );

		intLowLimit = (Int_t)2.5/binToMeV;
		IntHighLimit = (Int_t)3.2/binToMeV;
		Info("statesRatioFitting", "left slope: %3.1f (sim)/ %3.1f (exp) = %3.3f\n",
				hsSpectra[j]->Integral(intLowLimit, IntHighLimit), heSpectra[j]->Integral(intLowLimit, IntHighLimit),
				hsSpectra[j]->Integral(intLowLimit, IntHighLimit)/heSpectra[j]->Integral(intLowLimit, IntHighLimit) );
472 473
	}//for j

474
	SaveFigures(cSpectra, "Spectra", 0);
475 476

	Info("sfAngInt_spectra.cxx", "Finished.");
477
	printf("\n");
478 479

}
480 481 482

void BeAnalysis::EpsilonT() {

483 484 485 486
	if(!epsilonT) {
		Error("BeAnalysis::EpsilonT", "Energy intervals were not set.");
		return;
	}
487

488 489
	TCanvas *canEpsilonT[noIntervals];
	for (Int_t i = 0; i<noIntervals; i++) {	//energy intervals (canvases)
490

491 492 493
//		TH1F *hseT[noIntervals][6];
//		TH1F *heeT[noIntervals][6];
//		TH1F *hieT[noIntervals][6];
494 495

		if (!epsilonT[i]) continue;
496 497 498 499 500

		canEpsilonT[i] = new TCanvas();

		canvasTitle.Form("epsilon in %s T-system;\t(%d,%d) degrees", (const char*)cBeE[i], kMinAngle, kMaxAngle);
		canEpsilonT[i]->SetTitle(canvasTitle.Data());
501 502
//		canEpsilonT[i]->Divide(2, 3, 0., 0.);
		CanvasDivision(canEpsilonT[i]);
503

504 505 506 507 508
//		cProtons.Print();
//		cQ.Print();
//		crBeE[i].Print();
//		crAngles.Print();

509
//		TFile fw("histos.root", "RECREATE");
510

511 512 513
		che->SetLineColor(kBlack);
		for (Int_t j = 0; j < 6; j++) {	//different files
			if (!kChains[j]) continue;
514 515 516 517 518

//			sRatio[j].Print();
//			cout << sEventsECuts[i][j] << endl;
//			cout << eEventsECuts[i][j] << endl;

519
			canEpsilonT[i]->cd(j+1);
520 521
//			chs[j]->SetLineColor(kGray+1);
//			chs[j]->SetFillColor(kGray+1);
522
			hsName.Form("hseT%d_%d", i, j);
523 524 525 526 527 528
//			hsSpectra[j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsSpectra, 0, 10);
			hseT[i][j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsCorr, 0, 1.);
			hseT[i][j]->SetLineColor(kGray+1);
			hseT[i][j]->SetFillColor(kGray+1);
//			drawCommand.Form("fTpp/f6BeIM>>%s(30,0,1)", hsName.Data());
			drawCommand.Form("fTpp/f6BeIM>>%s", hsName.Data());
529
			chs[j]->Draw(drawCommand.Data(), cProtons && cQ && crBeE[i] && crAngles && sRatio[j], "", sEventsECuts[i][j]);
530
//			hseT[i][j] = (TH1F*)gPad->FindObject(hsName.Data());
531
			heName.Form("heeT%d_%d", i, j);
532
			heeT[i][j] = new TH1F(heName.Data(), cAngles.GetTitle(), noBinsCorr, 0, 1.);
533 534
			drawCommand.Form("fTpp/fBeIM>>%s", heName.Data());
			che->Draw(drawCommand.Data(), cProtons && cQ && cBeE[i] && cAngles, "E same", eEventsECuts[i][j]);
535
//			heeT[i][j] = (TH1F*)gPad->FindObject(heName.Data());
536
//			continue;
537 538

			hseT[i][j]->Draw();
539
//			hseT[i][j]->SetTitle("");
540
			hseT[i][j]->SetXTitle("\\varepsilon");
541 542
//			hseT[i][j]->GetXaxis()->SetTitleOffset(0.95);
//			hseT[i][j]->GetXaxis()->SetTitleSize(0.11);
543 544
			hseT[i][j]->GetXaxis()->CenterTitle();
			hseT[i][j]->SetYTitle("counts");
545
//			hseT[i][j]->GetYaxis()->SetTitleOffset(0.7);
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
			hseT[i][j]->GetYaxis()->CenterTitle();
			heeT[i][j]->Draw("E same");
			if (kAutoRange) {
				Float_t leftMaxMC = kRangeProportion*hseT[i][j]->GetMaximum();
				Float_t leftMaxE = kRangeProportion*heeT[i][j]->GetMaximum();
				hseT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
				leftMaxMC > leftMaxE ? hseT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hseT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
			}
			else {
				hseT[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]);
			}
			canEpsilonT[i]->Update();


			hiName.Form("hieT%d_%d", i, j);
			drawCommand.Form("sTpp/E_IM>>%s", hiName.Data());
562
			hieT[i][j] = new TH1F(hiName.Data(), cAngles.GetTitle(), noBinsCorr, 0, 1.);
563
			ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same");
564
//			hieT[i][j] = (TH1F*)gPad->FindObject(hiName.Data());
565 566 567 568 569 570
			Float_t rightmax = kRangeProportionIn*hieT[i][j]->GetMaximum();
			Float_t scale = canEpsilonT[i]->GetPad(j+1)->GetUymax()/rightmax;
			hieT[i][j]->SetLineColor(kRed);
			hieT[i][j]->Scale(scale);

			//draw an axis on the right side
571 572 573 574 575
//			TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
//					gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
//			axis->SetLineColor(kRed);
//			axis->SetLabelColor(kRed);
//			axis->Draw();
576 577 578 579

			canEpsilonT[i]->Update();

			if (kVerbose) {
580
				Info("BeAnalysis::EpsilonT", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f",
581 582 583 584 585
						i, j, heeT[i][j]->Integral(0,heeT[i][j]->GetNbinsX()),
						hseT[i][j]->Integral(0,hseT[i][j]->GetNbinsX()),
						heeT[i][j]->Integral(0,heeT[i][j]->GetNbinsX())/hseT[i][j]->Integral(0,hseT[i][j]->GetNbinsX()) );
			}

586 587
//			hseT[i][j]->Write();

588 589 590
		}//for j
		if (kVerbose) cout << endl;

591 592
//		fw.Close();

593 594
		SaveFigures(canEpsilonT[i], "epsilonT", i);

595 596 597
	}//for i

}
598 599 600

void BeAnalysis::CosThetaTk() {

601 602 603 604 605
	if(!cosThetaT) {
		Error("BeAnalysis::CosThetaTk", "Energy intervals were not set.");
		return;
	}

606 607 608
	TCanvas *cThetaT[noIntervals];
	for (Int_t i = 0; i<noIntervals; i++) {	//energy intervals (canvases)

609 610 611
//		TH1F *hscoskT[noIntervals][6];
//		TH1F *hecoskT[noIntervals][6];
//		TH1F *hicoskT[noIntervals][6];
612 613 614 615 616 617 618 619

		if (!cosThetaT[i]) continue;
		//		{

		cThetaT[i] = new TCanvas();

		canvasTitle.Form("cos thetak in %s T-system;\t(%d,%d) degrees", (const char*)cBeE[i], kMinAngle, kMaxAngle);
		cThetaT[i]->SetTitle(canvasTitle.Data());
620 621
//		cThetaT[i]->Divide(2, 3);
		CanvasDivision(cThetaT[i]);
622 623 624 625 626

		che->SetLineColor(kBlack);
		for (Int_t j = 0; j < 6; j++) {	//different files
			if (!kChains[j]) continue;
			cThetaT[i]->cd(j+1);
627 628
//			chs[j]->SetLineColor(kGray+1);
//			chs[j]->SetFillColor(kGray+1);
629
			hsName.Form("hscoskT%d_%d", i, j);
630 631 632 633
			hscoskT[i][j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsCorr, -1., 1.);
			hscoskT[i][j]->SetLineColor(kGray+1);
			hscoskT[i][j]->SetFillColor(kGray+1);
			drawCommand.Form("fCosThetaTk>>%s", hsName.Data());
634
			chs[j]->Draw(drawCommand.Data(), cQ && crBeE[i] && crAngles && sRatio[j], "", sEventsECuts[i][j]);
635 636
//			hscoskT[i][j] = (TH1F*)gPad->FindObject(hsName.Data());

637
			heName.Form("hecoskT%d_%d", i, j);
638 639 640
			hecoskT[i][j] = new TH1F(heName.Data(), cAngles.GetTitle(), noBinsCorr, -1., 1.);
			drawCommand.Form("fCosThetaTk>>%s", heName.Data());
//			drawCommand.Form("fCosThetaTk>>%s(30,-1,1)", heName.Data());
641
			che->Draw(drawCommand.Data(), cQ && cBeE[i] && cAngles, "E same", eEventsECuts[i][j]);
642
//			hecoskT[i][j] = (TH1F*)gPad->FindObject(heName.Data());
643 644

			hscoskT[i][j]->Draw();
645
//			hscoskT[i][j]->SetTitle("");
646 647 648 649 650 651 652 653 654 655
			hscoskT[i][j]->SetXTitle("\\cos \\theta_k");
//			hseT[i][j]->GetXaxis()->SetTitleOffset(0.95);
//			hseT[i][j]->GetXaxis()->SetTitleSize(0.11);
			hscoskT[i][j]->GetXaxis()->CenterTitle();
			hscoskT[i][j]->SetYTitle("counts");
//			hseT[i][j]->GetYaxis()->SetTitleOffset(0.7);
			hscoskT[i][j]->GetYaxis()->CenterTitle();



656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
			//				hscoskT[i][j]->GetYaxis()->SetRangeUser(0, coskTRange[i][j]);
			hecoskT[i][j]->Draw("E same");
			if (kAutoRange) {
				Float_t leftMaxMC = kRangeProportion*hecoskT[i][j]->GetMaximum();
				Float_t leftMaxE = kRangeProportion*hscoskT[i][j]->GetMaximum();
				hscoskT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
				leftMaxMC > leftMaxE ? hscoskT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hscoskT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
			}
			else {
				hscoskT[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]);
			}
			cThetaT[i]->Update();


			hiName.Form("hicoskT%d_%d", i, j);
671 672
			hicoskT[i][j] = new TH1F(hiName.Data(), cAngles.GetTitle(), noBinsCorr, -1., 1.);
			drawCommand.Form("sCosThetaTk>>%s", hiName.Data());
673
			ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same");
674
//			hicoskT[i][j] = (TH1F*)gPad->FindObject(hiName.Data());
675 676 677 678 679 680
			Float_t rightmax = 1.1*hicoskT[i][j]->GetMaximum();
			Float_t scale = cThetaT[i]->GetPad(j+1)->GetUymax()/rightmax;
			hicoskT[i][j]->SetLineColor(kRed);
			hicoskT[i][j]->Scale(scale);

			//draw an axis on the right side
681 682 683 684 685
//			TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
//					gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
//			axis->SetLineColor(kRed);
//			axis->SetLabelColor(kRed);
//			axis->Draw();
686 687 688 689

			cThetaT[i]->Update();

			if (kVerbose) {
690
				Info("BeAnalysis::CosThetaTk", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f",
691 692 693 694 695 696 697
						i, j, hecoskT[i][j]->Integral(0,hecoskT[i][j]->GetNbinsX()),
						hscoskT[i][j]->Integral(0,hscoskT[i][j]->GetNbinsX()),
						hecoskT[i][j]->Integral(0,hecoskT[i][j]->GetNbinsX())/hscoskT[i][j]->Integral(0,hscoskT[i][j]->GetNbinsX()) );
			}

		}//for j

698 699
		SaveFigures(cThetaT[i], "cosThetakT", i);

700 701
	}//for i

702 703 704
}

void BeAnalysis::EpsilonY() {
705

706 707 708 709 710
	if(!epsilonY) {
		Error("BeAnalysis::EpsilonY", "Energy intervals were not set.");
		return;
	}

711 712 713
	TCanvas *canEpsilonY[noIntervals];
	for (Int_t i = 0; i<noIntervals; i++) {	//energy intervals (canvases)

714 715 716
//		TH1F *hseY[noIntervals][6];
//		TH1F *heeY[noIntervals][6];
//		TH1F *hieY[noIntervals][6];
717 718 719 720 721 722 723

		if (!epsilonY[i]) continue;
		//		{

		canEpsilonY[i] = new TCanvas();
		canvasTitle.Form("epsilon in %s Y-system;\t(%d,%d) degrees", (const char*)cBeE[i], kMinAngle, kMaxAngle);
		canEpsilonY[i]->SetTitle(canvasTitle.Data());
724 725
//		canEpsilonY[i]->Divide(2, 3);
		CanvasDivision(canEpsilonY[i]);
726 727 728

		che->SetLineColor(kBlack);
		for (Int_t j = 0; j < 6; j++) {	//different files
729
			if (!kChains[j]) continue;
730
			canEpsilonY[i]->cd(j+1);
731

732
			hsName.Form("hseY%d_%d", i, j);
733
			hseY[i][j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsCorr, 0., 1.);
734 735 736
			hseY[i][j]->SetLineColor(kGray+1);
			hseY[i][j]->SetFillColor(kGray+1);
			drawCommand.Form("fTap/f6BeIM>>%s", hsName.Data());
737
			chs[j]->Draw(drawCommand.Data(), cQ && crBeE[i] && crAngles && sRatio[j], "", sEvents[j]);
738
//			hseY[i][j] = (TH1F*)gPad->FindObject(hsName.Data());
739

740
			heName.Form("heeY%d_%d", i, j);
741 742
			heeY[i][j] = new TH1F(heName.Data(), cAngles.GetTitle(), noBinsCorr, 0., 1.);
			drawCommand.Form("fTap/fBeIM>>%s", heName.Data());
743
			che->Draw(drawCommand.Data(), cQ && cBeE[i] && cAngles, "E same", eEvents[j]);
744
//			heeY[i][j] = (TH1F*)gPad->FindObject(heName.Data());
745 746

			hseY[i][j]->Draw();
747
//			hseY[i][j]->SetTitle("");
748 749 750 751 752 753 754 755
			hseY[i][j]->SetXTitle("\\varepsilon");
//			hseT[i][j]->GetXaxis()->SetTitleOffset(0.95);
//			hseT[i][j]->GetXaxis()->SetTitleSize(0.11);
			hseY[i][j]->GetXaxis()->CenterTitle();
			hseY[i][j]->SetYTitle("counts");
//			hseT[i][j]->GetYaxis()->SetTitleOffset(0.7);
			hseY[i][j]->GetYaxis()->CenterTitle();

756 757 758 759 760 761 762 763 764 765 766 767 768
			heeY[i][j]->Draw("E same");
			if (kAutoRange) {
				Float_t leftMaxMC = kRangeProportion*heeY[i][j]->GetMaximum();
				Float_t leftMaxE = kRangeProportion*hseY[i][j]->GetMaximum();
				hseY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
				leftMaxMC > leftMaxE ? hseY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hseY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
			}
			else {
				hseY[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]);
			}
			canEpsilonY[i]->Update();

			hiName.Form("hieY%d_%d", i, j);
769 770
			hieY[i][j] = new TH1F(hiName.Data(), cAngles.GetTitle(), noBinsCorr, 0., 1.);
			drawCommand.Form("sTap/E_IM>>%s", hiName.Data());
771
			ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same");
772
//			hieY[i][j] = (TH1F*)gPad->FindObject(hiName.Data());
773 774 775 776 777 778
			Float_t rightmax = 1.1*hieY[i][j]->GetMaximum();
			Float_t scale = canEpsilonY[i]->GetPad(j+1)->GetUymax()/rightmax;
			hieY[i][j]->SetLineColor(kRed);
			hieY[i][j]->Scale(scale);

			//draw an axis on the right side
779 780 781 782 783
//			TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
//					gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
//			axis->SetLineColor(kRed);
//			axis->SetLabelColor(kRed);
//			axis->Draw();
784 785 786 787

			canEpsilonY[i]->Update();

			if (kVerbose) {
788
				Info("BeAnalysis::EpsilonY", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f",
789 790 791 792 793 794 795
						i, j, heeY[i][j]->Integral(0,heeY[i][j]->GetNbinsX()),
						hseY[i][j]->Integral(0,hseY[i][j]->GetNbinsX()),
						heeY[i][j]->Integral(0,heeY[i][j]->GetNbinsX())/hseY[i][j]->Integral(0,hseY[i][j]->GetNbinsX()) );
			}

		}//for j

796 797
		SaveFigures(canEpsilonY[i], "EpsilonY", i);

798 799 800
	}//for i


801 802 803
}

void BeAnalysis::CosThetaYk() {
804

805 806 807 808 809
	if(!cosThetaY) {
		Error("BeAnalysis::CosThetaYk", "Energy intervals were not set.");
		return;
	}

810
	TCanvas *cThetaY[noIntervals];
811
	for (Int_t i = 0; i<noIntervals; i++) {	//energy intervals (canvases)
812 813 814 815 816

		TH1F *hscoskY[noIntervals][6];
		TH1F *hecoskY[noIntervals][6];
		TH1F *hicoskY[noIntervals][6];

817
		if (!cosThetaY[i]) continue;
818 819 820 821 822 823
		//			{

		cThetaY[i] = new TCanvas();

		canvasTitle.Form("cos thetak in %s Y-system;\t(%d,%d) degrees", (const char*)cBeE[i], kMinAngle, kMaxAngle);
		cThetaY[i]->SetTitle(canvasTitle.Data());
824 825
//		cThetaY[i]->Divide(2, 3);
		CanvasDivision(cThetaY[i]);
826 827 828

		che->SetLineColor(kBlack);
		for (Int_t j = 0; j < 6; j++) {	//different files
829
			if (!kChains[j]) continue;
830 831 832 833 834 835 836 837 838 839 840 841 842
			cThetaY[i]->cd(j+1);
			chs[j]->SetLineColor(kGray+1);
			chs[j]->SetFillColor(kGray+1);
			hsName.Form("hscoskY%d_%d", i, j);
			drawCommand.Form("fCosThetaYk>>%s(50,-1,1)", hsName.Data());
			chs[j]->Draw(drawCommand.Data(), cQ && crBeE[i] && crAngles && sRatio[j], "", sEvents[j]);
			hscoskY[i][j] = (TH1F*)gPad->FindObject(hsName.Data());
			heName.Form("hecoskY%d_%d", i, j);
			drawCommand.Form("fCosThetaYk>>%s(50,-1,1)", heName.Data());
			che->Draw(drawCommand.Data(), cQ && cBeE[i] && cAngles, "E same", eEvents[j]);
			hecoskY[i][j] = (TH1F*)gPad->FindObject(heName.Data());

			hscoskY[i][j]->Draw();
843 844 845 846 847 848 849 850
			hscoskY[i][j]->SetTitle("");
			hscoskY[i][j]->SetXTitle("\\cos \\theta_k");
//			hseT[i][j]->GetXaxis()->SetTitleOffset(0.95);
//			hseT[i][j]->GetXaxis()->SetTitleSize(0.11);
			hscoskY[i][j]->GetXaxis()->CenterTitle();
			hscoskY[i][j]->SetYTitle("counts");
//			hseT[i][j]->GetYaxis()->SetTitleOffset(0.7);
			hscoskY[i][j]->GetYaxis()->CenterTitle();
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873
			hecoskY[i][j]->Draw("E same");
			if (kAutoRange) {
				Float_t leftMaxMC = kRangeProportion*hecoskY[i][j]->GetMaximum();
				Float_t leftMaxE = kRangeProportion*hscoskY[i][j]->GetMaximum();
				hscoskY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
				leftMaxMC > leftMaxE ? hscoskY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hscoskY[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
			}
			else {
				hscoskY[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]);
			}

			cThetaY[i]->Update();

			hiName.Form("hicoskY%d_%d", i, j);
			drawCommand.Form("sCosThetaYk>>%s", hiName.Data());
			ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same");
			hicoskY[i][j] = (TH1F*)gPad->FindObject(hiName.Data());
			Float_t rightmax = 1.1*hicoskY[i][j]->GetMaximum();
			Float_t scale = cThetaY[i]->GetPad(j+1)->GetUymax()/rightmax;
			hicoskY[i][j]->SetLineColor(kRed);
			hicoskY[i][j]->Scale(scale);

			//draw an axis on the right side
874 875 876 877 878
//			TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
//					gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
//			axis->SetLineColor(kRed);
//			axis->SetLabelColor(kRed);
//			axis->Draw();
879 880 881 882

			cThetaY[i]->Update();

			if (kVerbose) {
883
				Info("BeAnalysis::CosThetaYk", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f",
884 885 886 887 888 889 890
						i, j, hecoskY[i][j]->Integral(0,hecoskY[i][j]->GetNbinsX()),
						hscoskY[i][j]->Integral(0,hscoskY[i][j]->GetNbinsX()),
						hecoskY[i][j]->Integral(0,hecoskY[i][j]->GetNbinsX())/hscoskY[i][j]->Integral(0,hscoskY[i][j]->GetNbinsX()) );
			}


		}//for j
891 892 893 894

		SaveFigures(cThetaY[i], "cosThetakY", i);

	}//for i
895

896 897
}

898 899
void BeAnalysis::ThetaAT() {

900 901 902 903 904
	if(!thetaAT) {
		Error("BeAnalysis::ThetaAT", "Energy intervals were not set.");
		return;
	}

905
	TCanvas *cThetaAT[noIntervals];
906
	for (Int_t i = 0; i<noIntervals; i++) {	//energy intervals (canvases)
907 908 909 910 911

		TH1F *hsthetaAT[noIntervals][6];
		TH1F *hethetaAT[noIntervals][6];
		TH1F *hithetaAT[noIntervals][6];

912 913 914 915 916 917
		if (!thetaAT[i]) continue;

		cThetaAT[i] = new TCanvas();

		canvasTitle.Form("cos theta alpha in %s T-system;\t(%d,%d) degrees", (const char*)cBeE[i], kMinAngle, kMaxAngle);
		cThetaAT[i]->SetTitle(canvasTitle.Data());
918 919
//		cThetaAT[i]->Divide(2, 3);
		CanvasDivision(cThetaAT[i]);
920 921 922 923 924 925

		che->SetLineColor(kBlack);
		for (Int_t j = 0; j < 6; j++) {	//different files
			if (!kChains[j]) continue;
			cThetaAT[i]->cd(j+1);
			hsName.Form("hsthetaAT%d_%d", i, j);
926
			hsthetaAT[i][j] = new TH1F(hsName.Data(), "title", 30, 0, 3.14);
927 928 929 930 931
			hsthetaAT[i][j]->SetLineColor(kGray+1);
			hsthetaAT[i][j]->SetFillColor(kGray+1);
			drawCommand.Form("fAThetaCM>>%s", hsthetaAT[i][j]->GetName());
			chs[j]->Draw(drawCommand.Data(), cQ && crBeE[i] && crAngles && crEpsilonT && sRatio[j], "goff", sEventsECuts[i][j]);
			heName.Form("hethetaAT%d_%d", i, j);
932
			hethetaAT[i][j] = new TH1F(heName.Data(), "title", 30, 0, 3.14);
933 934 935 936 937
			drawCommand.Form("fAThetaCM>>%s", hethetaAT[i][j]->GetName());
			che->Draw(drawCommand.Data(), cQ && cBeE[i] && cAngles && cEpsilonT, "goff", eEventsECuts[i][j]);

			hsthetaAT[i][j]->Draw();
			hsthetaAT[i][j]->SetTitle("");
938 939
			hsthetaAT[i][j]->SetXTitle("\\theta_{\\alpha} (rad)");
//			hsthetaAT[i][j]->GetXaxis()->SetTitleOffset(0.95);
940 941 942
			hsthetaAT[i][j]->GetXaxis()->CenterTitle();
			hsthetaAT[i][j]->SetYTitle("counts");
			//				hsthetaAT[i][j]->GetYaxis()->SetTitleOffset(1.09);
943
//			hsthetaAT[i][j]->GetYaxis()->SetTitleOffset(0.7);
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958
			hsthetaAT[i][j]->GetYaxis()->CenterTitle();

			hethetaAT[i][j]->Draw("E same");
			if (kAutoRange) {
				Float_t leftMaxMC = kRangeProportion*hethetaAT[i][j]->GetMaximum();
				Float_t leftMaxE = kRangeProportion*hsthetaAT[i][j]->GetMaximum();
				hsthetaAT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
				leftMaxMC > leftMaxE ? hsthetaAT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hsthetaAT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE);
			}
			else {
				hsthetaAT[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]);
			}
			cThetaAT[i]->Update();

			hiName.Form("hithetaAT%d_%d", i, j);
959
			drawCommand.Form("sACM.Theta()>>%s(30,0,3.14)", hiName.Data());
960 961 962 963 964 965 966 967 968
			ti[j]->Draw(drawCommand.Data(), ciEpsilon && ciBeE[i] && sRatio[j], "same");
			hithetaAT[i][j] = (TH1F*)gPad->FindObject(hiName.Data());
			Float_t rightmax = 1.1*hithetaAT[i][j]->GetMaximum();
			Float_t scale = cThetaAT[i]->GetPad(j+1)->GetUymax()/rightmax;
			hithetaAT[i][j]->SetLineColor(kRed);
			hithetaAT[i][j]->Scale(scale);


			//draw an axis on the right side
969 970 971 972 973
//			TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
//					gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
//			axis->SetLineColor(kRed);
//			axis->SetLabelColor(kRed);
//			axis->Draw();
974 975 976 977

			cThetaAT[i]->Update();

			if (kVerbose) {
978
				Info("BeAnalysis::ThetaAT", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f",
979 980 981 982 983 984 985 986
						i, j, hethetaAT[i][j]->Integral(0,hethetaAT[i][j]->GetNbinsX()),
						hsthetaAT[i][j]->Integral(0,hsthetaAT[i][j]->GetNbinsX()),
						hethetaAT[i][j]->Integral(0,hethetaAT[i][j]->GetNbinsX())/hsthetaAT[i][j]->Integral(0,hsthetaAT[i][j]->GetNbinsX()) );
			}

		}//for j

		SaveFigures(cThetaAT[i], "thetaAT", i);
987

988
	}//for i
989

990 991
}

992 993 994 995 996
//void BeAnalysis::ExpEventsECuts(Long64_t **noExpEvents) {
//void BeAnalysis::ExpEventsECuts(Int_t (&noExpEvents)[5][6]) {
//void BeAnalysis::ExpEventsECuts(Int_t (*noExpEvents)[5][6]) {
void BeAnalysis::ExpEventsECuts(Long64_t noExpEvents[5][6]) {

997

998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
//	eMaxEvents = 5000000;

	if (!noExpEvents) {
		for (Int_t i = 0; i < 5; i++) {
			for (Int_t j = 0; j < 6; j++) {
				eEventsECuts[i][j] = eMaxEvents;
			}
		}
		Warning("BeAnalysis::ExpEventsECuts", "Default numbers of experimental events were set.");
		return;
	}
1009

1010 1011 1012 1013 1014 1015
	for (Int_t i = 0; i < 5; i++) {
		for (Int_t j = 0; j < 6; j++) {
			eEventsECuts[i][j] = (Long64_t)noExpEvents[i][j];
		}
	}
	return;
1016 1017


1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
//	eEventsECuts[0][0] = 3950000;
//	eEventsECuts[0][1] = 3950000;
//	eEventsECuts[0][2] = 3800000;
//	eEventsECuts[0][3] = 3850000;
//	eEventsECuts[0][4] = 3950000;
//	eEventsECuts[0][5] = 3900000;
//
//	eEventsECuts[1][0] = eMaxEvents;
//	eEventsECuts[1][1] = eMaxEvents;
//	eEventsECuts[1][2] = 4100000;
//	eEventsECuts[1][3] = eMaxEvents;
//	eEventsECuts[1][4] = eMaxEvents;
//	eEventsECuts[1][5] = eMaxEvents;
//
//	eEventsECuts[2][0] = 3050000;
//	eEventsECuts[2][1] = 3150000;
//	eEventsECuts[2][2] = 3200000;
//	eEventsECuts[2][3] = 3200000;
//	eEventsECuts[2][4] = 3250000;
//	eEventsECuts[2][5] = 3350000;
//
//	eEventsECuts[3][0] = 3850000;
//	eEventsECuts[3][1] = 3950000;
//	eEventsECuts[3][2] = 3900000;
//	eEventsECuts[3][3] = 3900000;
//	eEventsECuts[3][4] = 4000000;
//	eEventsECuts[3][5] = 4000000;
//
//	eEventsECuts[4][0]	= 4100000;
//	eEventsECuts[4][1]	= 4100000;
//	eEventsECuts[4][2]	= 4000000;
//	eEventsECuts[4][3]	= 4100000;
//	eEventsECuts[4][4]	= eMaxEvents;
//	eEventsECuts[4][5]	= eMaxEvents;
1052 1053
}

1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
void BeAnalysis::SimEventsECuts(Long64_t noSimEvents[5][6]) {


//	sMaxEvents;

	if (!noSimEvents) {
		for (Int_t i = 0; i < 5; i++) {
			for (Int_t j = 0; j < 6; j++) {
				sEventsECuts[i][j] = sMaxEvents;
			}
		}
		Warning("BeAnalysis::SimEventsECuts", "Default numbers of experimental events were set.");
		return;
	}
1068 1069 1070

	for (Int_t i = 0; i < 5; i++) {
		for (Int_t j = 0; j < 6; j++) {
1071
			sEventsECuts[i][j] = noSimEvents[i][j];
1072 1073
		}
	}
1074 1075 1076
	return;


1077

1078 1079 1080 1081 1082 1083 1084 1085 1086
//	for (Int_t i = 0; i < 5; i++) {
//		for (Int_t j = 0; j < 6; j++) {
//			sEventsECuts[i][j] = sMaxEvents;
//		}
//	}
//
//	sEventsECuts[1][1] = 2630000;
//	sEventsECuts[1][4] = 2660000;
//	sEventsECuts[1][5] = 2660000;
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101

}

void BeAnalysis::EpsilonTRange() {

	for (Int_t i = 0; i < 6; i++) {
		eTRange[0][i] = 300;
		eTRange[1][i] = 380;
		eTRange[2][i] = 300;
		eTRange[3][i] = 500;
		eTRange[4][i] = 500;
	}


}
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162

void BeAnalysis::SetFigures(TString figPath, TString figFormat,
		Bool_t kSave) {
	kSaveFigures = kSave;
	figureFormat = figFormat;
	figurePath = figPath;
}

void BeAnalysis::SetExpChain(TString files, Int_t minFnumber, Int_t maxFnumber) {

	lowExpFile = minFnumber;
	upExpFile = maxFnumber;
	expFiles = files;

}

void BeAnalysis::SetSimChains(TString chainAl0name, TString chainNoAl0name,
		TString chainAl180name, TString chainNoAl180name,
		TString chainAl90name, TString chainNoAl90name) {

	simFiles[0] = chainAl0name;
	simFiles[1] = chainNoAl0name;
	simFiles[2] = chainAl180name;
	simFiles[3] = chainNoAl180name;
	simFiles[4] = chainAl90name;
	simFiles[5] = chainNoAl90name;

}

void BeAnalysis::SetInputChains(TString inputAl0name, TString inputNoAl0name,
		TString inputAl180name, TString inputNoAl180name,
		TString inputAl90name, TString inputNoAl90name) {

	inputFiles[0] = inputAl0name;
	inputFiles[1] = inputNoAl0name;
	inputFiles[2] = inputAl180name;
	inputFiles[3] = inputNoAl180name;
	inputFiles[4] = inputAl90name;
	inputFiles[5] = inputNoAl90name;

}

void BeAnalysis::SetNoSimFiles(Int_t* minFnumber, Int_t* maxFnumber) {
	eMaxEvents = 5000000;

	if (!(minFnumber && maxFnumber)) {
		for (Int_t i = 0; i < 6; i++) {
			lowSimFile[i] = 0;
			upSimFile[i] = 14;
		}
		Info("BeAnalysis::SetNoSimFiles", "Default numbers of simfiles were set.");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
		lowSimFile[i] = minFnumber[i];
		upSimFile[i] = maxFnumber[i];
	}
	return;
}

1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
void BeAnalysis::SetEpsilonTintervals(Bool_t intervals[6]) {

	epsilonT = new Bool_t[noIntervals];

	if (!intervals) {
		for (Int_t i = 0; i < 6; i++) {
			epsilonT[i] = 1;
		}
		Warning("BeAnalysis::SetEpsilonTintervals", "All intervals epsilonT will be drawn");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
//		cout << intervals[i] << endl;
		epsilonT[i] = intervals[i];
	}
	return;

}

void BeAnalysis::SetCosThetaTkIntervals(Bool_t intervals[6]) {

	cosThetaT = new Bool_t[noIntervals];

	if (!intervals) {
		for (Int_t i = 0; i < 6; i++) {
			cosThetaT[i] = 1;
		}
		Warning("BeAnalysis::SetCosThetaTkIntervals", "All intervals epsilonT will be drawn");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
//		cout << intervals[i] << endl;
		cosThetaT[i] = intervals[i];
	}
	return;

}

void BeAnalysis::SetEpsilonYintervals(Bool_t intervals[6]) {
	epsilonY = new Bool_t[noIntervals];

	if (!intervals) {
		for (Int_t i = 0; i < 6; i++) {
			epsilonY[i] = 1;
		}
		Warning("BeAnalysis::SetEpsilonYintervals", "All intervals epsilonT will be drawn");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
//		cout << intervals[i] << endl;
		epsilonY[i] = intervals[i];
	}
	return;
}

void BeAnalysis::SetCosThetaYkIntervals(Bool_t intervals[6]) {
	cosThetaY = new Bool_t[noIntervals];

	if (!intervals) {
		for (Int_t i = 0; i < 6; i++) {
			cosThetaY[i] = 1;
		}
		Warning("BeAnalysis::SetCosThetaYkIntervals", "All intervals epsilonT will be drawn");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
//		cout << intervals[i] << endl;
		cosThetaY[i] = intervals[i];
	}
	return;
}

void BeAnalysis::SetThetaATintervals(Bool_t intervals[6]) {
	thetaAT = new Bool_t[noIntervals];

	if (!intervals) {
		for (Int_t i = 0; i < 6; i++) {
			thetaAT[i] = 1;
		}
		Warning("BeAnalysis::SetThetaATintervals", "All intervals epsilonT will be drawn");
		return;
	}

	for (Int_t i = 0; i < 6; i++) {
//		cout << intervals[i] << endl;
		thetaAT[i] = intervals[i];
	}
	return;
}

1257 1258 1259 1260 1261
void BeAnalysis::SaveFigures(TCanvas *canvas, TString variable, Int_t interval) {

	if (!kSaveFigures) return;

	canvasName.Form("%sfig%d%s:%d%d%s", figurePath.Data(), interval, variable.Data(), kMinAngle, kMaxAngle, figureFormat.Data());
1262 1263
	cout << canvasName << endl;
//	return;
1264 1265 1266 1267 1268 1269
	canvas->SaveAs(canvasName.Data());
	canvas->cd();
	canvas->Close();


}
1270

1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
void BeAnalysis::SetSimCuts(TString sEt[5]/*, TString sET0, TString sET1, TString sET2, TString sET3, TString sET4*/) {

//	if (sEt == 0) {
//		Error("BeAnalysis::SetSimCuts", "String array empty, no effect.");
//		return;
//	}

	for (Int_t i = 0; i < 5; i++) {
//		cout << sEt[i].Sizeof() << endl;
		if (sEt[i].Sizeof() <= 1) continue;
		crBeE[i] = sEt[i];
		Info("BeAnalysis::SetSimCuts", "crBeE[%d] was changed to \'%s\'.", i, sEt[i].Data());
//		cout << crBeE[i] << endl;
	}

}

1288 1289 1290
void BeAnalysis::CanvasDivision(TCanvas* c) {
	c->Divide(2, 3, 0., 0.);
}