In muon-related macros in EVE:
[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);
109 if (digitStore->GetSize() == 0 && !gEve->GetKeepEmptyCont()) return;
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}