Processing SPD Mean Vertex only in PHYSICS runs.
[u/mrichter/AliRoot.git] / STEER / AliESDPmdTest.C
CommitLineData
561b7b31 1// ----------------------------------------------------//
2// //
3// This macro reads the PMD clusters, //
4// does photon/hadron discrimination //
5// and stores in the ESD //
6// //
7// ----------------------------------------------------//
8
9#include <Riostream.h>
10#include "TBranch.h"
11#include "TStopwatch.h"
12
13extern AliRun *gAlice;
14
15Int_t AliESDPmdTest(Int_t nevent = 1)
16{
17 if (gAlice)
18 {
33c3c91a 19 delete AliRunLoader::Instance();
561b7b31 20 delete gAlice;//if everything was OK here it is already NULL
21 gAlice = 0x0;
22 }
23
24 AliRunLoader *fRunLoader = AliRunLoader::Open("galice.root");
25 if (!fRunLoader)
26 {
27 cerr<<"Can't load RunLoader"<<endl;
28 return 1;
29 }
30 fRunLoader->LoadgAlice();
31 gAlice = fRunLoader->GetAliRun();
32
33 AliLoader *pmdloader = fRunLoader->GetLoader("PMDLoader");
34 // Int_t nevent = fRunLoader->GetNumberOfEvents();
35 cout << " ************ nevent = " << nevent << endl;
36
37 if (pmdloader == 0x0)
38 {
39 cerr<<" ===> Can not find PMD or PMDLoader <===\n";
40 delete fRunLoader;
41 return 2;
42 }
43 pmdloader->LoadRecPoints("READ");
44
45 TFile *bf=TFile::Open("AliESDcheck.root","RECREATE");
46 if (!bf || !bf->IsOpen()) {
47 cerr<<"Can't open AliESDcheck.root !\n"; return 1;
48 }
49
50 Char_t ename[100];
51
52 for (Int_t ievt = 0; ievt < nevent; ievt++)
53 {
54
55 AliESD *event=new AliESD();
56 Int_t run = 0;
57 event->SetRunNumber(run);
58 event->SetEventNumber(ievt);
59
60 fRunLoader->GetEvent(ievt);
61 TTree *treeR = pmdloader->TreeR();
62 if (treeR == 0x0)
63 {
64 cout << " Can not get TreeR" << endl;
65 return 3;
66 }
67 AliPMDtracker *pmdtracker = new AliPMDtracker();
68 pmdtracker->LoadClusters(treeR);
69 pmdtracker->Clusters2Tracks(event);
70
71 bf->cd();
72 sprintf(ename,"in%d",ievt);
73 event->Write(ename); bf->Flush();
74
75 delete pmdtracker;
76 delete event;
77 }
78 bf->Close();
79 return 0;
80}
81