]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EVE/AliHLTEveMuon.cxx
From Indra: Bug fix to display the reconstructed hits for di-muon tracking chambers
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveMuon.cxx
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 "AliEveHOMERManager.h"
28 #include "TEveManager.h"
29 #include "AliMUONConstants.h"
30
31 ClassImp(AliHLTEveMuon);
32
33 AliHLTEveMuon::AliHLTEveMuon() : 
34   AliHLTEveBase(),
35   fTracks(NULL),
36   fClusters(NULL)
37 {
38   // Constructor.
39 }
40
41 AliHLTEveMuon::~AliHLTEveMuon()
42 {
43   //Destructor
44   if (fTracks)
45     delete fTracks;
46   fTracks = NULL;
47
48   if(fClusters)
49     delete fClusters;
50   fClusters = NULL;
51 }
52
53
54 void AliHLTEveMuon::ProcessBlock(AliHLTHOMERBlockDesc * block) {
55   //See header file for documentation
56     if ( (block->GetDataType().CompareTo("RECHITS") == 0) || (block->GetDataType().CompareTo("TRIGRECS") == 0) ) {
57       if(!fClusters) {
58       fClusters = CreateClusters();
59       fEventManager->GetEveManager()->AddElement(fClusters);
60     }
61     ProcessClusters( block, fClusters );
62     
63   }else if(block->GetDataType().CompareTo("MANTRACK") == 0){
64     
65     if ( !fTracks ) {
66       fTracks = CreateTrackSet(); 
67       fEventManager->GetEveManager()->AddElement(fTracks);
68       gEve->AddElement(fTracks);
69     }
70     
71     ProcessTracks( block, fTracks );
72   } 
73 }
74
75 TEvePointSet * AliHLTEveMuon::CreateClusters() {
76   //See header file for documentation
77   TEvePointSet * ps = new TEvePointSet("MUON RecHits");
78   ps->SetMainColor(kBlue);
79   ps->SetMarkerStyle(20);
80   return ps;
81 }
82
83 TEveStraightLineSet * AliHLTEveMuon::CreateTrackSet() {
84   TEveStraightLineSet * ls = new TEveStraightLineSet("MUON Tracks");
85   ls->SetMainColor(kRed);
86   ls->SetLineWidth(3);
87   return ls;
88 }
89
90 void AliHLTEveMuon::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
91   //See header file for documentation
92   if(!fCanvas) {
93     fCanvas = CreateCanvas("MUON QA", "MUON QA");
94     fCanvas->Divide(3, 2);
95   }
96   AddHistogramsToCanvas(block, fCanvas, fHistoCount);
97 }
98
99 void AliHLTEveMuon::UpdateElements() {
100   //See header file for documentation
101   if(fCanvas) fCanvas->Update();
102   if(fClusters) fClusters->ResetBBox();
103   if(fTracks) fTracks->ElementChanged();
104 }
105
106 void AliHLTEveMuon::ResetElements(){
107   //See header file for documentation
108   fHistoCount = 0;
109   
110   if ( fClusters ) fClusters->Reset();
111   if ( fTracks ){
112     fTracks->Destroy();
113     fTracks = NULL;
114   }
115
116 }
117
118 void AliHLTEveMuon::ProcessClusters(AliHLTHOMERBlockDesc * block, TEvePointSet * clusters) {
119     //See header file for documentation
120   unsigned long size = block->GetSize();
121   Int_t * buffer ;
122   
123   buffer = (Int_t *)block->GetData();
124   //cout<<"block size : "<<size<<", buffer : "<<buffer<<", DataType : "<<block->GetDataType()<<endl;
125
126   if(block->GetDataType().CompareTo("RECHITS") == 0){
127     
128     AliHLTMUONRecHitsBlockReader trackblock((char*)buffer, size);
129     const AliHLTMUONRecHitStruct* hit = trackblock.GetArray();
130     
131     for(AliHLTUInt32_t ientry = 0; ientry < trackblock.Nentries(); ientry++){
132       if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0)
133         clusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
134       hit++;
135       
136     }// track hit loop
137   }
138   
139   else{// if rechits
140     //     if(!strcmp((BlockType(ULong64_t(reader->GetBlockDataType(i)))).Data(),"TRIGRECS")){
141     
142     AliHLTMUONTriggerRecordsBlockReader trigblock(buffer, size);
143     const AliHLTMUONTriggerRecordStruct* trigrec = trigblock.GetArray();
144     for(AliHLTUInt32_t ientry = 0; ientry < trigblock.Nentries(); ientry++){
145       
146       const AliHLTMUONRecHitStruct* hit = &trigrec->fHit[0];
147       for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
148         {
149           if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0)
150             clusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
151           hit++;
152         }// trig chamber loop
153       trigrec++;
154     }//trig hit loop
155   }//else trigger
156   
157 }
158
159 void AliHLTEveMuon::ProcessTracks(AliHLTHOMERBlockDesc * block, TEveStraightLineSet * tracks) {
160   //See header file for documentation  
161   unsigned long size = block->GetSize();
162   Int_t * buffer = (Int_t *)block->GetData();
163   AliHLTMUONRecHitStruct hit1,hit2;
164   hit1.fX = hit1.fY = hit1.fZ = hit2.fX = hit2.fY = hit2.fZ = 0;
165   Int_t ch1=0, ch2=0;
166   Float_t x0=0.0,y0=0.0,z0=0.0;
167   Float_t x3=0.0,y3=0.0,z3=0.0;
168   if(block->GetDataType().CompareTo("MANTRACK") == 0){  
169     AliHLTMUONMansoTracksBlockReader mantrackblock(buffer, size);
170     const AliHLTMUONMansoTrackStruct* mtrack = mantrackblock.GetArray();
171     for(AliHLTUInt32_t ientry = 0; ientry < mantrackblock.Nentries(); ientry++){
172       const AliHLTMUONRecHitStruct* hit = &mtrack->fHit[0];
173       for(AliHLTUInt32_t ch = 0; ch < 4; ch++){
174         // cout << setw(10) << left << ch + 7 << setw(0);
175         // cout << setw(13) << left << hit->fX << setw(0);
176         // cout << setw(13) << left << hit->fY << setw(0);
177         // cout << hit->fZ << setw(0) << endl;
178         if(hit->fZ != 0.0){
179           if(ch==0 || ch==1){
180             hit1 = *hit; ch1 = ch+6;
181           }else{
182             hit2 = *hit; ch2 = ch+6;
183           }
184         }
185         hit++;
186       }// trig chamber loop
187       // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch1,hit1.fX,hit1.fY,hit1.fZ);
188       // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch2,hit2.fX,hit2.fY,hit2.fZ);
189       // meminfo();
190       z3 = AliMUONConstants::DefaultChamberZ(ch2+4);
191       y3 =  hit1.fY - (hit1.fZ-z3)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ;
192       x3 =  hit1.fX - (hit1.fZ-z3)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ;
193
194       z0 = AliMUONConstants::DefaultChamberZ(ch1);
195       y0 =  hit1.fY - (hit1.fZ-z0)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ;
196       x0 =  hit1.fX - (hit1.fZ-z0)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ;
197       
198
199       tracks->AddLine(x0,y0,z0,x3,y3,z3);
200       mtrack++;
201     }
202     //    cout<<"NofManso Tracks : "<<mantrackblock.Nentries()<<endl;
203   }
204 }