ROOT logo
/*
  marian.ivanov@cern.ch, Stefan.Rossegger@cern.ch

  Macro to fit  alignment/E field distortion maps
  As a input output cluster distortion maps (produced by  AliTPCcalibAling class)
  are used. Cluster distrotion maps granularity (180 *phi x44 *theta x 53 R)

  In total 440 parameters to fit using global fit:

  1. Rotation and translation for each sector (72x2)
  2. Rotation and translation for each quadrant of OROC (36x4x2)
  3. Rod/strip shifts in IFC and OFC (18 sectors x 2 sides x 2 ) 
  4. Rotated clips in IFC and OFC 


  Input file mean.root with distortion tree expected to be in directory:
  ../mergeField0/clusterDY.root
  The ouput file fitRodShift.root contains:
  1. Resulting (residual) AliTPCCalibMisalignment  and AliTPCFCVoltError3D classes
  2. All important temporary results are stored in the workspace (TTreeSRedirector)  associated
     with the file - fitrodShift
     2.a  Fit parameters with errors
     2.b  QA default graphs
     2.c  QA defualt histograms



  Functions:
  1. LoadModels()                   - load models to fit - Rod shift (10,20)
  2. RegisterAlignFunction()        - register align functions (10-16)
  3. LoadTrees                      - load trees and make aliases
  4. PrintFit                       - helper function to print substring of the fit 
  5. DeltaLookup                    - function to calulate the distortion for given distortion cunction
                                    -
  6. MakeAliases                    - Make tree aliases shortcuts for the fitting function
  //
  7. MakeAlignCorrection            - Crete alignment entry to be stored in the OCDB
                                    - Dump fit parameters and errors
  8. MakeQuadrantCorrection         - 
                                    - Dump fit parameters and errors

  9. FitRodShifts                   - main minimization function


  .x ~/rootlogon.C
  .x ~/NimStyle.C
  .L $ALICE_ROOT/TPC/CalibMacros/FitRodShift.C+
  FitRodShift(kFALSE);
  //

*/

#if !defined(__CINT__) || defined(__MAKECINT__)
#include "TFile.h"
#include "TTreeStream.h"
#include "TMath.h" 
#include "TGraph.h" 
#include "TRandom.h"
#include "TTree.h"
#include "TF1.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TAxis.h"
#include "TPad.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "AliTPCParamSR.h"
#include "TDatabasePDG.h"
#include "AliTPCFCVoltError3D.h"
#include "AliTPCROCVoltError3D.h"
#include "AliTPCComposedCorrection.h"
#include "AliTPCBoundaryVoltError.h"
#include "AliCDBEntry.h"
#include "AliTPCROC.h"
#include <TStatToolkit.h>
#include "TCut.h"
#include "TGraphErrors.h"
#include "AliTPCCalibGlobalMisalignment.h"
#endif

TTreeSRedirector *pcWorkspace= 0;    // Workspace to store the fit parameters and QA histograms
TTree * treeDY= 0;                       //distortion tree - Dy
TTree * treeDZ= 0;                       //distortion tree - Dz
// fit models ...
AliTPCFCVoltError3D *rotOFC  =0;          // fit models
AliTPCFCVoltError3D *rodOFC1 =0;
AliTPCFCVoltError3D *rodOFC2 =0;
AliTPCFCVoltError3D *rotIFC  =0;
AliTPCFCVoltError3D *rodIFC1 =0;
AliTPCFCVoltError3D *rodIFC2 =0;
AliTPCFCVoltError3D *rodAll  =0;        //all lookup initialized
//
AliTPCComposedCorrection *corFit0 = 0;  // composed correction
void FitFunctionQA();
void MakeQA();
void DrawAlignParam();

void PrintFit(TString fitString, TString filter){
  //
  // helper function to print substring of the fit
  // TString fitString =*strFitGA;
  // TString filter="rot";
  //
  TObjArray *arr = fitString.Tokenize("++");
  Int_t entries=arr->GetEntries();
  for (Int_t i=0; i<entries; i++){
    TString aaa = arr->At(i)->GetName();
    if (aaa.Contains(filter)==1){
      printf("%d\t%s\n",i,aaa.Data());
    }    
  }
}


void LoadModels(){
  //
  // Load the models from the file
  // Or create it
  //
  Int_t volt = 1;
  TFile f("OCDB-RodShifts.root");
  AliCDBEntry *entry = (AliCDBEntry*) f.Get("AliCDBEntry");
  if (entry) { // load file    
    AliTPCComposedCorrection *cor = (AliTPCComposedCorrection*) entry->GetObject();    
    cor->Print();
    TCollection *iter = cor->GetCorrections();    
    rotOFC = (AliTPCFCVoltError3D*)iter->FindObject("rotOFC");
    rodOFC1 = (AliTPCFCVoltError3D*)iter->FindObject("rodOFC1");
    rodOFC2 = (AliTPCFCVoltError3D*)iter->FindObject("rodOFC2");
    rotIFC = (AliTPCFCVoltError3D*)iter->FindObject("rotIFC");
    rodIFC1 = (AliTPCFCVoltError3D*)iter->FindObject("rodIFC1");
    rodIFC2 = (AliTPCFCVoltError3D*)iter->FindObject("rodIFC2");
    rodAll = (AliTPCFCVoltError3D*)iter->FindObject("rodAll");
    // rotOFC->CreateHistoDZinXY(1,500,500)->Draw("surf2");
  } else {    
    // OFC 
    rotOFC = new AliTPCFCVoltError3D();
    rotOFC->SetOmegaTauT1T2(0,1,1);
    rotOFC->SetRotatedClipVoltA(1,volt);
    rotOFC->SetRotatedClipVoltC(1,volt);
    //
    rodOFC1 = new AliTPCFCVoltError3D();
    rodOFC1->SetOmegaTauT1T2(0,1,1);
    rodOFC1->SetRodVoltShiftA(18,volt);
    rodOFC1->SetRodVoltShiftC(18,volt);
    //
    rodOFC2 = new AliTPCFCVoltError3D();
    rodOFC2->SetOmegaTauT1T2(0,1,1);
    rodOFC2->SetCopperRodShiftA(18,volt);
    rodOFC2->SetCopperRodShiftC(18,volt);    
    // IFC     
    rotIFC = new AliTPCFCVoltError3D();
    rotIFC->SetOmegaTauT1T2(0,1,1);
    rotIFC->SetRotatedClipVoltA(0,volt);
    rotIFC->SetRotatedClipVoltC(0,volt);
    //
    rodIFC1 = new AliTPCFCVoltError3D();
    rodIFC1->SetOmegaTauT1T2(0,1,1);
    rodIFC1->SetRodVoltShiftA(0,volt);
    rodIFC1->SetRodVoltShiftC(0,volt);
    //
    rodIFC2 = new AliTPCFCVoltError3D();
    rodIFC2->SetOmegaTauT1T2(0,1,1);
    rodIFC2->SetCopperRodShiftA(0,volt);
    rodIFC2->SetCopperRodShiftC(0,volt);
    // dummy object with all inits
    rodAll = new AliTPCFCVoltError3D();
    Double_t volt0=0.0000000001;
    rodAll->SetRotatedClipVoltA(1,volt0);
    rodAll->SetRotatedClipVoltC(1,volt0);
    rodAll->SetRodVoltShiftA(18,volt0);
    rodAll->SetRodVoltShiftC(18,volt0);
    rodAll->SetCopperRodShiftA(18,volt0);
    rodAll->SetCopperRodShiftC(18,volt0);    
    rodAll->SetRotatedClipVoltA(0,volt0);
    rodAll->SetRotatedClipVoltC(0,volt0);
    rodAll->SetRodVoltShiftA(0,volt0);
    rodAll->SetRodVoltShiftC(0,volt0);
    rodAll->SetCopperRodShiftA(0,volt0);
    rodAll->SetCopperRodShiftC(0,volt0);
    rodAll->SetOmegaTauT1T2(0,1,1);
    //
    //
    // Initialization of the lookup tables
    //
    printf(" ------- OFC rotated clip:\n"); rotOFC->InitFCVoltError3D();
    printf(" ------- OFC rod & strip:\n");  rodOFC1->InitFCVoltError3D();
    printf(" ------- OFC copper rod:\n");   rodOFC2->InitFCVoltError3D();
    printf(" ------- IFC rotated clip:\n"); rotIFC->InitFCVoltError3D();
    printf(" ------- IFC rod & strip:\n");  rodIFC1->InitFCVoltError3D();
    printf(" ------- IFC copper rod:\n");   rodIFC2->InitFCVoltError3D();
    printf(" ------- Dummy all:\n");        rodAll->InitFCVoltError3D();
    // give names
    rotOFC->SetName("rotOFC");rotOFC->SetTitle("rotOFC");
    rodOFC1->SetName("rodOFC1");rodOFC1->SetTitle("rodOFC1");
    rodOFC2->SetName("rodOFC2");rodOFC2->SetTitle("rodOFC2");
    rotIFC->SetName("rotIFC");rotIFC->SetTitle("rotIFC");
    rodIFC1->SetName("rodIFC1");rodIFC1->SetTitle("rodIFC1");
    rodIFC2->SetName("rodIFC2");rodIFC2->SetTitle("rodIFC2");
    rodAll->SetName("rodAll");rodAll->SetTitle("rodAll");
    //
    // save in file
    AliTPCComposedCorrection *corFit0 = new AliTPCComposedCorrection();
    TObjArray *cs = new TObjArray();
    cs->Add(rotIFC); cs->Add(rotOFC);
    cs->Add(rodIFC1); cs->Add(rodOFC1);
    cs->Add(rodIFC2); cs->Add(rodOFC2);
    cs->Add(rodAll);
    corFit0->SetCorrections(cs);
    corFit0->SetOmegaTauT1T2(0,1.,1.);
    corFit0->Print();    
    corFit0->StoreInOCDB(0,1000000,"testForFit");    
  }
  //
  AliTPCCorrection::AddVisualCorrection(rotOFC,0); 
  AliTPCCorrection::AddVisualCorrection(rodOFC1,1); 
  AliTPCCorrection::AddVisualCorrection(rodOFC2,2); 
  AliTPCCorrection::AddVisualCorrection(rotIFC,3); 
  AliTPCCorrection::AddVisualCorrection(rodIFC1,4); 
  AliTPCCorrection::AddVisualCorrection(rodIFC2,5); 
  AliTPCCorrection::AddVisualCorrection(rodAll,6); 
}


void RegisterAlignFunction(){
  //
  // Register primitive alignment components.
  // Linear conbination of primitev forulas used for fit
  // The nominal delta 1 mm in shift and 1 mrad in rotation
  // Primitive formulas registeren in AliTPCCoreection::AddvisualCorrection
  // 10 - deltaX 
  // 11 - deltaY
  // 12 - deltaZ
  // 13 - rot0 (phi)
  // 14 - rot1 (theta)
  // 15 - rot2 
  //
  TGeoHMatrix matrixX;
  TGeoHMatrix matrixY;
  TGeoHMatrix matrixZ;
  TGeoRotation rot0;
  TGeoRotation rot1;
  TGeoRotation rot2;  //transformation matrices
  TGeoRotation rot90;  //transformation matrices
  matrixX.SetDx(0.1); matrixY.SetDy(0.1); matrixZ.SetDz(0.1); //1 mm translation
  rot0.SetAngles(0.001*TMath::RadToDeg(),0,0);
  rot1.SetAngles(0,0.001*TMath::RadToDeg(),0);
  rot2.SetAngles(0,0,0.001*TMath::RadToDeg());
  //how to get rot02 ?
  rot90.SetAngles(0,90,0);
  rot2.MultiplyBy(&rot90,kTRUE);
  rot90.SetAngles(0,-90,0);
  rot2.MultiplyBy(&rot90,kFALSE);
  AliTPCCalibGlobalMisalignment *alignRot0  =new  AliTPCCalibGlobalMisalignment;
  alignRot0->SetAlignGlobal(&rot0);
  AliTPCCalibGlobalMisalignment *alignRot1=new  AliTPCCalibGlobalMisalignment;
  alignRot1->SetAlignGlobal(&rot1);
  AliTPCCalibGlobalMisalignment *alignRot2=new  AliTPCCalibGlobalMisalignment;
  alignRot2->SetAlignGlobal(&rot2);
  //
  AliTPCCalibGlobalMisalignment *alignTrans0  =new  AliTPCCalibGlobalMisalignment;
  alignTrans0->SetAlignGlobal(&matrixX);
  AliTPCCalibGlobalMisalignment *alignTrans1=new  AliTPCCalibGlobalMisalignment;
  alignTrans1->SetAlignGlobal(&matrixY);
  AliTPCCalibGlobalMisalignment *alignTrans2=new  AliTPCCalibGlobalMisalignment;
  alignTrans2->SetAlignGlobal(&matrixZ);
  AliTPCCorrection::AddVisualCorrection(alignTrans0  ,10);
  AliTPCCorrection::AddVisualCorrection(alignTrans1  ,11);
  AliTPCCorrection::AddVisualCorrection(alignTrans2  ,12);
  AliTPCCorrection::AddVisualCorrection(alignRot0    ,13);
  AliTPCCorrection::AddVisualCorrection(alignRot1    ,14);
  AliTPCCorrection::AddVisualCorrection(alignRot2    ,15);
  TObjArray arrAlign(6);
  arrAlign.AddAt(alignTrans0->Clone(),0);
  arrAlign.AddAt(alignTrans1->Clone(),1);
  arrAlign.AddAt(alignTrans2->Clone(),2);
  arrAlign.AddAt(alignRot0->Clone(),3);
  arrAlign.AddAt(alignRot1->Clone(),4);
  arrAlign.AddAt(alignRot2->Clone(),5);
  //combAlign.SetCorrections((TObjArray*)arrAlign.Clone());
}


void LoadTrees(){
  //
  // 1. Load trees
  // 2. Make standard cuts - filter the tree
  // 3. makeStandard aliases
  //
  TFile *fy = new TFile("clusterDY.root");
  TFile *fz = new TFile("clusterDZ.root");
  treeDY= (TTree*)fy->Get("delta");
  treeDZ= (TTree*)fz->Get("delta");
  TCut cutAll = "entries>3000&&abs(kZ)<1&&localX>80&&localX<246&&abs(sector-int(sector)-0.5)<0.41&&abs(localX-134)>2&&rmsG<0.5&&abs(localX-189)>3";

  treeDY->Draw(">>outListY",cutAll,"entryList");
  TEntryList *elistOutY = (TEntryList*)gDirectory->Get("outListY");
  treeDY->SetEntryList(elistOutY);
  treeDZ->Draw(">>outListZ",cutAll,"entryList");
  TEntryList *elistOutZ = (TEntryList*)gDirectory->Get("outListZ");
  treeDZ->SetEntryList(elistOutZ);
  //
  // Make aliases
  //
  treeDY->SetAlias("dsec","(sector-int(sector)-0.5)");
  treeDY->SetAlias("dsec0","(sector-int(sector))");
  treeDY->SetAlias("signy","(-1.+2*(sector-int(sector)>0.5))");
  treeDY->SetAlias("dx","(localX-165.5)");   // distance X to ref. plane
  treeDY->SetAlias("dxm","0.001*(localX-165.5)");
  treeDY->SetAlias("rx","(localX/166.5)");   //ratio distrnace to reference plane
  treeDY->SetAlias("dq1","(((q1==0)*(-rx)+q1*(1-rx))*signy)");
  //
  {for (Int_t isec=0; isec<18; isec++){ // sectors
      treeDY->SetAlias(Form("sec%d",isec), Form("(abs(sector-%3.1lf)<0.5)",isec+0.5));
      treeDZ->SetAlias(Form("sec%d",isec), Form("(abs(sector-%3.1lf)<0.5)",isec+0.5));
    }}
  treeDY->SetAlias("gy","localX*sin(pi*sector/9)");
  treeDY->SetAlias("gx","localX*cos(pi*sector/9)");
  treeDY->SetAlias("side","(-1.+2.*(kZ>0))");  
  treeDY->SetAlias("drphi","mean");
  treeDY->SetMarkerStyle(25);
}

Double_t DeltaLookup(Double_t sector, Double_t localX, Double_t kZ, Double_t xref, Int_t value, Int_t corr){
  //
  // Distortion maps are calculated relative to the reference X plane
  // The same procedure applied for given correction
  // fd(sector, localX, kZ) ==>  fd(sector, localX, kZ)-fd(sector, xref, kZ)*localX/xref
  //
  Double_t distortion    = AliTPCCorrection::GetCorrSector(sector,localX,kZ,value,corr);
  Double_t distortionRef = AliTPCCorrection::GetCorrSector(sector,xref,kZ,value,corr)*localX/xref;
  return distortion-distortionRef;
}

void MakeAliases(){
  //
  // make alias names
  //
  AliTPCROC * roc = AliTPCROC::Instance();
  Double_t xref  = ( roc->GetPadRowRadii(0,0)+roc->GetPadRowRadii(36,roc->GetNRows(36)-1))*0.5;
  treeDY->SetAlias("iroc","(localX<134)");  // IROC
  treeDY->SetAlias("oroc","(localX>134)");  // OROC
  treeDY->SetAlias("q1","abs(localX-161)<28"); // OROC first haf
  treeDY->SetAlias("q2","(localX>189)");       // OROC second half
  //
  treeDY->SetAlias("dIFC","abs(localX-83)");    // distance to IFC
  treeDY->SetAlias("dOFC","abs(localX-250)");   // distance to OFC
  treeDY->SetAlias("errY","(1.+1/(1+(dIFC/2.))+1/(1+dOFC/2.))");

  //
  // rotated clip - IFC --------------------
  treeDY->SetAlias("rotClipI","DeltaLookup(sector,localX,kZ,165.6,1,3+0)");
  // rotated clip - OFC --------------------
  treeDY->SetAlias("rotClipO","DeltaLookup(sector,localX,kZ,165.6,1,0+0)");
  for (Int_t isec=0;isec<18; isec++){    
    //
    // alignment IROC - shift cm - rotation mrad
    treeDY->SetAlias(Form("dyI_%d",isec),Form("(iroc*sec%d)",isec));
    treeDY->SetAlias(Form("drotI_%d",isec),Form("(iroc*sec%d*(localX-%3.1lf)/1000.)",isec,xref));
    // alignment OROC
    treeDY->SetAlias(Form("dyO_%d",isec),Form("(sec%d*oroc-sec%d*localX/165.6)",isec,isec)); // fix local Y shift - do not use it
    treeDY->SetAlias(Form("drotO_%d",isec),Form("(sec%d*oroc*(localX-%3.1lf)/1000.)",isec,xref));
    //
    // quadrant shift OROC 
    treeDY->SetAlias(Form("dqO0_%d",isec),Form("(sec%d*sign(dsec)*(q1-localX/165.6))",isec));
    // quadrant delta rotation OFC inner
    treeDY->SetAlias(Form("dqOR0_%d",isec),Form("(sec%d*sign(dsec)*q1*(localX-165.6)/1000.)",isec));
    //
    treeDY->SetAlias(Form("dqO1_%d",isec),Form("(q2*sec%d*sign(dsec))",isec));  // delta
    treeDY->SetAlias(Form("dqOR1_%d",isec),Form("(q2*sec%d*sign(dsec)*(localX-165.6)/1000.)",isec));
    treeDY->SetAlias(Form("dqO2_%d",isec),Form("(q2*sec%d)",isec)); //common
    treeDY->SetAlias(Form("dqOR2_%d",isec),Form("(q2*sec%d*(localX-165.6)/1000.)",isec));
    //
    //
    // shifted rod -  OFC
    treeDY->SetAlias(Form("rodStripO_%d",isec),Form("DeltaLookup(sector-%d,localX,kZ,165.6,1,1+0)",isec));
    // Shifted cooper rod OFC 
    treeDY->SetAlias(Form("coppRodO_%d",isec),Form("DeltaLookup(sector-%d,localX,kZ,165.6,1,2+0)",isec)); 
    // shifted rod - IFC 
    treeDY->SetAlias(Form("rodStripI_%d",isec),Form("DeltaLookup(sector-%d,localX,kZ,165.6,1,4+0)",isec)); 
    // Shifted cooper rod IFC 
    treeDY->SetAlias(Form("coppRodI_%d",isec),Form("DeltaLookup(sector-%d,localX,kZ,165.6,1,5+0)",isec)); 
  }
  //
  // fitted correction - Using the saved coposed corrections
  //
  treeDY->SetAlias("dAlign","DeltaLookup(sector,localX,kZ,165.6,1,1000+0)");
  treeDY->SetAlias("dQuadrant","DeltaLookup(sector,localX,kZ,165.6,1,1100+0)");
  treeDY->SetAlias("dField","DeltaLookup(sector,localX,kZ,165.6,1,100+0)");
  treeDY->SetAlias("dAll","(dAlign+dQuadrant+dField)");
}

AliTPCCalibGlobalMisalignment *MakeAlignCorrection(TVectorD paramA, TVectorD paramC,  TMatrixD covar, Double_t chi2){
  //
  // Make a global alignmnet 
  // Take a fit parameters and make a combined correction:
  // Only delta local Y and delta phi are fitted - not sensitivity for other parameters
  // GX and GY shift extracted per side.
  //
  // Algorithm:
  //   1. Loop over sectors
  //   2. Make combined AliTPCCalibGlobalMisalignment
  //  
  AliTPCCalibGlobalMisalignment *alignLocal  =new  AliTPCCalibGlobalMisalignment;  
  Int_t offset=3;
  AliTPCROC * roc = AliTPCROC::Instance();
  Double_t xref  = ( roc->GetPadRowRadii(0,0)+roc->GetPadRowRadii(36,roc->GetNRows(36)-1))*0.5;
  // 
  pcWorkspace->GetFile()->cd();
  TObjArray * array = new TObjArray(72);
  
  for (Int_t side=-1; side<2; side+=2){
    TVectorD &param = (side==1) ? paramA : paramC;
    TGeoHMatrix matrixGX;
    TGeoHMatrix matrixGY;
    matrixGX.SetDx(0.1*param[1]); 
    matrixGY.SetDy(0.1*param[2]); 
    //  
    for (Int_t isec=0; isec<18; isec++){ 
      TGeoHMatrix matrixOROC;
      TGeoHMatrix matrixIROC; 
      TGeoRotation rotIROC;
      TGeoRotation rotOROC;
      Double_t phi= (Double_t(isec)+0.5)*TMath::Pi()/9.;
      //
      Double_t drotIROC = -param[offset+isec+18]*0.001;
      Double_t drotOROC = -param[offset+isec+36]*0.001;
      Double_t dlyIROC  = param[offset+isec];
      Double_t dlyIROC0 = param[offset+isec]+drotIROC*xref;     // shift at x=0
      Double_t dlyOROC  = 0;
      Double_t dlyOROC0 = 0+drotOROC*xref;  // shift at x=0
      //
      Double_t dgxIROC = TMath::Cos(phi)*0+TMath::Sin(phi)*dlyIROC0;
      Double_t dgyIROC = TMath::Sin(phi)*0-TMath::Cos(phi)*dlyIROC0;
      Double_t dgxOROC = TMath::Cos(phi)*0+TMath::Sin(phi)*dlyOROC0;
      Double_t dgyOROC = TMath::Sin(phi)*0-TMath::Cos(phi)*dlyOROC0;    
      Double_t errYIROC=TMath::Sqrt(covar(offset+isec, offset+isec)*chi2);
      Double_t errPhiIROC=TMath::Sqrt(covar(offset+isec+18, offset+isec+18)*chi2);
      Double_t errPhiOROC=TMath::Sqrt(covar(offset+isec+36, offset+isec+36)*chi2);
      matrixIROC.SetDx(dgxIROC);
      matrixIROC.SetDy(dgyIROC);
      matrixOROC.SetDx(dgxOROC);
      matrixOROC.SetDy(dgyOROC);
      rotIROC.SetAngles(drotIROC*TMath::RadToDeg(),0,0);
      matrixIROC.Multiply(&matrixGX);
      matrixIROC.Multiply(&matrixGY);
      matrixIROC.Multiply(&rotIROC);
      rotOROC.SetAngles(drotOROC*TMath::RadToDeg(),0,0);
      matrixOROC.Multiply(&matrixGX);
      matrixOROC.Multiply(&matrixGY);
      matrixOROC.Multiply(&rotOROC);
      if (side>0){
	array->AddAt(matrixIROC.Clone(),isec);
	array->AddAt(matrixOROC.Clone(),isec+36);
      }
      if (side<0){
	array->AddAt(matrixIROC.Clone(),isec+18);
	array->AddAt(matrixOROC.Clone(),isec+36+18);
      }
      Double_t rms=TMath::Sqrt(chi2); //chi2 normalized 1/npoints before
      (*pcWorkspace)<<"align"<<
	"isec="<<isec<<           // sector
	"side="<<side<<           // side
	"phi="<<phi<<             // phi
	"rms="<<rms<<             // rms in cm
	"cov.="<<&covar<<
	// errors
	"errYIROC="<<errYIROC<<      //error in local y
	"errPhiIROC="<<errPhiIROC<<  //error in phi IROC
	"errPhiOROC="<<errPhiOROC<<  //error in phi OROC
	//
	"dlyIROC="<<dlyIROC<<        //delta Local Y at refX=165 -IROC
	"dlyIROC0="<<dlyIROC0<<      //delta Local Y at refX=0   -IROC
	"dgxIROC="<<dgxIROC<<        //
	"dgyIROC="<<dgyIROC<<
	"drotIROC="<<drotIROC<<
	//
	"dlyOROC="<<dlyOROC<<       // assuming 0 at 
	"dlyOROC0="<<dlyOROC0<<
	"dgxOROC="<<dgxOROC<<
	"dgyOROC="<<dgyOROC<<
	"drotOROC="<<drotOROC<<
	"\n";
    } 
  }
  alignLocal->SetAlignSectors(array);
  AliTPCCorrection::AddVisualCorrection(alignLocal,1000);
  /*
    Check:
    alignLocal->CreateHistoDRPhiinXY(10,100,100)->Draw("colz");  // OK
    treeDY->Draw("DeltaLookup(sector,localX,kZ,165.6,1,1001):localX:int(sector)","kZ>0","colz");
    //
    (( (*pcWorkspace)<<"align"))->GetTree()->Draw("dlyOROC-dlyOROC:isec","","*")
    treeDY->Draw("tfitA:DeltaLookup(sector,localX,kZ,165.6,1,1001):sector","kZ>0","colz");

  */
  return alignLocal;
}

AliTPCCalibGlobalMisalignment *MakeQuadrantCorrection(TVectorD paramA, TVectorD paramC, TMatrixD covar, Double_t chi2){
  //
  // Make a global alignmnet 
  // side= 1 - A side
  // side=-1 - C side
  // Take a fit parameters and make a combined correction:
  // Only delta local Y and delta phi are fitted - not sensitivity for other parameters
  // GX and GY shift extracted per side.
  //
  // Algorithm:
  //   1. Loop over sectors
  //   2. Make combined AliTPCCalibGlobalMisalignment
  //  
  AliTPCCalibGlobalMisalignment *alignLocalQuadrant  =new  AliTPCCalibGlobalMisalignment;  
  //
  Int_t offset=3+3*18;
  TVectorD quadrantQ0(36);   //dly+=sign*(*fQuadrantQ0)[isec];  // shift in cm
  TVectorD quadrantRQ0(36);  //dly+=sign*(*fQuadrantRQ0)[isec]*(pos[0]-xref);      
  TVectorD quadrantQ1(36);   //dly+=sign*(*fQuadrantQ1)[isec];  // shift in cm
  TVectorD quadrantRQ1(36);  //dly+=sign*(*fQuadrantRQ1)[isec]*(pos[0]-xref);      
  TVectorD quadrantQ2(36);   //dly+=(*fQuadrantQ2)[isec];  // shift in cm
  TVectorD quadrantRQ2(36);  //dly+=(*fQuadrantRQ2)[isec]*(pos[0]-xref);      

  for (Int_t side=-1; side<2; side+=2){
    Int_t offsetSec= (side==1) ? 0:18;
    TVectorD &param = (side==1) ? paramA : paramC;
    for (Int_t isec=0; isec<18; isec++){ 
      Double_t  q0=-param[offset+isec+0*18];
      Double_t rq0=-param[offset+isec+1*18]*0.001;
      Double_t  q1=-param[offset+isec+2*18];
      Double_t rq1=-param[offset+isec+3*18]*0.001;
      Double_t  q2=-param[offset+isec+4*18];
      Double_t rq2=-param[offset+isec+5*18]*0.001;
      //
      Double_t  sq0=TMath::Sqrt(covar(offset+isec+0*18,offset+isec+0*18)*chi2);
      Double_t srq0=TMath::Sqrt(covar(offset+isec+1*18,offset+isec+1*18)*chi2)*0.001;
      Double_t  sq1=TMath::Sqrt(covar(offset+isec+2*18,offset+isec+2*18)*chi2);
      Double_t srq1=TMath::Sqrt(covar(offset+isec+3*18,offset+isec+3*18)*chi2)*0.001;
      Double_t  sq2=TMath::Sqrt(covar(offset+isec+4*18,offset+isec+4*18)*chi2);
      Double_t srq2=TMath::Sqrt(covar(offset+isec+5*18,offset+isec+5*18)*chi2)*0.001;
      //
      quadrantQ0[offsetSec+isec]=q0;
      quadrantRQ0[offsetSec+isec]=rq0;
      quadrantQ1[offsetSec+isec]=q1;
      quadrantRQ1[offsetSec+isec]=rq1;
      quadrantQ2[offsetSec+isec]=q2;
      quadrantRQ2[offsetSec+isec]=rq2;
      Double_t rms=TMath::Sqrt(chi2); //chi2 normalized 1/npoints before
      (*pcWorkspace)<<"quadrant"<<
	"isec="<<isec<<           // sector
	"side="<<side<<           // side
	"rms="<<rms<<             // rms in cm
	"cov.="<<&covar<<
	//
	"q0="<<q0<<               // quadrant alignment
	"rq0="<<rq0<<
	"q1="<<q1<<
	"rq1="<<rq1<<
	"q2="<<q2<<
	"rq2="<<rq2<<
	"sq0="<<sq0<<             //rms of quadrant parameters 
	"srq0="<<srq0<<
	"sq1="<<sq1<<
	"srq1="<<srq1<<
	"sq2="<<sq2<<
	"srq2="<<srq2<<
	"\n";    
    }
  }
  alignLocalQuadrant->SetQuadranAlign(&quadrantQ0, &quadrantRQ0, &quadrantQ1, &quadrantRQ1, &quadrantQ2, &quadrantRQ2);
  AliTPCCorrection::AddVisualCorrection(alignLocalQuadrant,1100);  
  /*
    (( (*pcWorkspace)<<"quadrant"))->GetTree()->Draw("q0:isec","","*")

    alignLocalQuadrant->CreateHistoDRPhiinXY(10,100,100)->Draw("colz");  //OK
    
    treeDY->Draw("tfitA-DeltaLookup(sector,localX,kZ,165.6,1,1000):DeltaLookup(sector,localX,kZ,165.6,1,1100):int(sector)","kZ>0&&oroc","colz");
  */
  return alignLocalQuadrant;
}

AliTPCFCVoltError3D* MakeEfieldCorrection(TVectorD paramA, TVectorD paramC, TMatrixD covar, Double_t chi2){
  //
  // Make a global  AliTPCFCVoltError3D object
  //
  // Take a fit parameters and make a combined correction:
  // Only delta local Y and delta phi are fitted - not sensitivity for other parameters
  // GX and GY shift extracted per side.
  //
  // Algorithm:
  //   1. Loop over sectors
  //   2. Make combined AliTPCCalibGlobalMisalignment
  //
  Int_t offset=3+9*18;
  //
  AliTPCFCVoltError3D* corrField = new AliTPCFCVoltError3D;
  //
  Double_t rotIROCA=paramA[offset+0];
  Double_t rotIROCC=paramC[offset+0];
  Double_t rotOROCA=paramA[offset+1];
  Double_t rotOROCC=paramC[offset+1];
  //
  corrField->SetRotatedClipVoltA(0,paramA[offset+0]);
  corrField->SetRotatedClipVoltC(0,paramC[offset+0]);
  corrField->SetRotatedClipVoltA(1,paramA[offset+1]);
  corrField->SetRotatedClipVoltC(1,paramC[offset+1]);
  {for (Int_t isec=0; isec<18; isec++){
      corrField->SetRodVoltShiftA(isec,paramA[offset+2+36+isec]);     // rod shift IFC
      corrField->SetRodVoltShiftA(18+isec,paramA[offset+2+isec]);     // rod shift OFC
      corrField->SetRodVoltShiftC(isec,paramC[offset+2+36+isec]);    // rod shift IFC
      corrField->SetRodVoltShiftC(18+isec,paramC[offset+2+isec]);    // rod shift OFC
      Double_t rodIROCA=paramA[offset+2+36+isec];
      Double_t rodIROCC=paramC[offset+2+36+isec];
      Double_t rodOROCA=paramA[offset+2+isec];
      Double_t rodOROCC=paramC[offset+2+isec];
      //
      Double_t srodIROCA=TMath::Sqrt(covar(offset+2+36+isec,offset+2+36+isec)*chi2);
      Double_t srodOROCA=TMath::Sqrt(covar(offset+2+isec,offset+2+isec)*chi2);
      Double_t phi= (Double_t(isec)+0.5)*TMath::Pi()/9.;
      Double_t rms=TMath::Sqrt(chi2); //chi2 normalized 1/npoints before
      (*pcWorkspace)<<"field"<<
	"isec="<<isec<<           // sector
	//"side="<<side<<           // side
	"phi="<<phi<<             // phi
	"rms="<<rms<<             // rms in cm
	"cov.="<<&covar<<
	//
	"rotIROCA="<<rotIROCA<<  
	"rotIROCC="<<rotIROCC<<
	"rotOROCA="<<rotOROCA<<
	"rotOROCC="<<rotOROCC<<
	//
	"rodIROCA="<<rodIROCA<<
	"rodIROCC="<<rodIROCC<<
	"rodOROCA="<<rodOROCA<<
	"rodOROCC="<<rodOROCC<<
	//
	"srodIROCA="<<srodIROCA<<
	"srodOROCA="<<srodOROCA<<
	"srodIROCC="<<srodIROCA<<
	"srodOROCC="<<srodOROCA<<
	"\n";
    }    
  }
  corrField->SetOmegaTauT1T2(0,1.,1.);
  corrField->InitFCVoltError3D();
  AliTPCCorrection::AddVisualCorrection(corrField,100);  
  return corrField;
}


void FitRodShift(Bool_t flagIFCcopper = kTRUE) {
  //
  // Main fit function
  // In total 440 parameters to fit using global fit:
  //   1. Rotation and translation for each sector (72x2)
  //   2. Rotation and translation for each quadrant of OROC (36x4x2)
  //   3. Rod/strip shifts in IFC and OFC (18 sectors x 2 sides x 2 ) 
  //   4. Rotated clips in IFC and OFC 
  //
  LoadTrees();
  LoadModels();
  RegisterAlignFunction();
  MakeAliases();

  pcWorkspace= new TTreeSRedirector("fitAlignLookup.root");
  TFormula::SetMaxima(10000);
  //
  // 1. fit Global
  //
  Double_t chi2G=0;   Int_t npointsG=0;  TVectorD paramG;  TMatrixD covarG;
  TString fstringGlobal="";  
  fstringGlobal+="DeltaLookup(sector,localX,kZ,165.6,1,10-0)++"; // deltaGX
  fstringGlobal+="DeltaLookup(sector,localX,kZ,165.6,1,11-0)++"; // deltaGY
  fstringGlobal+="DeltaLookup(sector,localX,kZ,165.6,1,10-0)*side++"; // deltaGX - sides
  fstringGlobal+="DeltaLookup(sector,localX,kZ,165.6,1,11-0)*side++"; // deltaGY -sides
  //
  TString *strFitGlobal = TStatToolkit::FitPlane(treeDY,"drphi", fstringGlobal.Data(),"1", chi2G,npointsG,paramG,covarG,-1,0, 10000000, kTRUE);
  treeDY->SetAlias("fitYGlobal",strFitGlobal->Data());
  strFitGlobal->Tokenize("++")->Print();
  printf("chi2=%f\n",TMath::Sqrt(chi2G/npointsG));
  // testplots - if necessary - e.g.
  // treeDY->Draw("AliTPCCorrection::GetCorrSector(sector,localX,kZ,1,2):sector:localX","Cut","colz")

  // FIT PREPARATION +++++++++++++++++++++++++++++++++
  // define the fit function

  TString  fstring="";         

  //
  // Alignment
  //
  {
    fstring+="DeltaLookup(sector,localX,kZ,165.6,1,10-0)++"; // deltaGX
    fstring+="DeltaLookup(sector,localX,kZ,165.6,1,11-0)++"; // deltaGY
    // alignment IROC
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dyI_%d++",i);  // alignment - linear shift (in cm)
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("drotI_%d++",i);  // alignment - rotation (in mrad)
    }
    // alignment OROC
    for (Int_t i=0;i<18;i++){ // shift of OROC is not allowed
      //fstring+=Form("dyO_%d++",i);  // alignment - linear shift (in cm)
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("drotO_%d++",i);  // alignment - rotation (in mrad)
    }
    //
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dqO0_%d++",i);  // alignment - quadrant shift OROC in
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dqOR0_%d++",i);  // alignment - quadrant rotation OROC in
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dqO1_%d++",i);  // alignment - quadrant shift OROC out
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dqOR1_%d++",i);  // alignment - quadrant rotation OROC out
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dqO2_%d++",i);  // alignment - quadrant shift OROC out
    }
    for (Int_t i=0;i<18;i++){
      fstring+=Form("dqOR2_%d++",i);  // alignment - quadrant rotation OROC out
    }
  }
  //
  // Field distortion
  //
  {
    // rotated clip - IFC --------------------
    treeDY->SetAlias("rotClipI","DeltaLookup(sector,localX,kZ,165.6,1,3+0)");
    fstring+="rotClipI++";
    // rotated clip - OFC --------------------
    treeDY->SetAlias("rotClipO","DeltaLookup(sector,localX,kZ,165.6,1,0+0)");
    fstring+="rotClipO++";
    
    // shifted rod -  OFC
    for (Int_t i=0;i<18;i++){
      fstring+=Form("rodStripO_%d++",i);
    }    
    // Shifted cooper rod OFC     
    for (Int_t i=0;i<18;i++){
      fstring+=Form("coppRodO_%d++",i);
    }    
    // shifted rod - IFC 
    for (Int_t i=0;i<18;i++){
      fstring+=Form("rodStripI_%d++",i);
    }    
    // Shifted cooper rod IFC 
    if (flagIFCcopper) for (Int_t i=0;i<18;i++){
	fstring+=Form("coppRodI_%d++",i);
    }  
  }
  //fstring+=fstringGlobal;
 
  // FIT ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  Double_t chi2A=0;   Int_t npointsA=0;  TVectorD paramA;  TMatrixD covarA;
  Double_t chi2C=0;   Int_t npointsC=0;  TVectorD paramC;  TMatrixD covarC;
  
  
  printf("Fitting A side\n");
  TCut cutAllA = "Cut&&kZ>0";
  TString *strFitGA = TStatToolkit::FitPlane(treeDY,"drphi:errY", fstring.Data(),"kZ>0", chi2A,npointsA,paramA,covarA,-1,0, 10000000, kTRUE);
  treeDY->SetAlias("tfitA",strFitGA->Data());
  // strFitGA->Tokenize("++")->Print();
  printf("chi2=%f\n",TMath::Sqrt(chi2A/npointsA));
  printf("Sigma Y:\t%f (mm)\n",10.*TMath::Sqrt(covarA(3,3)*chi2A/npointsA));
  printf("IROC Sigma Angle:\t%f (mrad)\n",TMath::Sqrt(covarA(3+18,3+18)*chi2A/npointsA));
  printf("OROC Sigma Angle:\t%f (mrad)\n",TMath::Sqrt(covarA(3+36,3+36)*chi2A/npointsA));

  printf("Fitting C side\n");
  TCut cutAllC = "Cut&&kZ<0";
  TString *strFitGC = TStatToolkit::FitPlane(treeDY,"drphi:errY", fstring.Data(),"kZ<0", chi2C,npointsC,paramC,covarC,-1,0, 10000000, kTRUE);
  treeDY->SetAlias("tfitC",strFitGC->Data());
  //  strFitGC->Tokenize("++")->Print();
  printf("chi2=%f\n",TMath::Sqrt(chi2C/npointsC));
  printf("Sigma Y:\t%f (mm)\n",10.*TMath::Sqrt(covarC(3,3)*chi2C/npointsC));
  printf("IROC Sigma Angle:\t%f (mrad)\n",TMath::Sqrt(covarC(3+18,3+18)*chi2C/npointsC));
  printf("OROC Sigma Angle:\t%f (mrad)\n",TMath::Sqrt(covarC(3+36,3+36)*chi2C/npointsC));

  //
  // make combined correction
  //
  TH2 *hdist =0;
  //
  AliTPCCalibGlobalMisalignment * alignLocal = MakeAlignCorrection(paramA, paramC, covarA, chi2A/npointsA);
  alignLocal->SetName("alignLocal");
  alignLocal->Write("alignLocal");
  hdist = alignLocal->CreateHistoDRPhiinXY(10,250,250);
  hdist->SetName("AlignLocalAside"); hdist->SetTitle("Alignment map (A side)");
  hdist->Write("AlignLocalAside");
  hdist = alignLocal->CreateHistoDRPhiinXY(-10,250,250);
  hdist->SetName("AlignLocalCside"); hdist->SetTitle("Alignment map (C side)");
  hdist->Write("AlignLocalCside");
  //
  AliTPCCalibGlobalMisalignment *alignQuadrant = MakeQuadrantCorrection(paramA, paramC,  covarA, chi2A/npointsA);
  alignQuadrant->SetName("alignQuadrant");
  alignQuadrant->Write("alignQuadrant");
  hdist = alignQuadrant->CreateHistoDRPhiinXY(10,250,250);
  hdist->SetName("AlignQuadrantAside"); hdist->SetTitle("Quadrant Alignment map (A side)");
  hdist->Write("AlignQuadrantAside");
  hdist = alignQuadrant->CreateHistoDRPhiinXY(-10,250,250);
  hdist->SetName("AlignQuadrantCside"); hdist->SetTitle("Quadrant Alignment map (C side)");
  hdist->Write("AlignQuadrantCside");
  //
  AliTPCFCVoltError3D* corrField = MakeEfieldCorrection(paramA, paramC, covarA, chi2A/npointsA);
  corrField->SetName("corrField");
  corrField->Write("corrField");

  hdist = corrField->CreateHistoDRPhiinXY(10,250,250);
  hdist->SetName("AlignEfieldAside"); hdist->SetTitle("Efield Alignment map (A side)");
  hdist->Write("AlignEfieldAside");
  hdist = corrField->CreateHistoDRPhiinXY(-10,250,250);
  hdist->SetName("AlignEfieldCside"); hdist->SetTitle("Efield Alignment map (C side)");
  hdist->Write("AlignEfieldCside");


  //
  delete pcWorkspace;
  MakeQA();
  return;  
}


void MakeQA(){
  LoadTrees();
  LoadModels();
  RegisterAlignFunction();
  MakeAliases();
  TFile f("fitAlignLookup.root","update");  
  AliTPCCalibGlobalMisalignment*     alignLocal =  (AliTPCCalibGlobalMisalignment*)f.Get("alignLocal");
  AliTPCCalibGlobalMisalignment*  alignQuadrant =  (AliTPCCalibGlobalMisalignment*)f.Get("alignQuadrant");
  AliTPCFCVoltError3D      *corrField= (AliTPCFCVoltError3D*)f.Get("corrField");
  AliTPCCorrection::AddVisualCorrection(alignLocal,1000);
  AliTPCCorrection::AddVisualCorrection(alignQuadrant,1100);
  AliTPCCorrection::AddVisualCorrection(corrField,100);
  FitFunctionQA();
  DrawAlignParam();
  f.Close();
}

void FitFunctionQA(){
  //
  //
  //
  TH1 *his=0;
  TCanvas *canvasDist= new TCanvas("FitQA","fitQA",1200,800);
  canvasDist->Divide(2,2);
  //
  canvasDist->cd(1)->SetLogy(kFALSE); canvasDist->cd(1)->SetRightMargin(0.15);
  treeDY->Draw("10*mean:sector:localX","kZ<0&&localX<134","colz"); 
  his= (TH1*)treeDY->GetHistogram()->Clone();   his->SetName("DeltaRPhi1");
  his->GetXaxis()->SetTitle("Sector"); 
  his->GetZaxis()->SetTitle("R (cm)"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mm)");
  his->Draw("cont2"); 
  his->Draw("colz");
  //
  canvasDist->cd(2)->SetLogy(kFALSE); canvasDist->cd(2)->SetRightMargin(0.15);
  treeDY->Draw("10*mean:sector:localX","kZ<0&&localX>160","colz"); 
  his= (TH1*)treeDY->GetHistogram()->Clone();   his->SetName("DeltaRPhi2");
  his->GetXaxis()->SetTitle("Sector"); 
  his->GetZaxis()->SetTitle("R (cm)"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mm)");
  his->Draw("cont2"); 
  his->Draw("colz");
  //
  canvasDist->cd(3)->SetLogy(kFALSE); canvasDist->cd(3)->SetRightMargin(0.15);
  treeDY->Draw("10*(mean-dAll):sector:localX","kZ<0&&localX<134","colz"); 
  his= (TH1*)treeDY->GetHistogram()->Clone();   his->SetName("DeltaRPhi3"); his->SetTitle("Delta #RPhi");
  his->GetXaxis()->SetTitle("Sector"); 
  his->GetZaxis()->SetTitle("R (cm)"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phifit}-#Delta_{r#phi} (mm)"); 
  his->Draw("cont2"); 
  his->Draw("colz");
  //
  canvasDist->cd(4)->SetLogy(kFALSE); canvasDist->cd(4)->SetRightMargin(0.15);
  treeDY->SetMarkerColor(1);
  treeDY->Draw("10*mean:10*dAll:localX","","colz"); 
  his= (TH1*)treeDY->GetHistogram()->Clone();   his->SetName("DeltaRPhi4");
  his->GetXaxis()->SetTitle("Fit value #Delta_{r#phi} (mm)"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mm)"); 
  his->GetZaxis()->SetTitle("R (cm)"); 
  his->Draw("cont2");
  his->Draw("colz");
  //
  canvasDist->Write("FitQA");
}

void DrawAlignParam(){
  //
  //
  //
  TFile f("fitAlignLookup.root");
  TTree * treeAlign=(TTree*)f.Get("align");
  TTree * treeQuadrant=(TTree*)f.Get("quadrant");
  TCanvas *canvasAlign=new TCanvas("align","align",1000,800); 
  TH1 *his=0;
  canvasAlign->Divide(2,2);
  treeAlign->SetMarkerStyle(25);
  treeQuadrant->SetMarkerStyle(25);
  gStyle->SetOptStat(kTRUE);
  //
  canvasAlign->cd(1); canvasAlign->cd(1)->SetRightMargin(0.15);
  treeAlign->Draw("10*dlyIROC*side:isec:1+side","","colz");
  his= (TH1*)treeAlign->GetHistogram()->Clone();   his->SetName("dlyIROC");his->SetTitle("IROC Alignment #Delta_{r#phi}");
  his->GetXaxis()->SetTitle("sector"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mm)"); 
  his->GetZaxis()->SetTitle("side");
  his->Draw("cont2"); 
  his->Draw("colz");
  //
  canvasAlign->cd(2); canvasAlign->cd(2)->SetRightMargin(0.15);
  treeAlign->Draw("1000*drotIROC*side:isec:1+side","","colz");
  his= (TH1*)treeAlign->GetHistogram()->Clone();   his->SetName("drotIROC");his->SetTitle("IROC Angular Alignment #Delta_{r#phi}");
  his->GetXaxis()->SetTitle("sector"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mrad)"); 
  his->GetZaxis()->SetTitle("side");
  his->Draw("cont2");
  his->Draw("colz");
  //
  canvasAlign->cd(4);canvasAlign->cd(4)->SetRightMargin(0.15);
  treeAlign->Draw("1000*drotOROC*side:isec:1+side","","colz");
  his= (TH1*)treeAlign->GetHistogram()->Clone();   his->SetName("drotOROC");his->SetTitle("OROC Angular Alignment #Delta_{r#phi}");
  his->GetXaxis()->SetTitle("sector"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mrad)"); 
  his->GetZaxis()->SetTitle("side");
  his->Draw("cont2");
  his->Draw("colz");
  //
  canvasAlign->cd(3);canvasAlign->cd(3)->SetRightMargin(0.15);
  treeQuadrant->Draw("10*q2*side:isec:1+side","","colz");
  his= (TH1*)treeQuadrant->GetHistogram()->Clone();   his->SetName("drphiOROC");his->SetTitle("OROC Alignment  Outer Quadrant #Delta_{r#phi}");
  his->GetXaxis()->SetTitle("sector"); 
  his->GetYaxis()->SetTitle("#Delta_{r#phi} (mm)"); 
  his->GetZaxis()->SetTitle("side");
  his->Draw("cont2");
  his->Draw("colz");


}
 FitRodShift.C:1
 FitRodShift.C:2
 FitRodShift.C:3
 FitRodShift.C:4
 FitRodShift.C:5
 FitRodShift.C:6
 FitRodShift.C:7
 FitRodShift.C:8
 FitRodShift.C:9
 FitRodShift.C:10
 FitRodShift.C:11
 FitRodShift.C:12
 FitRodShift.C:13
 FitRodShift.C:14
 FitRodShift.C:15
 FitRodShift.C:16
 FitRodShift.C:17
 FitRodShift.C:18
 FitRodShift.C:19
 FitRodShift.C:20
 FitRodShift.C:21
 FitRodShift.C:22
 FitRodShift.C:23
 FitRodShift.C:24
 FitRodShift.C:25
 FitRodShift.C:26
 FitRodShift.C:27
 FitRodShift.C:28
 FitRodShift.C:29
 FitRodShift.C:30
 FitRodShift.C:31
 FitRodShift.C:32
 FitRodShift.C:33
 FitRodShift.C:34
 FitRodShift.C:35
 FitRodShift.C:36
 FitRodShift.C:37
 FitRodShift.C:38
 FitRodShift.C:39
 FitRodShift.C:40
 FitRodShift.C:41
 FitRodShift.C:42
 FitRodShift.C:43
 FitRodShift.C:44
 FitRodShift.C:45
 FitRodShift.C:46
 FitRodShift.C:47
 FitRodShift.C:48
 FitRodShift.C:49
 FitRodShift.C:50
 FitRodShift.C:51
 FitRodShift.C:52
 FitRodShift.C:53
 FitRodShift.C:54
 FitRodShift.C:55
 FitRodShift.C:56
 FitRodShift.C:57
 FitRodShift.C:58
 FitRodShift.C:59
 FitRodShift.C:60
 FitRodShift.C:61
 FitRodShift.C:62
 FitRodShift.C:63
 FitRodShift.C:64
 FitRodShift.C:65
 FitRodShift.C:66
 FitRodShift.C:67
 FitRodShift.C:68
 FitRodShift.C:69
 FitRodShift.C:70
 FitRodShift.C:71
 FitRodShift.C:72
 FitRodShift.C:73
 FitRodShift.C:74
 FitRodShift.C:75
 FitRodShift.C:76
 FitRodShift.C:77
 FitRodShift.C:78
 FitRodShift.C:79
 FitRodShift.C:80
 FitRodShift.C:81
 FitRodShift.C:82
 FitRodShift.C:83
 FitRodShift.C:84
 FitRodShift.C:85
 FitRodShift.C:86
 FitRodShift.C:87
 FitRodShift.C:88
 FitRodShift.C:89
 FitRodShift.C:90
 FitRodShift.C:91
 FitRodShift.C:92
 FitRodShift.C:93
 FitRodShift.C:94
 FitRodShift.C:95
 FitRodShift.C:96
 FitRodShift.C:97
 FitRodShift.C:98
 FitRodShift.C:99
 FitRodShift.C:100
 FitRodShift.C:101
 FitRodShift.C:102
 FitRodShift.C:103
 FitRodShift.C:104
 FitRodShift.C:105
 FitRodShift.C:106
 FitRodShift.C:107
 FitRodShift.C:108
 FitRodShift.C:109
 FitRodShift.C:110
 FitRodShift.C:111
 FitRodShift.C:112
 FitRodShift.C:113
 FitRodShift.C:114
 FitRodShift.C:115
 FitRodShift.C:116
 FitRodShift.C:117
 FitRodShift.C:118
 FitRodShift.C:119
 FitRodShift.C:120
 FitRodShift.C:121
 FitRodShift.C:122
 FitRodShift.C:123
 FitRodShift.C:124
 FitRodShift.C:125
 FitRodShift.C:126
 FitRodShift.C:127
 FitRodShift.C:128
 FitRodShift.C:129
 FitRodShift.C:130
 FitRodShift.C:131
 FitRodShift.C:132
 FitRodShift.C:133
 FitRodShift.C:134
 FitRodShift.C:135
 FitRodShift.C:136
 FitRodShift.C:137
 FitRodShift.C:138
 FitRodShift.C:139
 FitRodShift.C:140
 FitRodShift.C:141
 FitRodShift.C:142
 FitRodShift.C:143
 FitRodShift.C:144
 FitRodShift.C:145
 FitRodShift.C:146
 FitRodShift.C:147
 FitRodShift.C:148
 FitRodShift.C:149
 FitRodShift.C:150
 FitRodShift.C:151
 FitRodShift.C:152
 FitRodShift.C:153
 FitRodShift.C:154
 FitRodShift.C:155
 FitRodShift.C:156
 FitRodShift.C:157
 FitRodShift.C:158
 FitRodShift.C:159
 FitRodShift.C:160
 FitRodShift.C:161
 FitRodShift.C:162
 FitRodShift.C:163
 FitRodShift.C:164
 FitRodShift.C:165
 FitRodShift.C:166
 FitRodShift.C:167
 FitRodShift.C:168
 FitRodShift.C:169
 FitRodShift.C:170
 FitRodShift.C:171
 FitRodShift.C:172
 FitRodShift.C:173
 FitRodShift.C:174
 FitRodShift.C:175
 FitRodShift.C:176
 FitRodShift.C:177
 FitRodShift.C:178
 FitRodShift.C:179
 FitRodShift.C:180
 FitRodShift.C:181
 FitRodShift.C:182
 FitRodShift.C:183
 FitRodShift.C:184
 FitRodShift.C:185
 FitRodShift.C:186
 FitRodShift.C:187
 FitRodShift.C:188
 FitRodShift.C:189
 FitRodShift.C:190
 FitRodShift.C:191
 FitRodShift.C:192
 FitRodShift.C:193
 FitRodShift.C:194
 FitRodShift.C:195
 FitRodShift.C:196
 FitRodShift.C:197
 FitRodShift.C:198
 FitRodShift.C:199
 FitRodShift.C:200
 FitRodShift.C:201
 FitRodShift.C:202
 FitRodShift.C:203
 FitRodShift.C:204
 FitRodShift.C:205
 FitRodShift.C:206
 FitRodShift.C:207
 FitRodShift.C:208
 FitRodShift.C:209
 FitRodShift.C:210
 FitRodShift.C:211
 FitRodShift.C:212
 FitRodShift.C:213
 FitRodShift.C:214
 FitRodShift.C:215
 FitRodShift.C:216
 FitRodShift.C:217
 FitRodShift.C:218
 FitRodShift.C:219
 FitRodShift.C:220
 FitRodShift.C:221
 FitRodShift.C:222
 FitRodShift.C:223
 FitRodShift.C:224
 FitRodShift.C:225
 FitRodShift.C:226
 FitRodShift.C:227
 FitRodShift.C:228
 FitRodShift.C:229
 FitRodShift.C:230
 FitRodShift.C:231
 FitRodShift.C:232
 FitRodShift.C:233
 FitRodShift.C:234
 FitRodShift.C:235
 FitRodShift.C:236
 FitRodShift.C:237
 FitRodShift.C:238
 FitRodShift.C:239
 FitRodShift.C:240
 FitRodShift.C:241
 FitRodShift.C:242
 FitRodShift.C:243
 FitRodShift.C:244
 FitRodShift.C:245
 FitRodShift.C:246
 FitRodShift.C:247
 FitRodShift.C:248
 FitRodShift.C:249
 FitRodShift.C:250
 FitRodShift.C:251
 FitRodShift.C:252
 FitRodShift.C:253
 FitRodShift.C:254
 FitRodShift.C:255
 FitRodShift.C:256
 FitRodShift.C:257
 FitRodShift.C:258
 FitRodShift.C:259
 FitRodShift.C:260
 FitRodShift.C:261
 FitRodShift.C:262
 FitRodShift.C:263
 FitRodShift.C:264
 FitRodShift.C:265
 FitRodShift.C:266
 FitRodShift.C:267
 FitRodShift.C:268
 FitRodShift.C:269
 FitRodShift.C:270
 FitRodShift.C:271
 FitRodShift.C:272
 FitRodShift.C:273
 FitRodShift.C:274
 FitRodShift.C:275
 FitRodShift.C:276
 FitRodShift.C:277
 FitRodShift.C:278
 FitRodShift.C:279
 FitRodShift.C:280
 FitRodShift.C:281
 FitRodShift.C:282
 FitRodShift.C:283
 FitRodShift.C:284
 FitRodShift.C:285
 FitRodShift.C:286
 FitRodShift.C:287
 FitRodShift.C:288
 FitRodShift.C:289
 FitRodShift.C:290
 FitRodShift.C:291
 FitRodShift.C:292
 FitRodShift.C:293
 FitRodShift.C:294
 FitRodShift.C:295
 FitRodShift.C:296
 FitRodShift.C:297
 FitRodShift.C:298
 FitRodShift.C:299
 FitRodShift.C:300
 FitRodShift.C:301
 FitRodShift.C:302
 FitRodShift.C:303
 FitRodShift.C:304
 FitRodShift.C:305
 FitRodShift.C:306
 FitRodShift.C:307
 FitRodShift.C:308
 FitRodShift.C:309
 FitRodShift.C:310
 FitRodShift.C:311
 FitRodShift.C:312
 FitRodShift.C:313
 FitRodShift.C:314
 FitRodShift.C:315
 FitRodShift.C:316
 FitRodShift.C:317
 FitRodShift.C:318
 FitRodShift.C:319
 FitRodShift.C:320
 FitRodShift.C:321
 FitRodShift.C:322
 FitRodShift.C:323
 FitRodShift.C:324
 FitRodShift.C:325
 FitRodShift.C:326
 FitRodShift.C:327
 FitRodShift.C:328
 FitRodShift.C:329
 FitRodShift.C:330
 FitRodShift.C:331
 FitRodShift.C:332
 FitRodShift.C:333
 FitRodShift.C:334
 FitRodShift.C:335
 FitRodShift.C:336
 FitRodShift.C:337
 FitRodShift.C:338
 FitRodShift.C:339
 FitRodShift.C:340
 FitRodShift.C:341
 FitRodShift.C:342
 FitRodShift.C:343
 FitRodShift.C:344
 FitRodShift.C:345
 FitRodShift.C:346
 FitRodShift.C:347
 FitRodShift.C:348
 FitRodShift.C:349
 FitRodShift.C:350
 FitRodShift.C:351
 FitRodShift.C:352
 FitRodShift.C:353
 FitRodShift.C:354
 FitRodShift.C:355
 FitRodShift.C:356
 FitRodShift.C:357
 FitRodShift.C:358
 FitRodShift.C:359
 FitRodShift.C:360
 FitRodShift.C:361
 FitRodShift.C:362
 FitRodShift.C:363
 FitRodShift.C:364
 FitRodShift.C:365
 FitRodShift.C:366
 FitRodShift.C:367
 FitRodShift.C:368
 FitRodShift.C:369
 FitRodShift.C:370
 FitRodShift.C:371
 FitRodShift.C:372
 FitRodShift.C:373
 FitRodShift.C:374
 FitRodShift.C:375
 FitRodShift.C:376
 FitRodShift.C:377
 FitRodShift.C:378
 FitRodShift.C:379
 FitRodShift.C:380
 FitRodShift.C:381
 FitRodShift.C:382
 FitRodShift.C:383
 FitRodShift.C:384
 FitRodShift.C:385
 FitRodShift.C:386
 FitRodShift.C:387
 FitRodShift.C:388
 FitRodShift.C:389
 FitRodShift.C:390
 FitRodShift.C:391
 FitRodShift.C:392
 FitRodShift.C:393
 FitRodShift.C:394
 FitRodShift.C:395
 FitRodShift.C:396
 FitRodShift.C:397
 FitRodShift.C:398
 FitRodShift.C:399
 FitRodShift.C:400
 FitRodShift.C:401
 FitRodShift.C:402
 FitRodShift.C:403
 FitRodShift.C:404
 FitRodShift.C:405
 FitRodShift.C:406
 FitRodShift.C:407
 FitRodShift.C:408
 FitRodShift.C:409
 FitRodShift.C:410
 FitRodShift.C:411
 FitRodShift.C:412
 FitRodShift.C:413
 FitRodShift.C:414
 FitRodShift.C:415
 FitRodShift.C:416
 FitRodShift.C:417
 FitRodShift.C:418
 FitRodShift.C:419
 FitRodShift.C:420
 FitRodShift.C:421
 FitRodShift.C:422
 FitRodShift.C:423
 FitRodShift.C:424
 FitRodShift.C:425
 FitRodShift.C:426
 FitRodShift.C:427
 FitRodShift.C:428
 FitRodShift.C:429
 FitRodShift.C:430
 FitRodShift.C:431
 FitRodShift.C:432
 FitRodShift.C:433
 FitRodShift.C:434
 FitRodShift.C:435
 FitRodShift.C:436
 FitRodShift.C:437
 FitRodShift.C:438
 FitRodShift.C:439
 FitRodShift.C:440
 FitRodShift.C:441
 FitRodShift.C:442
 FitRodShift.C:443
 FitRodShift.C:444
 FitRodShift.C:445
 FitRodShift.C:446
 FitRodShift.C:447
 FitRodShift.C:448
 FitRodShift.C:449
 FitRodShift.C:450
 FitRodShift.C:451
 FitRodShift.C:452
 FitRodShift.C:453
 FitRodShift.C:454
 FitRodShift.C:455
 FitRodShift.C:456
 FitRodShift.C:457
 FitRodShift.C:458
 FitRodShift.C:459
 FitRodShift.C:460
 FitRodShift.C:461
 FitRodShift.C:462
 FitRodShift.C:463
 FitRodShift.C:464
 FitRodShift.C:465
 FitRodShift.C:466
 FitRodShift.C:467
 FitRodShift.C:468
 FitRodShift.C:469
 FitRodShift.C:470
 FitRodShift.C:471
 FitRodShift.C:472
 FitRodShift.C:473
 FitRodShift.C:474
 FitRodShift.C:475
 FitRodShift.C:476
 FitRodShift.C:477
 FitRodShift.C:478
 FitRodShift.C:479
 FitRodShift.C:480
 FitRodShift.C:481
 FitRodShift.C:482
 FitRodShift.C:483
 FitRodShift.C:484
 FitRodShift.C:485
 FitRodShift.C:486
 FitRodShift.C:487
 FitRodShift.C:488
 FitRodShift.C:489
 FitRodShift.C:490
 FitRodShift.C:491
 FitRodShift.C:492
 FitRodShift.C:493
 FitRodShift.C:494
 FitRodShift.C:495
 FitRodShift.C:496
 FitRodShift.C:497
 FitRodShift.C:498
 FitRodShift.C:499
 FitRodShift.C:500
 FitRodShift.C:501
 FitRodShift.C:502
 FitRodShift.C:503
 FitRodShift.C:504
 FitRodShift.C:505
 FitRodShift.C:506
 FitRodShift.C:507
 FitRodShift.C:508
 FitRodShift.C:509
 FitRodShift.C:510
 FitRodShift.C:511
 FitRodShift.C:512
 FitRodShift.C:513
 FitRodShift.C:514
 FitRodShift.C:515
 FitRodShift.C:516
 FitRodShift.C:517
 FitRodShift.C:518
 FitRodShift.C:519
 FitRodShift.C:520
 FitRodShift.C:521
 FitRodShift.C:522
 FitRodShift.C:523
 FitRodShift.C:524
 FitRodShift.C:525
 FitRodShift.C:526
 FitRodShift.C:527
 FitRodShift.C:528
 FitRodShift.C:529
 FitRodShift.C:530
 FitRodShift.C:531
 FitRodShift.C:532
 FitRodShift.C:533
 FitRodShift.C:534
 FitRodShift.C:535
 FitRodShift.C:536
 FitRodShift.C:537
 FitRodShift.C:538
 FitRodShift.C:539
 FitRodShift.C:540
 FitRodShift.C:541
 FitRodShift.C:542
 FitRodShift.C:543
 FitRodShift.C:544
 FitRodShift.C:545
 FitRodShift.C:546
 FitRodShift.C:547
 FitRodShift.C:548
 FitRodShift.C:549
 FitRodShift.C:550
 FitRodShift.C:551
 FitRodShift.C:552
 FitRodShift.C:553
 FitRodShift.C:554
 FitRodShift.C:555
 FitRodShift.C:556
 FitRodShift.C:557
 FitRodShift.C:558
 FitRodShift.C:559
 FitRodShift.C:560
 FitRodShift.C:561
 FitRodShift.C:562
 FitRodShift.C:563
 FitRodShift.C:564
 FitRodShift.C:565
 FitRodShift.C:566
 FitRodShift.C:567
 FitRodShift.C:568
 FitRodShift.C:569
 FitRodShift.C:570
 FitRodShift.C:571
 FitRodShift.C:572
 FitRodShift.C:573
 FitRodShift.C:574
 FitRodShift.C:575
 FitRodShift.C:576
 FitRodShift.C:577
 FitRodShift.C:578
 FitRodShift.C:579
 FitRodShift.C:580
 FitRodShift.C:581
 FitRodShift.C:582
 FitRodShift.C:583
 FitRodShift.C:584
 FitRodShift.C:585
 FitRodShift.C:586
 FitRodShift.C:587
 FitRodShift.C:588
 FitRodShift.C:589
 FitRodShift.C:590
 FitRodShift.C:591
 FitRodShift.C:592
 FitRodShift.C:593
 FitRodShift.C:594
 FitRodShift.C:595
 FitRodShift.C:596
 FitRodShift.C:597
 FitRodShift.C:598
 FitRodShift.C:599
 FitRodShift.C:600
 FitRodShift.C:601
 FitRodShift.C:602
 FitRodShift.C:603
 FitRodShift.C:604
 FitRodShift.C:605
 FitRodShift.C:606
 FitRodShift.C:607
 FitRodShift.C:608
 FitRodShift.C:609
 FitRodShift.C:610
 FitRodShift.C:611
 FitRodShift.C:612
 FitRodShift.C:613
 FitRodShift.C:614
 FitRodShift.C:615
 FitRodShift.C:616
 FitRodShift.C:617
 FitRodShift.C:618
 FitRodShift.C:619
 FitRodShift.C:620
 FitRodShift.C:621
 FitRodShift.C:622
 FitRodShift.C:623
 FitRodShift.C:624
 FitRodShift.C:625
 FitRodShift.C:626
 FitRodShift.C:627
 FitRodShift.C:628
 FitRodShift.C:629
 FitRodShift.C:630
 FitRodShift.C:631
 FitRodShift.C:632
 FitRodShift.C:633
 FitRodShift.C:634
 FitRodShift.C:635
 FitRodShift.C:636
 FitRodShift.C:637
 FitRodShift.C:638
 FitRodShift.C:639
 FitRodShift.C:640
 FitRodShift.C:641
 FitRodShift.C:642
 FitRodShift.C:643
 FitRodShift.C:644
 FitRodShift.C:645
 FitRodShift.C:646
 FitRodShift.C:647
 FitRodShift.C:648
 FitRodShift.C:649
 FitRodShift.C:650
 FitRodShift.C:651
 FitRodShift.C:652
 FitRodShift.C:653
 FitRodShift.C:654
 FitRodShift.C:655
 FitRodShift.C:656
 FitRodShift.C:657
 FitRodShift.C:658
 FitRodShift.C:659
 FitRodShift.C:660
 FitRodShift.C:661
 FitRodShift.C:662
 FitRodShift.C:663
 FitRodShift.C:664
 FitRodShift.C:665
 FitRodShift.C:666
 FitRodShift.C:667
 FitRodShift.C:668
 FitRodShift.C:669
 FitRodShift.C:670
 FitRodShift.C:671
 FitRodShift.C:672
 FitRodShift.C:673
 FitRodShift.C:674
 FitRodShift.C:675
 FitRodShift.C:676
 FitRodShift.C:677
 FitRodShift.C:678
 FitRodShift.C:679
 FitRodShift.C:680
 FitRodShift.C:681
 FitRodShift.C:682
 FitRodShift.C:683
 FitRodShift.C:684
 FitRodShift.C:685
 FitRodShift.C:686
 FitRodShift.C:687
 FitRodShift.C:688
 FitRodShift.C:689
 FitRodShift.C:690
 FitRodShift.C:691
 FitRodShift.C:692
 FitRodShift.C:693
 FitRodShift.C:694
 FitRodShift.C:695
 FitRodShift.C:696
 FitRodShift.C:697
 FitRodShift.C:698
 FitRodShift.C:699
 FitRodShift.C:700
 FitRodShift.C:701
 FitRodShift.C:702
 FitRodShift.C:703
 FitRodShift.C:704
 FitRodShift.C:705
 FitRodShift.C:706
 FitRodShift.C:707
 FitRodShift.C:708
 FitRodShift.C:709
 FitRodShift.C:710
 FitRodShift.C:711
 FitRodShift.C:712
 FitRodShift.C:713
 FitRodShift.C:714
 FitRodShift.C:715
 FitRodShift.C:716
 FitRodShift.C:717
 FitRodShift.C:718
 FitRodShift.C:719
 FitRodShift.C:720
 FitRodShift.C:721
 FitRodShift.C:722
 FitRodShift.C:723
 FitRodShift.C:724
 FitRodShift.C:725
 FitRodShift.C:726
 FitRodShift.C:727
 FitRodShift.C:728
 FitRodShift.C:729
 FitRodShift.C:730
 FitRodShift.C:731
 FitRodShift.C:732
 FitRodShift.C:733
 FitRodShift.C:734
 FitRodShift.C:735
 FitRodShift.C:736
 FitRodShift.C:737
 FitRodShift.C:738
 FitRodShift.C:739
 FitRodShift.C:740
 FitRodShift.C:741
 FitRodShift.C:742
 FitRodShift.C:743
 FitRodShift.C:744
 FitRodShift.C:745
 FitRodShift.C:746
 FitRodShift.C:747
 FitRodShift.C:748
 FitRodShift.C:749
 FitRodShift.C:750
 FitRodShift.C:751
 FitRodShift.C:752
 FitRodShift.C:753
 FitRodShift.C:754
 FitRodShift.C:755
 FitRodShift.C:756
 FitRodShift.C:757
 FitRodShift.C:758
 FitRodShift.C:759
 FitRodShift.C:760
 FitRodShift.C:761
 FitRodShift.C:762
 FitRodShift.C:763
 FitRodShift.C:764
 FitRodShift.C:765
 FitRodShift.C:766
 FitRodShift.C:767
 FitRodShift.C:768
 FitRodShift.C:769
 FitRodShift.C:770
 FitRodShift.C:771
 FitRodShift.C:772
 FitRodShift.C:773
 FitRodShift.C:774
 FitRodShift.C:775
 FitRodShift.C:776
 FitRodShift.C:777
 FitRodShift.C:778
 FitRodShift.C:779
 FitRodShift.C:780
 FitRodShift.C:781
 FitRodShift.C:782
 FitRodShift.C:783
 FitRodShift.C:784
 FitRodShift.C:785
 FitRodShift.C:786
 FitRodShift.C:787
 FitRodShift.C:788
 FitRodShift.C:789
 FitRodShift.C:790
 FitRodShift.C:791
 FitRodShift.C:792
 FitRodShift.C:793
 FitRodShift.C:794
 FitRodShift.C:795
 FitRodShift.C:796
 FitRodShift.C:797
 FitRodShift.C:798
 FitRodShift.C:799
 FitRodShift.C:800
 FitRodShift.C:801
 FitRodShift.C:802
 FitRodShift.C:803
 FitRodShift.C:804
 FitRodShift.C:805
 FitRodShift.C:806
 FitRodShift.C:807
 FitRodShift.C:808
 FitRodShift.C:809
 FitRodShift.C:810
 FitRodShift.C:811
 FitRodShift.C:812
 FitRodShift.C:813
 FitRodShift.C:814
 FitRodShift.C:815
 FitRodShift.C:816
 FitRodShift.C:817
 FitRodShift.C:818
 FitRodShift.C:819
 FitRodShift.C:820
 FitRodShift.C:821
 FitRodShift.C:822
 FitRodShift.C:823
 FitRodShift.C:824
 FitRodShift.C:825
 FitRodShift.C:826
 FitRodShift.C:827
 FitRodShift.C:828
 FitRodShift.C:829
 FitRodShift.C:830
 FitRodShift.C:831
 FitRodShift.C:832
 FitRodShift.C:833
 FitRodShift.C:834
 FitRodShift.C:835
 FitRodShift.C:836
 FitRodShift.C:837
 FitRodShift.C:838
 FitRodShift.C:839
 FitRodShift.C:840
 FitRodShift.C:841
 FitRodShift.C:842
 FitRodShift.C:843
 FitRodShift.C:844
 FitRodShift.C:845
 FitRodShift.C:846
 FitRodShift.C:847
 FitRodShift.C:848
 FitRodShift.C:849
 FitRodShift.C:850
 FitRodShift.C:851
 FitRodShift.C:852
 FitRodShift.C:853
 FitRodShift.C:854
 FitRodShift.C:855
 FitRodShift.C:856
 FitRodShift.C:857
 FitRodShift.C:858
 FitRodShift.C:859
 FitRodShift.C:860
 FitRodShift.C:861
 FitRodShift.C:862
 FitRodShift.C:863
 FitRodShift.C:864
 FitRodShift.C:865
 FitRodShift.C:866
 FitRodShift.C:867
 FitRodShift.C:868
 FitRodShift.C:869
 FitRodShift.C:870
 FitRodShift.C:871
 FitRodShift.C:872
 FitRodShift.C:873
 FitRodShift.C:874
 FitRodShift.C:875
 FitRodShift.C:876
 FitRodShift.C:877
 FitRodShift.C:878
 FitRodShift.C:879
 FitRodShift.C:880
 FitRodShift.C:881
 FitRodShift.C:882
 FitRodShift.C:883
 FitRodShift.C:884
 FitRodShift.C:885
 FitRodShift.C:886
 FitRodShift.C:887
 FitRodShift.C:888
 FitRodShift.C:889
 FitRodShift.C:890
 FitRodShift.C:891
 FitRodShift.C:892
 FitRodShift.C:893
 FitRodShift.C:894
 FitRodShift.C:895
 FitRodShift.C:896
 FitRodShift.C:897
 FitRodShift.C:898
 FitRodShift.C:899
 FitRodShift.C:900
 FitRodShift.C:901
 FitRodShift.C:902
 FitRodShift.C:903
 FitRodShift.C:904
 FitRodShift.C:905
 FitRodShift.C:906
 FitRodShift.C:907
 FitRodShift.C:908
 FitRodShift.C:909
 FitRodShift.C:910
 FitRodShift.C:911
 FitRodShift.C:912
 FitRodShift.C:913
 FitRodShift.C:914
 FitRodShift.C:915
 FitRodShift.C:916
 FitRodShift.C:917
 FitRodShift.C:918
 FitRodShift.C:919
 FitRodShift.C:920
 FitRodShift.C:921
 FitRodShift.C:922
 FitRodShift.C:923
 FitRodShift.C:924
 FitRodShift.C:925
 FitRodShift.C:926
 FitRodShift.C:927
 FitRodShift.C:928
 FitRodShift.C:929
 FitRodShift.C:930
 FitRodShift.C:931
 FitRodShift.C:932
 FitRodShift.C:933
 FitRodShift.C:934
 FitRodShift.C:935
 FitRodShift.C:936
 FitRodShift.C:937
 FitRodShift.C:938
 FitRodShift.C:939
 FitRodShift.C:940
 FitRodShift.C:941
 FitRodShift.C:942
 FitRodShift.C:943
 FitRodShift.C:944
 FitRodShift.C:945
 FitRodShift.C:946