1 Double_t rpol2(Double_t *x, Double_t *par)
3 Double_t rp2 = par[0] + par[1]*x[0] + par[2]*x[0]*x[0];
9 TF1* f1 = new TF1("rpol2",rpol2,0.,300.,3);
10 f1->SetParNames("p0","p1","p2");
12 f1->SetParameter("p0",1.);
13 f1->SetParameter("p1",1.);
14 f1->SetParameter("p2",1.);
19 Double_t gausPol2(Double_t *x, Double_t *par)
21 //gaus+second order polynomial.
23 Double_t gp2 = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) /
25 + par[3] + par[4]*x[0] + par[5]*x[0]*x[0];
32 void pi0Calib(const char* file="Sum_All_Emc.root")
35 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
36 AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local://./");
38 AliPHOSCalibData cdb(0);
40 Int_t fMinEntr = 50; // min 50 pi0 canditates per cell
41 Double_t xmin = 100; // fit range lower end
42 Double_t xmax = 170; // fit range upper end
44 const Float_t pi0m = 134.98;
51 TH1F* hPi0Mass = new TH1F("pi0_mass","#pi^{0} mass in calibrated cells",100,0.,300.);
55 for(Int_t iMod=0; iMod<5; iMod++) {
56 for(Int_t iX=0; iX<64; iX++) {
57 for(Int_t iZ=0; iZ<56; iZ++) {
59 sprintf(hname,"%d_%d_%d",iMod,iX,iZ);
60 h1 = (TH1F*)f.Get(hname);
62 if(h1->GetEntries()<fMinEntr) continue;
64 TF1* rp2 = InitPol2();
65 rp2->SetRange(180,260);
66 // rp2->SetRange(50.,110.);
70 h1->GetXaxis()->SetRange(17,210);
71 Double_t max = h1->GetBinCenter(h1->GetMaximumBin()); // peak
73 TF1* f1 = new TF1("gpol2",gausPol2,xmin,xmax,6);
74 f1->SetParNames("Constant","Mean","Sigma","p0","p1","p2");
76 printf("Trying to fit %s, %d entries, peak at %.3f\n",
77 h1->GetName(),h1->GetEntries(),max);
79 f1->SetParameter("Constant",h1->GetMaximum());
80 f1->SetParameter("Mean",max);
81 f1->SetParameter("Sigma",1.);
82 f1->SetParameter("p0",rp2->GetParameter("p0"));
83 f1->SetParameter("p1",rp2->GetParameter("p1"));
84 f1->SetParameter("p2",rp2->GetParameter("p2"));
86 f1->SetLineColor(kBlue);
89 pi0f = f1->GetParameter("Mean");
92 //CC from the previous iteration.
93 cc_i = cdb.GetADCchannelEmc(iMod+1,iZ+1,iX+1);
95 if(pi0f>100. && pi0f<200.) {
96 Double_t k = pi0m/pi0f;
97 cc_ii = cc_i*(1+k**2)/2.;
98 cdb.SetADCchannelEmc(iMod+1,iZ+1,iX+1,cc_ii);
101 printf("%s: %d entries, mean=%.3f, peak=%.3f, rms= %.3f. pi0 = %.3f,
102 cc_i=%f, cc_ii=%f\n",
103 h1->GetName(),h1->GetEntries(),h1->GetMean(),max,h1->GetRMS(),
110 TFile ff("pi0Calib.root","recreate");
113 //Writing new calibration coefficients (CCs) to OCDB
115 AliCDBMetaData *md= new AliCDBMetaData();
116 md->SetResponsible("Boris Polishchuk");
118 cdb.WriteEmc(0,999999,md);
119 cdb.WriteCpv(0,999999,md);