Removing obsolete macros
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 May 2012 08:26:24 +0000 (08:26 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 May 2012 08:26:24 +0000 (08:26 +0000)
TPC/CalibMacros/CalibEdge.C [deleted file]
TPC/CalibMacros/CalibTimeVdrift.C [deleted file]
TPC/CalibMacros/MakeOCDB.C [deleted file]

diff --git a/TPC/CalibMacros/CalibEdge.C b/TPC/CalibMacros/CalibEdge.C
deleted file mode 100644 (file)
index 55ba6e1..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
-
-.x ~/rootlogon.C
-
-gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
-gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
-AliXRDPROOFtoolkit tool;
-gSystem->Load("libSTAT.so");
-
-
-//  Load - Calibration using the CE  
-.L $ALICE_ROOT/TPC/CalibMacros/AnalyzeLaser.C+
-LoadViewer();
-tree->SetAlias("dedgePI","tan(10*pi/180.)*lx.fElements-ly.fElements+0.5*0.4");
-tree->SetAlias("dedgeMI","ly.fElements+tan(10*pi/180.)*lx.fElements-0.5*0.4");
-tree->SetAlias("dedgePO","tan(10*pi/180.)*lx.fElements-ly.fElements+0.5*0.6");
-tree->SetAlias("dedgeMO","ly.fElements+tan(10*pi/180.)*lx.fElements-0.5*0.6");
-
-// Load -Calibration using laser tracks
-// PROOF neccessary
-
-
-TChain * chainFit=0;
-TChain * chainTrack=0;
-TChain * chain=0;
-//
-gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
-gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+");
-AliXRDPROOFtoolkit tool;
-chainTrack = tool.MakeChain("laser.txt","Track",0,10200);
-chainTrack->Lookup();
-chainTrack->SetProof(kTRUE);
-chain = tool.MakeChain("laser.txt","Residuals",0,10200);
-chain->Lookup();
-chainFit = tool.MakeChain("laser.txt","FitModels",0,10200);
-chainFit->Lookup();
-chainFit->SetProof(kTRUE);
-chain->SetProof(kTRUE);
-chainDrift = tool.MakeChain("laser.txt","driftv",0,10200);
-chainDrift->Lookup();
-chainDrift->SetProof(kTRUE);
-
- TCut cutChi2YOut("sqrt(chi2y2Out*dEdx)<5");
-  TCut cutChi2ZOut("sqrt(chi2z2Out*dEdx)<5");
-  TCut cutChi2YIn("sqrt(chi2y2In*dEdx)<5");
-  TCut cutChi2ZIn("sqrt(chi2z2In*dEdx)<5");
-  //
-  TCut cutdEdx("sqrt(dEdx)<30&&sqrt(dEdx)>3");
-  TCut cutDY("abs(yPol2In.fElements[2]*nclO*nclO/4.)<3");
-  TCut cutN("nclO>20&&nclI>20");
-  TCut cutA = cutChi2YOut+cutChi2ZOut+cutChi2YIn+cutChi2ZIn+cutN+cutdEdx;
-  //
-  // Cluster cuts
-  //
-  TCut cutClY("Cl[].fY!=0&&abs(Cl[].fY-TrYpol2.fElements)<1.");
-  TCut cutClZ("abs(Cl[].fZ-TrZpol2.fElements)<1.0");
-  TCut cutClX("abs(Cl[].fX)>10");
-  TCut cutE("abs(Cl[].fY/Cl[].fX)<0.14");
-  TCut cutSY("sqrt(Cl[].fSigmaY2)>0.05");
-  TCut cutSZ("sqrt(Cl[].fSigmaZ2)>0.05");
-  TCut cutQ("sqrt(Cl[].fMax)>4");
-  TCut cutCl=cutClY+cutClZ+cutClX+cutE+cutSY+cutSZ+cutQ;
-
-
-
-*/
-
-
-
-
-void CalibEdgeQPad(){
-  //
-  // Get the Mean charge on pad as function of pad number
-  //
-  TH2* hisQPadPShort= 0;
-  TH2* hisQPadMMiddle= 0;
-  TH2* hisQPadMLong= 0;
-  //
-  tree->Draw("qIn.fElements/qF2.fElements:pad.fElements>>hisQPadPShort(10,0,10,50,0.1,2)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector<36","");
-  hisQPadPShort = (TH2*)gROOT->FindObject("hisQPadPShort");
-  hisQPadPShort->FitSlicesY();
-  TH1 * hisQPadPShortM =  (TH1*)(gROOT->FindObject("hisQPadPShort_1")->Clone());
-  //
-  tree->Draw("qIn.fElements/qF2.fElements:pad.fElements>>hisQPadPMiddle(10,0,10,50,0.1,2)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector>36&&lx.fElements<197","");
-  hisQPadPMiddle = (TH2*)gROOT->FindObject("hisQPadPMiddle");
-  hisQPadPMiddle->FitSlicesY();
-  TH1 * hisQPadPMiddleM =  (TH1*)(gROOT->FindObject("hisQPadPMiddle_1")->Clone());
-  //
-  tree->Draw("qIn.fElements/qF2.fElements:pad.fElements>>hisQPadPLong(10,0,10,50,0.1,2)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector>36&&lx.fElements>197","");
-  hisQPadPLong = (TH2*)gROOT->FindObject("hisQPadPLong");
-  hisQPadPLong->FitSlicesY();
-  TH1 * hisQPadPLongM =  (TH1*)(gROOT->FindObject("hisQPadPLong_1")->Clone());
-  //
-  hisQPadPShortM->SetLineColor(2);
-  hisQPadPMiddleM->SetLineColor(4);
-  hisQPadPLongM->SetLineColor(6);
-  hisQPadPShortM->SetMarkerStyle(23);
-  hisQPadPMiddleM->SetMarkerStyle(24);
-  hisQPadPLongM->SetMarkerStyle(25);
-
-  hisQPadPShortM->Draw();
-  hisQPadPShortM->SetMinimum(0);
-  hisQPadPShortM->SetMaximum(1.4);
-  hisQPadPMiddleM->Draw("same");
-  hisQPadPLongM->Draw("same");
-  TLegend *legend = new TLegend(0.45,0.12,0.85,0.55, "Mean charge vs Pad number");
-  legend->SetBorderSize(1);
-  legend->AddEntry(hisQPadPShortM,"Short pads");
-  legend->AddEntry(hisQPadPMiddleM,"Medium pads");
-  legend->AddEntry(hisQPadPLongM,"Long pads");
-  legend->Draw();
-
-}
-
-void CalibEdgeTPad(){
-  //
-  // Get the Mean charge on pad as function of pad number
-  //
-  TH2* hisTPadPShort= 0;
-  TH2* hisTPadMMiddle= 0;
-  TH2* hisTPadMLong= 0;
-  //
-  tree->Draw("(timeIn.fElements-timeF2.fElements)*2.64:pad.fElements>>hisTPadPShort(10,0,10,50,-1,1)","timeIn.fElements!=0&&sector%36>17&&sector<36","");
-  hisTPadPShort = (TH2*)gROOT->FindObject("hisTPadPShort");
-  hisTPadPShort->FitSlicesY();
-  TH1 * hisTPadPShortM =  (TH1*)(gROOT->FindObject("hisTPadPShort_1")->Clone());
-  //
-  tree->Draw("(timeIn.fElements-timeF2.fElements)*2.64:pad.fElements>>hisTPadPMiddle(10,0,10,50,-1,1)","timeIn.fElements!=0&&sector%36>17&&sector>36&&lx.fElements<197","");
-  hisTPadPMiddle = (TH2*)gROOT->FindObject("hisTPadPMiddle");
-  hisTPadPMiddle->FitSlicesY();
-  TH1 * hisTPadPMiddleM =  (TH1*)(gROOT->FindObject("hisTPadPMiddle_1")->Clone());
-  //
-  tree->Draw("(timeIn.fElements-timeF2.fElements)*2.64:pad.fElements>>hisTPadPLong(10,0,10,50,-1,1)","timeIn.fElements!=0&&sector%36>17&&sector>36&&lx.fElements>197","");
-  hisTPadPLong = (TH2*)gROOT->FindObject("hisTPadPLong");
-  hisTPadPLong->FitSlicesY();
-  TH1 * hisTPadPLongM =  (TH1*)(gROOT->FindObject("hisTPadPLong_1")->Clone());
-  //
-
-
-
-  //
-  hisTPadPShortM->SetLineColor(2);
-  hisTPadPMiddleM->SetLineColor(4);
-  hisTPadPLongM->SetLineColor(6);
-  hisTPadPShortM->SetMarkerStyle(23);
-  hisTPadPMiddleM->SetMarkerStyle(24);
-  hisTPadPLongM->SetMarkerStyle(25);
-
-  hisTPadPShortM->Draw();
-  hisTPadPShortM->SetMinimum(-0.3);
-  hisTPadPShortM->SetMaximum(0.2);
-  hisTPadPMiddleM->Draw("same");
-  hisTPadPLongM->Draw("same");
-  TLegend *legend = new TLegend(0.45,0.12,0.85,0.35, "Mean charge vs Pad number");
-  legend->SetBorderSize(1);
-  legend->AddEntry(hisTPadPShortM,"Short pads");
-  legend->AddEntry(hisTPadPMiddleM,"Medium pads");
-  legend->AddEntry(hisTPadPLongM,"Long pads");
-  legend->Draw();
-
-}
-
-
-
-
-void CalibEdgeQ(){
-  //
-  // 
-  //
-  TH1* hisQedgePInner= 0;
-  TH1* hisQedgeMInner= 0;
-  TH1* hisQedgePOuter= 0;
-  TH1* hisQedgeMOuter= 0;
-
-  tree->Draw("qIn.fElements/qF2.fElements:dedgePI>>hisQedgePInner(50,0,5)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector<36","prof");
-  tree->Draw("qIn.fElements/qF2.fElements:dedgeMI>>hisQedgeMInner(50,0,5)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector<36","prof");
-  
-  hisQedgePInner = (TH1*)gROOT->FindObject("hisQedgePInner");
-  hisQedgeMInner = (TH1*)gROOT->FindObject("hisQedgeMInner");
-  hisQedgePInner->SetLineColor(2);
-  hisQedgeMInner->SetLineColor(4);
-  hisQedgePInner->Draw();
-  hisQedgeMInner->Draw("same");
-  //
-  //
-  //
-  tree->Draw("qIn.fElements/qF2.fElements:dedgePO>>hisQedgePOuter(50,0,5)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector>36&&lx.fElements<200","prof");
-  tree->Draw("qIn.fElements/qF2.fElements:dedgeMO>>hisQedgeMOuter(50,0,5)","abs(qIn.fElements/qF2.fElements-1)<0.9&&sector%36>17&&sector>36&&lx.fElements<200","prof");  
-  hisQedgePOuter = (TH1*)gROOT->FindObject("hisQedgePOuter");
-  hisQedgeMOuter = (TH1*)gROOT->FindObject("hisQedgeMOuter");
-  hisQedgePOuter->SetLineColor(2);
-  hisQedgeMOuter->SetLineColor(4);
-  hisQedgePOuter->Draw();
-  hisQedgeMOuter->Draw("same");
-}
-
-
-
-
-
-
-void EdgeLaserZ(){
-  
-
-  TH2* hisZedgePInnerA   = 0;
-  TH2* hisZedgePMiddleA = 0;
-  TH2* hisZedgePLongA   = 0;
-  TObjArray farray(100);
-  delete gROOT->FindObject("hisEdge");
-  chain->Draw("Cl[].fZ-TrZpol1.fElements:Cl[].fPad>>hisEdge1(50,0,10,50, -0.5,0.5)",cutA+cutClZ+"Cl[].fDetector<36&&Cl[].fDetector<18&&Cl[].fPad>0","",50000);  
-  hisZedgePInnerA = (TH2*)(gROOT->FindObject("hisEdge"));
-  
-  hisZedgePInnerA->FitSlicesY(0,0,-1,0,"QNR",&farray);
-  farray->At(1)->Draw();
-
-}
diff --git a/TPC/CalibMacros/CalibTimeVdrift.C b/TPC/CalibMacros/CalibTimeVdrift.C
deleted file mode 100644 (file)
index 7e97213..0000000
+++ /dev/null
@@ -1,670 +0,0 @@
-/* 
-   Small macro to generate and update OCDB entries for a given run:
-   To be used together with pother macros to create OCDB entries
-   // How to use it...
-   //
-   // 1. go to the directory with the "CalibObjectsTrain1.root" file and start your aliroot
-   //
-   // 2. copy and paste the following commands
-   //
-   gSystem->Load("libSTEER");
-   gSystem->Load("libANALYSIS");
-   gSystem->Load("libSTAT");
-   gSystem->Load("libTPCcalib");
-   gSystem->AddIncludePath("-I$ALICE_ROOT/STEER");
-   gSystem->AddIncludePath("-I$ALICE_ROOT/TPC");
-   .L $ALICE_ROOT/TPC/CalibMacros/CalibTimeVdrift.C+
-   
-   //
-   // 3. setup your OCDB output path e.g:
-   //
-   ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
-   //
-   // 4. simple execution
-   //
-   CalibTimeVdrift("CalibObjectsTrain1.root", 110000, AliCDBRunRange::Infinity())
-   //
-   // 5. try to visualize new entry
-   //   
-   TObjArray *picArray = new TObjArray;
-   MakeDefaultPlots(vdriftArray,picArray);
-*/
-
-
-#if !defined(__CINT__) || defined(__MAKECINT__)
-#include "TMap.h"
-#include "TGraphErrors.h"
-#include "AliExternalTrackParam.h"
-#include "TFile.h"
-#include "TGraph.h"
-#include "TMultiGraph.h"
-#include "TCanvas.h"
-#include "THnSparse.h"
-#include "TLegend.h"
-#include "TPad.h"
-#include "TH2D.h"
-
-#include "AliESDfriend.h"
-
-
-#include "AliTPCcalibTime.h"
-#include "AliSplineFit.h"
-#include "AliCDBMetaData.h"
-#include "AliCDBId.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
-#include "AliTPCcalibBase.h"
-#include "AliTPCcalibDB.h"
-#include "AliTPCcalibDButil.h"
-#include "AliRelAlignerKalman.h"
-#include "AliTPCParamSR.h"
-#endif
-
-
-TString ocdbStorage="dummy";
-const Int_t    kMinEntries=100;     // minimal number of entries
-Int_t startRun=0, endRun=0;
-Int_t startTime=0, endTime=0;
-TObjArray * vdriftArray = 0;
-AliTPCcalibTime * timeDrift=0;
-//
-// functions:
-//
-void CalibTimeVdrift(Char_t* file="CalibObjectsTrain1.root", Int_t ustartRun=0, Int_t uendRun=AliCDBRunRange::Infinity(),TString ocdbStorage="");
-void UpdateOCDBDrift(Int_t ustartRun, Int_t uendRun);
-void AddHistoGraphs(  TObjArray * vdriftArray, AliTPCcalibTime *timeDrift, Int_t minEntries);
-void AddAlignmentGraphs(  TObjArray * vdriftArray, AliTPCcalibTime *timeDrift);
-void AddLaserGraphs(  TObjArray * vdriftArray, AliTPCcalibTime *timeDrift);
-void SetDefaultGraphDrift(TGraph *graph, Int_t color, Int_t style);
-TGraphErrors* FilterGraphMedianAbs(TGraphErrors * graph, Float_t cut,Double_t &medianY);
-TGraphErrors* FilterGraphDrift(TGraphErrors * graph, Float_t errSigmaCut, Float_t medianCutAbs);
-TGraphErrors * MakeGraphFilter0(THnSparse *hisN, Int_t itime, Int_t ival, Int_t minEntries, Double_t offset=0);
-
-
-void GetRunRange(AliTPCcalibTime* timeDrift){
-  //
-  // find the fist and last run
-  //
-  TObjArray *hisArray =timeDrift->GetHistoDrift();
-  {for (Int_t i=0; i<hisArray->GetEntriesFast(); i++){
-    THnSparse* addHist=(THnSparse*)hisArray->UncheckedAt(i);
-    if (addHist->GetEntries()<kMinEntries) continue;
-    if (!addHist) continue;
-    TH1D* histo    =addHist->Projection(3);
-    TH1D* histoTime=addHist->Projection(0);
-    printf("%s\t%f\t%d\t%d\n",histo->GetName(), histo->GetEntries(),histo->FindFirstBinAbove(0),histo->FindLastBinAbove(0));
-
-    if (startRun<=0){ 
-      startRun=histo->FindFirstBinAbove(0);
-      endRun  =histo->FindLastBinAbove(0);
-    }else{
-      startRun=TMath::Min(histo->FindFirstBinAbove(0),startRun);
-      endRun  =TMath::Max(histo->FindLastBinAbove(0),endRun);
-    }
-    if (startTime==0){ 
-      startTime=histoTime->FindFirstBinAbove(0);
-      endTime  =histoTime->FindLastBinAbove(0);
-    }else{
-      startTime=TMath::Min(histoTime->FindFirstBinAbove(0),startTime);
-      endTime  =TMath::Max(histoTime->FindLastBinAbove(0),endTime);
-    }
-    delete histo;
-    delete histoTime;
-  }}
-  if (startRun<0) startRun=0;
-  if (endRun<0) endRun=100000000;
-  printf("Run range  :\t%d-%d\n", startRun, endRun);
-  printf("Time range :\t%d-%d\n", startTime, endTime);
-
-}
-
-
-
-void CalibTimeVdrift(Char_t* file, Int_t ustartRun, Int_t uendRun, TString pocdbStorage){
-  //
-  //
-  //
-  const Int_t    kMinEntries=500;     // minimal number of entries
-  if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
-  //
-  // 1. Initialization and run range setting
-  TFile fcalib(file);
-  timeDrift=(AliTPCcalibTime*)fcalib.Get("calibTime");
-  startRun=ustartRun;
-  endRun=ustartRun; 
-  TObjArray *hisArray =timeDrift->GetHistoDrift();  
-  GetRunRange(timeDrift);
-  for (Int_t i=0; i<hisArray->GetEntriesFast(); i++){
-    THnSparse* addHist=(THnSparse*)hisArray->At(i);
-    if (!addHist) continue;
-    if (startTime<endTime) addHist->GetAxis(0)->SetRange(startTime-1,endTime+1);
-    if (startRun<endRun) addHist->GetAxis(3)->SetRange(startRun-1,endRun+1);
-  }
-  //
-  //
-  // 2. extraction of the information
-  //
-  vdriftArray = new TObjArray();
-  AddAlignmentGraphs(vdriftArray,timeDrift);
-  AddHistoGraphs(vdriftArray,timeDrift,kMinEntries);
-  AddLaserGraphs(vdriftArray,timeDrift);
-  //
-  // 3. Append QA plots
-  //
-  MakeDefaultPlots(vdriftArray,vdriftArray);
-  //
-  //
-  // 4. update of OCDB
-  //
-  //
-  UpdateOCDBDrift(ustartRun,uendRun);
-}
-
-void UpdateOCDBDrift( Int_t ustartRun, Int_t uendRun){
-  //
-  // Update OCDB 
-  //
-  AliCDBMetaData *metaData= new AliCDBMetaData();
-  metaData->SetObjectClassName("TObjArray");
-  metaData->SetResponsible("Marian Ivanov");
-  metaData->SetBeamPeriod(1);
-  metaData->SetAliRootVersion("05-25-01"); //root version
-  metaData->SetComment("Calibration of the time dependence of the drift velocity");
-  AliCDBId* id1=NULL;
-  id1=new AliCDBId("TPC/Calib/TimeDrift", ustartRun, uendRun);
-  AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
-  gStorage->Put(vdriftArray, (*id1), metaData);
-}
-
-
-
-void UpdateDriftParam(AliTPCParam *param, TObjArray *arr, Int_t startRun){
-  //
-  //  update the OCDB entry for the nominal time0
-  //
-  //
-  //  AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
-  AliTPCParam *paramNew = (AliTPCParam *)param->Clone();
-  TGraphErrors *grT =  (TGraphErrors *)arr->FindObject("ALIGN_ITSM_TPC_T0");
-  Double_t deltaTcm = TMath::Median(grT->GetN(),grT->GetY());
-  Double_t deltaT   = deltaTcm/param->GetDriftV();
-  paramNew->SetL1Delay(param->GetL1Delay()-deltaT);
-  paramNew->Update();
-
-  AliCDBMetaData *metaData= new AliCDBMetaData();
-  metaData->SetObjectClassName("TObjArray");
-  metaData->SetResponsible("Marian Ivanov");
-  metaData->SetBeamPeriod(1);
-  metaData->SetAliRootVersion("05-25-02"); //root version
-  metaData->SetComment("Updated calibration of nominal time 0");
-  AliCDBId* id1=NULL;
-  id1=new AliCDBId("TPC/Calib/Parameters", startRun, AliCDBRunRange::Infinity());
-  AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
-  gStorage->Put(param, (*id1), metaData);
-
-}
-
-
-void PrintArray(TObjArray *array){
-  //
-  //
-  //
-  Int_t entries = array->GetEntries();
-  for (Int_t i=0; i<entries; i++){
-    printf("%d\t %s\n", i,  array->At(i)->GetName());
-  }
-}
-
-
-
-TGraphErrors* FilterGraphDrift(TGraphErrors * graph, Float_t errSigmaCut, Float_t medianCutAbs){
-  // 2 filters:
-  //    1. filter graph - error cut errSigmaCut
-  //    2. filter graph - medianCutAbs around median
-  //
-  // errSigmaCut   - cut on error
-  // medianCutAbs  - cut on value around median
-  Double_t dummy=0;               //   
-  //
-  // 1. filter graph - error cut errSigmaCut
-  //              
-  TGraphErrors *graphF; 
-  graphF = AliTPCcalibDButil::FilterGraphMedianErr(graph,errSigmaCut,dummy);
-  delete graph;
-  if (!graphF) return 0;
-  graph = AliTPCcalibDButil::FilterGraphMedianErr(graphF,errSigmaCut,dummy);
-  delete graphF;
-  if (!graph) return 0;
-  //
-  // filter graph - kMedianCutAbs around median
-  // 
-  graphF=FilterGraphMedianAbs(graph, medianCutAbs,dummy);
-  delete graph;
-  if (!graphF) return 0;
-  graph=FilterGraphMedianAbs(graphF, medianCutAbs,dummy);
-  delete graphF;
-  if (!graph) return 0;
-  return graph;
-}
-
-
-
-TGraphErrors* FilterGraphMedianAbs(TGraphErrors * graph, Float_t cut,Double_t &medianY){
-  //
-  // filter outlyer measurement
-  // Only points around median +- cut filtered 
-  //
-  if (!graph) return  0;
-  Int_t kMinPoints=2;
-  Int_t npoints0 = graph->GetN();
-  Int_t npoints=0;
-  Float_t  rmsY=0;
-  Double_t *outx=new Double_t[npoints0];
-  Double_t *outy=new Double_t[npoints0];
-  Double_t *errx=new Double_t[npoints0];
-  Double_t *erry=new Double_t[npoints0];
-  //
-  //
-  if (npoints0<kMinPoints) return 0;
-  for (Int_t iter=0; iter<3; iter++){
-    npoints=0;
-    for (Int_t ipoint=0; ipoint<npoints0; ipoint++){
-      if (graph->GetY()[ipoint]==0) continue;
-      if (iter>0 &&TMath::Abs(graph->GetY()[ipoint]-medianY)>cut) continue;  
-      outx[npoints]  = graph->GetX()[ipoint];
-      outy[npoints]  = graph->GetY()[ipoint];
-      errx[npoints]  = graph->GetErrorX(ipoint);
-      erry[npoints]  = graph->GetErrorY(ipoint);
-      npoints++;
-    }
-    if (npoints<=1) break;
-    medianY  =TMath::Median(npoints,outy);
-    rmsY   =TMath::RMS(npoints,outy);
-  }
-  TGraphErrors *graphOut=0;
-  if (npoints>1) graphOut= new TGraphErrors(npoints,outx,outy,errx,erry); 
-  return graphOut;
-}
-
-
-void AddHistoGraphs(  TObjArray * vdriftArray, AliTPCcalibTime *timeDrift, Int_t minEntries){
-  //
-  // Add graphs corresponding to the alignment
-  //
-  const Double_t kErrSigmaCut=5;      // error sigma cut - for filtering
-  const Double_t kMedianCutAbs=0.03;  // error sigma cut - for filtering
-  //
-  TObjArray * array=timeDrift->GetHistoDrift();
-  if (array){
-    THnSparse* hist=NULL;
-    // 2.a) cosmics with different triggers
-    for (Int_t i=0; i<array->GetEntriesFast();i++){
-      hist=(THnSparseF*)array->UncheckedAt(i);
-      if(!hist) continue;
-      if (hist->GetEntries()<minEntries) continue;
-      //hist->Print();
-      TString name=hist->GetName();
-      Int_t dim[4]={0,1,2,3};
-      THnSparse* newHist=hist->Projection(4,dim);
-      newHist->SetName(name);
-      TGraphErrors* graph=AliTPCcalibBase::FitSlices(newHist,2,0,400,100,0.05,0.95, kTRUE);
-      printf("name=%s graph=%i, N=%i\n", name.Data(), graph==0, graph->GetN());
-      Int_t pos=name.Index("_");
-      name=name(pos,name.Capacity()-pos);
-      TString graphName=graph->ClassName();
-      graphName+=name;
-      graphName.ToUpper();
-      //
-      graph = FilterGraphDrift(graph, kErrSigmaCut, kMedianCutAbs);
-      if (!graph) {
-       printf("Graph =%s filtered out\n", name.Data());
-       continue;
-      }
-      //
-      graph->SetMarkerStyle(i%8+20);
-      graph->SetMarkerColor(i%7);
-      graph->GetXaxis()->SetTitle("Time");
-      graph->GetYaxis()->SetTitle("v_{dcor}");
-      graph->SetName(graphName);
-      graph->SetTitle(graphName);
-      printf("Graph %d\t=\t%s\n", i, graphName.Data());
-      vdriftArray->Add(graph);
-    }
-  }
-}
-
-
-
-
-void AddAlignmentGraphs(  TObjArray * vdriftArray, AliTPCcalibTime *timeDrift){
-  //
-  // Add graphs corresponding to alignment to the object array
-  //
-  TObjArray *arrayITS=0;
-  TObjArray *arrayTOF=0;
-  TObjArray *arrayTRD=0;
-  TMatrixD *mstatITS=0;
-  TMatrixD *mstatTOF=0;
-  TMatrixD *mstatTRD=0;
-  //
-  arrayITS=timeDrift->GetAlignITSTPC();
-  arrayTRD=timeDrift->GetAlignTRDTPC();
-  arrayTOF=timeDrift->GetAlignTOFTPC();
-
-  if (arrayITS->GetEntries()>0) mstatITS= AliTPCcalibDButil::MakeStatRelKalman(arrayITS,0.9,50,0.025);
-  if (arrayTOF->GetEntries()>0) mstatTOF= AliTPCcalibDButil::MakeStatRelKalman(arrayTOF,0.9,1000,0.025);
-  if (arrayTRD->GetEntries()>0) mstatTRD= AliTPCcalibDButil::MakeStatRelKalman(arrayTRD,0.9,50,0.025);
-  //
-  TObjArray * arrayITSP= AliTPCcalibDButil::SmoothRelKalman(arrayITS,*mstatITS, 0, 5.);
-  TObjArray * arrayITSM= AliTPCcalibDButil::SmoothRelKalman(arrayITS,*mstatITS, 1, 5.);
-  TObjArray * arrayITSB= AliTPCcalibDButil::SmoothRelKalman(arrayITSP,arrayITSM);
-  TObjArray * arrayTOFP= AliTPCcalibDButil::SmoothRelKalman(arrayTOF,*mstatTOF, 0, 5.);
-  TObjArray * arrayTOFM= AliTPCcalibDButil::SmoothRelKalman(arrayTOF,*mstatTOF, 1, 5.);
-  TObjArray * arrayTOFB= AliTPCcalibDButil::SmoothRelKalman(arrayTOFP,arrayTOFM);
-
-  TObjArray * arrayTRDP= 0x0;
-  TObjArray * arrayTRDM= 0x0;
-  TObjArray * arrayTRDB= 0x0;
-  arrayTRDP= AliTPCcalibDButil::SmoothRelKalman(arrayTRD,*mstatTRD, 0, 5.);
-  arrayTRDM= AliTPCcalibDButil::SmoothRelKalman(arrayTRD,*mstatTRD, 1, 5.);
-  arrayTRDB= AliTPCcalibDButil::SmoothRelKalman(arrayTRDP,arrayTRDM);
-  //
-  //
-  Int_t entries=TMath::Max(arrayITS->GetEntriesFast(),arrayTOF->GetEntriesFast());
-  TObjArray *arrays[12]={arrayITS, arrayITSP, arrayITSM, arrayITSB,
-                        arrayTRD, arrayTRDP, arrayTRDM, arrayTRDB,
-                        arrayTOF, arrayTOFP, arrayTOFM, arrayTOFB};
-  TString   grnames[12]={"ALIGN_ITS", "ALIGN_ITSP", "ALIGN_ITSM", "ALIGN_ITSB",
-                        "ALIGN_TRD", "ALIGN_TRDP", "ALIGN_TRDM","ALIGN_TRDB",
-                        "ALIGN_TOF", "ALIGN_TOFP", "ALIGN_TOFM","ALIGN_TOFB"};
-  TString   grpar[9]={"DELTAPSI", "DELTATHETA", "DELTAPHI",
-                     "DELTAX", "DELTAY", "DELTAZ",
-                     "DRIFTVD", "T0", "VDGY"};
-
-  
-  TVectorD vX(entries);
-  TVectorD vY(entries);
-  TVectorD vEx(entries);
-  TVectorD vEy(entries);
-  TObjArray *arr=0;
-  for (Int_t iarray=0; iarray<12; iarray++){
-    arr = arrays[iarray];
-    if (arr==0) continue;
-    for (Int_t ipar=0; ipar<9; ipar++){      
-      Int_t counter=0;
-      for (Int_t itime=0; itime<arr->GetEntriesFast(); itime++){
-       AliRelAlignerKalman * kalman = (AliRelAlignerKalman *) arr->UncheckedAt(itime);
-       if (!kalman) continue;
-       vX[counter]=kalman->GetTimeStamp();
-       vY[counter]=(*(kalman->GetState()))[ipar];
-       if (ipar==6) vY[counter]=1./(*(kalman->GetState()))[ipar]-1;
-       vEx[counter]=0;
-       vEy[counter]=TMath::Sqrt((*(kalman->GetStateCov()))(ipar,ipar));
-       counter++;
-      }
-    
-      TGraphErrors * graph=new TGraphErrors(counter, vX.GetMatrixArray(),
-                                         vY.GetMatrixArray(),
-                                         vEx.GetMatrixArray(),
-                                         vEy.GetMatrixArray());
-      TString grName=grnames[iarray];
-      grName+="_TPC_";
-      grName+=grpar[ipar];
-      graph->SetName(grName.Data());
-      vdriftArray->AddLast(graph);
-    }
-  }  
-}
-
-
-
-
-void AddLaserGraphs(  TObjArray * vdriftArray, AliTPCcalibTime *timeDrift){
-  //
-  // add graphs for laser
-  //
-  const Double_t delayL0L1 = 0.071;  //this is hack for 1/2 weeks
-  THnSparse *hisN=0;
-  TGraphErrors *grLaser[6]={0,0,0,0,0,0};
-  hisN = timeDrift->GetHistVdriftLaserA(0);
-  if (timeDrift->GetHistVdriftLaserA(0)){
-    grLaser[0]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserA(0),0,2,5,delayL0L1);
-    grLaser[0]->SetName("GRAPH_MEAN_DELAY_LASER_ALL_A");
-    vdriftArray->AddLast(grLaser[0]);
-  }    
-  if (timeDrift->GetHistVdriftLaserA(1)){
-    grLaser[1]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserA(1),0,2,5);
-    grLaser[1]->SetName("GRAPH_MEAN_DRIFT_LASER_ALL_A");
-    vdriftArray->AddLast(grLaser[1]);
-  }    
-  if (timeDrift->GetHistVdriftLaserA(2)){
-    grLaser[2]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserA(2),0,2,5);
-    grLaser[2]->SetName("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_A");
-    vdriftArray->AddLast(grLaser[2]);
-  }    
-  if (timeDrift->GetHistVdriftLaserC(0)){
-    grLaser[3]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserC(0),0,2,5,delayL0L1);
-    grLaser[3]->SetName("GRAPH_MEAN_DELAY_LASER_ALL_C");
-    vdriftArray->AddLast(grLaser[3]);
-  }    
-  if (timeDrift->GetHistVdriftLaserC(1)){
-    grLaser[4]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserC(1),0,2,5);
-    grLaser[4]->SetName("GRAPH_MEAN_DRIFT_LASER_ALL_C");
-    vdriftArray->AddLast(grLaser[4]);
-  }    
-  if (timeDrift->GetHistVdriftLaserC(2)){
-    grLaser[5]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserC(2),0,2,5);
-    grLaser[5]->SetName("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_C");    
-    vdriftArray->AddLast(grLaser[5]);
-  }    
-  for (Int_t i=0; i<6;i++){
-    if (grLaser[i]) {
-      SetDefaultGraphDrift(grLaser[i], 1,(i+20));
-      grLaser[i]->GetYaxis()->SetTitle("Laser Correction");
-    }
-  }
-}
-TGraphErrors * MakeGraphFilter0(THnSparse *hisN, Int_t itime, Int_t ival, Int_t minEntries, Double_t offset){
-  //
-  // Make graph with mean values and rms
-  //
-  hisN->GetAxis(itime)->SetRange(0,100000000);
-  hisN->GetAxis(ival)->SetRange(0,100000000);
-  TH1 * hisT      = hisN->Projection(itime);
-  TH1 * hisV      = hisN->Projection(ival);
-  //
-  Int_t firstBinA = hisT->FindFirstBinAbove(2);
-  Int_t lastBinA  = hisT->FindLastBinAbove(2);    
-  Int_t firstBinV = hisV->FindFirstBinAbove(0);
-  Int_t lastBinV  = hisV->FindLastBinAbove(0);    
-  hisN->GetAxis(itime)->SetRange(firstBinA,lastBinA);
-  hisN->GetAxis(ival)->SetRange(firstBinV,lastBinV);
-  Int_t entries=0;
-  for (Int_t ibin=firstBinA; ibin<lastBinA; ibin++){
-    Double_t cont = hisT->GetBinContent(ibin);
-    if (cont<minEntries) continue;
-    entries++;
-  }
-  TVectorD vecTime(entries);
-  TVectorD vecMean0(entries);
-  TVectorD vecRMS0(entries);
-  TVectorD vecMean1(entries);
-  TVectorD vecRMS1(entries);
-  entries=0;
-  {for (Int_t ibin=firstBinA; ibin<lastBinA; ibin++){
-      Double_t cont = hisT->GetBinContent(ibin);
-      if (cont<minEntries) continue;
-      hisN->GetAxis(itime)->SetRange(ibin-1,ibin+1);
-      Double_t time = hisT->GetBinCenter(ibin);
-      TH1 * his = hisN->Projection(ival);
-      Double_t nentries0= his->GetBinContent(his->FindBin(0));
-      if (cont-nentries0<minEntries) continue;
-      //
-      his->SetBinContent(his->FindBin(0),0);
-      vecTime[entries]=time;
-      vecMean0[entries]=his->GetMean()+offset;
-      vecMean1[entries]=his->GetMeanError();
-      vecRMS0[entries] =his->GetRMS();
-      vecRMS1[entries] =his->GetRMSError();
-      delete his;  
-      entries++;
-    }}
-  delete hisT;
-  delete hisV;
-  TGraphErrors * graph =  new TGraphErrors(entries,vecTime.GetMatrixArray(), vecMean0.GetMatrixArray(),                                           0, vecMean1.GetMatrixArray());
-  return graph;
-}
-
-
-
-
-
-
-
-
-void SetDefaultGraphDrift(TGraph *graph, Int_t color, Int_t style){
-  //
-  //
-  //
-  graph->GetXaxis()->SetTimeDisplay(kTRUE);
-  graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
-  graph->SetMaximum( 0.025);
-  graph->SetMinimum(-0.025);
-  graph->GetXaxis()->SetTitle("Time");
-  graph->GetYaxis()->SetTitle("v_{dcorr}");
-  //
-  graph->GetYaxis()->SetLabelSize(0.03);
-  graph->GetXaxis()->SetLabelSize(0.03);
-  //
-  graph->GetXaxis()->SetNdivisions(10,5,0);
-  graph->GetYaxis()->SetNdivisions(10,5,0);
-  //
-  graph->GetXaxis()->SetLabelOffset(0.02);
-  graph->GetYaxis()->SetLabelOffset(0.005);
-  //
-  graph->GetXaxis()->SetTitleOffset(1.3);
-  graph->GetYaxis()->SetTitleOffset(1.2);
-  //
-  graph->SetMarkerColor(color);
-  graph->SetLineColor(color);
-  graph->SetMarkerStyle(style);
-}
-
-void SetPadStyle(TPad *pad, Float_t mx0, Float_t mx1, Float_t my0, Float_t my1){
-  //
-  //
-  pad->SetTicks(1,1);
-  pad->SetMargin(mx0,mx1,my0,my1);
-}
-
-
-void MakeDefaultPlots(TObjArray * arr, TObjArray *picArray){
-  //
-  //
-  //
-  // margins
-  Float_t mx0=0.12, mx1=0.1, my0=0.15, my1=0.1;
-  //
-  TGraphErrors* laserA       =(TGraphErrors*)arr->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_A");
-  TGraphErrors* laserC       =(TGraphErrors*)arr->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_C");
-  TGraphErrors* cosmic       =(TGraphErrors*)arr->FindObject("TGRAPHERRORS_MEAN_VDRIFT_COSMICS_ALL");
-  TGraphErrors* cross        =(TGraphErrors*)arr->FindObject("TGRAPHERRORS_VDRIFT_CROSS_ALL");
-  TGraphErrors* itstpcP       =(TGraphErrors*)arr->FindObject("ALIGN_ITSP_TPC_DRIFTVD");
-  TGraphErrors* itstpcM       =(TGraphErrors*)arr->FindObject("ALIGN_ITSM_TPC_DRIFTVD");
-  TGraphErrors* itstpcB       =(TGraphErrors*)arr->FindObject("ALIGN_ITSB_TPC_DRIFTVD");
-  //
-  if (laserA)  SetDefaultGraphDrift(laserA,2,25);
-  if (laserC)  SetDefaultGraphDrift(laserC,4,26);
-  if (cosmic)  SetDefaultGraphDrift(cosmic,3,27);
-  if (cross)   SetDefaultGraphDrift(cross,4,28);
-  if (itstpcP) SetDefaultGraphDrift(itstpcP,2,29);
-  if (itstpcM) SetDefaultGraphDrift(itstpcM,4,30);
-  if (itstpcB) SetDefaultGraphDrift(itstpcB,1,31);
-  //
-  //
-  TPad *pad=0;
-  //
-  // Laser-Laser
-  //
-  if (laserA&&laserC){
-    pad = new TCanvas("TPCLaserVDrift","TPCLaserVDrift");
-    laserA->Draw("alp");
-    SetPadStyle(pad,mx0,mx1,my0,my1);
-    laserA->Draw("apl");
-    laserC->Draw("p");
-    TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
-    legend->AddEntry(laserA,"Laser A side");
-    legend->AddEntry(laserC,"Laser C side");
-    legend->Draw();    
-    picArray->AddLast(pad);
-  }
-
-  if (itstpcP&&itstpcM){
-    pad = new TCanvas("ITSTPC","ITSTPC");
-    itstpcP->Draw("alp");
-    SetPadStyle(pad,mx0,mx1,my0,my1);    
-    itstpcP->Draw("alp");
-    gPad->Clear();
-    itstpcM->Draw("apl");
-    itstpcP->Draw("p");
-    itstpcB->Draw("p");
-    TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
-    legend->AddEntry(itstpcP,"ITS-TPC smooth plus");
-    legend->AddEntry(itstpcM,"ITS-TPC smooth minus");
-    legend->AddEntry(itstpcB,"ITS-TPC smooth ");
-    legend->Draw();    
-    picArray->AddLast(pad);
-  }
-
-  if (itstpcB&&laserA){
-    pad = new TCanvas("ITSTPC_LASER","ITSTPC_LASER");
-    SetPadStyle(pad,mx0,mx1,my0,my1);    
-    laserA->Draw("alp");
-    itstpcP->Draw("p");
-    itstpcM->Draw("p");
-    itstpcB->Draw("p");
-    TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
-    legend->AddEntry(laserA,"TPC laser");
-    legend->AddEntry(itstpcP,"ITS-TPC smooth plus");   
-    legend->AddEntry(itstpcM,"ITS-TPC smooth minus");   
-    legend->AddEntry(itstpcB,"ITS-TPC smooth ");
-    legend->Draw();
-    picArray->AddLast(pad);
-  }
-
-  if (itstpcP&&cross){ 
-    pad = new TCanvas("ITSTPC_CROSS","ITSTPC_CROSS");
-    SetPadStyle(pad,mx0,mx1,my0,my1);    
-    itstpcP->Draw("alp");
-    pad->Clear();
-    cross->Draw("ap");
-    itstpcP->Draw("p");
-    //
-    TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
-
-    legend->AddEntry(cross,"TPC cross tracks");
-    legend->AddEntry(itstpcB,"ITS-TPC smooth");
-    legend->Draw();        
-    picArray->AddLast(pad);
-  }
-  if (itstpcP&&cosmic){ 
-    pad = new TCanvas("ITSTPC_COSMIC","ITSTPC_COSMIC");
-    SetPadStyle(pad,mx0,mx1,my0,my1);    
-    itstpcP->Draw("alp");
-    pad->Clear();
-    cosmic->Draw("ap");
-    itstpcP->Draw("p");
-    //
-    TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
-
-    legend->AddEntry(cosmic,"TPC cross tracks0 up-down");
-    legend->AddEntry(itstpcB,"ITS-TPC smooth");
-    legend->Draw();        
-    picArray->AddLast(pad);
-  }
-}
-
-
-
diff --git a/TPC/CalibMacros/MakeOCDB.C b/TPC/CalibMacros/MakeOCDB.C
deleted file mode 100644 (file)
index a8a8246..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-void MakeOCDB(Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity(),TString inputFile="CalibObjectsTrain1.root"){
-  //
-  //
-  //
-  gSystem->Load("libSTEER");
-  gSystem->Load("libANALYSIS");
-  gSystem->Load("libSTAT");
-  gSystem->Load("libTPCcalib");
-  gSystem->AddIncludePath("-I$ALICE_ROOT/STEER");
-  gSystem->AddIncludePath("-I$ALICE_ROOT/TPC");
-
-  gROOT->LoadMacro("$ALICE_ROOT/TPC/CalibMacros/CalibTimeVdrift.C+");
-  gROOT->LoadMacro("$ALICE_ROOT/TPC/CalibMacros/CalibTimeGain.C+");
-  ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
-  //
-  // Make gain calibration
-  //
-  TFile fcalib(inputFile.Data());
-  AliTPCcalibTimeGain * gain = ( AliTPCcalibTimeGain *)fcalib.Get("calibTimeGain");    
-  if (gain==0) return;
-  CalibTimeGain(gain, ocdbStorage.Data(),startRun,endRun,kTRUE);
-  //
-  // Make vdrift calibration
-  //
-  CalibTimeVdriftGlobal(inputFile.Data(),startRun,AliCDBRunRange::Infinity());
-  //
-  // Make calibration plot
-  //
-  Int_t run=endRun;
-  ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
-  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/TimeDrift",ocdbStorage.Data());  
-  AliCDBEntry* entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeDrift",run);
-  TObjArray * arr = (TObjArray*)entry->GetObject();
-  TObjArray *picArray = new TObjArray;
-  MakeDefaultPlots(arr,picArray);
-  TFile fdrift("vdrift.root","recreate");
-  picArray->Write("drift Plot");
-  fdrift.Close();  
-}