ATLAS Offline Software
Loading...
Searching...
No Matches
OfflineCalibUtils.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TH1.h"
6#include "TF1.h"
7#include <vector>
8#include <cmath>
9
10// utility for Pixel Offline Claibration Classes
11inline double *LogaritmicBins(int NTOT, double START, double END){
12 double *bins = new double[NTOT+1];
13 for(int i = 0 ; i < NTOT + 1 ; i++)
14 bins[i] = START * pow( END/START, double(i)/double(NTOT) );
15 return bins;
16}
17
18
19inline double *IntegerBins(int NTOT, double NSTART = 0, double PASS = 1){
20 double *bins = new double[NTOT+1];
21 for(int i = 0; i < NTOT + 1; i++) bins[i] = NSTART + PASS * i;
22 return bins;
23}
24
25inline int EtaModuleBins(double *&bins){
26 bins = IntegerBins(13,-6);
27 return 13;
28}
29
30inline int DiskEtaModuleBins(double *&bins){
31 bins = IntegerBins(2,-1);
32 return 2;
33}
34
35inline int BlayerPhiModuleBins(double *&bins){
36 bins = IntegerBins(22);
37 return 22;
38}
39
40inline int Layer1PhiModuleBins(double *&bins){
41 bins = IntegerBins(36);
42 return 36;
43}
44
45inline int Layer2PhiModuleBins(double *&bins){
46 bins = IntegerBins(52);
47 return 52;
48}
49
50inline int DiskPhiModuleBins(double *&bins){
51 bins = IntegerBins(48);
52 return 48;
53}
54
55inline std::vector<float> *getLayersBins(){
56
57 std::vector<float> *layers = new std::vector<float>();
58 for(int i =0 ; i < 8; i++ ) layers->push_back(float(i));
59 return layers;
60
61}
62
63inline void RecursiveFit(TH1 *swap, TF1 *f1, int parameter){
64 double oldrms = 1;
65 double newrms = 0;
66 double mean = 0;
67 int nfits = 0;
68 const char* f1name = f1->GetName();
69 swap->Fit(f1name,"RQ0");
70 while(fabs(newrms - oldrms) > oldrms*0.01 ){
71 if( nfits++ > 100 ) break;
72 oldrms = f1->GetParameter(parameter);
73 mean = f1->GetParameter(1);
74 f1->SetRange(mean-1.5*oldrms,mean+1.5*oldrms);
75 swap->Fit("f1","RQ0");
76 newrms = f1->GetParameter(parameter);
77 //std::cout << oldrms << " " << newrms << std::endl;
78 }
79}