]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EVE/AliHLTEveTRD.cxx
HLTqadm
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveTRD.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  TPC processor for the HLT EVE display
20
21 #include "TClonesArray.h"
22 #include "AliHLTEveTRD.h"
23 #include "AliHLTHOMERBlockDesc.h"
24 #include "TCanvas.h"
25 #include "AliHLTEveBase.h"
26 #include "AliEveHLTEventManager.h"
27 #include "TEveManager.h"
28 #include "TEvePointSet.h"
29 #include "TColor.h"
30 #include "TMath.h"
31 #include "TH1F.h"
32 #include "AliHLTTRDUtils.h"
33 #include "AliTRDcluster.h"
34
35 ClassImp(AliHLTEveTRD)
36
37 AliHLTEveTRD::AliHLTEveTRD() : 
38   AliHLTEveBase("TRD"), 
39   fEveClusters(NULL),
40   fEveColClusters(NULL),
41   fNColorBins(15),
42   fClusterArray(NULL)
43 {
44   // Constructor.
45   fClusterArray = new TClonesArray("AliTRDcluster");
46 }
47
48 AliHLTEveTRD::~AliHLTEveTRD()
49 {
50   //Destructor, not implemented
51   if(fEveColClusters)
52     delete fEveColClusters;
53   fEveColClusters = NULL;
54   
55   if(fEveClusters)
56     delete fEveClusters;
57   fEveClusters = NULL;
58
59   fClusterArray->Delete();
60   delete fClusterArray;
61   fClusterArray = NULL;
62 }
63
64
65 void AliHLTEveTRD::ProcessBlock(AliHLTHOMERBlockDesc * block) {
66   //See header file for documentation
67
68   if ( ! block->GetDataType().CompareTo("CLUSTERS") ) {
69     
70     if(!fEveColClusters){
71       fEveColClusters = CreatePointSetArray();
72       AddElement(fEveColClusters);
73     } 
74     
75     ProcessClusters(block, fEveColClusters);
76    
77   } else if ( ! block->GetDataType().CompareTo("ROOTHIST") ) {
78   
79     if(!fCanvas) {
80       fCanvas = CreateCanvas("TRD QA", "TRD QA");
81       fCanvas->Divide(3, 3);
82     }
83
84     AddHistogramsToCanvas(block, fCanvas, fHistoCount);
85                    
86   }
87   
88 }
89
90
91 void AliHLTEveTRD::AddHistogramsToCanvas(AliHLTHOMERBlockDesc* block, TCanvas * canvas, Int_t &cdCount ) {
92   //See header file for documentation
93   if ( ! block->GetClassName().CompareTo("TH1F")) {
94     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
95     ++cdCount;
96   
97     TVirtualPad* pad = canvas->cd(cdCount);
98     histo->Draw();
99     pad->SetGridy();
100     pad->SetGridx();
101
102     if ( ! strcmp(histo->GetName(), "nscls") ) {
103       histo->GetXaxis()->SetRangeUser(0.,15.);
104     }
105
106     if ( ! strcmp(histo->GetName(),"sclsdist") ||
107          ! strcmp(histo->GetName(),"evSize") )
108       pad->SetLogy();
109   }
110
111 }
112
113
114
115 TEvePointSet * AliHLTEveTRD::CreatePointSet() {
116   //See header file for documentation
117   TEvePointSet * ps = new TEvePointSet("TRD Clusters");
118   ps->SetMainColor(kBlue);
119   ps->SetMarkerStyle((Style_t)kFullDotSmall);
120  
121   return ps;
122
123 }
124
125 TEvePointSetArray * AliHLTEveTRD::CreatePointSetArray(){
126
127   Int_t i = 0;
128
129   cout << i++ << endl;
130   //See header file for documentation
131   TEvePointSetArray * cc = new TEvePointSetArray("TRD Clusters Colorized");
132   cout << i++ << endl;
133   cc->SetMainColor(kRed);
134   cout << i++ << endl;
135   cc->SetMarkerStyle(4); // antialiased circle
136   cout << i++ << endl;
137   cc->SetMarkerSize(0.4);
138   cout << i++ << endl;
139   cc->InitBins("Cluster Charge", fNColorBins, 0., fNColorBins*100.);
140   cout << i++ << endl;
141   
142   const Int_t nCol = TColor::GetNumberOfColors();
143   cout << i++ << endl;
144   for (Int_t ii = 0; ii < fNColorBins + 1; ++ii) {
145     cc->GetBin(ii)->SetMainColor(TColor::GetColorPalette(ii * nCol / (fNColorBins+2)));
146   }
147   cout << i++ << endl;
148
149   return cc;
150      
151 }
152
153
154 void AliHLTEveTRD::UpdateElements() {
155   //See header file for documentation
156   if(fCanvas) fCanvas->Update();
157   // if(fEveClusters) fEveClusters->ResetBBox();
158
159   if(fEveColClusters) {
160     for (Int_t ib = 0; ib <= fNColorBins + 1; ++ib) {
161       fEveColClusters->GetBin(ib)->ResetBBox();
162     }
163   }
164 }
165
166 void AliHLTEveTRD::ResetElements(){
167   //See header file for documentation
168   // if(fEveClusters) fEveClusters->Reset();
169  
170   if(fEveColClusters){
171     for (Int_t ib = 0; ib <= fNColorBins + 1; ++ib) {
172       fEveColClusters->GetBin(ib)->Reset();
173     }
174   }
175
176   fHistoCount = 0;
177 }
178
179 Int_t AliHLTEveTRD::ProcessClusters( AliHLTHOMERBlockDesc * block, TEvePointSetArray * contCol ){
180   //See header file for documentation
181
182   Int_t iResult = 0;
183
184   Int_t sm = block->GetSubDetector();
185   if ( sm == 6 ) sm = 7;
186   
187   Float_t phi   = ( sm + 0.5 ) * TMath::Pi() / 9.0;  
188   Float_t cos   = TMath::Cos( phi );
189   Float_t sin   = TMath::Sin( phi );
190   
191   Byte_t* ptrData = reinterpret_cast<Byte_t*>(block->GetData());
192   UInt_t ptrSize = block->GetSize();
193   Int_t unused;
194
195   AliHLTTRDUtils::ReadClusters(fClusterArray, ptrData, ptrSize, &unused);
196
197   for(int num=fClusterArray->GetEntriesFast(); num--;){
198     AliTRDcluster* trdCluster = (AliTRDcluster*)fClusterArray->At(num);
199     contCol->Fill(cos*trdCluster->GetX() - sin*trdCluster->GetY(), 
200                   sin*trdCluster->GetX() + cos*trdCluster->GetY(), 
201                   trdCluster->GetZ(),
202                   trdCluster->GetQ() );  
203   }
204   
205   return iResult;
206 }
207
208