00001 #if !defined(__CINT__) || defined(__MAKECINT__)
00002 #include "Riostream.h"
00003 #include <stdio.h>
00004 #include "TSystem.h"
00005 #include "TMath.h"
00006 #include "TH1.h"
00007 #include "TH2.h"
00008 #include "TH3.h"
00009 #include "TProfile.h"
00010 #include "TStyle.h"
00011 #include "TF1.h"
00012 #include "TTree.h"
00013 #include "TChain.h"
00014 #include "TFile.h"
00015 #include "TNtuple.h"
00016 #include "TCanvas.h"
00017 #include "TMinuit.h"
00018 #include "TSpectrum.h"
00019 #include "TString.h"
00020 #include "TLegend.h"
00021 #include "TLine.h"
00022 #include "TText.h"
00023 #include "TROOT.h"
00024 #include "TList.h"
00025 #include "TPolyMarker.h"
00026 #include "StBichsel/Bichsel.h"
00027 #include "BetheBloch.h"
00028 #include "TDirIter.h"
00029 #include "TTreeIter.h"
00030 #else
00031 class TSystem;
00032 class TMath;
00033 class TH1;
00034 class TH2;
00035 class TH3;
00036 class TProfile;
00037 class TStyle;
00038 class TF1;
00039 class TTree;
00040 class TChain;
00041 class TFile;
00042 class TNtuple;
00043 class TCanvas;
00044 class TMinuit;
00045 class TSpectrum;
00046 class TString;
00047 class TLegend;
00048 class TLine;
00049 class TText;
00050 class TROOT;
00051 class TList;
00052 class TPolyMarker;
00053 class Bichsel;
00054 class BetheBloch;
00055 class TDirIter;
00056 class TTreeIter;
00057 #endif
00058 TChain *chain = 0;
00059 const Char_t *Set[2] = {"tpt","sti"};
00060 TFile *fIn[2] = {0,0};
00061 const Char_t *charge[2] = {"P","N"};
00062 const Char_t *scharge[2] = {"+","-"};
00063 const Char_t *PG[2] = {"f","Gl"};
00064 static Int_t nPng = 0;
00065
00066 Int_t accept(Float_t pT, Float_t eta, Int_t nMcHit,Int_t GeantId, Int_t mFitPts,
00067 Float_t Qual, Int_t mNAssocGl, Int_t mNAssocPr, Char_t validMc=1, Short_t PrimaryMc=1 ) {
00068 if (! validMc || ! PrimaryMc) return 0;
00069
00070 #if 0
00071 if (TMath::Abs(eta) > 0.5 || nMcHit < 40) return 0;
00072 if (mFitPts > 0 && mFitPts < 25) return 0;
00073 #else
00074 if (TMath::Abs(eta) > 0.5 || nMcHit < 20) return 0;
00075 if (mFitPts > 0 && mFitPts < 15) return 0;
00076 #endif
00077 if (Qual > 0 && Qual < 90.0) return 0;
00078
00079 if (GeantId == 8) return -1;
00080 if (GeantId == 9) return 1;
00081 return 0;
00082 }
00083
00084 void DrawPng(TCanvas *c) {
00085 TString pngName("");
00086 if (c) {
00087 c->Update(); pngName = c->GetName();
00088 pngName.ReplaceAll(" ","_");
00089 pngName.ReplaceAll("(","_");
00090 pngName.ReplaceAll(")","_");
00091 pngName.ReplaceAll("{","_");
00092 pngName.ReplaceAll("}","_");
00093 pngName.ReplaceAll("<","lt");
00094 pngName.ReplaceAll(">","gt");
00095 pngName.ReplaceAll("tpt_sti_","");
00096 pngName.ReplaceAll("tpt_sti","");
00097 pngName.ReplaceAll("GeV/c","");
00098 pngName.ReplaceAll(".","_");
00099 pngName.ReplaceAll("/","_");
00100 pngName.ReplaceAll("^","_");
00101 pngName.ReplaceAll("__","_");
00102 pngName.ReplaceAll("__","_");
00103 pngName += ".png";
00104 TVirtualX::Instance()->WritePixmap(c->GetCanvasID(),-1,-1,(Char_t *)pngName.Data());
00105 nPng++;
00106 cout << "Draw #\t" << nPng << "\t" << pngName << endl;
00107 }
00108 }
00109
00110 void DrawpTdif(const Char_t *plot = "pTDiff") {
00111 TString Plot(plot);
00112 TString c1tit = Plot;
00113 Double_t yMin[2] = { 99999., 99999.};
00114 Double_t yMax[2] = {-99999., -99999.};
00115 Double_t xmin = 0;
00116 Double_t xmax = 2.5;
00117 TFile *f = 0;
00118 for (Int_t c = 0; c < 2; c++) {
00119 for (Int_t k = 1; k >= 0; k--) {
00120 f = fIn[k];
00121 if (! f) continue;
00122 cout << "File \t" << f->GetName() << endl;
00123 TString name = Plot; name += charge[c];
00124 f->cd();
00125 TH2D * pTDiff = (TH2D*) f->Get(name);
00126 if (! pTDiff) continue;
00127 pTDiff->FitSlicesY();
00128 TString Mu(name); Mu += "_1";
00129 TString Sigma(name); Sigma += "_2";
00130 TH1D *mu = (TH1D*)gDirectory->Get(Mu);
00131 TH1D *sigma = (TH1D*)gDirectory->Get(Sigma);
00132 if (! mu || ! sigma) continue;
00133 Int_t nx = mu->GetNbinsX();
00134 for (Int_t i = 1; i <= nx; i++) {
00135 Double_t x = mu->GetBinCenter(i);
00136 if (x < xmin || x > xmax) continue;
00137 Double_t y = mu->GetBinContent(i);
00138 Double_t dy = TMath::Abs(mu->GetBinError(i));
00139 if (dy > 0 && TMath::Abs(y) > dy) {
00140 if (y - dy < yMin[0]) yMin[0] = y - dy;
00141 if (y + dy > yMax[0]) yMax[0] = y + dy;
00142 }
00143
00144 y = sigma->GetBinContent(i);
00145 dy = TMath::Abs(sigma->GetBinError(i));
00146 if (dy > 0 && TMath::Abs(y) > dy) {
00147 if (y - dy < yMin[1]) yMin[1] = y - dy;
00148 if (y + dy > yMax[1]) yMax[1] = y + dy;
00149 }
00150
00151 }
00152 }
00153 }
00154
00155
00156 for (Int_t i = 0; i < 2; i++) {
00157 if (yMin[i] < 0) yMin[i] *= 1.1; else yMin[i] *= 0.9;
00158 if (yMax[i] > 0) yMax[i] *= 1.1; else yMax[i] *= 0.9;
00159 }
00160 TCanvas *c1 = new TCanvas(c1tit,c1tit,400,400);
00161 TString c2tit = c1tit;
00162 c2tit += "Sigma";
00163 TCanvas *c2 = new TCanvas(c2tit,c2tit,400,400);
00164 TString same1("e");
00165 TString same2("e");
00166 TString title1, title2;
00167 Double_t scale = 1.e3;
00168 TLegend *l1 = 0;
00169 TLegend *l2 = 0;
00170 if (Plot == "pTDiff" || Plot == "pTDifGl") {
00171 l1 = new TLegend(.2,.15,.35,.35);
00172 l1->SetBorderSize(0);
00173 l1->SetFillColor(0);
00174 l1->SetTextSize(0.033);
00175 l2 = new TLegend(.2,.65,.45,.85);
00176 l2->SetBorderSize(0);
00177 l2->SetFillColor(0);
00178 l2->SetTextSize(0.033);
00179 Double_t ymin = -20; Double_t ymax = 5;
00180 title1 = "pT diff. #Delta p_{T} (MeV/c) for ";
00181 title2 = "sigma of pT diff.#sigma #Delta p_{T} (MeV/c) for ";
00182 if (Plot == "pTDifGl") {
00183 title1 += "Globals"; title2 += "Globals";
00184 } else {
00185 title1 += "Primaries"; title2 += "Primaries";
00186 }
00187 if (scale*yMin[0] > ymin) ymin = scale*yMin[0];
00188 if (scale*yMax[0] < ymax) ymax = scale*yMax[0];
00189 c1->cd();
00190 if (Plot == "pTDifGl") {ymin = -10; ymax = 2.;}
00191 else {ymin = -15.; ymax = 5;}
00192 TH1F *dummy = c1->DrawFrame(xmin ,ymin, xmax,ymax, title1);
00193 dummy->SetName("hframe1");
00194 dummy->SetXTitle("p_{TMc} (GeV/c)");
00195 dummy->SetYTitle("Delta p_{T} MeV/c");
00196 if (scale*yMin[1] > ymin) ymin = scale*yMin[1];
00197 if (scale*yMax[1] < ymax) ymax = scale*yMax[1];
00198 ymin = 0; ymax = 50;
00199 dummy->Draw();
00200 c2->cd();
00201 if (Plot == "pTDifGl") {ymin = 0; ymax = 50.;}
00202 TH1F *dummy2 = c2->DrawFrame(xmin ,ymin, xmax,ymax,title2);
00203 dummy2->SetName("hframe2");
00204 dummy2->SetXTitle("p_{TMc} (GeV/c)");
00205 dummy2->SetYTitle("sigma Delta p_{T} [MeV/c]");
00206 dummy2->Draw();
00207 } else if (Plot == "pTRel" || Plot == "pTRelGl") {
00208 l1 = new TLegend(.6,.20,.8,.45);
00209 l1->SetBorderSize(0);
00210 l1->SetFillColor(0);
00211 l1->SetTextSize(0.033);
00212 l2 = new TLegend(.2,.65,.45,.90);
00213 l2->SetBorderSize(0);
00214 l2->SetFillColor(0);
00215 l2->SetTextSize(0.033);
00216 scale = 1e2;
00217 Double_t ymin = -5; Double_t ymax = 1;
00218 title1 = "Relative pT diff.#delta p_{T} (%) for ";
00219 title2 = "sigma of relative pT diff. #sigma #delta p_{T} (%) for ";
00220 if (Plot == "pTRelGl") {
00221 title1 += "Globals"; title2 += "Globals";
00222 } else {
00223 title1 += "Primaries"; title2 += "Primaries";
00224 }
00225 if (scale*yMin[0] > ymin) ymin = scale*yMin[0];
00226 if (scale*yMax[0] < ymax) ymax = scale*yMax[0];
00227 c1->cd();
00228 if (Plot == "pTRelGl") {ymin = -5.; ymax = 1;}
00229 else {ymin = -2.; ymax = 0.5;}
00230 TH1F *dummy = c1->DrawFrame(xmin ,ymin, xmax,ymax, title1);
00231 dummy->SetName(c1->GetName());
00232 dummy->SetXTitle("p_{TMc} (GeV/c)");
00233 dummy->SetYTitle("#delta p_{T} [%]");
00234 dummy->Draw();
00235 c2->cd();
00236 if (scale*yMin[1] > ymin) ymin = scale*yMin[1];
00237 if (scale*yMax[1] < ymax) ymax = scale*yMax[1];
00238 ymin = 0; ymax = 5;
00239 TH1F *dummy2 = c2->DrawFrame(xmin ,ymin, xmax,ymax, title2);
00240 dummy2->SetName(c2->GetName());
00241 dummy2->SetXTitle("p_{TMc} (GeV/c)");
00242 dummy2->SetYTitle("sigma delta p_{T}) [%]");
00243 dummy2->Draw();
00244 } else return;
00245 TString opt("e");
00246 for (Int_t c = 0; c < 2; c++) {
00247 for (Int_t k = 1; k >= 0; k--) {
00248 f = fIn[k];
00249 if (! f) continue;
00250 cout << "File \t" << f->GetName() << endl;
00251 TString name = Plot; name += charge[c];
00252 f->cd();
00253 TH2D * pTDiff = (TH2D*) f->Get(name);
00254 if (! pTDiff) continue;
00255 pTDiff->FitSlicesY();
00256 TString Mu(name); Mu += "_1";
00257 TString Sigma(name); Sigma += "_2";
00258 TH1D *mu = (TH1D*)gDirectory->Get(Mu);
00259 TH1D *sigma = (TH1D*)gDirectory->Get(Sigma);
00260 if (! mu || ! sigma) continue;
00261 mu->SetMarkerStyle(21-k);
00262 mu->SetMarkerColor(1+c+2*k);
00263 sigma->SetMarkerStyle(21-k);
00264 sigma->SetMarkerColor(1+c+2*k);
00265 TString caption("pi"); caption += scharge[c];
00266 if (! Mu.Contains("Gl",TString::kIgnoreCase)) caption += " Pr.";
00267 else caption += " Gl.";
00268 caption += Set[k];
00269 cout << mu->GetName() << "\t" << caption << endl;
00270 l1->AddEntry(mu,caption.Data(),"p");
00271 mu->Scale(scale);
00272 c1->cd();
00273 mu->Draw("same");
00274 l2->AddEntry(sigma,caption.Data(),"p");
00275 sigma->Scale(scale);
00276 c2->cd();
00277 sigma->Draw("same");
00278 }
00279 }
00280 c1->cd();
00281 l1->Draw();
00282 c1->Update();
00283 DrawPng(c1);
00284 c2->cd();
00285 l2->Draw();
00286 c2->Update();
00287 DrawPng(c2);
00288 }
00289
00290 void DrawEff() {
00291 #if 1
00292 TCanvas *caneff = new TCanvas("Efficiency","Efficiency");
00293 TH1D * pTMcP = (TH1D*) gDirectory->Get("pTMcP");
00294 TH1D * pTMcN = (TH1D*) gDirectory->Get("pTMcN");
00295 TH1D * pTMcA = (TH1D*) gDirectory->Get("pTMcA");
00296
00297 TH1D * pTGlP = (TH1D*) gDirectory->Get("pTGlP");
00298 TH1D * pTGlN = (TH1D*) gDirectory->Get("pTGlN");
00299 TH1D * pTGlA = (TH1D*) gDirectory->Get("pTGlA");
00300
00301 TH1D * pTPrP = (TH1D*) gDirectory->Get("pTPrP");
00302 TH1D * pTPrN = (TH1D*) gDirectory->Get("pTPrN");
00303 TH1D * pTPrA = (TH1D*) gDirectory->Get("pTPrA");
00304
00305 TH1D *effN = (TH1D *) pTPrN->Clone(); effN->SetName("effN"); effN->Reset();
00306 TH1D *effP = (TH1D *) pTPrP->Clone(); effP->SetName("effP"); effP->Reset();
00307 TH1D *effGlN = (TH1D *) pTGlN->Clone(); effGlN->SetName("effGlN");effGlN->Reset();
00308 TH1D *effGlP = (TH1D *) pTGlP->Clone(); effGlP->SetName("effGlP");effGlP->Reset();
00309 Int_t nx = effN->GetNbinsX();
00310 Double_t val, sum, err;
00311 for (Int_t l = 1; l <= nx; l++) {
00312 val = pTPrN->GetBinContent(l);
00313 sum = pTMcN->GetBinContent(l);
00314 if (sum < 1.e-7 || val > sum) {val = 0; err = 0;}
00315 else { val /= sum; err = TMath::Sqrt(val*(1.-val)/sum);}
00316 effN->SetBinContent(l,100.*val);
00317 effN->SetBinError(l,100.*err);
00318
00319 val = pTPrP->GetBinContent(l);
00320 sum = pTMcP->GetBinContent(l);
00321 if (sum < 1.e-7 || val > sum) {val = 0; err = 0;}
00322 else { val /= sum; err = TMath::Sqrt(val*(1.-val)/sum);}
00323 effP->SetBinContent(l,100.*val);
00324 effP->SetBinError(l,100.*err);
00325
00326 val = pTGlN->GetBinContent(l);
00327 sum = pTMcN->GetBinContent(l);
00328 if (sum < 1.e-7 || val > sum) {val = 0; err = 0;}
00329 else { val /= sum; err = TMath::Sqrt(val*(1.-val)/sum);}
00330 effGlN->SetBinContent(l,100.*val);
00331 effGlN->SetBinError(l,100.*err);
00332
00333 val = pTGlP->GetBinContent(l);
00334 sum = pTMcP->GetBinContent(l);
00335 if (sum < 1.e-7 || val > sum) {val = 0; err = 0;}
00336 else { val /= sum; err = TMath::Sqrt(val*(1.-val)/sum);}
00337 effGlP->SetBinContent(l,100.*val);
00338 effGlP->SetBinError(l,100.*err);
00339 }
00340
00341 effP->SetMarkerStyle(28);
00342 effP->SetMarkerColor(4);
00343 effN->SetMarkerStyle(23);
00344 effN->SetMarkerColor(3);
00345 effGlP->SetMarkerStyle(28);
00346 effGlP->SetMarkerColor(7);
00347 effGlN->SetMarkerStyle(23);
00348 effGlN->SetMarkerColor(6);
00349 TString title("Efficiency (%)."); title += effP->GetTitle();
00350 effP->SetTitle(title);
00351 effP->SetXTitle("Mc pT [GeV/c]");
00352 effP->SetYTitle("Efficiency (%)");
00353 TLegend *l4 = new TLegend(.5,.2,0.9,.4);
00354 effP->SetStats(0);
00355 effP->SetAxisRange(0,2);
00356 effP->Draw(); l4->AddEntry(effP,"#pi+ Pr.","p");
00357 effN->Draw("same"); l4->AddEntry(effN,"#pi- Pr.","p");
00358
00359
00360 l4->Draw();
00361 DrawPng(caneff);
00362 #endif
00363 }
00364
00365 void DrawPrimVx() {
00366 Char_t *XYZ[3] = {"X","Y","Z"};
00367 for (Int_t i = 0; i < 3; i++) {
00368 TH1* h = (TH1 *) gDirectory->Get(Form("DifPv%s",XYZ[i]));
00369 if (! h) continue;
00370 TCanvas *c = new TCanvas(Form("PrimaryVertex%sdiff",XYZ[i]),Form("PrimaryVertex%sdiff",XYZ[i]));
00371 h->Draw();
00372 DrawPng(c);
00373 }
00374 }
00375
00376 void Draw(const Char_t *fNameTPT, const Char_t *fNameSTI=0) {
00377 if (fNameTPT) fIn[0] = new TFile(fNameTPT);
00378 if (fNameSTI) fIn[1] = new TFile(fNameSTI);
00379 if (! fIn[0] && ! fIn[1] ) return;
00380 TString tFile;
00381 if (fNameTPT) {tFile = fNameTPT; tFile.ReplaceAll(".root","");}
00382 if (fNameSTI) {tFile = fNameSTI; tFile.ReplaceAll(".root","");}
00383 DrawpTdif("pTDiff");
00384 DrawpTdif("pTDifGl");
00385 DrawpTdif("pTRel");
00386 DrawpTdif("pTRelGl");
00387 DrawEff();
00388 DrawPrimVx();
00389 }
00390
00391
00392 void MiniMcPlots(const Char_t *files="*minimc.root") {
00393 if (! files) return;
00394 TDirIter Dir(files);
00395 TTreeIter iter("StMiniMcTree");
00396 TFile *f = 0;
00397 Int_t NFiles = 0;
00398 Char_t *file = 0;
00399 Char_t *file1 = 0;
00400 while ((file = (Char_t *) Dir.NextFile())) {iter.AddFile(file); NFiles++; file1 = file;}
00401 cout << files << "\twith " << NFiles << " files" << "\t" << file1 << endl;
00402 if (! file1 ) return;
00403 TString pFile(file1);
00404 Int_t i1 = pFile.Index("TbyT/");
00405 if (i1 >= 0) i1 += 5;
00406 else {
00407 i1 = pFile.Index("MC/");
00408 if (i1 >= 0) i1 += 3;
00409 else {
00410 i1 = pFile.Index("./");
00411 if (i1 >= 0) i1 += 2;
00412 else i1 = 0;
00413 }
00414 }
00415 Int_t i2 = pFile.Index(".root");
00416 cout << pFile.Data() << "\t" << i1 << "\t/" << i2 << endl;
00417 TString tFile(pFile.Data()+i1,i2-i1);
00418 tFile.ReplaceAll("/","_"); cout << "Master file\t" << tFile.Data() << endl;
00419 TString Out(tFile);
00420 Out += ".15_20.Plots.root";
00421 TFile *fOut = new TFile(Out.Data(),"recreate");
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 const Float_t &mVertexX = iter("mVertexX");
00441 const Float_t &mVertexY = iter("mVertexY");
00442 const Float_t &mVertexZ = iter("mVertexZ");
00443 const Float_t &mMcVertexX = iter("mMcVertexX");
00444 const Float_t &mMcVertexY = iter("mMcVertexY");
00445 const Float_t &mMcVertexZ = iter("mMcVertexZ");
00446
00447
00448
00449
00450
00451
00452
00453
00454 const Int_t &mNMcTrack = iter("mNMcTrack");
00455 const Int_t &mNMatchedPair = iter("mNMatchedPair");
00456
00457
00458
00459
00460
00461 const Int_t &mMcTracks_ = iter("mMcTracks_");
00462
00463 const Float_t *&mMcTracks_mPtMc = iter("mMcTracks.mPtMc");
00464
00465 const Float_t *&mMcTracks_mEtaMc = iter("mMcTracks.mEtaMc");
00466
00467 const Short_t *&mMcTracks_mNHitMc = iter("mMcTracks.mNHitMc");
00468
00469
00470
00471 const Short_t *&mMcTracks_mGeantId = iter("mMcTracks.mGeantId");
00472
00473
00474
00475 const Short_t *&mMcTracks_mNAssocGl = iter("mMcTracks.mNAssocGl");
00476 const Short_t *&mMcTracks_mNAssocPr = iter("mMcTracks.mNAssocPr");
00477
00478 const Int_t &mMatchedPairs_ = iter("mMatchedPairs_");
00479
00480
00481
00482
00483 const Float_t *&mMatchedPairs_mAvgQuality = iter("mMatchedPairs.mAvgQuality");
00484
00485 const Float_t *&mMatchedPairs_mPtMc = iter("mMatchedPairs.mPtMc");
00486
00487 const Float_t *&mMatchedPairs_mEtaMc = iter("mMatchedPairs.mEtaMc");
00488
00489 const Short_t *&mMatchedPairs_mNHitMc = iter("mMatchedPairs.mNHitMc");
00490
00491
00492
00493 const Short_t *&mMatchedPairs_mGeantId = iter("mMatchedPairs.mGeantId");
00494
00495
00496
00497 const Short_t *&mMatchedPairs_mNAssocGl = iter("mMatchedPairs.mNAssocGl");
00498 const Short_t *&mMatchedPairs_mNAssocPr = iter("mMatchedPairs.mNAssocPr");
00499 const Float_t *&mMatchedPairs_mPtPr = iter("mMatchedPairs.mPtPr");
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 const Float_t *&mMatchedPairs_mPtGl = iter("mMatchedPairs.mPtGl");
00515
00516
00517
00518
00519 const Float_t *&mMatchedPairs_mDcaXYGl = iter("mMatchedPairs.mDcaXYGl");
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536 const Short_t *&mMatchedPairs_mFitPts = iter("mMatchedPairs.mFitPts");
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 TH1D *DifPvX = new TH1D("DifPvX","Difference in X for Rc - Mc positions",100,-0.25,0.25);
00548 TH1D *DifPvY = new TH1D("DifPvY","Difference in Y for Rc - Mc positions",100,-0.25,0.25);
00549 TH1D *DifPvZ = new TH1D("DifPvZ","Difference in Z for Rc - Mc positions",100,-0.25,0.25);
00550 TString Title("");
00551 if (tFile.Contains("tpt",TString::kIgnoreCase)) Title = "TPT :";
00552 else Title = "ITTF:";
00553
00554 Title +=" #eta |<0.5 && McHit>39 FitPts>24 Q>90";
00555 TH2D * pTDiffP = new TH2D("pTDiffP",Title,40,0.,4.,200,-.2,.2);
00556 TH2D * pTDiffN = new TH2D("pTDiffN",Title,40,0.,4.,200,-.2,.2);
00557 TH2D * pTRelP = new TH2D("pTRelP",Title,40,0.,4.,200,-.2,.2);
00558 TH2D * pTRelN = new TH2D("pTRelN",Title,40,0.,4.,200,-.2,.2);
00559
00560 TH2D * pTDifGlP = new TH2D("pTDifGlP",Title,40,0.,4.,200,-.2,.2);
00561 TH2D * pTDifGlN = new TH2D("pTDifGlN",Title,40,0.,4.,200,-.2,.2);
00562 TH2D * pTRelGlP = new TH2D("pTRelGlP",Title,40,0.,4.,200,-.2,.2);
00563 TH2D * pTRelGlN = new TH2D("pTRelGlN",Title,40,0.,4.,200,-.2,.2);
00564
00565 TH2D * dcaP = new TH2D("dcaP",Title,20,0.,4.,120,-3.,3.);
00566 TH2D * dcaN = new TH2D("dcaN",Title,20,0.,4.,120,-3.,3.);
00567
00568 TH1D * pTMcP = new TH1D("pTMcP","pT for MC pion+",100,0.,5.);
00569 TH1D * pTMcN = new TH1D("pTMcN","pT for MC pion-",100,0.,5.);
00570 TH1D * pTMcA = new TH1D("pTMcA","pT for MC all",100,0.,5.);
00571
00572 TH1D * pTPrP = new TH1D("pTPrP","pT for Matched pion+",100,0.,5.);
00573 TH1D * pTPrN = new TH1D("pTPrN","pT for Matched pion-",100,0.,5.);
00574 TH1D * pTPrA = new TH1D("pTPrA","pT for Matched all",100,0.,5.);
00575
00576 TH1D * pTGlP = new TH1D("pTGlP","pT for Global pion+",100,0.,5.);
00577 TH1D * pTGlN = new TH1D("pTGlN","pT for Global pion-",100,0.,5.);
00578 TH1D * pTGlA = new TH1D("pTGlA","pT for Global all",100,0.,5.);
00579
00580 TH1D * EtaMcP = new TH1D("EtaMcP","Eta for MC pion+",100,-2.5,2.5);
00581 TH1D * EtaMcN = new TH1D("EtaMcN","Eta for MC pion-",100,-2.5,2.5);
00582 TH1D * EtaMcA = new TH1D("EtaMcA","Eta for MC all",100,-2.5,2.5);
00583
00584 TH1D * EtaPrP = new TH1D("EtaPrP","Eta for Matched pion+",100,-2.5,2.5);
00585 TH1D * EtaPrN = new TH1D("EtaPrN","Eta for Matched pion-",100,-2.5,2.5);
00586 TH1D * EtaPrA = new TH1D("EtaPrA","Eta for Matched all",100,-2.5,2.5);
00587
00588 TH1D * EtaGlP = new TH1D("EtaGlP","Eta for Global pion+",100,-2.5,2.5);
00589 TH1D * EtaGlN = new TH1D("EtaGlN","Eta for Global pion-",100,-2.5,2.5);
00590 TH1D * EtaGlA = new TH1D("EtaGlA","Eta for Global all",100,-2.5,2.5);
00591
00592
00593 Int_t nread = 0;
00594 while (iter.Next()) {
00595 DifPvX->Fill(mVertexX - mMcVertexX);
00596 DifPvY->Fill(mVertexY - mMcVertexY);
00597 DifPvZ->Fill(mVertexZ - mMcVertexZ);
00598 if (TMath::Abs(mVertexX - mMcVertexX) > 0.25 ||
00599 TMath::Abs(mVertexY - mMcVertexY) > 0.25 ||
00600 TMath::Abs(mVertexZ - mMcVertexZ) > 0.25) continue;
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610 Int_t k;
00611 for (k = 0; k < mNMcTrack; k++) {
00612
00613 Int_t iok = accept(mMcTracks_mPtMc[k],mMcTracks_mEtaMc[k],mMcTracks_mNHitMc[k],mMcTracks_mGeantId[k],-1,-1.,
00614 mMcTracks_mNAssocGl[k],mMcTracks_mNAssocPr[k],1,1);
00615
00616 if (! iok) continue;
00617 pTMcA->Fill(mMcTracks_mPtMc[k]);
00618 EtaMcA->Fill(mMcTracks_mEtaMc[k]);
00619 if (iok < 0) {
00620 pTMcN->Fill(mMcTracks_mPtMc[k]);
00621 EtaMcN->Fill(mMcTracks_mEtaMc[k]);
00622 } else {
00623 pTMcP->Fill(mMcTracks_mPtMc[k]);
00624 EtaMcP->Fill(mMcTracks_mEtaMc[k]);
00625 }
00626 }
00627 for (k = 0; k < mNMatchedPair; k++) {
00628
00629 if (mMatchedPairs_mFitPts[k] < 15) continue;
00630 Int_t iok = accept(mMatchedPairs_mPtMc[k],mMatchedPairs_mEtaMc[k],mMatchedPairs_mNHitMc[k],
00631 mMatchedPairs_mGeantId[k],mMatchedPairs_mFitPts[k],mMatchedPairs_mAvgQuality[k],
00632 mMatchedPairs_mNAssocGl[k],mMatchedPairs_mNAssocPr[k]);
00633
00634 if (! iok) continue;
00635
00636 Double_t EtaMc = mMatchedPairs_mEtaMc[k];
00637 Double_t pTMc = mMatchedPairs_mPtMc[k];
00638 Double_t dif = mMatchedPairs_mPtGl[k]-pTMc;
00639 Double_t rel = dif/pTMc;
00640 EtaGlA->Fill(EtaMc);
00641 pTGlA->Fill(pTMc);
00642 if (iok < 0) {
00643 pTGlN->Fill(pTMc);
00644 EtaGlN->Fill(EtaMc);
00645 pTDifGlN->Fill(pTMc,dif);
00646 pTRelGlN->Fill(pTMc,rel);
00647 } else {
00648 pTGlP->Fill(pTMc);
00649 EtaGlP->Fill(EtaMc);
00650 pTDifGlP->Fill(pTMc,dif);
00651 pTRelGlP->Fill(pTMc,rel);
00652 }
00653
00654 dif = mMatchedPairs_mPtPr[k]-pTMc;
00655 rel = dif/pTMc;
00656 EtaPrA->Fill(EtaMc);
00657 pTPrA->Fill(pTMc);
00658 if (iok < 0) {
00659 pTPrN->Fill(pTMc);
00660 EtaPrN->Fill(EtaMc);
00661 pTDiffN->Fill(pTMc,dif);
00662 pTRelN->Fill(pTMc,rel);
00663 dcaN->Fill(pTMc,mMatchedPairs_mDcaXYGl[k]);
00664 } else {
00665 pTPrP->Fill(pTMc);
00666 EtaPrP->Fill(EtaMc);
00667 pTDiffP->Fill(pTMc,dif);
00668 pTRelP->Fill(pTMc,rel);
00669 dcaP->Fill(pTMc,mMatchedPairs_mDcaXYGl[k]);
00670 }
00671 }
00672 nread++;
00673
00674 if (nread%1000 == 1) cout << "read " << nread << " events" << endl;
00675 }
00676 fOut->Write();
00677 delete fOut;
00678 if (Title.BeginsWith("TPT",TString::kIgnoreCase)) Draw(Out, 0);
00679 else Draw(0, Out);
00680 }