AEvent.h 4.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * AEvent.h
 *
 *  Created on: Dec 28, 2016
 *      Author: daria
 */

#ifndef DATACLASSES_AEVENT_H_
#define DATACLASSES_AEVENT_H_

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

#include "TError.h"
#include "TString.h"
#include "TTree.h"
#include "TFile.h"
20
#include "TF1.h"
21 22 23 24 25
//#include "TMath.h"


#include "RawEvent.h"

26
//#define NCELLS 1024
27 28 29 30 31 32 33 34 35

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

class AEvent {

private:

	const Int_t fNPoints;	//!
36 37 38
	TArrayD fAmpPos;	//array for raw amplitudes
	TArrayD fTime;		//array for raw times

39 40
	Double_t fAmpMax;
	Double_t fTimeAmpMax;
41
	Double_t fZeroLevel;
42
	Double_t fEdgeXi;
43 44 45
	Double_t fEdgeSlope;	//slope coefficient for the rising edge of the signal
	Double_t fTime10;		//time of 10% of rising edge amplitude in ns
	Double_t fTime90;		//time of 10% of rising edge amplitude in ns
46
	Double_t fTimeMid;		//time point between fTime90 and fTime10
47 48
	Double_t fAmpMid;		//amplitude in fTimeMid point. Used in ToT on 50% of rising edge determination
	Double_t fToT;
Muzalevsky I.A's avatar
Muzalevsky I.A committed
49
	Double_t fTimeLast;  //!
50 51

	TArrayD fAmpCFD;	//array for CFD amplitudes (attenuated, inversed and delayed)
52
	Double_t fTimeCFD;			//zero-crossing time
Muzalevsky I.A's avatar
Muzalevsky I.A committed
53
	Double_t fChargeCFD;
54
	Double_t fChargeLED;	//charge of the signal in Coulomb
55
	Double_t fChargeTF;	//
56

Muzalevsky I.A's avatar
Muzalevsky I.A committed
57 58
	Double_t fTimeThresh;  // time of thresh crossing rising edge
	Double_t fTimeThreshBack;  // time of threshBack crossing
59
	Double_t fTimeLED;	//time of LED threshold crossing
60
	Double_t fTimeFront;	//time of front fit crossing zero level
61

62 63
	TGraph *fGraphSignal;
	TGraph *fGraphCFD;
64
//	TGraph *fGraphSmooth;
65 66 67

	RawEvent *fInputEvent;		//!

68
	Double_t fCFratio;		//!
69 70
	Double_t fCFtimeDelay;		//!

71 72
	Double_t fNoiseRangeMin;	//!
	Double_t fNoiseRangeMax;	//!
73
	Int_t fWinSize;			//!
74

75 76
public:
	AEvent();
77
	AEvent(const Int_t npoints);
78 79
	virtual ~AEvent();
	ClassDef(AEvent,1);
80 81
	
	Double_t GetT_10();
82 83
	//returns time of 10% of rising edge amplitude in ns

84
	Double_t GetT_90();
85 86
	//returns time of 90% of rising edge amplitude in ns

87
	Double_t GetEdgeSlope();
88 89
	//returns slope coefficient for the rising edge of the signal

90 91
	Double_t GetEdgeXi();

Muzalevsky I.A's avatar
Muzalevsky I.A committed
92 93 94 95
	Double_t GetfChargeCFD();

	Double_t GetfChargeTF();

Muzalevsky I.A's avatar
Muzalevsky I.A committed
96
	Double_t GetfCFD();
97

Muzalevsky I.A's avatar
Muzalevsky I.A committed
98
	Double_t GetfLED();
Muzalevsky I.A's avatar
Muzalevsky I.A committed
99 100 101
	
	Double_t GetfThresh();
	
Muzalevsky I.A's avatar
Muzalevsky I.A committed
102
	Double_t GetOnefTime(Int_t i);
103

Muzalevsky I.A's avatar
Muzalevsky I.A committed
104
	Double_t GetOnefAmpPos(Int_t i);
105

Vratislav Chudoba's avatar
Vratislav Chudoba committed
106
	void ProcessEvent(Bool_t bSmooth = kFALSE);
107
	void SetInputEvent(RawEvent** event);
108

109 110 111 112 113
	void SetCFratio(Double_t ratio) { fCFratio = ratio; };	
	//CFD set attenuation coefficient

	void SetCFtimeDelay(Double_t timeDelay) { fCFtimeDelay = timeDelay; };	
	//CFD set time delay (in points)
114

115 116 117
	void SetNoiseRange(Double_t min, Double_t max) { fNoiseRangeMin = min; fNoiseRangeMax = max; };
	//Set noise range to be used in FindZeroLevel()

118 119 120
	void SetSmoothPoints(Int_t numofp) {fWinSize = numofp; };
	//set number of smoothing points

121 122 123 124
	void SetToT();
	//calculate time-over-threshold. the threshold value is fTimeMid - middle point of the rising edge
	//ToT is calculated within 15 ns range in order to consider all the weirdness of the signal form

125 126 127
	void Reset();
	 //Resets arrays to zeros

128 129
	TGraph* GetGraphCFD() {

130
		return fGraphCFD;
131
	}
132 133 134 135 136 137
	//draws CFD graphs

	TGraph* GetGraphSignal() {

		return fGraphSignal;
	}
138

139
	/*TGraph* GetGraphSmooth() {
140 141

		return fGraphSmooth;
142
	}*/
143 144
	//draws signal shape graphs

145 146
	void FindFrontProperties();

147
	Double_t FindZeroLevel();
148
	//for zero level correction. one parameter fit between pmin and pmax
149
	//returns fit parameter i.e. number on which amplitude should be corrected
150

151
	void SetChargeCFD(Int_t tmin = -3, Int_t tmax = 17);
152 153 154 155
	//calculates charge of the signal (i.e. its integral 
	//in range of (tmin,tmax) in ns)
	//CFD time is taken as a start point

156 157
	void SetChargeLED(Int_t tmin = -3, Int_t tmax = 17);

158 159 160 161
	void SetChargeTF(Int_t tmin = -3, Int_t tmax = 17);
	//calculates charge of the signal (i.e. its integral 
	//in range of (tmin,tmax) in ns) 
	//time of front fit crossing zero is taken as a start point
162

Muzalevsky I.A's avatar
Muzalevsky I.A committed
163
	//void SetLED(Double_t threshold = 0.001);
164

Muzalevsky I.A's avatar
Muzalevsky I.A committed
165
	void SetLED(Double_t threshold = 0.01);
166

167
	//leading edge discriminator
Muzalevsky I.A's avatar
Muzalevsky I.A committed
168 169
	void SetThreshold(Double_t thresholdBack = 0.035, Double_t threshRise = 0.01);
	
170 171
private:
	void Init();
172
	void SetMaxAmplitudes();
173
	void SetGraphs();
174
	void SmoothGraphs();
175
	void SetCFD(); 	//constant fraction discriminator method
176 177 178
};

#endif /* DATACLASSES_AEVENT_H_ */