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 **************************************************************************/
10 /// \file muon_digits.C
11 /// \brief Macro to visualise digits from MUON spectrometer
12 /// (both tracker and trigger).
14 /// Use muon_digits() in order to run it
16 /// Needs that alieve_init() is already called
18 /// \author P. Pillot, L. Aphecetche; Subatech
20 #if !defined(__CINT__) || defined(__MAKECINT__)
22 #include "AliMUONGeometryTransformer.h"
23 #include "AliMUONVDigit.h"
24 #include "AliMUONVDigitStore.h"
27 #include "AliMpSegmentation.h"
28 #include "AliMpVSegmentation.h"
31 #include "AliRunLoader.h"
33 #include "EveBase/AliEveEventManager.h"
35 #include <TEveManager.h>
36 #include <TEveQuadSet.h>
40 #include <Riostream.h>
44 //______________________________________________________________________________
45 void add_muon_digits(TIter* next, TEveQuadSet* bending, TEveQuadSet* nonBending, Bool_t fromRaw)
48 AliMpCDB::LoadAll(kFALSE);
51 static AliMUONGeometryTransformer* gMUONGeometryTransformer = 0x0;
52 if (!gMUONGeometryTransformer)
54 AliEveEventManager::AssertGeometry();
55 gMUONGeometryTransformer = new AliMUONGeometryTransformer();
56 gMUONGeometryTransformer->LoadGeometryData();
59 // loop over digits and produce corresponding graphic objects
61 while ( ( digit = static_cast<AliMUONVDigit*>((*next)() ) ) )
63 if (!digit->IsTrigger() && !fromRaw && digit->Charge() < 1.e-3) continue;
65 Int_t detElemId = digit->DetElemId();
66 Int_t manuId = digit->ManuId();
68 const AliMpVSegmentation* vseg =
69 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(digit->Cathode()));
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
76 AliMpPad pad = vseg->PadByLocation(manuId,digit->ManuChannel());
78 Double_t local[] = { pad.GetPositionX(), pad.GetPositionY(), 0.0 };
79 Double_t global[] = { 0.0, 0.0, 0.0 };
81 gMUONGeometryTransformer->Local2Global(detElemId,
82 local[0], local[1], local[2],
83 global[0], global[1], global[2]);
85 TEveQuadSet* pads = bending;
86 if (vseg->PlaneType()==AliMp::kNonBendingPlane) pads = nonBending;
88 pads->AddQuad(global[0]-pad.GetDimensionX(),global[1]-pad.GetDimensionY(),global[2],
89 2.*pad.GetDimensionX(),2.*pad.GetDimensionY());
91 if (fromRaw && !digit->IsTrigger()) pads->QuadValue(digit->ADC());
92 else pads->QuadValue((Int_t) digit->Charge());
97 //______________________________________________________________________________
101 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
102 rl->LoadDigits("MUON");
103 TTree* dt = rl->GetTreeD("MUON", kFALSE);
105 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*dt);
107 digitStore->Connect(*dt,0);
109 if (digitStore->GetSize() == 0 && !gEve->GetKeepEmptyCont()) return;
111 // container for graphic representation of digits
112 TEveElementList* cont = new TEveElementList("MUON Digits");
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);
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);
126 // add digits to the containers
127 TIter next(digitStore->CreateIterator());
128 add_muon_digits(&next, bending, nonBending, kFALSE);
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));
139 gStyle->SetPalette(1);
140 bending->AssertPalette();
141 nonBending->AssertPalette();
143 // add graphic containers
144 gEve->DisableRedraw();
145 gEve->AddElement(cont);
146 gEve->EnableRedraw();