.x $ALICE_ROOT/TPC/Upgrade/macros/ConfigOCDB.C(1)
.L $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C
-Example usage:
+Example usage rescaling fit:
-ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation/dir1/SpaceChargeFluc10_1.lookup.root current.root
-ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation/average/SpaceChargeFluc0_1.lookup.root mean.root
+
+aliroot -b -q $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C\(0\)
+
+
+Example usage Jens alignment lookup tables:
+
+ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/MeasuredResidual2D/residualMap.1.root current.root
+ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/ResidualResidual2D/residualMap.1.root mean.root
ln -sf $ALICE_ROOT/OCDB/TPC/Calib/Correction/Run0_999999999_v0_s2.root ocdb.root
-aliroot -b -q $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C
+aliroot -b -q $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C\(1\)
+
+
+
*/
-
-void makeResidualSpaceChargeOCDB(const char *ocdbInName="ocdb.root",const char *scCurrentName="current.root", const char *scMeanName="mean.root"){
+void makeResidualSpaceChargeOCDBFit(const char *ocdbInName="ocdb.root",const char *scCurrentName="current.root", const char *scMeanName="mean.root"){
//
// Macro to create a clone original OCDB entry with space point distortion and add there space point
// distortions cause by resifual sapce charge
}
+
+
+void makeResidualSpaceChargeOCDBAlign(const char *ocdbInName="ocdb.root",const char *scCurrentName="current.root", const char *scMeanName="mean.root"){
+ //
+ // Macro to create a clone original OCDB entry with space point distortion and add there space point
+ // distortion due residual space charge isalignemnt
+ // Output is stored by default in the current directory.
+ //
+
+ // Parameters to Specify:
+ // ocdbInName : path to the original OCDB entry
+ // scCurrentName : path to the fluctuetaed distortion map
+ // scMeanName : path to the mean distortion map
+ //
+
+ /*
+ scCurrentName="/hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/MeasuredResidual2D/residualMap.10.root";
+ scMeanName="/hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/ResidualResidual2D/residualMap.10.root";
+ ocdbInName="$ALICE_ROOT/OCDB/TPC/Calib/Correction/Run0_999999999_v0_s2.root"
+ */
+ TFile * finCurrent = TFile::Open(scCurrentName);
+ TFile * finMean = TFile::Open(scMeanName);
+ //
+ AliTPCCorrectionLookupTable *spaceChargeCurrent= (AliTPCCorrectionLookupTable *)finCurrent->Get("map");
+ AliTPCCorrectionLookupTable *spaceChargeMean = (AliTPCCorrectionLookupTable *)finMean->Get("map");
+ //
+ TObjArray * arraySC = new TObjArray(2);
+ arraySC->AddAt(spaceChargeCurrent,0);
+ arraySC->AddAt(spaceChargeMean,1);
+ AliTPCComposedCorrection *corrSC = new AliTPCComposedCorrection(arraySC,AliTPCComposedCorrection::kParallel);
+ AliTPCComposedCorrection *corrSCW = new AliTPCComposedCorrection(arraySC,AliTPCComposedCorrection::kParallel);
+ AliTPCComposedCorrection::AddVisualCorrection(spaceChargeCurrent,1); // reconstructed
+ AliTPCComposedCorrection::AddVisualCorrection(spaceChargeMean,2); // ideal
+ AliTPCComposedCorrection::AddVisualCorrection(corrSCW,5);
+ //
+ TVectorD weights(2);
+ weights[0]=1;
+ weights[1]=1;
+ corrSCW->SetWeights( &weights);
+ TTreeSRedirector * pcstream = new TTreeSRedirector("residualDelta.root","recreate");
+ //
+ for (Int_t ipoint=0; ipoint<50000; ipoint++){
+ Double_t phi = gRandom->Rndm()*TMath::TwoPi();
+ Double_t r = 85+gRandom->Rndm()*(245-85);
+ Double_t theta = -0.9+gRandom->Rndm()*1.8;
+ Double_t z=r*theta;
+ Double_t x = r*TMath::Cos(phi);
+ Double_t y = r*TMath::Sin(phi);
+ Double_t drInput = AliTPCCorrection::GetCorrXYZ(x,y,z,0,1);
+ Double_t drOutput = AliTPCCorrection::GetCorrXYZ(x,y,z,0,2);
+ Double_t drDiff = AliTPCCorrection::GetCorrXYZ(x,y,z,0,5);
+ Double_t drphiInput = AliTPCCorrection::GetCorrXYZ(x,y,z,1,1); //
+ Double_t drphiOutput = AliTPCCorrection::GetCorrXYZ(x,y,z,1,2); //
+ Double_t drphiDiff = AliTPCCorrection::GetCorrXYZ(x,y,z,1,5); //
+ //
+ (*pcstream)<<"diff"<<
+ "phi="<<phi<<
+ "r="<<r<<
+ "x="<<x<<
+ "y="<<y<<
+ "z="<<z<<
+ //
+ "drInput="<<drInput<<
+ "drOutput="<<drOutput<<
+ "drDiff="<<drDiff<<
+ //
+ "drphiInput="<<drphiInput<<
+ "drphiOutput="<<drphiOutput<<
+ "drphiDiff="<<drphiDiff<<
+ "\n";
+ }
+ TTree * tree = ((*pcstream)<<"diff")->GetTree();
+ //
+ TCanvas *canvas = new TCanvas("canvasDiff","canvasDiff",900,800);
+ canvas->Divide(3,2);
+ canvas->cd(1);
+ tree->Draw("drphiOutput:drphiInput","abs(drphiDiff)+abs(drphiOutput)+abs(drphiInput)<3","");
+ canvas->cd(2);
+ tree->Draw("drphiDiff:r","abs(drphiDiff)+abs(drphiOutput)+abs(drphiInput)<3","colz");
+ canvas->cd(3);
+ tree->Draw("drphiDiff","abs(drphiDiff)+abs(drphiOutput)+abs(drphiInput)<3","");
+ canvas->cd(4);
+ tree->Draw("drOutput:drInput","abs(drDiff)+abs(drOutput)+abs(drInput)<3","");
+ canvas->cd(5);
+ tree->Draw("drDiff:r","abs(drDiff)+abs(drOutput)+abs(drInput)<3","colz");
+ canvas->cd(6);
+ tree->Draw("drDiff","abs(drDiff)+abs(drOutput)+abs(drInput)<3","");
+ canvas->SaveAs("residualSpaceChargeDistortion.pdf");
+ //
+ //
+ //
+ TFile *fileOCDBIn=TFile::Open(ocdbInName);
+ AliCDBEntry *entry = ( AliCDBEntry *)fileOCDBIn->Get("AliCDBEntry");
+ TObjArray * array = (TObjArray*)entry->GetObject();
+ for (Int_t i=0; i<3; i++){
+ AliTPCComposedCorrection *corr = ( AliTPCComposedCorrection*)array->At(i);
+ if (corr){
+ TObjArray* corrArray = corr->GetCorrections();
+ corrArray->AddLast(corrSCW);
+ }
+ }
+ AliCDBMetaData *metaData= new AliCDBMetaData();
+ metaData->SetObjectClassName("TObjArray");
+ metaData->SetResponsible("Marian Ivanov");
+ metaData->SetBeamPeriod(1);
+ metaData->SetAliRootVersion("05-25-01"); //root version
+ metaData->SetComment("Standard+fluctuation");
+ AliCDBId* id1=NULL;
+ id1=new AliCDBId("TPC/Calib/Correction", 0, 9999999999999999);
+ //
+ TString localStorage = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+ pocdbStorage = AliCDBManager::Instance()->GetStorage(localStorage.Data());
+ pocdbStorage->Put(array, (*id1), metaData);
+
+
+}
+
+
+
+void makeResidualSpaceChargeOCDB(Int_t action=1){
+ //
+ //
+ //
+ if (action==0) makeResidualSpaceChargeOCDBFit(); // fit mean charge to current charge
+ if (action==1) makeResidualSpaceChargeOCDBAlign(); // use difference of the map and the reconstructed distorion map as a residual OCDB
+}
+