]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/Upgrade/macros/GetComposedResidualDistortion.C
df0e2344a4e3d7a2735806ec165085734f3d37fd
[u/mrichter/AliRoot.git] / TPC / Upgrade / macros / GetComposedResidualDistortion.C
1 #include <TString.h>
2 #include <TVectorD.h>
3 #include <TObjArray.h>
4 #include <TFile.h>
5
6 #include <AliTPCComposedCorrection.h>
7 #include <AliTPCCorrectionLookupTable.h>
8
9 #include <AliToyMCEventGenerator.h>
10
11
12 AliTPCComposedCorrection* GetComposedResidualDistortion(TString fluctuationMap, TString averageMap, Bool_t rescale=kTRUE)
13 {
14   //
15   //
16   //
17
18
19   TFile fFluct(fluctuationMap);
20   AliTPCCorrectionLookupTable *corrFluct = (AliTPCCorrectionLookupTable*)fFluct.Get("map");
21   fFluct.Close();
22
23   TFile fAverage(averageMap);
24   AliTPCCorrectionLookupTable *corrAverage = (AliTPCCorrectionLookupTable*)fAverage.Get("map");
25   fAverage.Close();
26
27   TObjArray *arrMaps = new TObjArray(2);
28   // !!!!! In AliTPCComposedCorrection::GetDistortion MakeInverseIterator is called !!!!
29   // for this reason we have to add the maps in the wrong order
30   
31   arrMaps->Add(corrAverage); // correction with the average Map
32   arrMaps->Add(corrFluct);   // distortion with the fluctuation Map
33
34   // create the composed correction
35   // if the weight are set to +1 and -1, the first map will be responsible for the distortions
36   // The second map for the corrections
37   AliTPCComposedCorrection *residualDistortion = new AliTPCComposedCorrection(arrMaps, AliTPCComposedCorrection::kQueueResidual);
38   TVectorD weights(2);
39   weights(0)=+1.;
40   weights(1)=-1.;
41   if (rescale) {
42     Float_t dummy=0;
43     weights(1)=-AliToyMCEventGenerator::GetSCScalingFactor(corrFluct, corrAverage,dummy);
44   }
45   residualDistortion->SetWeights(&weights);
46
47   return residualDistortion;
48 }
49
50 AliTPCCorrectionLookupTable* GetResidualTable(TString fluctuationMap, TString averageMap, Bool_t rescale=kTRUE)
51 {
52   TFile fFluct(fluctuationMap);
53   AliTPCCorrectionLookupTable *corrFluct = (AliTPCCorrectionLookupTable*)fFluct.Get("map");
54   fFluct.Close();
55   
56   TFile fAverage(averageMap);
57   AliTPCCorrectionLookupTable *corrAverage = (AliTPCCorrectionLookupTable*)fAverage.Get("map");
58   fAverage.Close();
59
60   Double_t scale=AliToyMCEventGenerator::GetSCScalingFactor(corrFluct, corrAverage,dummy);
61
62   corrAverage->SetCorrScaleFactor(scale);
63
64   AliTPCCorrectionLookupTable *tab=new AliTPCCorrectionLookupTable;
65   tab->CreateResidual(corrFluct, corrAverage);
66   
67 }