]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/muon_digits.C
Added last decoder version (V2) in TOF raw data visualization
[u/mrichter/AliRoot.git] / EVE / alice-macros / muon_digits.C
CommitLineData
39d6561a 1// $Id$
2
3/**************************************************************************
4 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
5 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
6 * full copyright notice. *
7 **************************************************************************/
8
25b4bdb2 9/// \ingroup evemacros
10/// \file muon_digits.C
11/// \brief Macro to visualise digits from MUON spectrometer
12/// (both tracker and trigger).
13///
14/// Use muon_digits() in order to run it
15///
16/// Needs that alieve_init() is already called
17///
18/// \author P. Pillot, L. Aphecetche; Subatech
39d6561a 19
20#if !defined(__CINT__) || defined(__MAKECINT__)
21
22#include "AliMUONGeometryTransformer.h"
23#include "AliMUONVDigit.h"
24#include "AliMUONVDigitStore.h"
25
26#include "AliMpPad.h"
27#include "AliMpSegmentation.h"
28#include "AliMpVSegmentation.h"
29#include "AliMpCDB.h"
30
31#include "AliRunLoader.h"
32
33#include "EveBase/AliEveEventManager.h"
34
35#include <TEveManager.h>
36#include <TEveQuadSet.h>
37
38#include <TTree.h>
39#include <TStyle.h>
40#include <Riostream.h>
41
42#endif
43
39d6561a 44//______________________________________________________________________________
45void add_muon_digits(TIter* next, TEveQuadSet* bending, TEveQuadSet* nonBending, Bool_t fromRaw)
46{
47 // load mapping
48 AliMpCDB::LoadAll(kFALSE);
49
50 // load geometry
2fcde5f6 51 static AliMUONGeometryTransformer* gMUONGeometryTransformer = 0x0;
52 if (!gMUONGeometryTransformer)
39d6561a 53 {
54 AliEveEventManager::AssertGeometry();
55 gMUONGeometryTransformer = new AliMUONGeometryTransformer();
56 gMUONGeometryTransformer->LoadGeometryData();
57 }
58
59 // loop over digits and produce corresponding graphic objects
60 AliMUONVDigit* digit;
61 while ( ( digit = static_cast<AliMUONVDigit*>((*next)() ) ) )
62 {
63 if (!digit->IsTrigger() && !fromRaw && digit->Charge() < 1.e-3) continue;
64
65 Int_t detElemId = digit->DetElemId();
66 Int_t manuId = digit->ManuId();
67
68 const AliMpVSegmentation* vseg =
69 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(digit->Cathode()));
70 if (!vseg)
71 {
72 cout << Form("Could not get segmentation for DE %4d MANU %4d",detElemId,manuId) << endl;
73 continue; // should not happen, unless we got a readout error and thus a bad de,manu pair
74 }
75
76 AliMpPad pad = vseg->PadByLocation(manuId,digit->ManuChannel());
77
78 Double_t local[] = { pad.GetPositionX(), pad.GetPositionY(), 0.0 };
79 Double_t global[] = { 0.0, 0.0, 0.0 };
80
81 gMUONGeometryTransformer->Local2Global(detElemId,
82 local[0], local[1], local[2],
83 global[0], global[1], global[2]);
84
85 TEveQuadSet* pads = bending;
86 if (vseg->PlaneType()==AliMp::kNonBendingPlane) pads = nonBending;
87
88 pads->AddQuad(global[0]-pad.GetDimensionX(),global[1]-pad.GetDimensionY(),global[2],
89 2.*pad.GetDimensionX(),2.*pad.GetDimensionY());
90
91 if (fromRaw && !digit->IsTrigger()) pads->QuadValue(digit->ADC());
2fcde5f6 92 else pads->QuadValue((Int_t) digit->Charge());
39d6561a 93 }
94
95}
96
97//______________________________________________________________________________
98void muon_digits()
99{
100 // load digits
101 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
102 rl->LoadDigits("MUON");
103 TTree* dt = rl->GetTreeD("MUON", kFALSE);
104 if (!dt) return;
105 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*dt);
106 digitStore->Clear();
107 digitStore->Connect(*dt,0);
108 dt->GetEvent(0);
7580e2a8 109 rl->UnloadDigits("MUON");
110
111 if (digitStore->GetSize() == 0 && !gEve->GetKeepEmptyCont()) {
112 delete digitStore;
113 return;
114 }
39d6561a 115
116 // container for graphic representation of digits
117 TEveElementList* cont = new TEveElementList("MUON Digits");
118
119 TEveQuadSet* bending = new TEveQuadSet(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
120 bending->SetName("Bending");
121 bending->SetRenderMode(TEveDigitSet::kRM_Fill);
122 bending->SetPickable(kFALSE);
123 cont->AddElement(bending);
124
125 TEveQuadSet* nonBending = new TEveQuadSet(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
126 nonBending->SetName("Non bending");
127 nonBending->SetRenderMode(TEveDigitSet::kRM_Line);
128 nonBending->SetPickable(kFALSE);
129 cont->AddElement(nonBending);
130
131 // add digits to the containers
132 TIter next(digitStore->CreateIterator());
133 add_muon_digits(&next, bending, nonBending, kFALSE);
134 delete digitStore;
135
136 // set containers' title
137 Int_t nDigitB = bending->GetPlex()->Size();
138 Int_t nDigitNB = nonBending->GetPlex()->Size();
139 cont->SetTitle(Form("N=%d",nDigitB+nDigitNB));
140 bending->SetTitle(Form("N=%d",nDigitB));
141 nonBending->SetTitle(Form("N=%d",nDigitNB));
142
143 // automatic scaling
144 gStyle->SetPalette(1);
145 bending->AssertPalette();
146 nonBending->AssertPalette();
147
148 // add graphic containers
149 gEve->DisableRedraw();
150 gEve->AddElement(cont);
151 gEve->EnableRedraw();
152 gEve->Redraw3D();
153}