ATLAS Offline Software
Classes | Functions | Variables
LArPhysWaveHECTool.cxx File Reference
#include "LArCalibUtils/LArPhysWaveHECTool.h"
#include "LArIdentifier/LArOnline_SuperCellID.h"
#include <gsl/gsl_integration.h>
#include <gsl/gsl_errno.h>
#include <TGraphSmooth.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
Include dependency graph for LArPhysWaveHECTool.cxx:

Go to the source code of this file.

Classes

struct  gsl_f_params
 
struct  usertim
 

Functions

Double_t normalize (TF1 *func, Double_t *rampl=NULL, Double_t from=0., Double_t to=0., Double_t step=1.)
 
Double_t normalize_prof (TProfile *histo, Double_t *rampl=NULL)
 
void Smooth_new (Double_t *x, Double_t *y, Double_t *yref, Int_t ymax)
 
void SmootKern (Double_t *x, Double_t *y, Int_t ymax, Double_t band=10.)
 

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY
 
const int NMAX =1000
 
int LArWaveFlag =0
 
int Tp4_gsl_err_counter =0
 
int Tp5_gsl_err_counter =0
 

Function Documentation

◆ normalize()

Double_t normalize ( TF1 *  func,
Double_t *  rampl = NULL,
Double_t  from = 0.,
Double_t  to = 0.,
Double_t  step = 1. 
)

Definition at line 825 of file LArPhysWaveHECTool.cxx.

827 {
828  static Double_t amax, tmax,t, ampl;
829  static Double_t t1,t2,tt1,tt2;
830  static Int_t i;
831 
832  if((from == to) || (from > to))
833  func->GetRange(t1,t2);
834  else {
835  func->GetRange(tt1,tt2);
836  if(from>tt1) t1 = from; else t1 = tt1;
837  if(to<tt2) t2 = to; else t2 = tt2;
838  }
839 
840  amax = 0; tmax = t1;
841  for(t=t1; t<=t2; t+=step)
842  {
843  if(func->Eval(t) > amax) {
844  amax = func->Eval(t); tmax = t;
845  }
846  }
847  Double_t x[20], y[20];
848  i=0;
849  for(t=tmax-5; t<tmax+5; ++t) {
850  x[i] = t;
851  y[i] = func->Eval(t);
852  ++i;
853  }
854  TGraph *g = new TGraph(10,x,y);
855  g->Fit("pol2","QIE0");
856  tmax = - g->GetFunction("pol2")->GetParameter(1) / (2 *g->GetFunction("pol2")->GetParameter(2));
857  amax = g->GetFunction("pol2")->Eval(tmax);
858 
859  ampl = func->GetParameter(1);
860  if(amax != 0) func->SetParameter(1,ampl/amax);
861  else tmax = 0;
862  cout << "Normalize: tmax="<<tmax << " ampl=" << ampl<<" amax="<<amax << endl;
863  if(rampl != NULL) *rampl = amax;
864  g->Delete();
865  return tmax;
866 }

◆ normalize_prof()

Double_t normalize_prof ( TProfile histo,
Double_t *  rampl = NULL 
)

Definition at line 868 of file LArPhysWaveHECTool.cxx.

869 {
870  Double_t amax, tmax, x, y, err;
871  Int_t nbins,i, j, nent;
872  amax = histo->GetBinContent(0);
873  tmax = histo->GetBinCenter(0);
874  nbins = histo->GetNbinsX();
875  for(i=1; i<nbins; i++)
876  {
877  if(amax < histo->GetBinContent(i))
878  {
879  amax = histo->GetBinContent(i);
880  tmax = histo->GetBinCenter(i);
881  }
882  }
883 
884  histo->Fit("pol2","0QI","",tmax-10., tmax+10.);
885  tmax = - histo->GetFunction("pol2")->GetParameter(1) / (2 * histo->GetFunction("pol2")->GetParameter(2));
886  amax = histo->GetFunction("pol2")->Eval(tmax);
887  TProfile *htmp = new TProfile(*histo);
888  histo->Reset();
889  for(i=0; i<=nbins; i++)
890  {
891  if(htmp->GetBinEntries(i) == 0) continue;
892  x = htmp->GetBinCenter(i);
893  y = htmp->GetBinContent(i);
894  nent=int(htmp->GetBinEntries(i));
895  err = htmp->GetBinError(i);
896 // Hack for stupid root v.3, which do not like the one entries in profile histo
897  for(j=0; j<7; ++j) {
898  if(nent != 0) {
899  histo->Fill(x,y/amax+sqrt(2)*err/nent);
900  histo->Fill(x,y/amax-sqrt(2)*err/nent);
901  } else {
902  histo->Fill(x,y/amax+sqrt(2)*err);
903  histo->Fill(x,y/amax-sqrt(2)*err);
904  }
905  }
906  }
907 
908  if(rampl != NULL) *rampl = amax;
909 
910  return tmax;
911 }

◆ Smooth_new()

void Smooth_new ( Double_t *  x,
Double_t *  y,
Double_t *  yref,
Int_t  ymax 
)

Definition at line 925 of file LArPhysWaveHECTool.cxx.

926 {
927 // Smoothing the difference between the yref and y,
928 // then y = y + smoothed differnce
929 // repeating few times
930  static Double_t *dif = NULL;
931  static Int_t i,j;
932 
933  if(dif) delete[] dif;
934  dif = new Double_t[ymax];
935  for(j=0; j<4; ++j) {
936  for(i=0; i<ymax; ++i) dif[i] = y[i] - yref[i];
937  SmootKern(x,dif,ymax, 10.);
938  for(i=0; i<ymax; ++i) yref[i] += dif[i];
939  }
940 }

◆ SmootKern()

void SmootKern ( Double_t *  x,
Double_t *  y,
Int_t  ymax,
Double_t  band = 10. 
)

Definition at line 912 of file LArPhysWaveHECTool.cxx.

913 {
914  Double_t *xx, *yy;
915  TGraph *g=new TGraph(ymax,x,y);
916  TGraphSmooth *gs = new TGraphSmooth();
917  TGraph *g1 = gs->SmoothKern(g,"normal",band);
918  xx = g1->GetX(); yy = g1->GetY();
919  for(Int_t i=0; i<g->GetN(); ++i) {
920  x[i] = xx[i]; y[i] = yy[i];
921  }
922  delete g; delete gs;
923 }

Variable Documentation

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 17 of file LArPhysWaveHECTool.cxx.

◆ LArWaveFlag

int LArWaveFlag =0

Definition at line 57 of file LArPhysWaveHECTool.cxx.

◆ NMAX

const int NMAX =1000

Definition at line 22 of file LArPhysWaveHECTool.cxx.

◆ Tp4_gsl_err_counter

int Tp4_gsl_err_counter =0

Definition at line 57 of file LArPhysWaveHECTool.cxx.

◆ Tp5_gsl_err_counter

int Tp5_gsl_err_counter =0

Definition at line 57 of file LArPhysWaveHECTool.cxx.

PlotCalibFromCool.yy
yy
Definition: PlotCalibFromCool.py:714
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
SmootKern
void SmootKern(Double_t *x, Double_t *y, Int_t ymax, Double_t band=10.)
Definition: LArPhysWaveHECTool.cxx:912
fitman.g1
g1
Definition: fitman.py:619
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
TProfile
Definition: rootspy.cxx:515
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:32
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
y
#define y
LArCellBinning.step
step
Definition: LArCellBinning.py:158
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
ymax
double ymax
Definition: listroot.cxx:64
TProfile::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:527