AliInfo displays better than std::cout
[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__)
ba978640 21#include <Riostream.h>
39d6561a 22#include <TTree.h>
23#include <TStyle.h>
ba978640 24#include <TEveManager.h>
25#include <TEveQuadSet.h>
39d6561a 26
6c49a8e1 27#include <AliMUONGeometryTransformer.h>
28#include <AliMUONVDigit.h>
29#include <AliMUONVDigitStore.h>
30#include <AliMpPad.h>
31#include <AliMpSegmentation.h>
32#include <AliMpVSegmentation.h>
33#include <AliMpCDB.h>
34#include <AliRunLoader.h>
35#include <AliEveEventManager.h>
39d6561a 36#endif
37
39d6561a 38//______________________________________________________________________________
39void add_muon_digits(TIter* next, TEveQuadSet* bending, TEveQuadSet* nonBending, Bool_t fromRaw)
40{
41 // load mapping
42 AliMpCDB::LoadAll(kFALSE);
43
44 // load geometry
2fcde5f6 45 static AliMUONGeometryTransformer* gMUONGeometryTransformer = 0x0;
46 if (!gMUONGeometryTransformer)
39d6561a 47 {
48 AliEveEventManager::AssertGeometry();
49 gMUONGeometryTransformer = new AliMUONGeometryTransformer();
50 gMUONGeometryTransformer->LoadGeometryData();
51 }
52
53 // loop over digits and produce corresponding graphic objects
54 AliMUONVDigit* digit;
55 while ( ( digit = static_cast<AliMUONVDigit*>((*next)() ) ) )
56 {
57 if (!digit->IsTrigger() && !fromRaw && digit->Charge() < 1.e-3) continue;
58
59 Int_t detElemId = digit->DetElemId();
60 Int_t manuId = digit->ManuId();
61
62 const AliMpVSegmentation* vseg =
63 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(digit->Cathode()));
64 if (!vseg)
65 {
1cec595f 66 AliInfo(Form("Could not get segmentation for DE %4d MANU %4d",detElemId,manuId));
39d6561a 67 continue; // should not happen, unless we got a readout error and thus a bad de,manu pair
68 }
69
70 AliMpPad pad = vseg->PadByLocation(manuId,digit->ManuChannel());
71
72 Double_t local[] = { pad.GetPositionX(), pad.GetPositionY(), 0.0 };
73 Double_t global[] = { 0.0, 0.0, 0.0 };
74
75 gMUONGeometryTransformer->Local2Global(detElemId,
76 local[0], local[1], local[2],
77 global[0], global[1], global[2]);
78
79 TEveQuadSet* pads = bending;
80 if (vseg->PlaneType()==AliMp::kNonBendingPlane) pads = nonBending;
81
82 pads->AddQuad(global[0]-pad.GetDimensionX(),global[1]-pad.GetDimensionY(),global[2],
83 2.*pad.GetDimensionX(),2.*pad.GetDimensionY());
84
85 if (fromRaw && !digit->IsTrigger()) pads->QuadValue(digit->ADC());
2fcde5f6 86 else pads->QuadValue((Int_t) digit->Charge());
39d6561a 87 }
88
89}
90
91//______________________________________________________________________________
92void muon_digits()
93{
94 // load digits
95 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
96 rl->LoadDigits("MUON");
97 TTree* dt = rl->GetTreeD("MUON", kFALSE);
98 if (!dt) return;
99 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*dt);
100 digitStore->Clear();
101 digitStore->Connect(*dt,0);
102 dt->GetEvent(0);
7580e2a8 103 rl->UnloadDigits("MUON");
104
105 if (digitStore->GetSize() == 0 && !gEve->GetKeepEmptyCont()) {
106 delete digitStore;
107 return;
108 }
39d6561a 109
110 // container for graphic representation of digits
111 TEveElementList* cont = new TEveElementList("MUON Digits");
112
113 TEveQuadSet* bending = new TEveQuadSet(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
114 bending->SetName("Bending");
115 bending->SetRenderMode(TEveDigitSet::kRM_Fill);
116 bending->SetPickable(kFALSE);
117 cont->AddElement(bending);
118
119 TEveQuadSet* nonBending = new TEveQuadSet(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
120 nonBending->SetName("Non bending");
121 nonBending->SetRenderMode(TEveDigitSet::kRM_Line);
122 nonBending->SetPickable(kFALSE);
123 cont->AddElement(nonBending);
124
125 // add digits to the containers
126 TIter next(digitStore->CreateIterator());
127 add_muon_digits(&next, bending, nonBending, kFALSE);
128 delete digitStore;
129
130 // set containers' title
131 Int_t nDigitB = bending->GetPlex()->Size();
132 Int_t nDigitNB = nonBending->GetPlex()->Size();
133 cont->SetTitle(Form("N=%d",nDigitB+nDigitNB));
134 bending->SetTitle(Form("N=%d",nDigitB));
135 nonBending->SetTitle(Form("N=%d",nDigitNB));
136
137 // automatic scaling
138 gStyle->SetPalette(1);
139 bending->AssertPalette();
140 nonBending->AssertPalette();
141
142 // add graphic containers
143 gEve->DisableRedraw();
144 gEve->AddElement(cont);
145 gEve->EnableRedraw();
146 gEve->Redraw3D();
147}