2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 #if !defined(__CINT__) || defined(__MAKECINT__)
13 #include <TGeoGlobalMagField.h>
14 #include <TGeoManager.h>
21 #include <TEveManager.h>
22 #include <TEveElement.h>
23 #include <TEvePointSet.h>
24 #include <TEveTreeTools.h>
26 #include <AliAltroRawStreamV3.h>
27 #include <AliEveEventManager.h>
28 #include <AliEveTPCData.h>
29 #include <AliEveTPCSector2D.h>
30 #include <AliEveTPCSector3D.h>
31 #include <AliGeomManager.h>
33 #include <AliRawReader.h>
35 #include <AliGRPObject.h>
36 #include <AliCDBManager.h>
37 #include <AliCDBPath.h>
38 #include <AliCDBEntry.h>
40 #include <STEER/STEER/AliGRPManager.h>
42 #include <TPC/AliTPCcalibDB.h>
43 #include <TPC/AliTPCTransform.h>
44 #include <TPC/AliTPCclusterMI.h>
45 #include <TPC/AliTPCClustersRow.h>
47 #include <TPC/AliTPCParam.h>
48 #include <TPC/AliTPCRawStreamV3.h>
49 #include <TPC/AliTPCRecoParam.h>
50 #include <TPC/AliTPCReconstructor.h>
52 #include <HLT/BASE/AliHLTOUT.h>
53 #include <HLT/BASE/AliHLTSystem.h>
54 #include <HLT/BASE/AliHLTPluginBase.h>
56 #include <RAW/AliRawHLTManager.h>
59 // read TPC clusters compressed by HLT from RawReader and return output in OutputTree
60 TTree* readHLTClusters(AliRawReader *RawReader);
62 // add the HLT clusters from clustersTree to visualization
63 void renderHLTClusters(TTree* clustersTree);
66 // Macro to visualise rootified raw-data from TPC.
68 // Use tpc_raw(Int_t mode) in order to run it
69 // Needs that alieve_init() is already called
70 // mode = 1 - show only 2D sectors
71 // mode = 2 - show only 3D sectors
72 // mode = 3 - show both 2D and 3D sectors
73 void tpc_raw(Int_t mode = 3)
75 gStyle->SetPalette(1, 0);
77 AliEveEventManager::AssertGeometry();
78 AliEveEventManager::AssertMagField();
80 AliRawReader *reader = AliEveEventManager::AssertRawReader();
83 AliTPCRawStreamV3 input(reader);
84 reader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
86 AliEveTPCData *x = new AliEveTPCData;
87 // x->SetLoadPedestal(5);
88 x->SetLoadThreshold(5);
89 x->SetAutoPedestal(kTRUE);
91 x->LoadRaw(input, kTRUE, kTRUE);
93 gEve->DisableRedraw();
95 TEveElementList* sec2d = new TEveElementList("TPC 2D");
96 gEve->AddElement(sec2d);
98 TEveElementList* sec3d = new TEveElementList("TPC 3D");
99 gEve->AddElement(sec3d);
101 AliEveTPCSector2D *s;
102 AliEveTPCSector3D *t;
104 for (Int_t i=0; i<=35; ++i) {
106 s = new AliEveTPCSector2D(Form("2D sector %d",i));
108 s->SetAutoTrans(kTRUE); // place on proper 3D coordinates
110 s->SetFrameColor(36);
111 sec2d->AddElement(s);
115 t = new AliEveTPCSector3D(Form("3D sector %d",i));
117 t->SetAutoTrans(kTRUE);
119 sec3d->AddElement(t);
124 // Display TPC clusters compressed by HLT
125 TTree* hltClustersTree = readHLTClusters(reader); // read HLT compressed clusters from TPC from raw reader and output them in hltClustersTree
126 if(hltClustersTree) renderHLTClusters(hltClustersTree);
128 gEve->EnableRedraw();
133 // read TPC Clusters compressed by HLT from a raw filename
134 TTree* readHLTClusters(AliRawReader *fRawReader)
136 /*************************
138 **************************/
139 AliRawReader* rawReader = AliRawHLTManager::CreateRawReaderHLT(fRawReader, "TPC");
140 rawReader->Select("TPC");
142 /*************************
144 **************************/
145 AliHLTSystem* hltSystem=AliHLTPluginBase::GetInstance();
147 AliHLTOUT* hltOut = AliHLTOUT::New(rawReader);
149 hltSystem->InitHLTOUT(hltOut);
151 /*************************
153 **************************/
154 AliGRPManager manGRP;
155 AliRecoParam* recoParam = AliEveEventManager::AssertRecoParams();
157 AliEveEventManager* curEventMan = (AliEveEventManager*)gEve->GetCurrentEvent();
159 const AliRunInfo* runInfo = manGRP.GetRunInfo();
160 const THashTable* cosmicTriggers = manGRP.GetCosmicTriggers();
161 const AliEventInfo* eventinfo = curEventMan->GetEventInfo();
163 recoParam->SetEventSpecie(runInfo,*eventinfo,cosmicTriggers);
165 AliTPCRecoParam *tpcRecoParam = (AliTPCRecoParam*)recoParam->GetDetRecoParam(1); // TPC has index 1
166 tpcRecoParam->SetUseHLTClusters(3); // reconstruct only HLT clusters
168 /**************************
169 * Reconstruction of Clusters
170 **************************/
171 TTree* outputClustersTree = new TTree;
173 AliTPCReconstructor *reconstructor = new AliTPCReconstructor();
174 reconstructor->SetOption("useHLT");
175 reconstructor->CreateTracker(); // this will set the option to reconstruct for only HLT clusters
177 reconstructor->SetRecoParam(tpcRecoParam);
178 reconstructor->SetRunInfo((AliRunInfo*)runInfo);
179 reconstructor->SetEventInfo((AliEventInfo*)eventinfo);
181 reconstructor->Reconstruct(rawReader, outputClustersTree);
183 delete reconstructor;
185 hltSystem->ReleaseHLTOUT(hltOut);
187 return outputClustersTree;
190 void renderHLTClusters(TTree* clustersTree)
193 /**************************
194 * Visualization of Clusters
195 **************************/
196 const Int_t kMaxCl=100*160;
197 Int_t fNColorBins = 5;
199 TEvePointSet* clusters = new TEvePointSet(kMaxCl);
200 clusters->SetOwnIds(kTRUE);
202 TEvePointSetArray * cc = new TEvePointSetArray("TPC Clusters Colorized");
203 cc->SetMainColor(kRed);
204 cc->SetMarkerStyle(4);
205 cc->SetMarkerSize(0.4);
206 cc->InitBins("Cluster Charge", fNColorBins, 0., fNColorBins*60.);
208 cc->GetBin(0)->SetMainColor(kGray);
209 cc->GetBin(0)->SetMarkerSize(0.4);
210 cc->GetBin(1)->SetMainColor(kBlue);
211 cc->GetBin(1)->SetMarkerSize(0.42);
212 cc->GetBin(2)->SetMainColor(kCyan);
213 cc->GetBin(2)->SetMarkerSize(0.44);
214 cc->GetBin(3)->SetMainColor(kGreen);
215 cc->GetBin(3)->SetMarkerSize(0.46);
216 cc->GetBin(4)->SetMainColor(kYellow);
217 cc->GetBin(4)->SetMarkerSize(0.48);
218 cc->GetBin(5)->SetMainColor(kRed);
219 cc->GetBin(5)->SetMarkerSize(0.50);
220 cc->GetBin(6)->SetMainColor(kMagenta);
221 cc->GetBin(6)->SetMarkerSize(0.52);
224 // Loop over clusters
225 Int_t nentries = clustersTree->GetEntriesFast();
227 AliTPCClustersRow *clrow = new AliTPCClustersRow();
228 clrow->SetClass("AliTPCclusterMI");
229 //clrow->SetArray(kMaxCl);
230 clustersTree->SetBranchAddress("Segment", &clrow);
232 for (Int_t i=0; i<nentries; i++) {
233 if (!clustersTree->GetEvent(i)) continue;
235 TClonesArray *cl = clrow->GetArray();
236 Int_t ncl = cl->GetEntriesFast();
240 AliTPCclusterMI* clusterMI = (AliTPCclusterMI*) cl->At(ncl);
242 AliCluster *c = (AliCluster*) cl->UncheckedAt(ncl);
243 Float_t g[3]; //global coordinates
246 cc->Fill(g[0], g[1], g[2], clusterMI->GetQ());
247 clusters->SetNextPoint(g[0], g[1], g[2]);
248 AliCluster *atp = new AliCluster(*clusterMI);
249 clusters->SetPointId(atp);
257 clusters->SetName("TPC Clusters");
258 clusters->SetTitle(Form("N=%d", clusters->Size()));
260 const TString viz_tag("REC Clusters TPC"); // to be changed
261 clusters->ApplyVizTag(viz_tag, "Clusters");
263 cc->SetRnrSelf(kTRUE);
265 gEve->AddElement(cc);