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