+ for (Int_t im=startim; im<nmips; im++)
+ {
+ TString cfd = Form("hCFD%i_%i",i+1,im+1);
+ TString qtc = Form("hQTC%i_%i",i+1,im+1);
+ TString led = Form("hLED%i_%i",i+1,im+1);
+
+ TH1F *hCFD = (TH1F*) gFile->Get(cfd.Data()) ;
+ TH1F *hLED = (TH1F*) gFile->Get(led.Data());
+ TH1F *hQTC = (TH1F*) gFile->Get(qtc.Data()) ;
+ hCFD->SetDirectory(0);
+ hQTC->SetDirectory(0);
+ hLED->SetDirectory(0);
+ if(!hCFD )
+ AliWarning(Form(" no CFD data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
+ if(!hQTC )
+ AliWarning(Form(" no QTC correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
+ if(!hLED)
+ AliWarning(Form(" no LED correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
+
+ if(hCFD ) {
+ hCFD->GetXaxis()->SetRangeUser(32200,32450);
+ TSpectrum *s = new TSpectrum(2*npeaks,1);
+ nfound = s->Search(hCFD,sigma," ",0.1);
+ if(nfound!=0){
+ Float_t *xpeak = s->GetPositionX();
+ TMath::Sort(nfound, xpeak, index,down);
+ Float_t xp = xpeak[index[0]];
+ Double_t hmax = xp+3*sigma;
+ Double_t hmin = xp-3*sigma;
+ hCFD->GetXaxis()->SetRangeUser(hmin-10,hmax+10);
+ }
+ else
+ {
+ hCFD->Rebin(2);
+ TSpectrum *s1 = new TSpectrum(2*npeaks,1);
+ nfound = s1->Search(hCFD,sigma," ",0.1);
+ if(nfound!=0){
+ Float_t *xpeak = s1->GetPositionX();
+ TMath::Sort(nfound, xpeak, index,down);
+ Float_t xp = xpeak[index[0]];
+ Double_t hmax = xp+3*sigma;
+ Double_t hmin = xp-3*sigma;
+ hCFD->GetXaxis()->SetRangeUser(hmin-10,hmax+10);
+ }
+ else
+ ok=false;
+ }
+
+ if (im == 0) cfd0[i] = hCFD->GetMean();
+ y1[im] = hCFD->GetMean() - cfd0[i];
+ }
+ if( hQTC) x1[im] = hQTC->GetMean();
+
+ if( hLED){
+ TSpectrum *s = new TSpectrum(2*npeaks,1);
+ nfound = s->Search(hLED,sigma," ",0.1);
+ if(nfound!=0){
+ Float_t *xpeak = s->GetPositionX();
+ TMath::Sort(nfound, xpeak, index,down);
+ Float_t xp = xpeak[index[0]];
+ Double_t hmax = xp+10*sigma;
+ Double_t hmin = xp-10*sigma;
+ hLED->GetXaxis()->SetRangeUser(hmin-10,hmax+10);
+ }
+ else
+ ok=false;
+ x2[im] = hLED->GetMean();
+ xx2[im] = x2[nmips-im-1];
+ }
+ xx[im]=mips[im];
+
+ if (hQTC) delete hQTC;
+ if (hCFD) delete hCFD;
+ if (hLED) delete hLED;
+ }
+
+ for (Int_t imi=0; imi<nmips; imi++)
+ {
+ yy1[imi] = Float_t (mips[nmips-imi-1]);
+ xx1[imi] = x2[nmips-imi-1];
+ // cout<<" LED rev "<<i<<" "<<imi<<" "<<xx1[imi]<<" "<< yy1[imi]<<"nmips-imi-1 = "<< nmips-imi-1<<endl;
+ }
+
+ if(i==0) cout<<"Making graphs..."<<endl;
+
+ TGraph *grwalkqtc = new TGraph (nmips,x1,y1);
+ grwalkqtc->SetTitle(Form("PMT%i",i));
+ TGraph *grwalkled = new TGraph (nmips,x2,y1);
+ grwalkled->SetTitle(Form("PMT%i",i));
+ fWalk.AddAtAndExpand(grwalkqtc,i);
+ fAmpLEDRec.AddAtAndExpand(grwalkled,i);
+ // cout<<" add walk "<<i<<endl;
+
+ //fit amplitude graphs to make comparison wth new one
+ TGraph *grampled = new TGraph (nmips,xx1,yy1);
+ TGraph *grqtc = new TGraph (nmips,x1,xx);
+ fQTC.AddAtAndExpand(grqtc,i);
+ fAmpLED.AddAtAndExpand(grampled,i);
+ // cout<<" add amp "<<i<<endl;
+
+ if(i==23)
+ cout<<"Graphs created..."<<endl;