]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
87f60d9e | 9 | |
10 | // Functions to read data from HOMER. | |
11 | // | |
12 | // Setup: edit location of HLT configuration in first line of | |
13 | // homer_display(). This is a temporary solution. | |
14 | // | |
15 | // Run as: alieve command_queue.C+ hlt_structs.C+ homer_display.C | |
16 | // | |
17 | // nextEvent() will get next event from HOMER. | |
18 | ||
87f60d9e | 19 | #include "TTimer.h" |
20 | #include "TRandom.h" | |
21 | #include "TVirtualPad.h" | |
87f60d9e | 22 | |
23 | class AliRawReaderMemory; | |
24 | ||
d810d0de | 25 | class AliEveHOMERManager; |
65ad0491 | 26 | class AliHLTHOMERBlockDesc; |
27 | ||
84aff7a4 | 28 | class TEvePointSet; |
29 | class TEveTrackList; | |
30 | class TEveTrack; | |
87f60d9e | 31 | |
d810d0de | 32 | class AliEveTPCLoader; |
33 | class AliEveTPCData; | |
34 | class AliEveTPCSector2D; | |
35 | class AliEveTPCSector3D; | |
46eadbb4 | 36 | class AliEveITSDigitsInfo; |
37 | ||
38 | #include "TGLViewer.h" | |
39 | #include "TThread.h" | |
40 | #include "TGFileBrowser.h" | |
41 | #include "TStyle.h" | |
42 | #include "TList.h" | |
43 | #include "TDirectory.h" | |
44 | ||
45 | #include "TEveManager.h" | |
46 | #include "TEvePointSet.h" | |
47 | #include "TEveTrack.h" | |
48 | #include "TEveVSDStructs.h" | |
49 | #include "TEveTrackPropagator.h" | |
50 | #include "TEveElement.h" | |
51 | ||
52 | #include "AliESDEvent.h" | |
53 | #include "AliCDBManager.h" | |
54 | #include "AliRawReaderMemory.h" | |
55 | ||
56 | #include "AliEveHOMERManager.h" | |
57 | #include "AliEveTPCLoader.h" | |
58 | #include "AliEveTPCData.h" | |
59 | #include "AliEveITSDigitsInfo.h" | |
60 | #include "AliEveITSModule.h" | |
61 | ||
62 | #include "AliHLTHOMERBlockDesc.h" | |
63 | #include "AliTPCRawStream.h" | |
64 | ||
65 | //*********************************************************** | |
66 | #include "DIMUONRawReader.C" | |
67 | ||
68 | #include "TEvePointSet.h" | |
69 | #include "TEveScene.h" | |
70 | #include "AliEveMUONData.h" | |
71 | #include "AliEveMUONChamber.h" | |
72 | #include "AliEveMUONChamberData.h" | |
73 | ||
74 | #include "AliGeomManager.h" | |
75 | ||
76 | #include "AliMpCDB.h" | |
77 | #include "AliMpDDLStore.h" | |
78 | #include "AliMpDetElement.h" | |
79 | #include "AliMpDEIterator.h" | |
80 | #include "AliMpVSegmentation.h" | |
81 | #include "AliMUONGeometryTransformer.h" | |
82 | #include "AliMpSegmentation.h" | |
83 | #include "AliMUONCalibrationData.h" | |
84 | #include "AliMUONVCalibParam.h" | |
85 | #include "TEveEventManager.h" | |
86 | #include "AliMpTriggerCrate.h" | |
87 | #include "AliMpLocalBoard.h" | |
88 | #include "AliMUONGeometryDetElement.h" | |
89 | ||
90 | //*********************************************************** | |
91 | ||
92 | // -- globals -- | |
93 | ||
94 | AliEveTPCLoader* gTPCLoader = 0; | |
95 | AliEveTPCData* gTPCData = 0; | |
96 | TEvePointSet* gTPCClusters = 0; | |
97 | TEveTrackList* gTPCTrack = 0; | |
d810d0de | 98 | |
46eadbb4 | 99 | AliEveITSDigitsInfo* gITSDigits = 0; |
87f60d9e | 100 | |
46eadbb4 | 101 | AliRawReaderMemory* gMemReader = 0; |
102 | AliEveHOMERManager* gHomerManager = 0; | |
103 | ||
104 | //*********************************************************** | |
105 | ||
106 | map <UInt_t,AliHLTMUONTrackerMappingData> gDimuTrackerMapping; | |
107 | vector<UInt_t> gDimuTrackerDataList; | |
108 | vector<AliHLTMUONTriggerPointData> gDimuTriggerDataList; | |
109 | AliHLTMUONTriggerMappingData gDimuTriggerMapping[2]; | |
110 | Bool_t gMUONRawData = false; | |
111 | ||
112 | ||
113 | Int_t globMaxPoint = 0 ; | |
114 | ||
115 | //*********************************************************** | |
116 | ||
117 | // -- needed below ?? | |
87f60d9e | 118 | |
119 | Int_t event = -1; | |
120 | ||
121 | TTimer timer; | |
122 | TTimer event_timer; | |
123 | ||
124 | TThread* ldthread = 0; | |
125 | ||
126 | TRandom rnd(0); | |
127 | ||
46eadbb4 | 128 | Bool_t vC = kFALSE; |
129 | TGFileBrowser *g_hlt_browser = 0; | |
130 | TCanvas *g_hlt_canvas = 0; | |
131 | ||
87f60d9e | 132 | TGLViewer::ECameraType camera = TGLViewer::kCameraPerspXOZ; |
133 | ||
46eadbb4 | 134 | //**************************************************************************** |
135 | Int_t nextEvent(Int_t ADCCut = 6); | |
87f60d9e | 136 | |
137 | //**************************************************************************** | |
46eadbb4 | 138 | Int_t processSPDRawData( AliHLTHOMERBlockDesc* block ); |
139 | Int_t drawSPDRawData(); | |
87f60d9e | 140 | |
141 | //**************************************************************************** | |
46eadbb4 | 142 | Int_t processTPCRawData( AliHLTHOMERBlockDesc* block ); |
143 | Int_t processTPCClusters( AliHLTHOMERBlockDesc* block ); | |
144 | Int_t processTPCTracks( AliHLTHOMERBlockDesc* block ); | |
87f60d9e | 145 | |
146 | //**************************************************************************** | |
46eadbb4 | 147 | Int_t initDiMuonMapping(); |
148 | Int_t initTrackerMapping() ; | |
149 | Int_t processDiMuonRawData( AliHLTHOMERBlockDesc* block ); | |
150 | Int_t drawDiMuonRawData(Int_t); | |
87f60d9e | 151 | |
46eadbb4 | 152 | //**************************************************************************** |
153 | TEveTrack* makeESDTrack( TEveTrackPropagator* rnrStyle, | |
154 | Int_t idx, | |
155 | AliESDtrack* at, | |
156 | AliExternalTrackParam* tp = 0 ); | |
157 | ||
158 | //**************************************************************************** | |
159 | void homer_display(Int_t run = 0) { | |
87f60d9e | 160 | |
46eadbb4 | 161 | AliCDBManager::Instance()->SetRun(run); |
162 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); | |
a15e6d7d | 163 | |
46eadbb4 | 164 | gMemReader = new AliRawReaderMemory(0, 0); |
87f60d9e | 165 | |
87f60d9e | 166 | gStyle->SetPalette(1, 0); |
167 | ||
46eadbb4 | 168 | // -- Create HOMER Manager |
169 | gHomerManager = new AliEveHOMERManager("/local/home/hlt/AliEVE-Config.xml"); | |
170 | ||
171 | // -- Set Realm ( can be "GPN","ACR","HLT" ) | |
172 | gHomerManager->SetRealm("ACR"); | |
173 | ||
174 | gEve->AddToListTree(gHomerManager, kTRUE); | |
175 | ||
176 | // -- Create list of HOMER sources | |
177 | gHomerManager->CreateHOMERSourcesList(); | |
178 | ||
179 | // -- TPC Loader | |
180 | gTPCLoader = new AliEveTPCLoader; | |
181 | gTPCLoader->SetDoubleSR(kTRUE); | |
182 | gTPCLoader->SetInitParams(40, 900, 10, 100); // Sector params (mint, maxt, thr, maxval) | |
183 | ||
184 | // -- TPC Data | |
185 | gTPCData = gTPCLoader->GetData(); | |
186 | gTPCData->SetLoadPedestal(0); | |
187 | gTPCData->SetLoadThreshold(0); | |
188 | gTPCData->SetAutoPedestal(kFALSE); // For zero suppressed data. | |
87f60d9e | 189 | |
46eadbb4 | 190 | // -- Load MUON mapping |
191 | initDiMuonMapping(); | |
192 | ||
193 | gEve->AddElement(gTPCLoader); | |
194 | } | |
87f60d9e | 195 | |
196 | //**************************************************************************** | |
46eadbb4 | 197 | Int_t nextEvent(Int_t ADCCut) { |
87f60d9e | 198 | |
46eadbb4 | 199 | Int_t iResult = 0; |
87f60d9e | 200 | |
46eadbb4 | 201 | // ** Get Next Event from HOMER |
202 | if ( gHomerManager->NextEvent() ) | |
203 | return ++iResult; | |
87f60d9e | 204 | |
46eadbb4 | 205 | // ** Reset |
206 | if ( gTPCClusters ) gTPCClusters->Reset(); | |
207 | if ( gTPCTrack ) gTPCTrack->DestroyElements(); | |
208 | if ( gTPCData ) gTPCData->DropAllSectors(); | |
87f60d9e | 209 | |
46eadbb4 | 210 | if ( gITSDigits ) { |
211 | delete gITSDigits; | |
212 | gITSDigits = NULL; | |
213 | } | |
214 | ||
215 | if(gDimuTrackerDataList.size()>0) | |
216 | gDimuTrackerDataList.clear(); | |
217 | ||
218 | if(gDimuTriggerDataList.size()>0) | |
219 | gDimuTriggerDataList.clear(); | |
220 | ||
221 | for(Int_t ipoint=0;ipoint<globMaxPoint;ipoint++) | |
222 | point3d[ipoint].SetPoint(0,0.0,0.0,0.0); | |
223 | ||
224 | ||
225 | // ----------------------------------- foo A | |
226 | vC = kFALSE; | |
227 | ||
228 | // TList* hListKR = new TList; | |
229 | // TList* hListCF = new TList; | |
230 | ||
231 | gDirectory = 0; | |
232 | // ----------------------------------- foo A | |
233 | ||
234 | TIter next(gHomerManager->GetBlockList()); | |
235 | AliHLTHOMERBlockDesc* block = 0; | |
236 | ||
237 | while ((block = (AliHLTHOMERBlockDesc*)next())) { | |
238 | ||
239 | printf ( "Det : %s\n" ,block->GetDetector().Data() ); | |
240 | printf ( "Datatype : %s\n" ,block->GetDataType().Data() ); | |
241 | ||
242 | // +++ CLUSTERS BLOCK | |
243 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
244 | if ( block->GetDataType().CompareTo("CLUSTERS") == 0 ) { | |
245 | ||
246 | // ** Initialize TPC Clusters | |
247 | if ( !gTPCClusters ) { | |
248 | gTPCClusters = new TEvePointSet("TPC Clusters"); | |
fbc350a3 | 249 | gTPCClusters->SetMainColor(kRed); |
46eadbb4 | 250 | gTPCClusters->SetMarkerStyle((Style_t)kFullDotSmall); |
251 | gEve->AddElement(gTPCClusters); | |
252 | } | |
253 | ||
254 | // ** Process Clusters | |
255 | processTPCClusters( block ); | |
256 | ||
257 | gTPCClusters->ElementChanged(); | |
258 | ||
259 | // +++ ESD BLOCK | |
260 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
261 | } else if ( block->GetDataType().CompareTo("ESD_TREE") == 0 ) { | |
262 | ||
263 | // ** Initialize TPC Tracks | |
264 | if ( !gTPCTrack ) { | |
265 | gTPCTrack = new TEveTrackList("TPC Tracks"); | |
fbc350a3 | 266 | gTPCTrack->SetMainColor(kBlue); |
46eadbb4 | 267 | |
268 | gEve->AddElement(gTPCTrack); | |
269 | ||
270 | TEveTrackPropagator* rnrStyle = gTPCTrack->GetPropagator(); | |
271 | rnrStyle->SetMagField( 0 ); | |
272 | rnrStyle->SetFitDecay( 1 ); | |
273 | } | |
274 | ||
275 | // ** Proces Tracks | |
276 | processTPCTracks( block ); | |
277 | ||
278 | // +++ RAW DATA BLOCK | |
279 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
280 | } else if ( block->GetDataType().CompareTo("DDL_RAW") == 0 ) { | |
281 | ||
282 | // -- TPC | |
283 | // ----------------------------------------------------- | |
284 | if ( ! block->GetDetector().CompareTo("TPC") ) | |
285 | processTPCRawData( block ); | |
286 | ||
287 | // -- SPD | |
288 | // ----------------------------------------------------- | |
289 | else if ( ! block->GetDetector().CompareTo("SPD") ) { | |
290 | // !!!!!! TODO add also other ITS detectors | |
291 | ||
292 | // ** Initialize SPD Digits | |
293 | if ( !gITSDigits ) { | |
294 | gITSDigits = new AliEveITSDigitsInfo(); | |
295 | } | |
296 | ||
297 | processSPDRawData( block ); | |
298 | } | |
299 | ||
300 | // -- MUON | |
301 | // ----------------------------------------------------- | |
302 | else if ( ! block->GetDetector().CompareTo("MUON") ) { | |
303 | ||
304 | if( processDiMuonRawData ( block ) ) | |
305 | gMUONRawData = true; | |
306 | } | |
307 | ||
308 | // +++ KRYPTON HISTOGRAM BLOCK | |
309 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
310 | } else if (block->GetDataType().CompareTo("KRPTHIST") == 0) { | |
311 | ||
312 | ||
313 | ||
314 | ||
315 | // ++ else | |
316 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
317 | } else { | |
318 | ||
319 | ||
320 | printf ("This is nothing"); | |
87f60d9e | 321 | } |
46eadbb4 | 322 | |
87f60d9e | 323 | } |
324 | ||
46eadbb4 | 325 | if ( gTPCLoader ) gTPCLoader->UpdateSectors( kTRUE ); |
326 | if ( gTPCClusters ) gTPCClusters->ResetBBox(); | |
327 | if ( gTPCTrack ) gTPCTrack->MakeTracks(); | |
328 | if ( gITSDigits ) drawSPDRawData(); | |
329 | if ( gMUONRawData ) drawDiMuonRawData ( ADCCut ) ; | |
87f60d9e | 330 | |
46eadbb4 | 331 | gEve->Redraw3D(0,1); // (0, 1) |
332 | gMUONRawData = false; | |
333 | ||
334 | return iResult; | |
87f60d9e | 335 | } |
336 | ||
46eadbb4 | 337 | |
87f60d9e | 338 | //**************************************************************************** |
46eadbb4 | 339 | Int_t processSPDRawData(AliHLTHOMERBlockDesc* block) { |
340 | Int_t iResult = 0; | |
341 | ||
342 | Int_t partition = block->GetSubDetector().Atoi(); | |
343 | Int_t eqId = partition; | |
344 | ||
345 | gMemReader->SetMemory( reinterpret_cast<UChar_t*> ( block->GetData() ), block->GetSize() ); | |
346 | gMemReader->SetEquipmentID( eqId ); | |
347 | gMemReader->Reset(); | |
348 | ||
349 | gITSDigits->ReadRaw( gMemReader, 3); | |
350 | ||
351 | return iResult; | |
352 | } | |
353 | ||
354 | //**************************************************************************** | |
355 | Int_t drawSPDRawData() { | |
356 | ||
357 | Int_t iResult = 0; | |
358 | ||
359 | TString sSector; | |
360 | TString bsSector="Sector"; | |
361 | TString sStave; | |
362 | TString bsStave="Stave"; | |
363 | ||
364 | Int_t ndx=0; | |
365 | Int_t sector, stave, module; | |
366 | ||
367 | gEve->DisableRedraw(); | |
368 | ||
369 | // ** first layer ** | |
370 | ||
371 | TEveElementList* layer1 = new TEveElementList( "SPD0" ); | |
372 | layer1->SetTitle( "SPDs' first layer" ); | |
fbc350a3 | 373 | layer1->SetMainColor(2); |
46eadbb4 | 374 | gEve->AddElement( layer1 ); |
375 | ||
376 | for ( sector=0; sector<10; sector++ ) { | |
377 | sSector = bsSector; | |
378 | sSector += sector; | |
379 | ||
380 | TEveElementList* relSector = new TEveElementList( sSector.Data() ); | |
fbc350a3 | 381 | relSector->SetMainColor(2); |
46eadbb4 | 382 | gEve->AddElement( relSector, layer1 ); |
383 | ||
384 | for ( stave=0; stave<2; stave++ ) { | |
385 | sStave = bsStave; | |
386 | sStave += stave; | |
387 | ||
388 | TEveElementList* relStave = new TEveElementList( sStave.Data() ); | |
fbc350a3 | 389 | relStave->SetMainColor(2); |
46eadbb4 | 390 | gEve->AddElement( relStave, relSector ); |
391 | ||
392 | for ( module=0; module<4; module++ ) { | |
393 | ||
394 | if ( gITSDigits->GetDigits( ndx, 0 ) && | |
395 | gITSDigits->GetDigits( ndx, 0 )->GetEntriesFast() > 0) { | |
396 | ||
397 | AliEveITSModule* moduleITS = new AliEveITSModule( ndx, gITSDigits ); | |
398 | gEve->AddElement( moduleITS, relStave ); | |
399 | } | |
400 | ||
401 | ++ndx; | |
402 | ||
403 | } // for ( module=0; module<4; module++ ) { | |
404 | } // for ( stave=0; stave<2; stave++ ) { | |
405 | } // for ( sector=0; sector<10; sector++ ) { | |
406 | ||
407 | // ** second layer ** | |
408 | ||
409 | TEveElementList* layer2 = new TEveElementList( "SPD1" ); | |
410 | layer2->SetTitle( "SPDs' second layer" ); | |
fbc350a3 | 411 | layer2->SetMainColor(2); |
46eadbb4 | 412 | gEve->AddElement(layer2); |
413 | ||
414 | for ( sector=0; sector<10; sector++ ) { | |
415 | sSector = bsSector; | |
416 | sSector += sector; | |
417 | ||
418 | TEveElementList* relSector = new TEveElementList( sSector.Data() ); | |
fbc350a3 | 419 | relSector->SetMainColor(2); |
46eadbb4 | 420 | gEve->AddElement(relSector, layer2 ); |
421 | ||
422 | for ( stave=0; stave<4; stave++ ) { | |
423 | sStave = bsStave; | |
424 | sStave += stave; | |
425 | ||
426 | TEveElementList* relStave = new TEveElementList( sStave.Data() ); | |
fbc350a3 | 427 | relStave->SetMainColor(2); |
46eadbb4 | 428 | gEve->AddElement( relStave, relSector ); |
429 | ||
430 | for ( module=0; module<4; module++) { | |
431 | ||
432 | if ( gITSDigits->GetDigits( ndx, 0 ) && | |
433 | gITSDigits->GetDigits( ndx, 0 )->GetEntriesFast() > 0) { | |
434 | ||
435 | AliEveITSModule* moduleITS = new AliEveITSModule( ndx, gITSDigits ); | |
436 | gEve->AddElement( moduleITS, relStave ); | |
437 | } | |
438 | ||
439 | ++ndx; | |
440 | } // for ( module=0; module<4; module++) { | |
441 | } // for ( stave=0; stave<2; stave++ ) { | |
442 | } //for ( sector=0; sector<10; sector++ ) { | |
443 | ||
444 | gEve->EnableRedraw(); | |
445 | ||
446 | return iResult; | |
447 | } | |
448 | ||
449 | ||
450 | //**************************************************************************** | |
451 | Int_t processTPCRawData(AliHLTHOMERBlockDesc* block) { | |
452 | ||
453 | Int_t iResult = 0; | |
454 | ||
455 | Int_t sector = block->GetSubDetector().Atoi(); | |
456 | Int_t patch = block->GetSubSubDetector().Atoi(); | |
457 | Int_t eqId = 768 + patch; | |
458 | ||
459 | if ( patch >= 2) eqId += 4 * sector + 70; | |
460 | else eqId += 2 * sector; | |
461 | ||
462 | printf("%d %d %d -- %p %lu\n", sector, patch, eqId, block->GetData(), block->GetSize()); | |
463 | ||
464 | gMemReader->SetMemory( reinterpret_cast<UChar_t*> ( block->GetData() ), block->GetSize() ); | |
465 | gMemReader->SetEquipmentID( eqId ); | |
466 | gMemReader->Reset(); | |
467 | ||
468 | AliTPCRawStream tpcStream( gMemReader ); | |
46eadbb4 | 469 | gMemReader->Select("TPC"); |
470 | ||
471 | gTPCData->LoadRaw( tpcStream, kTRUE, kTRUE ); | |
472 | ||
473 | return iResult; | |
474 | } | |
475 | ||
476 | //**************************************************************************** | |
477 | Int_t processTPCClusters(AliHLTHOMERBlockDesc* block) { | |
478 | Int_t iResult = 0; | |
479 | ||
480 | Int_t slice = block->GetSubDetector().Atoi(); | |
481 | Int_t patch = block->GetSubSubDetector().Atoi(); | |
482 | Float_t phi = ( slice + 0.5 ) * TMath::Pi() / 9.0; | |
483 | Float_t cos = TMath::Cos( phi ); | |
484 | Float_t sin = TMath::Sin( phi ); | |
485 | ||
486 | AliHLTTPCClusterData *cd = (AliHLTTPCClusterData*) block->GetData(); | |
487 | UChar_t *data = (UChar_t*) cd->fSpacePoints; | |
488 | ||
489 | if ( cd->fSpacePointCnt == 0 ) { | |
490 | printf ("No Clusters found in sector %d patch %d.\n", slice, patch ); | |
491 | iResult = -1; | |
492 | } | |
493 | else { | |
494 | ||
495 | for (Int_t ii = 0; ii < cd->fSpacePointCnt; ++ii, data += sizeof(AliHLTTPCSpacePointData)) { | |
496 | AliHLTTPCSpacePointData *sp = (AliHLTTPCSpacePointData *) data; | |
497 | ||
498 | gTPCClusters->SetNextPoint(cos*sp->fX - sin*sp->fY, sin*sp->fX + cos*sp->fY, sp->fZ); | |
499 | } | |
87f60d9e | 500 | } |
46eadbb4 | 501 | |
502 | return iResult; | |
87f60d9e | 503 | } |
504 | ||
505 | //**************************************************************************** | |
46eadbb4 | 506 | TEveTrack* makeESDTrack( TEveTrackPropagator* rnrStyle, |
507 | Int_t idx, | |
508 | AliESDtrack* esdTrack, | |
509 | AliExternalTrackParam* trackParam ) { | |
87f60d9e | 510 | // Helper function |
46eadbb4 | 511 | |
512 | Double_t pbuf[3], vbuf[3]; | |
513 | TEveRecTrack rt; | |
514 | ||
515 | if ( trackParam == 0 ) | |
516 | trackParam = esdTrack; | |
517 | ||
518 | rt.fLabel = esdTrack->GetLabel(); | |
519 | rt.fIndex = idx; | |
520 | rt.fStatus = (Int_t) esdTrack->GetStatus(); | |
521 | rt.fSign = (Int_t) trackParam->GetSign(); | |
522 | trackParam->GetXYZ(vbuf); | |
523 | rt.fV.Set(vbuf); | |
524 | ||
525 | { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines | |
526 | ||
527 | Double_t pt= TMath::Abs(trackParam->GetSigned1Pt()); | |
528 | pt = (pt>kAlmost0) ?1./pt :100.; | |
529 | ||
530 | Double_t cA=TMath::Cos(trackParam->GetAlpha()), sA=TMath::Sin(trackParam->GetAlpha()); | |
531 | ||
532 | Double_t sT=trackParam->GetSnp(); | |
533 | if( sT>=kAlmost1 ){ sT = kAlmost1; } | |
534 | else if( sT<-kAlmost1 ){ sT = -kAlmost1; } | |
535 | Double_t cT = TMath::Sqrt(TMath::Abs(1 - sT*sT)); | |
536 | ||
537 | pbuf[0] = pt*(cT*cA - sT*sA); | |
538 | pbuf[1] = pt*(sT*cA + cT*sA); | |
539 | pbuf[2] = pt*trackParam->GetTgl(); | |
540 | } | |
541 | ||
542 | rt.fP.Set(pbuf); | |
543 | ||
544 | Double_t ep = esdTrack->GetP(), mc = esdTrack->GetMass(); | |
545 | rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc); | |
51346b82 | 546 | |
84aff7a4 | 547 | TEveTrack* track = new TEveTrack(&rt, rnrStyle); |
46eadbb4 | 548 | |
549 | AliExternalTrackParam endParam = *trackParam; | |
550 | if( endParam.PropagateTo(esdTrack->GetTPCPoints(2), 0.) ){ // 5 kG | |
551 | ||
552 | TEvePathMark *startPoint = new TEvePathMark(TEvePathMark::kReference); | |
553 | TEvePathMark *endPoint = new TEvePathMark(TEvePathMark::kDecay); | |
554 | startPoint->fV.Set(vbuf); | |
555 | startPoint->fP.Set(pbuf); | |
556 | ||
557 | endParam.GetXYZ(vbuf); | |
558 | endPoint->fV.Set(vbuf); | |
559 | cout<<"endPoint = "<<vbuf[0]<<" "<<vbuf[1]<<" "<<vbuf[2]<<endl; | |
560 | ||
561 | { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines | |
562 | ||
563 | Double_t pt= TMath::Abs(endParam.GetSigned1Pt()); | |
564 | pt = (pt>kAlmost0) ?1./pt :100.; | |
565 | ||
566 | Double_t cA=TMath::Cos(endParam.GetAlpha()), sA=TMath::Sin(endParam.GetAlpha()); | |
567 | ||
568 | Double_t sT=endParam.GetSnp(); | |
569 | if( sT>=kAlmost1 ){ sT = kAlmost1; } | |
570 | else if( sT<-kAlmost1 ){ sT = -kAlmost1; } | |
571 | Double_t cT = TMath::Sqrt(TMath::Abs(1 - sT*sT)); | |
572 | ||
573 | pbuf[0] = pt*(cT*cA - sT*sA); | |
574 | pbuf[1] = pt*(sT*cA + cT*sA); | |
575 | pbuf[2] = pt*endParam.GetTgl(); | |
576 | } | |
577 | ||
578 | endPoint->fP.Set(pbuf); | |
579 | ||
580 | track->AddPathMark( startPoint ); | |
581 | track->AddPathMark( endPoint ); | |
582 | } | |
87f60d9e | 583 | //PH The line below is replaced waiting for a fix in Root |
584 | //PH which permits to use variable siza arguments in CINT | |
585 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
586 | //PH track->SetName(Form("ESDTrack %d", rt.label)); | |
587 | //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)", | |
588 | //PH rt.sign*TMath::Hypot(rt.P.x, rt.P.y), rt.P.z, | |
589 | //PH rt.V.x, rt.V.y, rt.V.z)); | |
590 | char form[1000]; | |
46eadbb4 | 591 | sprintf(form,"TEveTrack %d", rt.fIndex); |
87f60d9e | 592 | track->SetName(form); |
593 | track->SetStdTitle(); | |
594 | return track; | |
595 | } | |
596 | ||
597 | //**************************************************************************** | |
46eadbb4 | 598 | Int_t processTPCTracks(AliHLTHOMERBlockDesc* block) { |
599 | ||
600 | TTree *tr = (TTree*) block->GetTObject(); | |
601 | ||
602 | AliESDEvent* esd = new AliESDEvent; | |
603 | esd->ReadFromTree(tr); | |
604 | tr->GetEntry(0); | |
605 | ||
606 | TEveTrackPropagator* rnrStyle = gTPCTrack->GetPropagator(); | |
607 | rnrStyle->SetMagField( 0.1*esd->GetMagneticField() ); | |
87f60d9e | 608 | |
46eadbb4 | 609 | cout << "Number of tracks found :" << esd->GetNumberOfTracks() << endl; |
610 | ||
611 | for (Int_t ii=0; ii< esd->GetNumberOfTracks(); ii++) { | |
612 | ||
613 | AliESDtrack *esdTrack = esd->GetTrack(ii); | |
614 | AliExternalTrackParam *trackParam = esdTrack; | |
615 | ||
616 | TEveTrack* track = makeESDTrack( rnrStyle, ii, esdTrack, trackParam ); | |
617 | ||
618 | track->SetAttLineAttMarker(gTPCTrack); | |
619 | ||
620 | gEve->AddElement(track, gTPCTrack); | |
621 | } | |
622 | ||
623 | // delete esd; | |
624 | ||
625 | return 0; | |
626 | } | |
627 | //**************************************************************************** | |
628 | Int_t initTrackerMapping() | |
629 | { | |
630 | gDimuTrackerMapping.clear(); | |
87f60d9e | 631 | |
46eadbb4 | 632 | if (! AliMpCDB::LoadDDLStore(true)){ |
633 | cerr<<__FILE__<<": Failed to Load DDLStore specified for CDBPath " | |
634 | <<AliCDBManager::Instance()->GetDefaultStorage()<<endl; | |
635 | return kFALSE; | |
636 | } | |
87f60d9e | 637 | |
46eadbb4 | 638 | AliMpSegmentation *mpSegFactory = AliMpSegmentation::Instance(); |
639 | AliGeomManager::LoadGeometry(); | |
640 | AliMUONGeometryTransformer* chamberGeometryTransformer = new AliMUONGeometryTransformer(); | |
641 | ||
642 | if(! chamberGeometryTransformer->LoadGeometryData()){ | |
643 | cerr<<__FILE__<<": Failed to Load Geomerty Data "<<endl; | |
644 | return kFALSE; | |
87f60d9e | 645 | } |
646 | ||
46eadbb4 | 647 | AliMUONCalibrationData cd((AliCDBManager::Instance())->GetRun()); |
648 | AliHLTMUONTrackerMappingData md; | |
649 | ||
650 | cout<<"Loading Mapping for Dimuon Tracking Chambers.....be patient..."<<endl; | |
651 | ||
652 | for(Int_t iCh = 0; iCh < 10; iCh++){ | |
653 | ||
654 | AliMpDEIterator it; | |
655 | for ( it.First(iCh); ! it.IsDone(); it.Next() ) { | |
656 | ||
657 | Int_t detElemId = it.CurrentDEId(); | |
658 | ||
659 | for(Int_t iCath = 0 ; iCath <= 1 ; iCath++){ | |
660 | ||
661 | AliMp::CathodType cath; | |
662 | ||
663 | if(iCath == 0) | |
664 | cath = AliMp::kCath0 ; | |
665 | else | |
666 | cath = AliMp::kCath1 ; | |
667 | ||
668 | const AliMpVSegmentation* seg = mpSegFactory->GetMpSegmentation(detElemId, cath); | |
669 | AliMp::PlaneType plane = seg->PlaneType(); | |
670 | Int_t maxIX = seg->MaxPadIndexX(); | |
671 | Int_t maxIY = seg->MaxPadIndexY(); | |
672 | UInt_t idManuChannel; | |
673 | Int_t buspatchId, manuId, channelId; | |
674 | Double_t realX, realY, realZ; | |
675 | Double_t localX, localY, localZ; | |
676 | ||
677 | //Pad Info of a segment | |
678 | for(Int_t iX = 0; iX<= maxIX ; iX++){ | |
679 | for(Int_t iY = 0; iY<= maxIY ; iY++){ | |
680 | if(seg->HasPad(AliMpIntPair(iX,iY))){ | |
681 | AliMpPad pad = seg->PadByIndices(AliMpIntPair(iX,iY),kFALSE); | |
682 | ||
683 | ||
684 | // Getting Manu id | |
685 | manuId = pad.GetLocation().GetFirst(); | |
686 | manuId &= 0x7FF; // 11 bits | |
687 | ||
688 | // Getting channel id | |
689 | channelId = pad.GetLocation().GetSecond(); | |
690 | channelId &= 0x3F; // 6 bits | |
691 | ||
692 | buspatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId); | |
693 | ||
694 | idManuChannel &= 0x0; | |
695 | idManuChannel = (idManuChannel|buspatchId)<<11; | |
696 | idManuChannel = (idManuChannel|manuId)<<6 ; | |
697 | idManuChannel |= channelId ; | |
698 | ||
699 | localX = pad.Position().X(); | |
700 | localY = pad.Position().Y(); | |
701 | localZ = 0.0; | |
702 | ||
703 | chamberGeometryTransformer->Local2Global(detElemId,localX,localY,localZ, | |
704 | realX,realY,realZ); | |
705 | md.fDetElemId = detElemId; | |
706 | md.fIX = iX ; | |
707 | md.fIY = iY ; | |
708 | md.fCath = cath ; | |
709 | md.fRealX = realX ; | |
710 | md.fRealY = realY; | |
711 | md.fRealZ = realZ; | |
712 | md.fPed = (cd.Pedestals(detElemId,manuId))->ValueAsFloat(channelId); | |
713 | ||
714 | gDimuTrackerMapping[idManuChannel] = md; | |
715 | ||
716 | }// HasPad condn | |
717 | }// iY loop | |
718 | }// iX loop | |
719 | ||
720 | }// iPlane | |
721 | ||
722 | } // detElemId loop | |
723 | ||
724 | }// ichamber loop | |
725 | ||
726 | return 0; | |
87f60d9e | 727 | } |
46eadbb4 | 728 | //**************************************************************************** |
729 | Int_t initTrackerMappingPed() | |
730 | { | |
731 | cout<<"Loading Pedestal for Dimuon..."<<endl; | |
732 | Int_t linenum = 0; | |
733 | ||
734 | char line[90]; | |
735 | int buspatch,manu,channel; | |
736 | float mean,sigma; | |
737 | int idManuChannel; | |
738 | ||
739 | FILE *fin[2] ; | |
740 | fin[0] = fopen("/local/home/hlt/pedestal/MUONTRKda_ped_25948.St1.ped","r"); | |
741 | fin[1] = fopen("/local/home/hlt/pedestal/MUONTRKda_ped_25948.St2.ped","r"); | |
742 | ||
743 | while(feof(fin[0])==0){ | |
744 | fgets(line,100,fin[0]); | |
745 | sscanf(line,"%d\t%d\t%d\t%f\t%f\n",&buspatch,&manu,&channel,&mean,&sigma); | |
746 | if(linenum>12){ | |
747 | // printf("%d\t%d\t%d\t%f\t%f\n",buspatch,manu,channel,mean,sigma); | |
748 | ||
749 | idManuChannel &= 0x0; | |
750 | idManuChannel = (idManuChannel|buspatch)<<11; | |
751 | idManuChannel = (idManuChannel|manu)<<6 ; | |
752 | idManuChannel |= channel ; | |
753 | ||
754 | // data.fBuspatchId = UInt_t(buspatch) ; | |
755 | // data.fManuId = UInt_t(manu) ; | |
756 | // data.fChannelId = UInt_t(channel) ; | |
757 | // data.fADC = UShort_t(mean); | |
758 | ||
759 | // lookuptable[idManuChannel] = data; | |
760 | ||
761 | gDimuTrackerMapping[idManuChannel].fPed = mean; | |
762 | gDimuTrackerMapping[idManuChannel].fSigma = sigma; | |
763 | ||
764 | } | |
765 | linenum++; | |
766 | } | |
767 | ||
768 | linenum = 0; | |
769 | ||
770 | while(feof(fin[1])==0){ | |
771 | fgets(line,100,fin[1]); | |
772 | sscanf(line,"%d\t%d\t%d\t%f\t%f\n",&buspatch,&manu,&channel,&mean,&sigma); | |
773 | if(linenum>12){ | |
774 | // printf("%d\t%d\t%d\t%f\t%f\n",buspatch,manu,channel,mean,sigma); | |
775 | ||
776 | idManuChannel &= 0x0; | |
777 | idManuChannel = (idManuChannel|buspatch)<<11; | |
778 | idManuChannel = (idManuChannel|manu)<<6 ; | |
779 | idManuChannel |= channel ; | |
87f60d9e | 780 | |
46eadbb4 | 781 | // data.fBuspatchId = UInt_t(buspatch) ; |
782 | // data.fManuId = UInt_t(manu) ; | |
783 | // data.fChannelId = UInt_t(channel) ; | |
784 | // data.fADC = UShort_t(mean); | |
785 | ||
786 | // lookuptable[idManuChannel] = data; | |
787 | ||
788 | gDimuTrackerMapping[idManuChannel].fPed = mean; | |
789 | gDimuTrackerMapping[idManuChannel].fSigma = sigma; | |
790 | } | |
791 | linenum++; | |
792 | ||
793 | } | |
794 | ||
795 | return 0; | |
796 | } | |
87f60d9e | 797 | //**************************************************************************** |
46eadbb4 | 798 | Int_t initTriggerMapping() |
87f60d9e | 799 | { |
87f60d9e | 800 | |
46eadbb4 | 801 | for (Int_t d = 0; d < 2; d++) |
802 | for (Int_t i = 0; i < 8; i++) | |
803 | for (Int_t j = 0; j < 16; j++) | |
804 | for (Int_t k = 0; k < 4; k++) | |
805 | for (Int_t n = 0; n < 2; n++) | |
806 | for (Int_t m = 0; m < 16; m++){ | |
807 | gDimuTriggerMapping[d].fLut[i][j][k][n][m].fDetElemId = 0; | |
808 | gDimuTriggerMapping[d].fLut[i][j][k][n][m].fX = 0; | |
809 | gDimuTriggerMapping[d].fLut[i][j][k][n][m].fY = 0; | |
810 | gDimuTriggerMapping[d].fLut[i][j][k][n][m].fZ = 0; | |
811 | } | |
812 | ||
813 | ||
814 | AliCDBManager* cdbManager = AliCDBManager::Instance(); | |
815 | cdbManager->SetRun((AliCDBManager::Instance())->GetRun()); | |
816 | ||
817 | AliGeomManager::LoadGeometry(); | |
818 | ||
819 | AliMUONGeometryTransformer transformer; | |
820 | if (! transformer.LoadGeometryData()){ | |
821 | cerr << "ERROR: Could not load geometry into transformer." << endl; | |
822 | return false; | |
823 | } | |
824 | ||
825 | if (! AliMpCDB::LoadDDLStore()){ | |
826 | cerr << "ERROR: Could not load DDL mapping." << endl; | |
827 | return false; | |
828 | } | |
829 | ||
830 | AliMpSegmentation* segmentation = AliMpSegmentation::Instance(); | |
831 | if (segmentation == NULL){ | |
832 | cerr << "ERROR: AliMpSegmentation::Instance() was NULL." << endl; | |
833 | return false; | |
834 | } | |
835 | ||
87f60d9e | 836 | |
46eadbb4 | 837 | AliMpDDLStore* ddlStore = AliMpDDLStore::Instance(); |
838 | if (ddlStore == NULL){ | |
839 | cerr << "ERROR: AliMpDDLStore::Instance() was NULL." << endl; | |
840 | return false; | |
87f60d9e | 841 | } |
46eadbb4 | 842 | |
843 | cout << "Loading Mapping for Dimuon Trigger Chambers....." << endl; | |
844 | ||
845 | AliMpDEIterator detElemIter; | |
846 | for (Int_t iDDL = 20; iDDL <= 21; iDDL++){ | |
847 | ||
848 | for (Int_t iReg = 0; iReg < 8; iReg++){ | |
849 | ||
850 | AliMpTriggerCrate* crate = ddlStore->GetTriggerCrate(iDDL, iReg); | |
851 | ||
852 | if (crate == NULL){ | |
853 | cerr << "ERROR: Could not get crate for regional header = " << iReg | |
854 | << ", and DDL ID = " << iDDL << endl; | |
855 | continue; | |
856 | } | |
857 | ||
858 | for (Int_t iLocBoard = 0; iLocBoard < 16; iLocBoard++){ | |
859 | Int_t boardId = crate->GetLocalBoardId(iLocBoard); | |
860 | if (boardId == 0) continue; | |
861 | ||
862 | AliMpLocalBoard* localBoard = ddlStore->GetLocalBoard(boardId); | |
863 | if (localBoard == NULL){ | |
864 | cerr << "ERROR: Could not get loacl board: " << boardId << endl; | |
865 | continue; | |
866 | } | |
867 | ||
868 | // skip copy cards | |
869 | if (! localBoard->IsNotified()) continue; | |
870 | ||
871 | for (Int_t iChamber = 0; iChamber < 4; iChamber++){ | |
872 | ||
873 | Int_t detElemId = ddlStore->GetDEfromLocalBoard(boardId, iChamber); | |
874 | ||
875 | const AliMUONGeometryDetElement* detElemTransform = transformer.GetDetElement(detElemId); | |
876 | if (detElemTransform == NULL){ | |
877 | cerr << "ERROR: Got NULL pointer for geometry transformer for detection element ID = " | |
878 | << detElemId << endl; | |
879 | continue; | |
880 | } | |
881 | ||
882 | for (Int_t iCathode = 0; iCathode <= 1; iCathode++){ | |
883 | const AliMpVSegmentation* seg = segmentation->GetMpSegmentation | |
884 | (detElemId, AliMp::GetCathodType(iCathode)); | |
885 | ||
886 | for (Int_t bitxy = 0; bitxy < 16; bitxy++){ | |
887 | Int_t offset = 0; | |
888 | if (iCathode && localBoard->GetSwitch(6)) offset = -8; | |
889 | ||
890 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(boardId, bitxy+offset), kFALSE); | |
891 | ||
892 | if (! pad.IsValid()){ | |
893 | // There is no pad associated with the given local board and bit pattern. | |
894 | continue; | |
895 | } | |
896 | ||
897 | // Get the global coodinates of the pad. | |
898 | Float_t lx = pad.Position().X(); | |
899 | Float_t ly = pad.Position().Y(); | |
900 | Float_t gx, gy, gz; | |
901 | detElemTransform->Local2Global(lx, ly, 0, gx, gy, gz); | |
902 | ||
903 | // Fill the LUT | |
904 | gDimuTriggerMapping[(iDDL%20)].fLut[iReg][iLocBoard][iChamber][iCathode][bitxy].fDetElemId = detElemId; | |
905 | gDimuTriggerMapping[(iDDL%20)].fLut[iReg][iLocBoard][iChamber][iCathode][bitxy].fX = gx; | |
906 | gDimuTriggerMapping[(iDDL%20)].fLut[iReg][iLocBoard][iChamber][iCathode][bitxy].fY = gy; | |
907 | gDimuTriggerMapping[(iDDL%20)].fLut[iReg][iLocBoard][iChamber][iCathode][bitxy].fZ = gz; | |
908 | ||
909 | }// ibitxy loop | |
910 | }// cathode loop | |
911 | }// chamber loop | |
912 | }// local board loop | |
913 | }// regional card loop | |
914 | }// ddl loop | |
915 | ||
916 | ||
917 | return true; | |
918 | } | |
919 | //**************************************************************************** | |
920 | Int_t initDiMuonMapping() | |
921 | { | |
922 | initTrackerMapping(); | |
923 | initTrackerMappingPed(); | |
924 | initTriggerMapping(); | |
925 | ||
926 | return 0; | |
927 | } | |
928 | //**************************************************************************** | |
929 | ||
930 | int ReadRawData(int iEvent = 0) | |
931 | { | |
932 | cout<<"Executing for Event : "<<iEvent<<endl; | |
933 | ||
934 | TString rawDataPath = "$HOME/MUON_RawData"; | |
935 | ||
936 | bool MakeTrackDDLStream(int*& rawData, int* rawDataSize, TString rawDataPath, int iEvent, int iDDL); | |
937 | ||
938 | int *buffer; | |
939 | int bufferSize; | |
940 | ||
941 | AliMUONTrackerDDLDecoder<DiMuonTrackerCustomHandler> trackerDDLDecoder; | |
942 | DiMuonTrackerCustomHandler& handler = | |
943 | reinterpret_cast<DiMuonTrackerCustomHandler&>(trackerDDLDecoder.GetHandler()); | |
944 | ||
945 | for(Int_t iDDL=1;iDDL<=20;iDDL++){ | |
946 | ||
947 | if(!MakeTrackDDLStream(buffer,&bufferSize,rawDataPath,iEvent,iDDL)){ | |
948 | printf("Cannot Read DDL Stream, Check the Event number in RawData Directory or DDL number \n"); | |
949 | continue ; | |
950 | } | |
951 | ||
952 | // for(int i=0;i<int(bufferSize/sizeof(int));i++) | |
953 | // printf("rawData[%d] : %-8x :: %15d\n",i,buffer[i],buffer[i]); | |
954 | ||
955 | handler.ResetDataCounter(); | |
956 | if(!trackerDDLDecoder.Decode(buffer, UInt_t(bufferSize))){ | |
957 | cerr<<"Cannot decode. "<<endl; | |
958 | continue ; | |
959 | ||
960 | } | |
961 | ||
962 | for(Int_t i=0;i<handler.GetDataSize();i++){ | |
963 | if(handler.GetData(i).fADC > 5){ | |
964 | gDimuTrackerMapping[handler.GetData(i).fDataId].fADC = | |
965 | Int_t(handler.GetData(i).fADC) ;//- | |
966 | // Int_t(gDimuTrackerMapping[handler.GetData(i).fDataId].fPed + 4*gDimuTrackerMapping[handler.GetData(i).fDataId].fSigma); | |
967 | ||
968 | // cout<<"detElem : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fDetElemId | |
969 | // <<", iX : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fIX | |
970 | // <<", iY : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fIY | |
971 | // <<", realX : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fRealX | |
972 | // <<", realY : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fRealY | |
973 | // <<", realZ : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fRealZ | |
974 | // <<", plane : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fCath | |
975 | // <<", ADC : "<<gDimuTrackerMapping[handler.GetData(i).fDataId].fADC | |
976 | // <<endl; | |
977 | ||
978 | gDimuTrackerDataList.push_back(handler.GetData(i).fDataId); | |
979 | }//fADC > refADC value | |
980 | ||
981 | } | |
982 | ||
983 | delete []buffer ; | |
984 | }// DDL loop | |
87f60d9e | 985 | |
46eadbb4 | 986 | cout<<"Tracker Data size : "<<gDimuTrackerDataList.size()<<endl; |
987 | return kTRUE; | |
87f60d9e | 988 | } |
989 | ||
990 | //**************************************************************************** | |
87f60d9e | 991 | |
46eadbb4 | 992 | bool MakeTrackDDLStream(int*& rawData, int* rawDataSize, TString rawDataPath, int iEvent, int iDDL) |
993 | { | |
994 | char rawDataFile[500]; | |
995 | sprintf(rawDataFile,"%s/raw%d/MUONTRK_%d.ddl",gSystem->ExpandPathName(rawDataPath.Data()),iEvent,0xA00 + iDDL - 1); | |
996 | ||
997 | ||
998 | FILE *fin = fopen(rawDataFile,"r"); | |
999 | if(fin == NULL){ | |
1000 | printf("Failed to open file %s\n",rawDataFile); | |
1001 | return false; | |
1002 | }else{ | |
1003 | // printf("Opening file %s\n",rawDataFile); | |
1004 | ||
1005 | int ddlHeader[8]; | |
1006 | int rawDDLSize; | |
1007 | ||
1008 | if(feof(fin)==0){ | |
1009 | fread((char *) & ddlHeader,(size_t)4*8,1,fin); | |
1010 | rawDDLSize = ddlHeader[0]/sizeof(int) - 8; | |
1011 | // rawDDLSize = ddlHeader[0]/sizeof(int) - 8 - 2 ; // temporary solution | |
1012 | //rewind(fin); | |
1013 | ||
1014 | // cout<<"rawDDLSize : "<<rawDDLSize<<endl; | |
1015 | // for(int i=0;i<8;i++) | |
1016 | // printf("ddlHeader[%d] : %d\n",i,ddlHeader[i]); | |
1017 | ||
1018 | if(ddlHeader[0]>10){ // 10 is temporary inprinciple 8 should be enough | |
1019 | int* buffer = new int[rawDDLSize]; | |
1020 | fread(buffer,sizeof(int), rawDDLSize,fin); | |
1021 | if(UInt_t(buffer[0])==0xFC0000FC){ | |
1022 | rawData = buffer; | |
1023 | *rawDataSize = rawDDLSize*sizeof(int) ; | |
1024 | //cout<<"buffer : "<<buffer<<endl; | |
1025 | }else{ | |
1026 | fclose(fin); | |
1027 | return false; | |
1028 | } | |
1029 | }else{ | |
1030 | fclose(fin); | |
1031 | return false; | |
1032 | } | |
1033 | } | |
1034 | ||
1035 | }// | |
1036 | ||
1037 | fclose(fin); | |
1038 | return true; | |
1039 | } | |
87f60d9e | 1040 | |
46eadbb4 | 1041 | //**************************************************************************** |
1042 | Int_t ReadPort( AliHLTHOMERBlockDesc* block ) | |
1043 | { | |
1044 | int *buffer; | |
1045 | int bufferSize; | |
87f60d9e | 1046 | |
46eadbb4 | 1047 | AliMUONTrackerDDLDecoder<DiMuonTrackerCustomHandler> trackerDDLDecoder; |
1048 | DiMuonTrackerCustomHandler& handler = | |
1049 | reinterpret_cast<DiMuonTrackerCustomHandler&>(trackerDDLDecoder.GetHandler()); | |
1050 | ||
1051 | DiMuonTriggerDDLDecoder triggerDecoder; | |
1052 | ||
1053 | unsigned long size = block->GetSize(); | |
1054 | bufferSize = UInt_t(int(size/sizeof(int))-10); | |
1055 | buffer = reinterpret_cast<int *>(block->GetData()); | |
1056 | buffer += 8; | |
1057 | ||
1058 | // if(buffer[0]==0xFC0000FC){ | |
1059 | // for(int i=0;i<int(bufferSize);i++) | |
1060 | // printf("rawData[%d] : %-8x :: %15d\n",i,buffer[i],buffer[i]); | |
1061 | // } | |
1062 | ||
1063 | if(buffer[0]!=int(0xFC0000FC)){ | |
1064 | ||
1065 | // for(int i=0;i<int(bufferSize);i++) | |
1066 | // printf("rawData[%d] : %-8x :: %15d\n",i,buffer[i],buffer[i]); | |
1067 | ||
1068 | triggerDecoder.ResetDataCounter(); | |
1069 | triggerDecoder.SetTriggerMappingData(&gDimuTriggerMapping[0]); | |
1070 | if(!triggerDecoder.Decode(buffer)){ | |
1071 | cerr<<"Cannot decode DiMuon Trigger RawData "<<endl; | |
1072 | //return kFALSE; | |
1073 | } | |
1074 | ||
1075 | for(Int_t i=0;i<triggerDecoder.GetDataSize();i++) | |
1076 | gDimuTriggerDataList.push_back(triggerDecoder.GetData(i)); | |
1077 | ||
1078 | ||
1079 | }else{ | |
1080 | ||
1081 | handler.ResetDataCounter(); | |
1082 | if(!trackerDDLDecoder.Decode(buffer,UInt_t(bufferSize*sizeof(int)))){ | |
1083 | cerr<<"Cannot decode DiMuon Tracker RawData "<<endl; | |
1084 | //return kFALSE; | |
1085 | } | |
1086 | ||
1087 | for(Int_t i=0;i<handler.GetDataSize();i++){ | |
1088 | if(handler.GetData(i).fADC > 0){ | |
1089 | ||
1090 | gDimuTrackerMapping[handler.GetData(i).fDataId].fADC = | |
1091 | Int_t(handler.GetData(i).fADC) - | |
1092 | Int_t(gDimuTrackerMapping[handler.GetData(i).fDataId].fPed);// + 4*gDimuTrackerMapping[handler.GetData(i).fDataId].fSigma); | |
1093 | ||
1094 | if(gDimuTrackerMapping[handler.GetData(i).fDataId].fADC > 0) | |
1095 | gDimuTrackerDataList.push_back(handler.GetData(i).fDataId); | |
1096 | ||
1097 | ||
1098 | }// adc cut | |
1099 | }// tracker dataSize | |
1100 | }// if trigger/tracker data | |
1101 | ||
1102 | ||
1103 | return true; | |
1104 | } | |
1105 | //**************************************************************************** | |
1106 | Int_t processDiMuonRawData( AliHLTHOMERBlockDesc* block ) | |
1107 | { | |
1108 | if(!ReadRawData(0)) | |
1109 | return false; | |
87f60d9e | 1110 | |
46eadbb4 | 1111 | // if(!ReadPort(block)) |
1112 | // return false; | |
1113 | ||
1114 | return true ; | |
1115 | } | |
87f60d9e | 1116 | //**************************************************************************** |
46eadbb4 | 1117 | Int_t drawDiMuonRawData(Int_t ADCCut) |
87f60d9e | 1118 | { |
46eadbb4 | 1119 | |
1120 | cout<<"Trying to read RawData "<<endl; | |
1121 | ||
1122 | ||
1123 | char ChamberName[50]; | |
1124 | TEveElement *eveMuonEventElmt = gEve->GetCurrentEvent()->FindChild("MUONChamberData"); | |
1125 | TEveElement *eveMuonGeomElmt = gEve->GetGlobalScene()->FindChild("MUONChambers"); | |
1126 | ||
1127 | eveMuonEventElmt->DestroyElements(); | |
1128 | ||
1129 | AliEveMUONChamber* mch = 0; | |
1130 | int ipoint = 0 ; | |
1131 | ||
1132 | ||
1133 | for(Int_t ichamber = 0 ; ichamber < 14; ichamber++){ | |
1134 | ||
1135 | if(ichamber<10) | |
1136 | sprintf(ChamberName,"Chamber 0%d (trac)",ichamber); | |
1137 | else | |
1138 | sprintf(ChamberName,"Chamber %2d (trig)",ichamber); | |
1139 | ||
1140 | mch = (AliEveMUONChamber*)(eveMuonGeomElmt->FindChild(ChamberName)); | |
1141 | ||
1142 | // cout<<"ichamber : "<<ichamber<<", mch : "<<mch<<endl; | |
1143 | mch->GetChamberData()->DropData(); | |
1144 | } | |
1145 | ||
1146 | ||
1147 | // -- DrawTracker RawData | |
1148 | Int_t dataId,ich, busPatchId, manuId ; | |
1149 | ||
1150 | cout<<"Total number of Tracker data : "<<Int_t(gDimuTrackerDataList.size())<<endl; | |
1151 | ||
1152 | for(Int_t idata = 0 ; idata < Int_t(gDimuTrackerDataList.size()); idata++){ | |
1153 | ||
1154 | dataId = gDimuTrackerDataList.at(idata); | |
1155 | cout<<"ADC : "<<gDimuTrackerMapping[dataId].fADC<<endl; | |
1156 | if(gDimuTrackerMapping[dataId].fADC > ADCCut){ | |
1157 | ||
1158 | if(Int_t(gDimuTrackerMapping[dataId].fDetElemId)<100 or Int_t(gDimuTrackerMapping[dataId].fDetElemId) > 1025 ) | |
1159 | continue ; | |
1160 | ||
1161 | ich = Int_t(gDimuTrackerMapping[dataId].fDetElemId/100) - 1; | |
1162 | sprintf(ChamberName,"Chamber 0%d (trac)",ich); | |
1163 | ||
1164 | mch = (AliEveMUONChamber*)(eveMuonGeomElmt->FindChild(ChamberName)); | |
1165 | ||
1166 | //if(ich==0) continue ; | |
1167 | ||
1168 | manuId = (dataId>>6) & 0x7FF ; | |
1169 | busPatchId = (dataId>>17) & 0xFFF ; | |
1170 | ||
1171 | if(busPatchId==728 and manuId==1122) continue ; | |
1172 | ||
1173 | cout<<"ich : "<<ich<<", idata : "<<idata | |
1174 | <<", detElemId : "<<gDimuTrackerMapping[dataId].fDetElemId | |
1175 | <<" bus : "<<busPatchId | |
1176 | <<" manu : "<<manuId | |
1177 | <<" iX : "<<gDimuTrackerMapping[dataId].fIX | |
1178 | <<" iY : "<<gDimuTrackerMapping[dataId].fIY | |
1179 | <<" realX : "<<gDimuTrackerMapping[dataId].fRealX | |
1180 | <<" realY : "<<gDimuTrackerMapping[dataId].fRealY | |
1181 | <<" realZ : "<<gDimuTrackerMapping[dataId].fRealZ | |
1182 | <<" ADC : "<<gDimuTrackerMapping[dataId].fADC | |
1183 | <<endl; | |
1184 | ||
1185 | if(gDimuTrackerMapping[dataId].fCath == 0) | |
1186 | mch->GetChamberData()->RegisterDigit(gDimuTrackerMapping[dataId].fDetElemId, | |
1187 | 0, | |
1188 | gDimuTrackerMapping[dataId].fIX, | |
1189 | gDimuTrackerMapping[dataId].fIY, | |
1190 | gDimuTrackerMapping[dataId].fADC); | |
1191 | ||
1192 | mch->GetChamberData()->RegisterHit(gDimuTrackerMapping[dataId].fDetElemId, | |
1193 | gDimuTrackerMapping[dataId].fRealX, | |
1194 | gDimuTrackerMapping[dataId].fRealY, | |
1195 | gDimuTrackerMapping[dataId].fRealZ); | |
1196 | ||
1197 | TEvePointSet* ps = new TEvePointSet(Form("Point-%d-Ch-0%d",ipoint,ich),1); | |
1198 | ps->SetPoint(0, | |
1199 | gDimuTrackerMapping[dataId].fRealX, | |
1200 | gDimuTrackerMapping[dataId].fRealY, | |
1201 | gDimuTrackerMapping[dataId].fRealZ); | |
1202 | ||
1203 | //point3d[ipoint].SetElementName(); | |
1204 | //point3d[ipoint].SetRnrState(kFALSE); | |
1205 | //point3d[ipoint].SetMarkerSize(15); | |
1206 | //point3d[ipoint].SetMarkerColor(4); | |
1207 | //point3d[ipoint].SetMarkerStyle(4); | |
1208 | ||
1209 | //gEve->AddElement(&point3d[ipoint],eveMuonEventElmt); | |
1210 | ||
1211 | ps->SetMarkerSize(15); | |
1212 | ps->SetMarkerColor(4); | |
1213 | ps->SetMarkerStyle(4); | |
1214 | ||
1215 | eveMuonEventElmt->AddElement(ps); | |
1216 | ipoint++; | |
1217 | ||
1218 | }// ADC Cut | |
1219 | }//foor loop | |
1220 | ||
1221 | // -- DrawTrigger RawData | |
1222 | // cout<<"Total number of Trigger data : "<<Int_t(gDimuTriggerDataList.size())<<endl; | |
1223 | // AliHLTMUONTriggerPointData data; | |
1224 | // for(Int_t idata = 0 ; idata < Int_t(gDimuTriggerDataList.size()); idata++){ | |
1225 | ||
1226 | // data = gDimuTriggerDataList.at(idata) ; | |
1227 | ||
1228 | // if(Int_t(data.fDetElemId)<1100 or Int_t(data.fDetElemId) > 1417 ) | |
1229 | // continue ; | |
1230 | ||
1231 | // ich = Int_t(data.fDetElemId/100) - 1; | |
1232 | // sprintf(ChamberName,"Chamber %2d (trig)",ich); | |
1233 | ||
1234 | // mch = (AliEveMUONChamber*)(eveMuonGeomElmt->FindChild(ChamberName)); | |
1235 | ||
1236 | ||
1237 | // cout<<"ich : "<<ich<<", idata : "<<idata | |
1238 | // <<", detElemId : "<<data.fDetElemId | |
1239 | // <<" realX : "<<data.fX | |
1240 | // <<" realY : "<<data.fY | |
1241 | // <<" realZ : "<<data.fZ | |
1242 | // <<endl; | |
1243 | ||
1244 | // mch->GetChamberData()->RegisterHit(data.fDetElemId,data.fX,data.fY,data.fZ); | |
1245 | ||
1246 | ||
1247 | // point3d[ipoint].SetPoint(0,data.fX,data.fY,data.fZ); | |
1248 | ||
1249 | ||
1250 | // sprintf(ChamberName,"Point-%d-Ch-0%d",ipoint,ich); | |
1251 | // point3d[ipoint].SetName(ChamberName); | |
1252 | // point3d[ipoint].SetRnrState(kFALSE); | |
1253 | // point3d[ipoint].SetMarkerSize(15); | |
1254 | // point3d[ipoint].SetMarkerColor(4); | |
1255 | // point3d[ipoint].SetMarkerStyle(4); | |
1256 | ||
1257 | // gEve->AddElement(&point3d[ipoint],eveMuonEventElmt); | |
1258 | // ipoint++; | |
1259 | ||
1260 | // }// data loop | |
1261 | ||
1262 | ||
1263 | globMaxPoint = ipoint ; | |
1264 | ||
1265 | ||
1266 | ||
1267 | return 0; | |
1268 | } | |
1269 | //**************************************************************************** | |
1270 | void loopEvent() { | |
87f60d9e | 1271 | event_timer.SetCommand("nextEvent()"); |
1272 | event_timer.Start(60); | |
1273 | } | |
1274 | ||
1275 | //**************************************************************************** | |
46eadbb4 | 1276 | void stopLoopEvent() { |
87f60d9e | 1277 | event_timer.Stop(); |
1278 | } | |
46eadbb4 | 1279 |