/* * AEvent.cpp * * Created on: Dec 28, 2016 * Author: daria */ #include "AEvent.h" AEvent::AEvent() : fNPoints(1024) { //fNPoints is number of points in one event, 1024 or 1000 Init(); Reset(); } AEvent::AEvent(const Int_t npoints) : fNPoints(npoints) { Init(); Reset(); } AEvent::~AEvent() { // TODO Auto-generated destructor stub delete gSignal; delete gCFD; delete fInputEvent; } void AEvent::SetRawDataFile(const char* inprawfile, const char* treename) { TString iFileName = inprawfile; TFile *fraw = new TFile(iFileName.Data()); if ( !fraw->IsOpen() ) { Error("SetRawDataFile", "File %s was not opened and won't be processed", iFileName.Data()); } TTree *traw = (TTree*)fraw->Get(treename); if (!traw) { Error("SetRawDataFile", "Tree %s was not found in file %s", treename, iFileName.Data()); } } void AEvent::ProcessEvent() { if (fInputEvent == NULL) { Warning("AEvent::ProcessEvent", "Input event wasn't set. Function won't be processed."); return; } const Double_t *amp = fInputEvent->GetAmp(); const Double_t *time = fInputEvent->GetTime(); for(Int_t j = 0; j < fNPoints; j++) { fAmpPos[j] = amp[j]*(-1.); fTime[j] = time[j]; } Double_t maxAmp = 0.; Double_t maxAmpT = 0.; maxAmp = fAmpPos[0]; for(Int_t j=0; j < fNPoints; j++) { if(fAmpPos[j] > maxAmp) { maxAmp = fAmpPos[j]; maxAmpT = fTime[j]; } } fAmpMax = maxAmp; fTimeAmpMax = maxAmpT; SetGraphs(); SetCFD(); return; } void AEvent::Reset() { for (Int_t i = 0; i < fNPoints; i++) { fAmpPos[i] = 0; fTime[i] = 0; fAmpCFD[i] = 0; } fAmpMax = 0.; fTimeAmpMax = 0.; } void AEvent::SetInputEvent(RawEvent** event) { if (event == 0) { Warning("AEvent::SetInputEvent", "Input event was set as 0."); } fInputEvent = *event; } void AEvent::Init() { fAmpPos.Set(fNPoints); fTime.Set(fNPoints); fAmpCFD.Set(fNPoints); gSignal = new TGraph(); gCFD = new TGraph(); fInputEvent = 0; } void AEvent::SetGraphs() { gSignal->Set(fNPoints); for (Int_t i=0; iSetPoint(i, fTime[i], fAmpPos[i]); } return; } void AEvent::SetCFD(/*Double_t c, Int_t td*/) { gCFD->Set(fNPoints); Double_t c = 0.5; //attenuation coefficient Int_t td = 5; //time of delay in points Double_t maxCFD, minCFD, imax, imin, tmax, tmin, level; maxCFD = 0.; minCFD = 0.; level = 100.; for (Int_t i=0; itd) { fAmpCFD[i] = fAmpPos[i]*c*(-1); fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - td]; gCFD->SetPoint(i, fTime[i], fAmpCFD[i]); } //point for max CFD amplitude if(fAmpCFD[i] > maxCFD) { maxCFD = fAmpCFD[i]; imax = i; tmax = fTime[i]; } //point for min CFD amplitude if(fAmpCFD[i] < minCFD) { minCFD = fAmpCFD[i]; imin = i; tmin = fTime[i]; } } //finding "zero" of CFD amplitude for(Int_t j = imin; j < imax; j++) { if(abs(fAmpCFD[j]) < level) {level = abs(fAmpCFD[j]); fCFD = fTime[j];} } return; }