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__)
21 #include <Riostream.h>
24 #include <TEveManager.h>
25 #include <TEveQuadSet.h>
28 #include <AliMUONGeometryTransformer.h>
29 #include <AliMUONVDigit.h>
30 #include <AliMUONVDigitStore.h>
32 #include <AliMpSegmentation.h>
33 #include <AliMpVSegmentation.h>
35 #include <AliRunLoader.h>
36 #include <AliEveEventManager.h>
39 //______________________________________________________________________________
40 void add_muon_digits(TIter* next, TEveQuadSet* bending, TEveQuadSet* nonBending, Bool_t fromRaw)
43 AliMpCDB::LoadAll(kFALSE);
46 static AliMUONGeometryTransformer* gMUONGeometryTransformer = 0x0;
47 if (!gMUONGeometryTransformer)
49 AliEveEventManager::AssertGeometry();
50 gMUONGeometryTransformer = new AliMUONGeometryTransformer();
51 gMUONGeometryTransformer->LoadGeometryData();
54 // loop over digits and produce corresponding graphic objects
56 while ( ( digit = static_cast<AliMUONVDigit*>((*next)() ) ) )
58 if (!digit->IsTrigger() && !fromRaw && digit->Charge() < 1.e-3) continue;
60 Int_t detElemId = digit->DetElemId();
61 Int_t manuId = digit->ManuId();
63 const AliMpVSegmentation* vseg =
64 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(digit->Cathode()));
67 AliInfoGeneral("muon_digits.C", Form("Could not get segmentation for DE %4d MANU %4d",detElemId,manuId));
68 continue; // should not happen, unless we got a readout error and thus a bad de,manu pair
71 AliMpPad pad = vseg->PadByLocation(manuId,digit->ManuChannel());
73 Double_t local[] = { pad.GetPositionX(), pad.GetPositionY(), 0.0 };
74 Double_t global[] = { 0.0, 0.0, 0.0 };
76 gMUONGeometryTransformer->Local2Global(detElemId,
77 local[0], local[1], local[2],
78 global[0], global[1], global[2]);
80 TEveQuadSet* pads = bending;
81 if (vseg->PlaneType()==AliMp::kNonBendingPlane) pads = nonBending;
83 pads->AddQuad(global[0]-pad.GetDimensionX(),global[1]-pad.GetDimensionY(),global[2],
84 2.*pad.GetDimensionX(),2.*pad.GetDimensionY());
86 if (fromRaw && !digit->IsTrigger()) pads->QuadValue(digit->ADC());
87 else pads->QuadValue((Int_t) digit->Charge());
92 //______________________________________________________________________________
96 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
97 rl->LoadDigits("MUON");
98 TTree* dt = rl->GetTreeD("MUON", kFALSE);
100 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*dt);
102 digitStore->Connect(*dt,0);
104 rl->UnloadDigits("MUON");
106 if (digitStore->GetSize() == 0 && !gEve->GetKeepEmptyCont()) {
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();