]>
Commit | Line | Data |
---|---|---|
006b5f7f | 1 | #ifndef __CINT__ |
2 | #include "AliRun.h" | |
3 | #include "AliITS.h" | |
4 | #include "AliITSgeom.h" | |
5 | #include "AliITSRecPoint.h" | |
6 | #include "AliITSclusterV2.h" | |
7 | #include "AliITSsimulationFastPoints.h" | |
8 | ||
9 | #include "TFile.h" | |
10 | #include "TTree.h" | |
11 | #include "TParticle.h" | |
12 | #endif | |
13 | ||
14 | Int_t AliITSFindClustersV2() { | |
15 | /**************************************************************** | |
16 | * Just something to start with * | |
17 | ****************************************************************/ | |
18 | cerr<<"Looking for clusters...\n"; | |
19 | ||
20 | if (gAlice) {delete gAlice; gAlice=0;} | |
21 | ||
22 | TFile *in=TFile::Open("galice.root","update"); | |
23 | if (!in->IsOpen()) { | |
24 | cerr<<"Can't open galice.root !\n"; | |
25 | return 1; | |
26 | } | |
27 | ||
28 | if (!(gAlice=(AliRun*)in->Get("gAlice"))) { | |
29 | cerr<<"Can't find gAlice !\n"; | |
30 | return 2; | |
31 | } | |
32 | ||
33 | Int_t ev=0; | |
34 | gAlice->GetEvent(ev); | |
35 | ||
36 | AliITS *ITS = (AliITS*)gAlice->GetModule("ITS"); | |
37 | if (!ITS) { | |
38 | cerr<<"Can't find the ITS !\n"; | |
39 | return 3; | |
40 | } | |
41 | ||
42 | gAlice->MakeTree("R"); | |
43 | ITS->MakeBranch("R",0); | |
44 | gAlice->TreeR()->Fill(); | |
45 | ||
46 | //////////////// Taken from ITSHitsToFastPoints.C /////////////////////// | |
47 | AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints(); | |
48 | for (Int_t i=0;i<3;i++) { ITS->SetSimulationModel(i,sim); } | |
49 | ||
50 | Int_t nsignal=25; | |
51 | Int_t size=-1; | |
52 | Int_t bgr_ev=Int_t(ev/nsignal); | |
53 | ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," "); | |
54 | ////////////////////////////////////////////////////////////////////////// | |
55 | ||
56 | delete gAlice; gAlice=0; | |
57 | in->Close(); | |
58 | ||
59 | ///////////////// Conversion AliITSRecPoint -> AliITSclusterV2 ////////////// | |
60 | /*TFile */in=TFile::Open("galice.root"); | |
61 | ||
62 | if (gAlice) {delete gAlice; gAlice=0;} | |
63 | ||
64 | if (!(gAlice=(AliRun*)in->Get("gAlice"))) { | |
65 | cerr<<"Can't find gAlice !\n"; | |
66 | return 4; | |
67 | } | |
68 | ||
69 | gAlice->GetEvent(0); | |
70 | ||
71 | /*AliITS */ITS = (AliITS*)gAlice->GetModule("ITS"); | |
72 | if (!ITS) { | |
73 | cerr<<"Can't find the ITS !\n"; | |
74 | return 5; | |
75 | } | |
76 | AliITSgeom *geom=ITS->GetITSgeom(); | |
77 | ||
78 | TFile *out=TFile::Open("AliITSclustersV2.root","new"); | |
79 | if (!out->IsOpen()) { | |
80 | cerr<<"Delete old AliITSclustersV2.root !\n"; | |
81 | return 6; | |
82 | } | |
83 | geom->Write(); | |
84 | ||
85 | TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000); | |
86 | TTree *cTree=new TTree("cTree","ITS clusters"); | |
87 | cTree->Branch("Clusters",&clusters); | |
88 | ||
89 | TTree *pTree=gAlice->TreeR(); | |
90 | if (!pTree) { | |
91 | cerr<<"Can't get TreeR !\n"; | |
92 | return 7; | |
93 | } | |
94 | TBranch *branch=pTree->GetBranch("ITSRecPoints"); | |
95 | if (!branch) { | |
96 | cerr<<"Can't get ITSRecPoints branch !\n"; | |
97 | return 8; | |
98 | } | |
99 | TClonesArray *points=new TClonesArray("AliITSRecPoint",10000); | |
100 | branch->SetAddress(&points); | |
101 | ||
102 | TClonesArray &cl=*clusters; | |
103 | Int_t nclusters=0; | |
104 | Int_t nentr=(Int_t)pTree->GetEntries(); | |
105 | ||
106 | cerr<<"Number of entries: "<<nentr<<endl; | |
107 | ||
108 | for (Int_t i=0; i<nentr; i++) { | |
109 | if (!pTree->GetEvent(i)) {cTree->Fill(); continue;} | |
110 | Int_t lay,lad,det; geom->GetModuleId(i-1,lay,lad,det); | |
111 | Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift); | |
112 | Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot); | |
113 | Double_t yshift = x*rot[0] + y*rot[1]; | |
114 | Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1); | |
115 | Int_t ncl=points->GetEntriesFast(); | |
116 | nclusters+=ncl; | |
117 | for (Int_t j=0; j<ncl; j++) { | |
118 | AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j); | |
119 | Float_t lp[5]; | |
120 | lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0]; | |
121 | lp[1]=p->GetZ()+zshift; | |
122 | lp[2]=p->GetSigmaX2(); | |
123 | lp[3]=p->GetSigmaZ2(); | |
124 | lp[4]=p->GetQ(); | |
125 | Int_t lab[6]; | |
126 | lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2); | |
127 | lab[3]=ndet; | |
128 | ||
129 | Int_t label=lab[0]; | |
130 | TParticle *part=(TParticle*)gAlice->Particle(label); | |
131 | label=-3; | |
132 | while (part->P() < 0.005) { | |
133 | Int_t m=part->GetFirstMother(); | |
134 | if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;} | |
135 | label=m; | |
136 | part=(TParticle*)gAlice->Particle(label); | |
137 | } | |
138 | if (lab[1]<0) lab[1]=label; | |
139 | else if (lab[2]<0) lab[2]=label; | |
140 | else cerr<<"No empty labels !\n"; | |
141 | ||
142 | new(cl[j]) AliITSclusterV2(lab,lp); | |
143 | } | |
144 | cTree->Fill(); clusters->Delete(); | |
145 | points->Delete(); | |
146 | } | |
147 | cTree->Write(); | |
148 | ||
149 | cerr<<"Number of clusters: "<<nclusters<<endl; | |
150 | ||
151 | delete cTree; delete clusters; delete points; | |
152 | ||
153 | delete gAlice; gAlice=0; | |
154 | in->Close(); | |
155 | out->Close(); | |
156 | ||
157 | return 0; | |
158 | } | |
159 | ||
160 | ||
161 | ||
162 | ||
163 | ||
164 | ||
165 | ||
166 | ||
167 | ||
168 | ||
169 | ||
170 | ||
171 | ||
172 |