AculCalibration.h 5.51 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 128 129 130 131 132 133 134 135
#pragma once

#include <TObject.h>
#include <TFile.h>
#include <TTree.h>
#include <TH1I.h>
#include <TPolyMarker.h>
#include <TF1.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TCanvas.h>
#include <TMath.h>
#include <TGraph.h>
#include <TObjArray.h>
#include <TRandom3.h>
#include <THStack.h>
#include <TString.h>
#include <TSpectrum.h>

#include "AculRaw.h"		//potreba zaridit nezavislost na teto tride

#include <iostream>
#include <fstream>
#include <iomanip>
#include <sstream>

#define DEFAULTNOPEAKS 20
#define	BLOCKSNUMBER 24
#define ADDRESSNUMBER 16

using std::cout;
using std::endl;
using std::setw;
using std::setprecision;
using std::stringstream;
using std::ostringstream;

class AculCalibration : public TObject
{


public:

	//smysl jako verejne globalni promenne maji:
	//fNOSpectra	- pocet zkalibrovanych spekter
	//????			- pocet spravne zkalibrovanych spekter
	//????			- pocet nespravne zkalibrovanych spekter
	//fEnergy[4]	- tabulka s energiemi piku, nacita se zvenci

//private:


//	TObjArray	*fHRawList;			//list of raw histograms, list is set to owner
	TObjArray	fHRawList;			//list of raw histograms, list is set to owner
	TObjArray	fHAnalyzedList;	//list of fitted and analyzed histograms, list is set to owner
	TObjArray	fHEnergyList;		//list of calibrated histograms, list is set to owner
	THStack		fHEnergyStack;		//some stack
	THStack		*fCurrentHStack;
	//dodelat current histograms
	TObjArray	fCurrentHistList;



//	TRandom3	*fRanGen;
//	static TRandom3 fRanGen;	//!
//	THStack		*fHStack;

	//parameters to be read from file
	Int_t		kRaNOPEAKS;
	Double_t	fEnergy[DEFAULTNOPEAKS];
	Double_t	fLowerPeakRelativeHight;	//pouziva se, private
	Double_t	fUpperPeakRelativeHight;	//pouziva se, private, nastavit nenulovou prednastavenou hodnotu
	Double_t	fPeakPositionTolerance;		//pouziva se, private
	Width_t		fFitFuncLineWidth;			//private
	Double_t	fFitMinSigma;				//pouziva se, private
	Double_t	fFitPeakThreshold;			//pouziva se, private, prozkoumat, k cemu vlastne slouzi ve fci ShowPeaks, popremyslet o vhodnem prednastaveni v konstruktoru

	//tyto promenne jsou smyslem tridy, mely by tedy byt snad jako jedine verejne
	Double_t	fA[BLOCKSNUMBER][ADDRESSNUMBER];	//kalibracni parametry, f(x) = fA*x + fB
	Double_t	fB[BLOCKSNUMBER][ADDRESSNUMBER];	//kalibracni parametry, f(x) = fA*x + fB
	Double_t	fC[BLOCKSNUMBER][ADDRESSNUMBER];	//treti kalibracni parametr, jine zavislosti nez pol1
	Double_t	fD[BLOCKSNUMBER][ADDRESSNUMBER];	//ctvrty kalibracni parametr



									//smysl je velmi pochybny
	TFile		*fCalInformation;

//	AculCalibratedData	*fCalData;

//private:
	Double_t	fPeak[DEFAULTNOPEAKS];				//v teto promenne je ulozena momentalni hodnota piku v kanalech, zejmena v jedne fci, mozno udelat ji jako lokalni, bude navratovou hodnotou fce PeaksFitting, predelat delku pole

public:
	AculCalibration();		//
	AculCalibration(const char* parfile);		//
	virtual ~AculCalibration();
	ClassDef(AculCalibration, 1);

	//public
	Bool_t	SetInputParameters(const char* inputparfile = "parforcal.par");
	Bool_t	SetCalibrationParameters(const char* calparfile);
	//public
	void	PrintInputParameters();
	void	PrintCalibrationParameters(const Int_t blockmin = 1, const Int_t blockmax = BLOCKSNUMBER - 1);

	//public
	Bool_t	CalculateCalibParameters(const char* inputfilename, const Int_t block, Int_t lowerchannel = 0, Int_t upperchannel = 4095, Int_t lowersubaddress = 0, Int_t uppersubaddress = 15); //calculate calibration parameters for given block in given file
	Bool_t	CalculateCalibParameters(const char* inputfile, const char* block, const Int_t address, const char* treename, Int_t lowerchannel = 0, Int_t upperchannel = 4095, Int_t lowersubaddress = 0, Int_t uppersubaddress = 15); //calculate calibration parameters for given block in given file
	Int_t	CalibrateBlock(const Char_t* inputfilename, const Int_t block, const Char_t* outputfilename, Int_t lowersubaddress = 0, Int_t uppersubaddress = 15); //vysvetlit, co je to outputfile
	Int_t	PeaksFitting(TH1I* hSpectrum, Option_t* option = "", Double_t sigmamin = 2);  //possible options: "V", "Q", ""
	Int_t	SearchPeaks(const TH1 *hin, Double_t sigma = 2, Option_t *option = "", Double_t threshold = 0.05, const Int_t searchedpeaks = 100);

	void	FillRawSpectraFile(const char* rawdatafile, const char* block, const char* treename, TCanvas* rawCanvas = NULL, Option_t *option = "", Int_t xaxismin = 0, Int_t xaxismax = 4096);

	void	ShowRawSpectra(const char* filename, const Int_t block, TCanvas* rawCanvas = NULL, Int_t xaxismin = 0, Int_t xaxismax = 4096, /*TObjArray* histList = NULL,*/ const Int_t subaddress = 16);
	void	ShowSpectra(const char* filename, TCanvas* rawCanvas = NULL, Option_t *option = "", Int_t xaxismin = 0, Int_t xaxismax = 4096, /*TObjArray* histList = NULL,*/ const Int_t subaddress = 16);
	void	ShowAnalyzedSpectra(const char* filename, TCanvas* fittedRawCanvas = NULL, Int_t xaxismin = 0, Int_t xaxismax = 4096, Int_t subaddress = 16);
	void	ShowEnergySpectra(const char *filename, TCanvas* energyCanvas = NULL, const Int_t subaddress = 16, Option_t* option = "", Double_t xaxismin = 0., Double_t xaxismax = 10.); //option: "sum", "c", "+",

//	void

	//dodelat funkce TTree* Get...(...) pro raw, anal i E spectra
	Bool_t	AddCalFileToList(const char* calfilelist = "CalFileList.log");

	void	ClearHistograms(Option_t* option = "");
	void	DeleteStacks(Option_t* option = "");

	void	MakeCalibrationFile(Char_t* calibrationfile, Char_t* calfilelist);

	void	Reset();

//private:

};