2 // This class is the task to check the
3 // Propagation method used in the
4 // 1. AliExternalTrackParam
7 // Principle - Creates AliExternalTrackParam form 1 Track Refernece -
8 // Propagate it to other
9 // Magnetic filed and the geomtry has to bec
20 #include <TTreeStream.h>
21 #include <AliAnalysisManager.h>
22 #include <AliESDInputHandler.h>
24 #include "AliMCEvent.h"
25 #include "AliMCEventHandler.h"
28 #include "AliMCTrackingTestTask.h"
29 #include "AliGenInfoMaker.h"
33 #include "AliMCInfo.h"
34 #include "AliComparisonObject.h"
35 #include "AliESDRecInfo.h"
36 #include "AliTPCParamSR.h"
37 #include "AliTracker.h"
38 #include "AliTPCseed.h"
45 ClassImp(AliMCTrackingTestTask)
47 //________________________________________________________________________
48 AliMCTrackingTestTask::AliMCTrackingTestTask() :
50 fMCinfo(0), //! MC event handler
58 // Default constructor (should not be used)
62 AliMCTrackingTestTask::AliMCTrackingTestTask(const AliMCTrackingTestTask& /*info*/) :
64 fMCinfo(0), //! MC event handler
73 // Default constructor
79 //________________________________________________________________________
80 AliMCTrackingTestTask::AliMCTrackingTestTask(const char *name) :
81 AliAnalysisTask(name, "AliMCTrackingTestTask"),
82 fMCinfo(0), //! MC event handler
92 // Input slot #0 works with a TChain
93 DefineInput(0, TChain::Class());
94 // Output slot #0 writes into a TList
95 DefineOutput(0, TObjArray::Class());
100 AliMCTrackingTestTask::~AliMCTrackingTestTask(){
104 if (fDebugLevel>0) printf("AliMCTrackingTestTask::~AliMCTrackingTestTask\n");
105 if (fDebugStreamer) delete fDebugStreamer;
110 //________________________________________________________________________
111 void AliMCTrackingTestTask::ConnectInputData(Option_t *)
114 // Connect the input data
117 cout << "AnalysisTaskTPCCluster::ConnectInputData()" << endl;
119 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
121 //Printf("ERROR: Could not read chain from input slot 0");
124 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
126 //Printf("ERROR: Could not get ESDInputHandler");
129 fESD = esdH->GetEvent();
130 //Printf("*** CONNECTED NEW EVENT ****");
133 AliMCEventHandler* mcinfo = (AliMCEventHandler*) (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
134 mcinfo->SetReadTR(kTRUE);
136 fMCinfo = mcinfo->MCEvent();
146 //________________________________________________________________________
147 void AliMCTrackingTestTask::CreateOutputObjects()
150 // Connect the output objects
153 cout << "AnalysisTaskTPCCluster::CreateOutputObjects()" << endl;
158 //________________________________________________________________________
159 void AliMCTrackingTestTask::Exec(Option_t *) {
161 // Execute analysis for current event
165 cout << "AliMCTrackingTestTask::Exec()" << endl;
168 // If MC has been connected
171 cout << "Not MC info\n" << endl;
183 //________________________________________________________________________
184 void AliMCTrackingTestTask::Terminate(Option_t *) {
189 printf("AliMCTrackingTestTask: Terminate() \n");
191 if (fDebugLevel>0) printf("AliMCtrackingTestTask::Terminate\n");
192 if (fDebugStreamer) delete fDebugStreamer;
199 TTreeSRedirector *AliMCTrackingTestTask::GetDebugStreamer(){
201 // Get Debug streamer
202 // In case debug streamer not yet initialized and StreamLevel>0 create new one
204 if (fStreamLevel==0) return 0;
205 if (fDebugStreamer) return fDebugStreamer;
208 dsName+="Debug.root";
209 dsName.ReplaceAll(" ","");
210 fDebugStreamer = new TTreeSRedirector(dsName.Data());
211 return fDebugStreamer;
219 AliExternalTrackParam * AliMCTrackingTestTask::MakeTrack(const AliTrackReference* ref, TParticle*part)
222 // Make track out of the track ref
223 // part - TParticle used to determine chargr
224 // the covariance matrix - equal 0 - starting from ideal MC position
225 Double_t xyz[3]={ref->X(),ref->Y(),ref->Z()};
226 Double_t pxyz[3]={ref->Px(),ref->Py(),ref->Pz()};
228 for (Int_t i=0; i<21;i++) cv[i]=0;
229 if (!part->GetPDG()) return 0;
230 AliExternalTrackParam * param = new AliExternalTrackParam(xyz,pxyz,cv,TMath::Nint(part->GetPDG()->Charge()/3.));
234 Bool_t AliMCTrackingTestTask::PropagateToPoint(AliExternalTrackParam *param, Double_t *xyz, Double_t mass, Float_t step){
236 // Propagate track to point xyz using
237 // AliTracker::PropagateTo functionality
239 // param - track parameters
240 // xyz - position to propagate
241 // mass - particle mass
242 // step - step to be used
243 Double_t radius=TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
244 AliTracker::PropagateTrackTo(param, radius+step, mass, step, kTRUE,0.99);
245 AliTracker::PropagateTrackTo(param, radius+0.5, mass, step*0.1, kTRUE,0.99);
246 Double_t sxyz[3]={0,0,0};
247 AliESDVertex vertex(xyz,sxyz);
248 Bool_t isOK = param->PropagateToDCA(&vertex,AliTracker::GetBz(),10);
253 void AliMCTrackingTestTask::ProcessMCInfo(){
258 TParticle * particle= new TParticle;
259 TClonesArray * trefs = new TClonesArray("AliTrackReference");
260 const Double_t kPcut=0.1;
265 Int_t npart = fMCinfo->GetNumberOfTracks();
266 if (npart==0) return;
267 Double_t vertex[4]={0,0,0,0};
268 fMCinfo->GetParticleAndTR(0, particle, trefs);
270 vertex[0]=particle->Vx();
271 vertex[1]=particle->Vy();
272 vertex[2]=particle->Vz();
273 vertex[3]=particle->R();
278 for (Int_t ipart=0;ipart<npart;ipart++){
279 Int_t status = fMCinfo->GetParticleAndTR(ipart, particle, trefs);
280 if (status<0) continue;
281 if (!particle) continue;
282 if (!trefs) continue;
283 Int_t nref = trefs->GetEntries();
284 if (nref<5) continue;
285 AliTrackReference * tpcIn=0;
286 AliTrackReference * tpcOut=0;
287 AliTrackReference * trdIn=0;
288 AliTrackReference * trdOut=0;
289 AliTrackReference * itsIn=0;
290 AliTrackReference * itsOut=0;
293 for (Int_t iref=0;iref<nref;iref++){
294 AliTrackReference * ref = (AliTrackReference*)trefs->At(iref);
297 Float_t dir = ref->X()*ref->Px()+ref->Y()*ref->Py();
299 if (dir<0) break; // oposite direction - looping track - return back
300 if (ref->P()<kPcut) continue;
301 if (ref->R()<rmax) break;
302 //if (ref->R()<rmin) break;
304 if (ref->DetectorId()==AliTrackReference::kTPC){
308 if (ref->R()>tpcIn->R()) tpcOut = ref;
312 if (ref->DetectorId()==AliTrackReference::kITS){
316 if (ref->R()>itsIn->R()) itsOut = ref;
320 if (ref->DetectorId()==AliTrackReference::kTRD){
324 if (ref->R()>trdIn->R()) trdOut = ref;
327 if (ref->R()<rmin) rmin=ref->R();
328 if (ref->R()>rmax) rmax=ref->R();
330 if (tpcIn && tpcOut) {
331 ProcessRefTracker(tpcIn,tpcOut,particle,1);
332 ProcessRefTracker(tpcIn,tpcOut,particle,3);
334 if (itsIn && itsOut) ProcessRefTracker(itsIn,itsOut,particle,0);
335 if (trdIn && trdOut) ProcessRefTracker(trdIn,trdOut,particle,2);
341 void AliMCTrackingTestTask::ProcessRefTracker(AliTrackReference* refIn, AliTrackReference* refOut, TParticle*part,Int_t type){
343 // Test propagation from In to out
345 AliExternalTrackParam *param = 0;
346 AliExternalTrackParam *paramMC = 0;
347 Double_t xyzIn[3]={refIn->X(),refIn->Y(), refIn->Z()};
348 Double_t mass = part->GetMass();
351 param=MakeTrack(refOut,part);
352 paramMC=MakeTrack(refOut,part);
354 if (type<3) PropagateToPoint(param,xyzIn, mass, step);
357 seed.Set(param->GetX(),param->GetAlpha(),param->GetParameter(),param->GetCovariance());
358 Float_t alpha= TMath::ATan2(refIn->Y(),refIn->X());
359 seed.Rotate(alpha-seed.GetAlpha());
361 for (Float_t xlayer= seed.GetX(); xlayer>refIn->R(); xlayer-=step){
362 seed.PropagateTo(xlayer);
364 seed.PropagateTo(refIn->R());
365 param->Set(seed.GetX(),seed.GetAlpha(),seed.GetParameter(),seed.GetCovariance());
367 TTreeSRedirector *pcstream = GetDebugStreamer();
370 param->GetXYZ(gpos.GetMatrixArray());
371 param->GetPxPyPz(gmom.GetMatrixArray());
389 void AliMCTrackingTestTask::FinishTaskOutput()
392 // According description in AliAnalisysTask this method is call
393 // on the slaves before sending data
396 gSystem->Exec("pwd");
397 RegisterDebugOutput();
402 void AliMCTrackingTestTask::RegisterDebugOutput(){
407 // store - copy debug output to the destination position
408 // currently ONLY for local copy
411 dsName+="Debug.root";
412 dsName.ReplaceAll(" ","");
413 TString dsName2=fDebugOutputPath.Data();
414 gSystem->MakeDirectory(dsName2.Data());
415 dsName2+=gSystem->HostName();
416 gSystem->MakeDirectory(dsName2.Data());
418 dsName2+=gSystem->BaseName(gSystem->pwd());
420 gSystem->MakeDirectory(dsName2.Data());
422 AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data()));
423 printf("copy %s\t%s\n",dsName.Data(),dsName2.Data());
424 TFile::Cp(dsName.Data(),dsName2.Data());
429 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
430 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
431 AliXRDPROOFtoolkit tool;
432 TChain * chain = tool.MakeChain("mctracking.txt","MC",0,100);
436 chain->SetAlias("pdg","(p.fPdgCode)");
437 chain->SetAlias("dPRec","(refOut.P()-par.P())/refIn.P()");
438 chain->SetAlias("dPMC","(refOut.P()-refIn.P())/refIn->P()");
439 chain->SetAlias("dPtRec","(refOut.Pt()-par.Pt())/refIn.Pt()");
440 chain->SetAlias("dPtMC","(refOut.Pt()-refIn.Pt())/refIn->Pt()");
444 chain->Draw("-sqrt(dPRec):-sqrt(dPMC)","abs(pdg)!=11&&type==0&&p.Pt()<0.5&&abs(p.R())<1&&abs(refOut.fZ)<220");
445 htemp->SetYTitle("#sqrt{#DeltaP_{rec}/P}");
446 htemp->SetXTitle("#sqrt{#DeltaP_{mc}/P}");
447 gPad->SaveAs("picLoss/dPcorr_ITS_step1.gif");
448 gPad->SaveAs("picLoss/dPcorr_ITS_step1.eps");
450 chain->Draw("-sqrt(dPRec):-sqrt(dPMC)","abs(pdg)!=11&&type==1&&p.Pt()<0.5&&abs(p.R())<1&&abs(refOut.fZ)<220");
451 htemp->SetYTitle("#sqrt{#DeltaP_{rec}/P}");
452 htemp->SetXTitle("#sqrt{#DeltaP_{mc}/P}");
453 gPad->SaveAs("picLoss/dPcorr_TPC_step1.gif");
454 gPad->SaveAs("picLoss/dPcorr_TPC_step1.eps");
457 chain->Draw("-sqrt(dPRec):-sqrt(dPMC)","abs(pdg)!=11&&type==3&&p.Pt()<0.5&&abs(p.R())<1&&abs(refOut.fZ)<220");
458 htemp->SetYTitle("#sqrt{#DeltaP_{rec}/P}");
459 htemp->SetXTitle("#sqrt{#DeltaP_{mc}/P}");
460 gPad->SaveAs("picLoss/dPcorr_TPCseed_step1.gif");
461 gPad->SaveAs("picLoss/dPcorr_TPCseed_step1.eps");
465 chain->Draw("-sqrt(dPRec):-sqrt(dPMC)","abs(pdg)!=11&&type==2&&p.Pt()<0.5&&abs(p.R())<1&&abs(refOut.fZ)<220");
466 htemp->SetYTitle("#sqrt{#DeltaP_{rec}/P}");
467 htemp->SetXTitle("#sqrt{#DeltaP_{mc}/P}");
468 gPad->SaveAs("picLoss/dPcorr_TRD_step1.gif");
469 gPad->SaveAs("picLoss/dPcorr_TRD_step1.eps");
474 chain->Draw("(par.Pt()-refIn.Pt())/refIn.Pt()>>his(100,-0.02,0.02)","abs(pdg)!=11&&type==3&&p.Pt()<0.5&&abs(p.R())<1&&abs(refOut.fZ)<220");
475 his->SetXTitle("(P_{trec}-P_{tmc})/P_{tmc}");
476 gPad->SaveAs("picLoss/dPtcorr_TPCseed_step1_1D.eps");
477 gPad->SaveAs("picLoss/dPtcorr_TPCseed_step1_1D.gif");
479 chain->Draw("(par.P()-refIn.P())/refIn.P()>>his(100,-0.02,0.02)","abs(pdg)!=11&&type==3&&p.Pt()<0.5&&abs(p.R())<1&&abs(refOut.fZ)<220");
480 his->SetXTitle("(P_{rec}-P_{mc})/P_{mc}");
481 gPad->SaveAs("picLoss/dPcorr_TPCseed_step1_1D.eps");
482 gPad->SaveAs("picLoss/dPcorr_TPCseed_step1_1D.gif");