]>
Commit | Line | Data |
---|---|---|
006b5f7f | 1 | #ifndef __CINT__ |
c7ee21ca | 2 | #include <iostream.h> |
3 | ||
006b5f7f | 4 | #include "AliRun.h" |
5 | #include "AliITS.h" | |
6 | #include "AliITSgeom.h" | |
7 | #include "AliITSRecPoint.h" | |
8 | #include "AliITSclusterV2.h" | |
006b5f7f | 9 | |
10 | #include "TFile.h" | |
11 | #include "TTree.h" | |
12 | #include "TParticle.h" | |
13 | #endif | |
14 | ||
a9a2d814 | 15 | Int_t AliITSFindClustersV2() { |
006b5f7f | 16 | /**************************************************************** |
a9a2d814 | 17 | * This macro converts AliITSRecPoint(s) to AliITSclusterV2(s) * |
006b5f7f | 18 | ****************************************************************/ |
a9a2d814 | 19 | cerr<<"AliITSRecPoint(s) -> AliITSclusterV2(s)...\n"; |
006b5f7f | 20 | |
21 | if (gAlice) {delete gAlice; gAlice=0;} | |
22 | ||
a9a2d814 | 23 | TFile *in=TFile::Open("galice.root"); |
24 | if (!in->IsOpen()) { cerr<<"Can't open galice.root !\n"; return 1; } | |
25 | ||
006b5f7f | 26 | if (!(gAlice=(AliRun*)in->Get("gAlice"))) { |
27 | cerr<<"Can't find gAlice !\n"; | |
a9a2d814 | 28 | return 2; |
006b5f7f | 29 | } |
006b5f7f | 30 | gAlice->GetEvent(0); |
31 | ||
a9a2d814 | 32 | AliITS *ITS = (AliITS*)gAlice->GetModule("ITS"); |
33 | if (!ITS) { cerr<<"Can't find the ITS !\n"; return 3; } | |
006b5f7f | 34 | AliITSgeom *geom=ITS->GetITSgeom(); |
35 | ||
36 | TFile *out=TFile::Open("AliITSclustersV2.root","new"); | |
37 | if (!out->IsOpen()) { | |
38 | cerr<<"Delete old AliITSclustersV2.root !\n"; | |
a9a2d814 | 39 | return 4; |
006b5f7f | 40 | } |
41 | geom->Write(); | |
42 | ||
43 | TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000); | |
c7ee21ca | 44 | TTree *cTree=new TTree("TreeC_ITS_0","ITS clusters"); |
006b5f7f | 45 | cTree->Branch("Clusters",&clusters); |
46 | ||
47 | TTree *pTree=gAlice->TreeR(); | |
a9a2d814 | 48 | if (!pTree) { cerr<<"Can't get TreeR !\n"; return 5; } |
006b5f7f | 49 | TBranch *branch=pTree->GetBranch("ITSRecPoints"); |
a9a2d814 | 50 | if (!branch) { cerr<<"Can't get ITSRecPoints branch !\n"; return 6; } |
006b5f7f | 51 | TClonesArray *points=new TClonesArray("AliITSRecPoint",10000); |
52 | branch->SetAddress(&points); | |
53 | ||
54 | TClonesArray &cl=*clusters; | |
55 | Int_t nclusters=0; | |
56 | Int_t nentr=(Int_t)pTree->GetEntries(); | |
57 | ||
58 | cerr<<"Number of entries: "<<nentr<<endl; | |
59 | ||
a9a2d814 | 60 | Float_t lp[5]; Int_t lab[6]; //Why can't it be inside a loop ? |
7f6ddf58 | 61 | |
006b5f7f | 62 | for (Int_t i=0; i<nentr; i++) { |
c7ee21ca | 63 | points->Clear(); |
64 | pTree->GetEvent(i); | |
65 | Int_t ncl=points->GetEntriesFast(); if (ncl==0){cTree->Fill();continue;} | |
14825d5a | 66 | Int_t lay,lad,det; geom->GetModuleId(i,lay,lad,det); |
006b5f7f | 67 | Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift); |
68 | Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot); | |
69 | Double_t yshift = x*rot[0] + y*rot[1]; | |
70 | Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1); | |
006b5f7f | 71 | nclusters+=ncl; |
6e35d89b | 72 | |
a9a2d814 | 73 | Float_t kmip=1; // ADC->mip normalization factor for the SDD and SSD |
74 | if(lay==4 || lay==3){kmip=280.;}; | |
75 | if(lay==6 || lay==5){kmip=38.;}; | |
6e35d89b | 76 | |
006b5f7f | 77 | for (Int_t j=0; j<ncl; j++) { |
78 | AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j); | |
a9a2d814 | 79 | //Float_t lp[5]; |
006b5f7f | 80 | lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0]; |
81 | lp[1]=p->GetZ()+zshift; | |
82 | lp[2]=p->GetSigmaX2(); | |
83 | lp[3]=p->GetSigmaZ2(); | |
6e35d89b | 84 | lp[4]=p->GetQ(); lp[4]/=kmip; |
a9a2d814 | 85 | //Int_t lab[6]; |
006b5f7f | 86 | lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2); |
87 | lab[3]=ndet; | |
6e35d89b | 88 | |
a9a2d814 | 89 | Int_t label=lab[0]; |
90 | if (label>=0) { | |
91 | TParticle *part=(TParticle*)gAlice->Particle(label); | |
92 | label=-3; | |
93 | while (part->P() < 0.005) { | |
94 | Int_t m=part->GetFirstMother(); | |
95 | if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;} | |
96 | label=m; | |
97 | part=(TParticle*)gAlice->Particle(label); | |
98 | } | |
99 | if (lab[1]<0) lab[1]=label; | |
100 | else if (lab[2]<0) lab[2]=label; | |
101 | else cerr<<"No empty labels !\n"; | |
102 | } | |
006b5f7f | 103 | |
104 | new(cl[j]) AliITSclusterV2(lab,lp); | |
105 | } | |
106 | cTree->Fill(); clusters->Delete(); | |
6e35d89b | 107 | points->Delete(); |
006b5f7f | 108 | } |
109 | cTree->Write(); | |
110 | ||
111 | cerr<<"Number of clusters: "<<nclusters<<endl; | |
112 | ||
113 | delete cTree; delete clusters; delete points; | |
114 | ||
115 | delete gAlice; gAlice=0; | |
c7ee21ca | 116 | |
006b5f7f | 117 | in->Close(); |
118 | out->Close(); | |
119 | ||
120 | return 0; | |
c7ee21ca | 121 | |
006b5f7f | 122 | } |
123 | ||
124 | ||
125 | ||
126 | ||
127 | ||
128 | ||
129 | ||
130 | ||
131 | ||
132 | ||
133 | ||
134 | ||
135 | ||
136 |