00001
00002
00003
00004
00005
00006
00007
00008
00009 TChain *theChain = 0;
00010
00011 TChain *GetChain() {
00012 if (! theChain) {
00013 gInterpreter->ProcessLine(".L Chain.C");
00014 theChain = Chain();
00015 }
00016 return theChain;
00017 }
00018
00019 Double_t RaftMirror(Double_t pXL, Double_t pYL, Double_t PhiT, Int_t Raft, Int_t Mirror) {
00020
00021 struct RaftCorr_t {
00022 Int_t raft;
00023 Double_t phi;
00024 Double_t dphi;
00025 };
00026
00027
00028 if (Raft < 1 || Raft > 14 ||
00029 Mirror < 1 || Mirror > 7) return 0;
00030 Double_t phiL = TMath::ATan2(pYL,pXL);
00031 Double_t dPhi = phiL - PhiT;
00032 if (dPhi >= TMath::Pi()) dPhi -= 2*TMath::Pi();
00033 if (dPhi <= -TMath::Pi()) dPhi += 2*TMath::Pi();
00034 return dPhi;
00035 }
00036
00037 Double_t SectorMirror(Double_t PhiL, Double_t PhiT, Int_t Sector, Int_t Mirror) {
00038
00039 #if 0
00040 struct SectorCorr_t {
00041 Int_t sector2;
00042 Double_t phi;
00043 Double_t dphi;
00044 Double_t sigma;
00045 Double_t dsigma;
00046 };
00047 SectorCorr_t SectorCorr0[12] = {
00048
00049 {2, -0.0186195, 1.4527e-05, 0.00184551, 1.02723e-05},
00050 {4, -0.0196896, 2.33502e-05, 0.00184777, 1.65113e-05},
00051 {6, -0.005116, 2.93135e-05, 0.00260989, 2.07281e-05},
00052 {8, 0.00437859, 2.77778e-05, 0.00329948, 1.96424e-05},
00053 {10, 0, 0, 0, 0},
00054 {12, 0.000916182, 2.43739e-05, 0.00234977, 1.72353e-05},
00055 {14, -0.0180773, 2.52572e-05, 0.00275963, 1.78601e-05},
00056 {16, 0.00312329, 1.55691e-05, 0.00204276, 1.10091e-05},
00057 {18, -0.00609319, 1.41944e-05, 0.00136081, 1.00371e-05},
00058 {20, 0.00649718, 2.39854e-05, 0.00278396, 1.69605e-05},
00059 {22, 0.0201383, 2.10855e-05, 0.00128673, 1.49099e-05},
00060 {24, 0.0374981, 4.71165e-05, 0.00324044, 3.33172e-05}
00061 };
00062 SectorCorr_t SectorMirror[7][12] = {
00063 {
00064 { 2, 0, 0, 0, 0},
00065 { 4, 0, 0, 0, 0},
00066 { 6, 0, 0, 0, 0},
00067 { 8, 0, 0, 0, 0},
00068 {12, 0, 0, 0, 0},
00069 {14, 0, 0, 0, 0},
00070 {16, 0, 0, 0, 0},
00071 {18, 0, 0, 0, 0},
00072 {20, 0, 0, 0, 0},
00073 {22, 0, 0, 0, 0},
00074 {24, 0, 0, 0, 0}
00075 },
00076 {
00077 {2, 1.47897e-02, 2.50330e-05, 5.15724e-04, 2.14312e-05},
00078 {4, -6.08707e-02, 2.16937e-05, 6.93992e-04, 1.60809e-05},
00079 {6, 0, 0, 0, 0},
00080 {8, -3.50111e-03, 3.93290e-05, 1.60574e-03, 2.70401e-05},
00081 {10, 0, 0, 0, 0},
00082 {12,-1.45117e-02, 5.64167e-05, 1.54124e-03, 3.65524e-05},
00083 {14,-3.28631e-02, 9.47326e-05, 1.92888e-03, 6.99189e-05},
00084 {16, 2.65153e-02, 1.00910e-05, 5.09772e-04, 5.99093e-06},
00085 {18, 2.26290e-02, 1.61950e-05, 5.65004e-04, 8.09284e-06},
00086 {20,-6.06357e-02, 1.44520e-05, 7.23663e-04, 1.35932e-05},
00087 {22, 6.01550e-03, 9.13966e-05, 1.07660e-03, 6.33931e-05},
00088 {24,-5.20394e-02, 2.44742e-05, 9.68631e-04, 1.61593e-05}
00089 },
00090 {
00091 {2, 0.0172837, 9.29745e-06, 0.000480627, 6.46204e-06},
00092 {4, 0.00212475, 5.27541e-05, 0.00229639, 3.73615e-05},
00093 {6, -0.00222559, 6.13796e-06, 6.34452e-05, 1.34243e-06},
00094 {8, 0.0433267, 9.80298e-06, 0.00051389, 6.37242e-06},
00095 {10, 0, 0, 0, 0},
00096 {12, 0.0246517, 1.91944e-05, 0.00101986, 1.51846e-0 },
00097 {14, 0.0047278, 0.000260374, 0.00157437, 0.000349249},
00098 {16, 0.00466532,1.16948e-05, 0.000832494,7.36983e-06},
00099 {18,-0.00221707,6.30134e-05, 0.00184436, 3.70755e-05},
00100 {20,-0.00400158,6.86993e-05, 0.00225299, 4.08153e-05},
00101 {22, 0.00392405,0.00010365, 0.00119326, 0.000110543},
00102 {24, 0.00557869,2.23633e-05, 0.000991408,1.30714e-05}
00103 },
00104 {
00105 {2, -2.0143e-05, 1.65561e-05, 0.00171236, 7.53284e-06},
00106 {4, -0.000256831,2.38597e-05, 0.00101118, 2.03843e-05},
00107 {6, 0.001134, 1.91263e-05, 0.00134625, 1.07783e-05},
00108 {8, -0.00081522, 1.04845e-05, 0.000613908,1.08238e-05},
00109 {10, 0, 0, 0, 0},
00110 {12, 0.000987496,1.66857e-05, 0.00104992, 1.11315e-05},
00111 {14, -0.00122242, 4.50794e-05, 0.00344171, 3.18769e-05},
00112 {16, 0.000131596,2.89793e-05, 0.00185695, 1.72874e-05},
00113 {18, 0.000805035,1.34267e-05, 0.000764655,7.61076e-06},
00114 {20, -0.00240851, 1.75617e-05, 0.00109031, 1.29384e-05},
00115 {22, -0.000366494,1.51986e-05, 0.000679965,1.06328e-05},
00116 {24, 0.00159829, 1.97649e-05, 0.00106986, 1.39759e-05}
00117 },
00118 {
00119 {2, 0.0202492, 1.21405e-05, 0.000651143, 8.64812e-06},
00120 {4, -0.127498, 4.41647e-05, 0.0015842, 2.73322e-05},
00121 {6, -0.0111096, 1.71769e-05, 0.000746844, 1.27916e-05},
00122 {8, 0.0115083, 1.07084e-05, 0.000388096, 4.30121e-06},
00123 {10, 0, 0, 0, 0},
00124 {12, 0.0797944, 2.68801e-05, 0.000825459, 2.09022e-05},
00125 {14, -0.00656188, 3.06239e-05, 0.00137091, 2.16544e-05},
00126 {16, -0.00293398, 1.50938e-05, 0.000800728, 1.4194e-05},
00127 {18, 0, 0, 0, 0},
00128 {20, 0.0247521, 1.0784e-05, 0.000544184, 8.77057e-06},
00129 {22, 0, 0, 0, 0},
00130 {24, -0.0035, 0.00010766, 0.000854507, 7.6101e-05}
00131 },
00132 {
00133 {2, -0.0211806, 8.82803e-05, 0.00193211, 6.24233e-05},
00134 {4, 0.00960692, 0.000803011, 0.00207609, 0.000503285},
00135 {6, -0.019809, 6.20976e-05, 0.00178037, 4.39096e-05},
00136 {8, -0.0244286, 3.08233e-05, 0.00143618, 2.17956e-05},
00137 {10, 0, 0, 0, 0},
00138 {12, 0.00980073, 9.14786e-05, 0.00101579, 6.82576e-05},
00139 {14, 0, 0, 0, 0},
00140 {16, -0.000329188, 6.08403e-05, 0.000869988, 4.33747e-05},
00141 {18, -0.00445835, 0.000235526, 0.000686245, 0.000139439},
00142 {20, 0.00150319, 0.000115474, 0.000571378, 8.76884e-05},
00143 {22, 0, 0, 0, 0},
00144 {24, 0.00230525, 5.80364e-05, 0.0015616, 4.10378e-05}
00145 },
00146 {
00147 { 2, 0, 0, 0, 0},
00148 { 4, 0, 0, 0, 0},
00149 { 6, 0, 0, 0, 0},
00150 { 8, 0, 0, 0, 0},
00151 {12, 0, 0, 0, 0},
00152 {14, 0, 0, 0, 0},
00153 {16, 0, 0, 0, 0},
00154 {18, 0, 0, 0, 0},
00155 {20, 0, 0, 0, 0},
00156 {22, 0, 0, 0, 0},
00157 {24, 0, 0, 0, 0}
00158 }
00159 };
00160 #endif
00161 Double_t dPhi = -999;
00162 if (Sector < 1 || Sector > 24 ||
00163 Mirror < 1 || Mirror > 7) return dPhi;
00164
00165
00166 Int_t i = (Sector-1)/2;
00167 Int_t m = Mirror - 1;
00168 if (SectorCorr0[i].sigma <= 0) return dPhi;
00169 if (SectorMirror[m][i].sigma <= 0) return dPhi;
00170 #if 0
00171 Double_t dPhi = PhiL - PhiT - SectorCorr0[i].phi - SectorMirror[m][i].phi;
00172 #else
00173 Double_t dPhi = PhiL - PhiT - SectorMirror[m][i].phi;
00174 #endif
00175 if (dPhi >= TMath::Pi()) dPhi -= 2*TMath::Pi();
00176 if (dPhi <= -TMath::Pi()) dPhi += 2*TMath::Pi();
00177 return dPhi;
00178 }
00179
00180 void FitRM(TH2* hist) {
00181 if (! hist) return;
00182 hist->FitSlicesY(0,-1,0,10,"lnr");
00183 TH1 *fit = (TH1 *) gDirectory->Get(Form("%s_1",hist->GetName()));
00184 TH1 *sigma = (TH1 *) gDirectory->Get(Form("%s_2",hist->GetName()));
00185 if (! fit || ! sigma) return;
00186 fit->SetMarkerStyle(20);
00187 hist->Draw("colz");
00188 fit->Draw("same");
00189 Int_t nx = fit->GetNbinsX();
00190 for (Int_t i = 1; i <= nx; i++)
00191 cout << "{" << 2*i << ", \t" << fit->GetBinContent(i) << ",\t" << fit->GetBinError(i) << ",\t" << sigma->GetBinContent(i) << ",\t" << sigma->GetBinError(i) <<"}," << endl;
00192 }
00193
00194 void FillRM(Int_t Mirror) {
00195 TTree *laser = (TTree *) gDirectory->Get("laser");
00196 if (! laser ) return;
00197
00198 TString Plot("SectorMirror(fTracks.Laser.PhiG,fTracks.fgeoOut.mPsi,fTracks.Laser.Sector,fTracks.Laser.Mirror):fTracks.Laser.Sector>>");
00199 TString hName(Form("Sector%iPhi2",Mirror));
00200 Plot += hName;
00201 Plot += "(12,1,25,400,-.2,.2)";
00202 TString Cut(Form("fTracks.Flag==2&&fTracks.Laser.Mirror==%i",Mirror));
00203 Cut += "&&abs(fTracks.XyzP.mX1-fTracks.Laser.XyzG.mX1)<0.1";
00204 Cut += "&&abs(fTracks.XyzP.mX2-fTracks.Laser.XyzG.mX2)<0.1";
00205 Cut += "&&fTracks.thePath > 5 && fTracks.thePath < 12";
00206 Cut += "&&fTracks.mNumberOfFitPointsTpc > 25";
00207 Cut += "&&TMath::Abs(fTracks.Laser.ThetaG-fTracks.fgeoOut.mDipAngle-TMath::Pi()/2) < 0.05";
00208 laser->Draw(Plot,Cut,"colz");
00209 TH2 *hist = (TH2 *) gDirectory->Get(hName);
00210 if (! hist) {cout << hName " << is missing" << endl; return;}
00211 FitRM(hist);
00212 }
00213
00214 void MembraneDip() {
00215 TTree *laser = (TTree *) gDirectory->Get("laser");
00216 if (! laser ) return;
00217 TF1 *SS = new TF1("SS","[0]+[1]*TMath::Sin(x+[2])");
00218 SS->SetParName(0,"A");
00219 SS->SetParName(1,"B");
00220 SS->SetParName(3,"#phi 0");
00221 TCanvas *c1 = new TCanvas();
00222 c1->Divide(1,2);
00223 c1->cd(1)->SetLogz(1);
00224
00225 TString Cut("fTracks.Flag==1&&(abs(fTracks.Vertex.mX3+3.3)<2||abs(fTracks.Vertex.mX3-3.6)<2)&&abs(fTracks.fgeoIn.mDipAngle)<0.010");
00226 TString cut = Cut;
00227 cut += "&&fTracks.mSector<=12";
00228 laser->Draw("1.e3*fTracks.fgeoIn.mDipAngle:fTracks.fgeoIn.mPsi>>DipPsiWW",cut,"colz");
00229 TH2 *DipPsiWW = (TH2 *) gDirectory->Get("DipPsiWW");
00230 DipPsiWW->SetXTitle("#psi");
00231 DipPsiWW->SetYTitle("#lambda");
00232 DipPsiWW->FitSlicesY();
00233 TH1 *DipPsiWW_1 = (TH1 *) gDirectory->Get("DipPsiWW_1");
00234 DipPsiWW_1->SetMarkerStyle(2);
00235 SS->SetParameter(2,1);
00236 DipPsiWW_1->Fit(SS);
00237 DipPsiWW_1->SetMarkerStyle(20);
00238 DipPsiWW->Draw("colz");
00239 DipPsiWW_1->Draw("sames");
00240 TLegend *w = new TLegend(0.25,0.7,0.4,0.9,"");
00241 w->AddEntry(DipPsiWW_1,"West");
00242 w->Draw();
00243 c1->cd(2)->SetLogz(1);
00244 cut = Cut;
00245 cut += "&&fTracks.mSector>12";
00246 laser->Draw("1.e3*fTracks.fgeoIn.mDipAngle:fTracks.fgeoIn.mPsi>>DipPsiEE",cut,"colz");
00247 TH2 *DipPsiEE = (TH2 *) gDirectory->Get("DipPsiEE");
00248 DipPsiEE->SetXTitle("#psi");
00249 DipPsiEE->SetYTitle("#lambda");
00250 DipPsiEE->FitSlicesY();
00251 TH1 *DipPsiEE_1 = (TH1 *) gDirectory->Get("DipPsiEE_1");
00252 DipPsiEE_1->SetMarkerStyle(2);
00253 SS->SetParameter(2,1);
00254 DipPsiEE_1->Fit(SS);
00255 DipPsiEE_1->SetMarkerStyle(20);
00256 DipPsiEE->Draw("colz");
00257 DipPsiEE_1->Draw("sames");
00258 TLegend *e = new TLegend(0.25,0.6,0.4,0.9,"");
00259 e->AddEntry(DipPsiEE_1,"East");
00260 e->Draw();
00261 }