00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015 #ifndef __CINT__
00016 #include "TROOT.h"
00017 #include "TSystem.h"
00018 #include <iostream.h>
00019 #include "TH1.h"
00020 #include "TH2.h"
00021 #include "TH3.h"
00022 #include "TFile.h"
00023 #include "TTree.h"
00024 #include "TChain.h"
00025 #include "TTreeHelper.h"
00026 #endif
00027
00028 void scan_embed_mc(Int_t id=9){
00029
00030
00031
00032 float VZCut = 25;
00033 float yCut = 0.5;
00034 float NFitCut = 25;
00035 int NCommCut= 10;
00036
00037
00038
00039 int nchNch = 200; float maxNch=1000;
00040
00041 int nchPt = 80; float maxPt = 15.0;
00042
00043 int nchNhits= 50; float minNhits = 0.; float maxNhits = 50.;
00044
00045 int nchDca = 100; float maxDca = 3.;
00046
00047 float maxDedx = 20.;
00048
00049 float mass2;
00050
00051 if (id == 8) { TString tag = "PiPlus"; mass2 = 0.019;}
00052 if (id == 9) { TString tag = "PiMinus"; mass2 = 0.019;}
00053 if (id == 11) { TString tag = "KPlus"; mass2 = 0.245;}
00054 if (id == 12) { TString tag = "KMinus"; mass2 = 0.245;}
00055 if (id == 14) { TString tag = "Proton"; mass2 = 0.880;}
00056 if (id == 15) { TString tag = "Pbar"; mass2 = 0.880;}
00057 if (id == 50) { TString tag = "Phi"; mass2 = 1.020;}
00058 if (id == 2) { TString tag = "Eplus"; mass2 = 0.511;}
00059
00060
00061
00062 TString filePathMC;
00063
00064 filePath="~/Phi_101/Mini_Mc/*root";
00065
00066 cout <<filePath<<endl;
00067
00068
00069
00070 TString oFile;
00071
00072 oFile="~/outputs/Phi/out_scan_embed_mc_"+tag+"1.root";
00073
00074
00075
00076 TTreeHelper TH("StMiniMcTree");
00077 TH.AddFile(filePath);
00078
00079
00080
00081
00082 TH1D* hMult=new TH1D("hMult","Multiplicity",1000,0,maxNch);
00083
00084 TH1D* nChTotal = new TH1D("nChTotal", "nCharged Distribution", 1200, 0, maxNch);
00085 TH2F* dedx = new TH2F("dedx", "de/dx vs P", 500, 0.0, maxPt, 400, 0., maxDedx);
00086 TH3D* hDca = new TH3D("hDca3","Nch:Pt:Dca",nchNch,0,maxNch,nchPt,0,maxPt,nchDca,0, maxDca);
00087 TH3D* hNfit = new TH3D("hNfit3","Nch:Pt:Nhits",nchNch,0,maxNch,nchPt,0,maxPt,nchNhits,0,maxNhits);
00088
00089
00090
00091 TH1D* vz = new TH1D("vz","Vertex Z",200,0.-50.,50.0);
00092 TH2D* v_xy = new TH2D("vxy", "Vertez_X_Y", 200, -3.0, 3., 400, -3.0, 3.);
00093
00094 TH1D* dvz = new TH1D("dvz","Delta Vertex Z MC - Reco",50,0.-5.,5.0);
00095 TH1D* dvx = new TH1D("dvx","Delat Vertex X MC - Reco",50,0.-5.,5.0);
00096 TH1D* dvy = new TH1D("dvy","Delta Vertex Y Mc - Reco",50,0.-5.,5.0);
00097
00098
00099
00100 TH1D* hPtMc =new TH1D("PtMc","Pt_Mc",400,0,20);
00101 TH1D* hEtaMc =new TH1D("EtaMc","Eta_Mc",200,-1.8,1.8);
00102 TH1D* hPhiMc =new TH1D("PhiMc","Phi_Mc",200,-5.0,5.0);
00103
00104
00105
00106
00107 TH1D* hPtPrMatched = new TH1D("PtPrMatched","Pt_Pr",400,0,20);
00108 TH1D* hEtaPrMatched = new TH1D("EtaPrMatched","EtaPr",200,-1.8,1.8);
00109 TH1D* hPhiPrMatched = new TH1D("PhiPrMatched","PhiPr",200,-5.0,5.0);
00110
00111
00112
00113 TH2D* hPtM_E_Pr =new TH2D("hPtM_E_Pr",title,100,0,10,200,-0.1,0.1);
00114 TH2D* hPtM_E_Gl =new TH2D("hPtM_E_Gl",title,100,0,10,200,-0.1,0.1);
00115
00116
00117
00118 const Int_t &nch = TH("mNUncorrectedPrimaries");
00119 const Float_t &VX = TH("mVertexX");
00120 const Float_t &VY = TH("mVertexY");
00121 const Float_t &VZ = TH("mVertexZ");
00122
00123 const Float_t &VXmc = TH("mMcVertexX");
00124 const Float_t &VYmc = TH("mMcVertexY");
00125 const Float_t &VZmc = TH("mMcVertexZ");
00126
00127
00128
00129
00130 const Int_t &ntrk1 = TH ("mMcTracks");
00131
00132 const Float_t *&PtMc = TH("mMcTracks.mPtMc");
00133 const Float_t *&PzMc = TH("mMcTracks.mPzMc");
00134 const Float_t *&NHits = TH("mMcTracks.mNHitMc");
00135 const Float_t *&EtaMc = TH("mMcTracks.mEtaMc");
00136 const Float_t *&PhiMc = TH("mMcTracks.mPhiMc");
00137
00138
00139
00140
00141
00142
00143 const Int_t &ntrk = TH("mMatchedPairs");
00144
00145 const Float_t *&PtPrMatched = TH("mMatchedPairs.mPtPr");
00146 const Float_t *&PzPrMatched = TH("mMatchedPairs.mPzPr");
00147 const Float_t *&EtaPrMatched = TH("mMatchedPairs.mEtaPr");
00148 const Float_t *&PhiPrMatched= TH("mMatchedPairs.mPhiPr");
00149
00150 const Float_t *&PtMcMatched = TH("mMatchedPairs.mPtMc");
00151 const Float_t *&PzMcMatched = TH("mMatchedPairs.mPzMc");
00152 const Float_t *&EtaMcMatched = TH("mMatchedPairs.mEtaMc");
00153 const Float_t *&PhiMcMatched= TH("mMatchedPairs.mPhiMc");
00154
00155 const Float_t *&PtGlMatched= TH("mMatchedPairs.mPtGl");
00156 const Float_t *&PzGlMatched= TH("mMatchedPairs.mPzGl");
00157 const Float_t *&EtaGlMatched = TH("mMatchedPairs.mEtaMGl");
00158 const Float_t *&PhiGlMatched = TH("mMatchedPairs.mPhiMGl");
00159
00160
00161 const Float_t *&dEdx = TH("mMatchedPairs.mDedx");
00162 const Float_t *&Dca = TH("mMatchedPairs.mDcaGl");
00163 const Short_t *&NFit = TH("mMatchedPairs.mFitPts");
00164 const Short_t *&NComm = TH("mMatchedPairs.mNCommonHit");
00165
00166 const Short_t *&GidMatched = TH("mMatchedPairs.mGeantId");
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 int ev = 0;
00216 while(TH.Next())
00217 {
00218
00219 vz->Fill(VZ);
00220
00221
00222 vxy->Fill(VX,VY);
00223
00224 dvz->Fill(VZ-VZmc);
00225 dvx->Fill(VX-VXmc);
00226 dvy->Fill(VY-VYmc);
00227
00228 if(fabs(VZ)> VZCut) continue;
00229 ev++;
00230
00231 for (Int_t itr=0; itr<ntrk; itr++)
00232 {
00233
00234 hMult ->Fill();
00235
00236 if ( GidMatched[itr]!=11 && GidMatched[itr]!=12) continue;
00237
00238 if (fabs(EtaPrMatched[itr]) > yCut) continue;
00239
00240
00241
00242 float p = sqrt(PtPrMatched[itr]*PtPrMatched[itr]+PzPrMatched[itr]*PzPrMatched[itr]);
00243
00244
00245 if (NFit[itr] >= NFitCut && NComm[itr] > NCommCut)
00246 hDca->Fill(nch, PtPrMatched[itr],Dca[itr]);
00247
00248 if (Dca[itr] < maxDca && (1.*(NFit[itr])/NComm[itr]) < 2.5)
00249 hNfit ->Fill(nch, PtPrMatched[itr], NFit[itr]);
00250
00251 if( Dca[itr] < maxDca && NFit[itr] >= NFitCut && fabs(EtaPrMatched[itr])< yCut)
00252 dedx->Fill(p,dEdx[itr]*1e6);
00253
00254
00255
00256 if(NFit[itr] >= NFitCut && NComm[itr] > NCommCut && Dca[itr] < maxDca )
00257 {
00258 v_xy->Fill(VX[itr], VY[itr]);
00259 hPtPrMatched->Fill(PtPrMatched[itr]);
00260 hEtaPrMatched->Fill(EtaPrMatched[itr]);
00261 hPhiPrMatched->Fill(PhiPrMatched[itr]);
00262 }
00263 }
00264
00265
00266
00267 for (int itr1=0; itr1 < ntrk1; itr1++)
00268 {
00269 if (fabs(EtaM[itr]) > yCut) continue;
00270
00271 hPtMc->Fill(PtMc[itr1]);
00272 hEtaMc->Fill(EtaMc[itr]);
00273 hPhiMc->Fill(PhiMc[itr]);
00274 }
00275
00276 }
00277
00278
00279
00280
00281
00282
00283 TTreeHelper THmu("MuDst");
00284
00285 THmu.AddFile(filePathR);
00286
00287
00288 TH1D* nChTotalR = new TH1D("nChTotalR", "nCharged Distribution", 1200, 0, 1200);
00289 TH2F* dedxR = new TH2F("dedxR", "de/dx vs P", 500, 0.0, 4., 400, 0., 20);
00290 TH1D* hDcax=new TH1D("hDcax", "Distance of Closest Approach x", 1000, 0, 5);
00291 TH1D* hDcay=new TH1D("hDcay", "Distance of Closest Approach y", 1000, 0, 5);
00292 TH1D* hDcaz=new TH1D("hDcaz", "Distance of Closest Approach z", 1000, 0, 5);
00293 TH3D* hDcaR=new TH3D("hDcaR","Nch:Pt:Dca",nchNch,0,maxNch,nchPt,0,maxPt,nchDca,0, maxDca);
00294 TH3D* hNfitR = new TH3D("hNfitR","Nch:Pt:Nhits",nchNch,0,maxNch,nchPt,0,maxPt,nchNhits,minNhits,maxNhits);
00295 TH1D* hNSigmaPi=new TH1D("hNSigmaPi","Sigma Pion",1000,0,1000);
00296 TH1D* hNSigmaK=new TH1D("hNSigmaK","Sigma Kaon",1000,0,1000);
00297 TH1D* hNSigmaP=new TH1D("hNSigmaP","Sigma Proton",1000,0,1000);
00298
00299
00300 const UShort_t *&nNeg= THmu("MuEvent.mRefMultNeg");
00301 const UShort_t *&nPos= THmu("MuEvent.mRefMultPos");
00302
00303 const Float_t *&VX1 = THmu("MuEvent.mEventSummary.mPrimaryVertexPos.mX1");
00304 const Float_t *&VY1 = THmu("MuEvent.mEventSummary.mPrimaryVertexPos.mX2");
00305 const Float_t *&VZ1 = THmu("MuEvent.mEventSummary.mPrimaryVertexPos.mX3");
00306
00307 const Int_t &ntrk1 = THmu("PrimaryTracks");
00308
00309 const Float_t *&dEdxR = THmu("PrimaryTracks.mdEdx");
00310 const Float_t *&Pt1 = THmu("PrimaryTracks.mPt");
00311 const Float_t *&Eta1 = THmu("PrimaryTracks.mEta");
00312
00313 const Float_t *&dcax1 = THmu("PrimaryTracks.mDCAGlobal.mX1");
00314 const Float_t *&dcay1 = THmu("PrimaryTracks.mDCAGlobal.mX2");
00315 const Float_t *&dcaz1 = THmu("PrimaryTracks.mDCAGlobal.mX3");
00316
00317 const UChar_t *&NHits1 = THmu("PrimaryTracks.mNHits");
00318 const Int_t *&NSigmaPion = THmu("PrimaryTracks.mNSigmaPion");
00319 const Int_t *&NSigmaKaon = THmu("PrimaryTracks.mNSigmaKaon");
00320 const Int_t *&NSigmaProton = THmu("PrimaryTracks.mNSigmaProton");
00321
00322
00323 if (id == 8 || id == 9)
00324 {const Int_t *&NSigma = THmu("PrimaryTracks.mNSigmaPion"); }
00325
00326 if (id == 11|| id ==12)
00327 {const Int_t *&NSigma = THmu("PrimaryTracks.mNSigmaKaon"); }
00328
00329 if (id == 14|| id ==15)
00330 {const Int_t *&NSigma = THmu("PrimaryTracks.mNSigmaProton"); }
00331
00332
00333
00334
00335
00336 int ev = 0;
00337 while(THmu.Next() )
00338 {
00339 hMult->Fill(*nPos + *nNeg);
00340
00341 for (Int_t itr=0; itr<ntrk1; itr++)
00342 {
00343 ev++;
00344
00345
00346
00347 if(fabs(*VZ1)>25.) continue;
00348
00349 float dca = sqrt(dcax1[itr]*dcax1[itr]+dcay1[itr]*dcay1[itr]+dcaz1[itr]*dcaz1[itr]);
00350 float p_r = Pt1[itr]*cosh(Eta1[itr]);
00351
00352 hDcax->Fill(dcax1[itr]);
00353 hDcay->Fill(dcay1[itr]);
00354 hDcaz->Fill(dcaz1[itr]);
00355
00356 hNSigmaPi->Fill(NSigmaPion[itr]);
00357 hNSigmaK->Fill(NSigmaKaon[itr]);
00358 hNSigmaP->Fill(NSigmaProton[itr]);
00359
00360
00361
00362 if (fabs(Eta1[itr]) >0.5) continue;
00363
00364 if(NHits1[itr]>= 25)
00365 hDcaR->Fill((*nNeg +*nPos), Pt1[itr],dca);
00366
00367
00368
00369
00370 if (dca < 3)
00371 hNfitR ->Fill(*nNeg +*nPos, Pt1[itr], NHits1[itr]);
00372
00373
00374
00375
00376 if(dca< 3. && NHits1[itr]>= 25 && fabs(Eta1[itr])< 0.5 && NSigma[itr]/1000 < 2.)
00377 dedxR->Fill(p_r,dEdxR[itr]*1e6);
00378
00379 }
00380 }
00381
00382
00383 cout<< "Creating output file .... "<<oFile; flush(cout);
00384
00385 TFile *fout=new TFile(oFile,"recreate");
00386 fout->cd();
00387
00388
00389
00390 nChTotal->Write();
00391 dedx->Write("dEdx");
00392 hNfit->Write();
00393 hDca-> Write();
00394
00395
00396
00397 v_xy->Write();
00398 vz->Write();
00399
00400 dvx->Write();
00401 dvy->Write();
00402 dvz->Write();
00403
00404 hPtPrMatched->Write();
00405 hEtaPrMatched->Write();
00406 hPhiPrMatched->Write();
00407
00408 hEtaMc->Write();
00409 hPtMc->Write();
00410 hPhiMc->Write();
00411
00412 fout->Close();
00413 cout<<" done"<<endl; flush(cout);
00414 }