]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: Svein Lindal <slindal@fys.uio.no > * | |
6 | * for The ALICE HLT Project. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /// @file AliHLTEvePhos.cxx | |
18 | /// @author Svein Lindal <slindal@fys.uio.no> | |
19 | /// @brief Muon processor for the HLT EVE display | |
20 | ||
21 | #include "AliHLTEveMuon.h" | |
22 | #include "AliHLTMUONDataBlockReader.h" | |
23 | #include "AliHLTHOMERBlockDesc.h" | |
24 | #include "TCanvas.h" | |
25 | #include "TEveStraightLineSet.h" | |
26 | #include "TEvePointSet.h" | |
27 | #include "AliEveHLTEventManager.h" | |
28 | #include "TEveManager.h" | |
29 | ||
30 | ||
31 | #include "TEveVSDStructs.h" | |
32 | #include "TGeoGlobalMagField.h" | |
33 | #include "AliMUONTrack.h" | |
34 | #include "AliMUONTrackParam.h" | |
35 | #include "AliMUONESDInterface.h" | |
36 | #include "AliMUONVTrackReconstructor.h" | |
37 | #include "AliEveMUONTrack.h" | |
38 | #include "AliHLTMUONConstants.h" | |
39 | #include "AliHLTMUONUtils.h" | |
40 | #include "AliMUONVCluster.h" | |
41 | #include "AliMUONVClusterStore.h" | |
42 | #include "AliMUONConstants.h" | |
43 | #include "TEveTrackPropagator.h" | |
44 | ||
45 | using namespace std; | |
46 | ||
47 | class AliHLTMUONUtils; | |
48 | class AliEveMuonTrack; | |
49 | ||
50 | ClassImp(AliHLTEveMuon); | |
51 | ||
52 | AliHLTEveMuon::AliHLTEveMuon() : | |
53 | AliHLTEveBase("Muon"), | |
54 | fFullTrackList(NULL), | |
55 | fTracks(NULL), | |
56 | fClusters(NULL) | |
57 | { | |
58 | // Constructor. | |
59 | SetMaxHistograms(6); | |
60 | } | |
61 | ||
62 | AliHLTEveMuon::~AliHLTEveMuon() | |
63 | { | |
64 | //Destructor | |
65 | if (fFullTrackList) | |
66 | delete fFullTrackList; | |
67 | fFullTrackList = NULL; | |
68 | ||
69 | if (fTracks) | |
70 | delete fTracks; | |
71 | fTracks = NULL; | |
72 | ||
73 | if(fClusters) | |
74 | delete fClusters; | |
75 | fClusters = NULL; | |
76 | } | |
77 | ||
78 | ||
79 | void AliHLTEveMuon::ProcessBlock(AliHLTHOMERBlockDesc * block) { | |
80 | //See header file for documentation | |
81 | if ( (block->GetDataType().CompareTo("RECHITS") == 0) || (block->GetDataType().CompareTo("TRIGRECS") == 0) ) { | |
82 | if(!fClusters) { | |
83 | fClusters = CreateClusters(); | |
84 | AddElement(fClusters); | |
85 | } | |
86 | ProcessClusters( block, fClusters ); | |
87 | ||
88 | }else if(block->GetDataType().CompareTo("MANTRACK") == 0){ | |
89 | ||
90 | if ( !fTracks ) { | |
91 | fTracks = CreateTrackSet(); | |
92 | AddElement(fTracks); | |
93 | } | |
94 | ||
95 | ProcessTracks( block, fTracks ); | |
96 | ||
97 | }else if(block->GetDataType().CompareTo("TRACKS") == 0){ | |
98 | ||
99 | if ( !fFullTrackList ) { | |
100 | fFullTrackList = CreateFullTrackList(); | |
101 | AddElement(fFullTrackList); | |
102 | } | |
103 | ||
104 | ProcessFullTracks( block, fFullTrackList ); | |
105 | ||
106 | } else if(block->GetDataType().CompareTo("ROOTHIST") == 0) { | |
107 | ProcessHistogram(block); | |
108 | } | |
109 | ||
110 | } | |
111 | ||
112 | TEvePointSet * AliHLTEveMuon::CreateClusters() { | |
113 | //See header file for documentation | |
114 | TEvePointSet * ps = new TEvePointSet("MUON RecHits"); | |
115 | ps->SetMainColor(kBlue); | |
116 | ps->SetMarkerStyle(20); | |
117 | return ps; | |
118 | } | |
119 | ||
120 | TEveStraightLineSet * AliHLTEveMuon::CreateTrackSet() { | |
121 | // See header file | |
122 | TEveStraightLineSet * lineset = new TEveStraightLineSet("MUON Tracks"); | |
123 | lineset->SetMainColor(kRed); | |
124 | lineset->SetLineWidth(3); | |
125 | return lineset; | |
126 | } | |
127 | ||
128 | TEveTrackList * AliHLTEveMuon::CreateFullTrackList(){ | |
129 | // See header file | |
130 | TEveTrackList * lineset = new TEveTrackList("MUON Full Tracks"); | |
131 | lineset->SetMainColor(kBlue); | |
132 | return lineset; | |
133 | } | |
134 | ||
135 | void AliHLTEveMuon::ProcessHistogram(AliHLTHOMERBlockDesc * block ) { | |
136 | //See header file for documentation | |
137 | if(!fCanvas) { | |
138 | fCanvas = CreateCanvas("MUON QA", "MUON QA"); | |
139 | fCanvas->Divide(3, 2); | |
140 | } | |
141 | AddHistogramsToCanvas(block, fCanvas, fHistoCount); | |
142 | } | |
143 | ||
144 | void AliHLTEveMuon::UpdateElements() { | |
145 | //See header file for documentation | |
146 | if(fCanvas) fCanvas->Update(); | |
147 | if(fClusters) fClusters->ResetBBox(); | |
148 | if(fTracks) fTracks->ElementChanged(); | |
149 | } | |
150 | ||
151 | void AliHLTEveMuon::ResetElements(){ | |
152 | //See header file for documentation | |
153 | fHistoCount = 0; | |
154 | ||
155 | if ( fClusters ) fClusters->Reset(); | |
156 | if ( fTracks ){ | |
157 | fTracks->Destroy(); | |
158 | fTracks = NULL; | |
159 | } | |
160 | if ( fFullTrackList ){ | |
161 | fFullTrackList->Destroy(); | |
162 | fFullTrackList = NULL; | |
163 | } | |
164 | ||
165 | ||
166 | } | |
167 | ||
168 | void AliHLTEveMuon::ProcessClusters(AliHLTHOMERBlockDesc * block, TEvePointSet * clusters) { | |
169 | //See header file for documentation | |
170 | unsigned long size = block->GetSize(); | |
171 | Int_t * buffer ; | |
172 | ||
173 | buffer = (Int_t *)block->GetData(); | |
174 | //cout<<"block size : "<<size<<", buffer : "<<buffer<<", DataType : "<<block->GetDataType()<<endl; | |
175 | ||
176 | if(block->GetDataType().CompareTo("RECHITS") == 0){ | |
177 | ||
178 | AliHLTMUONRecHitsBlockReader trackblock((char*)buffer, size); | |
179 | const AliHLTMUONRecHitStruct* hit = trackblock.GetArray(); | |
180 | ||
181 | for(AliHLTUInt32_t ientry = 0; ientry < trackblock.Nentries(); ientry++){ | |
182 | if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0) | |
183 | clusters->SetNextPoint(hit->fX,hit->fY,hit->fZ); | |
184 | hit++; | |
185 | ||
186 | }// track hit loop | |
187 | } | |
188 | ||
189 | else{// if rechits | |
190 | // if(!strcmp((BlockType(ULong64_t(reader->GetBlockDataType(i)))).Data(),"TRIGRECS")){ | |
191 | ||
192 | AliHLTMUONTriggerRecordsBlockReader trigblock(buffer, size); | |
193 | const AliHLTMUONTriggerRecordStruct* trigrec = trigblock.GetArray(); | |
194 | for(AliHLTUInt32_t ientry = 0; ientry < trigblock.Nentries(); ientry++){ | |
195 | ||
196 | const AliHLTMUONRecHitStruct* hit = &trigrec->fHit[0]; | |
197 | for(AliHLTUInt32_t ch = 0; ch < 4; ch++) | |
198 | { | |
199 | if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0) | |
200 | clusters->SetNextPoint(hit->fX,hit->fY,hit->fZ); | |
201 | hit++; | |
202 | }// trig chamber loop | |
203 | trigrec++; | |
204 | }//trig hit loop | |
205 | }//else trigger | |
206 | ||
207 | } | |
208 | ||
209 | void AliHLTEveMuon::ProcessTracks(AliHLTHOMERBlockDesc * block, TEveStraightLineSet * tracks) { | |
210 | //See header file for documentation | |
211 | unsigned long size = block->GetSize(); | |
212 | Int_t * buffer = (Int_t *)block->GetData(); | |
213 | AliHLTMUONRecHitStruct hit1,hit2; | |
214 | hit1.fX = hit1.fY = hit1.fZ = hit2.fX = hit2.fY = hit2.fZ = 0; | |
215 | Int_t ch1=0, ch2=0; | |
216 | Float_t x0=0.0,y0=0.0,z0=0.0; | |
217 | Float_t x3=0.0,y3=0.0,z3=0.0; | |
218 | if(block->GetDataType().CompareTo("MANTRACK") == 0){ | |
219 | AliHLTMUONMansoTracksBlockReader mantrackblock(buffer, size); | |
220 | const AliHLTMUONMansoTrackStruct* mtrack = mantrackblock.GetArray(); | |
221 | for(AliHLTUInt32_t ientry = 0; ientry < mantrackblock.Nentries(); ientry++){ | |
222 | const AliHLTMUONRecHitStruct* hit = &mtrack->fHit[0]; | |
223 | for(AliHLTUInt32_t ch = 0; ch < 4; ch++){ | |
224 | // cout << setw(10) << left << ch + 7 << setw(0); | |
225 | // cout << setw(13) << left << hit->fX << setw(0); | |
226 | // cout << setw(13) << left << hit->fY << setw(0); | |
227 | // cout << hit->fZ << setw(0) << endl; | |
228 | if(hit->fZ != 0.0){ | |
229 | if(ch==0 || ch==1){ | |
230 | hit1 = *hit; ch1 = ch+6; | |
231 | }else{ | |
232 | hit2 = *hit; ch2 = ch+6; | |
233 | } | |
234 | } | |
235 | hit++; | |
236 | }// trig chamber loop | |
237 | // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch1,hit1.fX,hit1.fY,hit1.fZ); | |
238 | // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch2,hit2.fX,hit2.fY,hit2.fZ); | |
239 | // meminfo(); | |
240 | z3 = AliMUONConstants::DefaultChamberZ(ch2+4); | |
241 | y3 = hit1.fY - (hit1.fZ-z3)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ; | |
242 | x3 = hit1.fX - (hit1.fZ-z3)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ; | |
243 | ||
244 | z0 = AliMUONConstants::DefaultChamberZ(ch1); | |
245 | y0 = hit1.fY - (hit1.fZ-z0)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ; | |
246 | x0 = hit1.fX - (hit1.fZ-z0)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ; | |
247 | ||
248 | ||
249 | tracks->AddLine(x0,y0,z0,x3,y3,z3); | |
250 | mtrack++; | |
251 | } | |
252 | // cout<<"NofManso Tracks : "<<mantrackblock.Nentries()<<endl; | |
253 | } | |
254 | } | |
255 | ||
256 | int AliHLTEveMuon::MakeMUONTrack(AliMUONTrack *muonTrack, const AliHLTMUONTrackStruct *muonHLTTrack) | |
257 | { | |
258 | // See header for documentation | |
259 | AliHLTUInt32_t clusterIndex = 0; // for the cluster unique ID. | |
260 | AliHLTMUONParticleSign sign; | |
261 | bool hitset[16]; | |
262 | AliHLTMUONUtils::UnpackTrackFlags( | |
263 | muonHLTTrack->fFlags, sign, hitset | |
264 | ); | |
265 | ||
266 | // add track parameters at vertex | |
267 | TVector3 mom(muonHLTTrack->fPx, muonHLTTrack->fPy, muonHLTTrack->fPz); | |
268 | AliMUONTrackParam paramAtVtx; | |
269 | if (mom.Mag() != 0) | |
270 | paramAtVtx.SetInverseBendingMomentum(muonHLTTrack->fInverseBendingMomentum); | |
271 | else | |
272 | paramAtVtx.SetInverseBendingMomentum(0.); | |
273 | paramAtVtx.SetNonBendingSlope(TMath::Tan(muonHLTTrack->fThetaX)); | |
274 | paramAtVtx.SetBendingSlope(TMath::Tan(muonHLTTrack->fThetaY)); | |
275 | paramAtVtx.SetZ(muonHLTTrack->fZ); | |
276 | paramAtVtx.SetBendingCoor(muonHLTTrack->fY); | |
277 | paramAtVtx.SetNonBendingCoor(muonHLTTrack->fX); | |
278 | muonTrack->SetTrackParamAtVertex(¶mAtVtx); | |
279 | ||
280 | //printf("(X,Y,Z) : (%8.3f,%8.3f,%8.3f)\n",muonHLTTrack->fX,muonHLTTrack->fY,muonHLTTrack->fZ); | |
281 | ||
282 | // add clusters | |
283 | Int_t nHits = 0; | |
284 | AliMUONVClusterStore* cStore = AliMUONESDInterface::NewClusterStore(); | |
285 | if (!cStore) return -1; | |
286 | AliMUONVCluster* cluster = cStore->CreateCluster(0,0,0); | |
287 | AliMUONTrackParam trackParam; | |
288 | for (int i = 0; i < 16; i++) | |
289 | { | |
290 | if (not hitset[i]) continue; | |
291 | ||
292 | AliHLTUInt8_t chamber; | |
293 | AliHLTUInt16_t detElemId; | |
294 | AliHLTMUONUtils::UnpackRecHitFlags((muonHLTTrack->fHit[i]).fFlags, chamber, detElemId); | |
295 | ||
296 | cluster->SetUniqueID(AliMUONVCluster::BuildUniqueID(chamber, detElemId, clusterIndex++)); | |
297 | cluster->SetXYZ((muonHLTTrack->fHit[i]).fX, (muonHLTTrack->fHit[i]).fY, (muonHLTTrack->fHit[i]).fZ); | |
298 | cluster->SetErrXY( // Use nominal values. | |
299 | AliHLTMUONConstants::DefaultNonBendingReso(), | |
300 | AliHLTMUONConstants::DefaultBendingReso() | |
301 | ); | |
302 | cluster->SetCharge(-1.); // Indicate no total charge calculated. | |
303 | cluster->SetChi2(-1.); // Indicate no fit made. | |
304 | trackParam.SetZ(cluster->GetZ()); | |
305 | muonTrack->AddTrackParamAtCluster(trackParam, *cluster, kTRUE); | |
306 | nHits++; | |
307 | } | |
308 | ||
309 | // compute track parameters at each cluster | |
310 | if (nHits > 0) { | |
311 | AliMUONTrackParam *firstTrackParam = (AliMUONTrackParam*) muonTrack->GetTrackParamAtCluster()->First(); | |
312 | trackParam = (*firstTrackParam); | |
313 | if (!AliMUONESDInterface::GetTracker()) AliMUONESDInterface::ResetTracker(); | |
314 | if (!AliMUONESDInterface::GetTracker()->RefitTrack(*muonTrack, kFALSE) && | |
315 | muonTrack->GetGlobalChi2() < AliMUONTrack::MaxChi2()) { | |
316 | *firstTrackParam = trackParam; | |
317 | muonTrack->UpdateCovTrackParamAtCluster(); | |
318 | } | |
319 | } | |
320 | ||
321 | muonTrack->SetGlobalChi2(muonHLTTrack->fChi2); | |
322 | ||
323 | return 0; | |
324 | } | |
325 | ||
326 | Int_t AliHLTEveMuon::ProcessFullTracks(AliHLTHOMERBlockDesc * block, TEveTrackList * fullTracks) { | |
327 | ||
328 | // See header for documentation | |
329 | ||
330 | Int_t iResult = 0; | |
331 | ||
332 | Double_t b[3], x[3]; | |
333 | x[0] = 0.0 ; x[1] = 0.0 ; x[2] = -950.0; | |
334 | TGeoGlobalMagField::Instance()->Field(x,b); | |
335 | //" Field at (0.0, 0.0, -950.0) [at the middle of dipole magnet] | |
336 | //should be (6.79, 0.03, -0.17) or similar value with change of sign" | |
337 | if(TMath::AreEqualAbs(b[0],0.0,1.0e-5) and TMath::AreEqualAbs(b[1],0.0,1.0e-5) and TMath::AreEqualAbs(b[2],0.0,1.0e-5)){ | |
338 | printf("At (X,Y,Z) : (%6.2lf,%6.2lf,%6.2lf) Field (Bx,By,Bz) is (%6.2lf,%6.2lf,%6.2lf)\n", | |
339 | x[0],x[1],x[2],b[0],b[1],b[2]); | |
340 | cerr<<"Magnetic field is not properly set, MUON tracking will not possble"<<endl; | |
341 | return 1; | |
342 | } | |
343 | ||
344 | ||
345 | ||
346 | TEveRecTrack rt; | |
347 | ||
348 | unsigned long size = block->GetSize(); | |
349 | Int_t * buffer = (Int_t *)block->GetData(); | |
350 | ||
351 | AliHLTMUONTracksBlockReader muontrackblock(buffer, size); | |
352 | const AliHLTMUONTrackStruct* mtrack = muontrackblock.GetArray(); | |
353 | //cout<<"NofTracks : "<<muontrackblock.Nentries()<<endl; | |
354 | for(AliHLTUInt32_t ientry = 0; ientry < muontrackblock.Nentries(); ientry++){ | |
355 | ||
356 | AliMUONTrack *muonTrack = new AliMUONTrack(); | |
357 | MakeMUONTrack(muonTrack,mtrack); | |
358 | if(muonTrack->GetNClusters()==0){ | |
359 | delete muonTrack; | |
360 | continue; | |
361 | } | |
362 | ||
363 | rt.fLabel = ientry; | |
364 | AliEveMUONTrack* track = new AliEveMUONTrack(&rt, fullTracks->GetPropagator()); | |
365 | track->MakeMUONTrack(muonTrack); | |
366 | //track->SetTitle(Form("HLT Track : %d, pt : %lf",ientry,TMath::Sqrt(((mtrack->fPx * mtrack->fPx) + (mtrack->fPy * mtrack->fPy))))); | |
367 | track->SetName(Form("HLT Track : %d, pt : %lf",ientry,TMath::Sqrt(((mtrack->fPx * mtrack->fPx) + (mtrack->fPy * mtrack->fPy))))); | |
368 | fullTracks->AddElement(track); | |
369 | ||
370 | mtrack++; | |
371 | }//track loop | |
372 | ||
373 | return iResult; | |
374 | ||
375 | } |