AculCalibCsI.h 2.56 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
#pragma once

//#include "TObject.h"
//#include "TROOT.h"
#include <iostream>
#include <fstream>

#include "TFile.h"
#include "TTree.h"
#include "TCutG.h"
#include "TCanvas.h"
#include "TClonesArray.h"
#include "TH1I.h"
#include "TGraphErrors.h"
#include "TArrayD.h"
#include "TF1.h"

#define NOCALFILES 5

using std::cout;
using std::endl;

class AculCalibCsI {

private:

	TString detName;
	TString partName;
	
	TClonesArray fr;		//TFile
//	TFile *fData;
	TClonesArray tr;
	TClonesArray colFiles;
	TClonesArray colTrees;
	Int_t nofiles;
	TString fileNames[100];
	TString cutNames[100];

	Int_t energyPoints;
	TArrayD fE;

	TFile *fCuts;
	TString cutsFileName;
	Int_t nCuts;				//number of cuts
	TClonesArray cutsCol;

	TH1I *hfull[NOCALFILES][16];
	TH1I *hcut[NOCALFILES][16];

	Int_t peakMin[NOCALFILES][16];
	Int_t peakMax[NOCALFILES][16];
	Double_t mean[NOCALFILES][16];
	Double_t meanRMS[NOCALFILES][16];

	TGraphErrors *gCal[16];
	TFile *fGraphs;
	TArrayD fA;
	TArrayD fB;

	TString fParFileName;

public:
//	AculCalibCsI() : a(0), b(0), c(0), p(0){};
	AculCalibCsI();
	AculCalibCsI(const char* parfile);
	virtual ~AculCalibCsI();
	// Define the class for the cint dictionary
	ClassDef (AculCalibCsI,1);


	void OpenTrees();
	void LoadCuts();

	void SetParFile(const char* parfile);

	void PrintParameters(const char* option = "");
	void PrintPeakRanges();

	void DrawVariable(const char* variable, Int_t tree, TCanvas *canvas, Int_t lowRange = 0, Int_t upRange = 4096);
	void DrawBeam(TCanvas *canvas, Int_t files, const char* variable);
//	void DrawdEE(const char* variable, Int_t tree, TCanvas *canvas);
	void DrawVariableCut(const char* variable, Int_t tree, TCanvas *canvas, const char* cut1, const char* cut2 = "", Int_t lowRange = 0);
	void GetPeakMean(const char* variable, Int_t tree, Int_t energy, TCanvas *canvas, const char* beamcut, const Int_t nbins = 4096, Int_t lowRange = 0);

	void Calibrate(TCanvas *canvas, Bool_t savefile = 0, const char* filename = "", const char* option = "READ");
	void FillGraph(TGraphErrors *g, Int_t npoints, Double_t *energies, Int_t graphNumber, const char* option = "");
	void WriteClbParameters(const char* filename);
	void SaveClbGraphs(const char* filename, const char* option = "READ");
	void ReadClbParameters(const char* filename);
	void DrawClbGraphs(const char* filename, const char* graphname, TCanvas *canvas);
	void DrawEnergyDeposite(const char* variable, TCanvas *canvas, Int_t tree, const char* option = "");

	void PrintTrees();
	void PrintFiles();
	void PrintCuts();

	Double_t GetA(Int_t i);
	Double_t GetB(Int_t i);

private:

	void SetPars();
};