AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONPainterHelper.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 
16 // $Id$
17 
18 #include <cstdlib>
19 #include "AliMUONPainterHelper.h"
20 
21 #include "AliCodeTimer.h"
22 #include "AliDAQ.h"
23 #include "AliLog.h"
24 #include "AliMUONContour.h"
25 #include "AliMUONContourHandler.h"
26 #include "AliMUONContourMaker.h"
30 #include "AliMUONPainterEnv.h"
31 #include "AliMUONPainterRegistry.h"
32 #include "AliMUONPadStatusMaker.h"
33 #include "AliMUONVCalibParam.h"
34 #include "AliMUONVDigit.h"
35 #include "AliMUONVTrackerData.h"
36 #include "AliMpCDB.h"
37 #include "AliMpConstants.h"
38 #include "AliMpDDLStore.h"
39 #include "AliMpDEIterator.h"
40 #include "AliMpDEManager.h"
41 #include "AliMpDetElement.h"
42 #include "AliMpExMap.h"
43 #include "AliMpMotifMap.h"
44 #include "AliMpMotifPosition.h"
45 #include "AliMpPCB.h"
46 #include "AliMpPad.h"
47 #include "AliMpSector.h"
48 #include "AliMpSegmentation.h"
49 #include "AliMpSlat.h"
50 #include "AliMpStationType.h"
51 #include "AliMpVPadIterator.h"
52 #include <Riostream.h>
53 #include <TArrayI.h>
54 #include <TCanvas.h>
55 #include <TClass.h>
56 #include <TCollection.h>
57 #include <TFile.h>
58 #include <TGLabel.h>
59 #include <TGMsgBox.h>
60 #include <TGeoMatrix.h>
61 #include <TLine.h>
62 #include <TList.h>
63 #include <TMap.h>
64 #include <TMath.h>
65 #include <TObjArray.h>
66 #include <TObjString.h>
67 #include <TStyle.h>
68 #include <TSystem.h>
69 #include <TVector2.h>
70 #include <TVector3.h>
71 #include <TVirtualPad.h>
72 #include <TVirtualX.h>
73 
74 #include "AliMUONChamberPainter.h"
75 
81 
82 using std::cout;
83 using std::endl;
87 
89 
90 //_____________________________________________________________________________
92 TObject(),
93 fEnv(0x0),
94 fReal(0x0),
95 fExploded(0x0)
96 {
98 
100  {
101  AliFatal("Could not access mapping from OCDB !");
102  }
103 
104  // Load DDL store
105  if ( ! AliMpCDB::LoadDDLStore() )
106  {
107  AliFatal("Could not access DDL Store from OCDB !");
108  }
109 }
110 
111 //_____________________________________________________________________________
113 {
115  delete fReal;
116  delete fExploded;
117  fEnv->Save();
118  fgInstance = 0;
119 }
120 
121 //_____________________________________________________________________________
124 {
126  if (!fExploded) fExploded = new AliMUONContourHandler(kTRUE);
127  return fExploded;
128 }
129 
130 //_____________________________________________________________________________
133 {
135  if (!fReal) fReal = new AliMUONContourHandler(kFALSE);
136  return fReal;
137 }
138 
139 //_____________________________________________________________________________
141 AliMUONPainterHelper::GetContour(const char* contourName, Bool_t explodedView) const
142 {
144  if (explodedView)
145  {
146  return Exploded()->GetContour(contourName);
147  }
148  else
149  {
150  if ( fReal )
151  {
152  return fReal->GetContour(contourName);
153  }
154  }
155  return 0x0;
156 }
157 
158 
159 //_____________________________________________________________________________
161 AliMUONPainterHelper::GetCathodeType(Int_t detElemId, Int_t manuId) const
162 {
164 
167  {
168  planeType = AliMp::kNonBendingPlane;
169  }
170  return AliMpDEManager::GetCathod(detElemId,planeType);
171 }
172 
173 
174 //_____________________________________________________________________________
176 AliMUONPainterHelper::GetMotifPosition(Int_t detElemId, Int_t manuId) const
177 {
180  if (vseg)
181  {
182  return vseg->MotifPosition(manuId);
183  }
184  return 0x0;
185 }
186 
187 //_____________________________________________________________________________
188 AliMpPCB*
189 AliMUONPainterHelper::GetPCB(Int_t detElemId, AliMp::CathodType cathodeType,
190  Int_t pcbNumber) const
191 {
193  const AliMpSlat* slat = GetSlat(detElemId,cathodeType);
194  if ( slat ) return slat->GetPCB(pcbNumber);
195  return 0x0;
196 }
197 
198 //_____________________________________________________________________________
199 AliMpPCB*
200 AliMUONPainterHelper::GetPCB(Int_t detElemId, AliMp::PlaneType planeType,
201  Int_t pcbNumber) const
202 {
204  AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,
205  planeType);
206  return GetPCB(detElemId,cathodeType,pcbNumber);
207 }
208 
209 //_____________________________________________________________________________
212 {
214 
216  {
218  }
219  return AliMp::kBendingPlane;
220 }
221 
222 //_____________________________________________________________________________
223 const AliMpSlat*
224 AliMUONPainterHelper::GetSlat(Int_t detElemId, AliMp::PlaneType planeType) const
225 {
227 
228  AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,
229  planeType);
230 
231  return GetSlat(detElemId,cathodeType);
232 }
233 
234 //_____________________________________________________________________________
235 const AliMpSector*
236 AliMUONPainterHelper::GetSector(Int_t detElemId, AliMp::PlaneType planeType) const
237 {
239  AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
240  if ( stationType != AliMp::kStation12 ) return 0x0;
241 
242  AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType);
243 
244  return AliMpSegmentation::Instance()->GetSector(detElemId,cathodeType);
245 }
246 
247 //_____________________________________________________________________________
248 const AliMpSlat*
249 AliMUONPainterHelper::GetSlat(Int_t detElemId, AliMp::CathodType cathodeType) const
250 {
252  AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
253  if ( stationType != AliMp::kStation345 ) return 0x0;
254 
255  return AliMpSegmentation::Instance()->GetSlat(detElemId,cathodeType);
256 }
257 
258 //_____________________________________________________________________________
259 const AliMpSlat*
260 AliMUONPainterHelper::GetSlat(Int_t detElemId, Int_t manuId) const
261 {
263  AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
264  if ( stationType != AliMp::kStation345 ) return 0x0;
265 
266  return AliMpSegmentation::Instance()->GetSlatByElectronics(detElemId,manuId);
267 }
268 
269 //_____________________________________________________________________________
272 {
274 
275  if (fgInstance) return fgInstance;
276 
277  AliCodeTimerAutoClass("",0);
278 
281  return fgInstance;
282 }
283 
284 //_____________________________________________________________________________
285 void
287  Double_t xg, Double_t yg, Double_t zg,
288  Double_t& xl, Double_t& yl, Double_t& zl) const
289 {
291 
292  TGeoHMatrix* matrix = static_cast<TGeoHMatrix*>(Exploded()->GetTransformations()->GetValue(detElemId));
293  Double_t pg[3] = { xg, yg, zg };
294  Double_t pl[3] = { 0., 0., 0. };
295  matrix->MasterToLocal(pg, pl);
296  xl = pl[0];
297  yl = pl[1];
298  zl = pl[2];
299 }
300 
301 //_____________________________________________________________________________
302 void
304  Double_t xl, Double_t yl, Double_t zl,
305  Double_t& xg, Double_t& yg, Double_t& zg) const
306 {
308 
309  TGeoHMatrix* matrix = static_cast<TGeoHMatrix*>(Exploded()->GetTransformations()->GetValue(detElemId));
310  Double_t pl[3] = { xl, yl, zl };
311  Double_t pg[3] = { 0., 0., 0. };
312  matrix->LocalToMaster(pl, pg);
313  xg = pg[0];
314  yg = pg[1];
315  zg = pg[2];
316 }
317 
318 //_____________________________________________________________________________
319 Int_t
320 AliMUONPainterHelper::ColorFromValue(Double_t value, Double_t min, Double_t max) const
321 {
323 
324  Int_t rv;
325 
326  if (value > max) rv = 1;
327  else if (value <= min) rv = 0;
328  else
329  {
330  if ( TMath::AreEqualRel(max,min,1E-6) ) return gStyle->GetColorPalette(1);
331  Double_t range = max - min;
332  Double_t offset = value - min;
333  rv = gStyle->GetColorPalette( 1 + int( offset*(gStyle->GetNumberOfColors()-2)/range - 0.5 ) );
334  }
335  return rv;
336 }
337 
338 //_____________________________________________________________________________
340 AliMUONPainterHelper::MergeContours(const TObjArray& contours, const char* contourName, Bool_t explodedGeometry)
341 {
343 
344  AliMUONContourMaker maker;
345 
346  AliMUONContour* contour = maker.MergeContour(contours,contourName);
347 
348  if (contour)
349  {
350  RegisterContour(contour,explodedGeometry);
351  }
352  return contour;
353 }
354 
355 
356 //_____________________________________________________________________________
357 void
358 AliMUONPainterHelper::Print(Option_t* opt) const
359 {
361  TString sopt(opt);
362  sopt.ToUpper();
363 
364  if ( sopt.Length() == 0 )
365  {
366  if ( fExploded ) fExploded->Print();
367  if ( fReal ) fReal->Print();
368  }
369 }
370 
371 //_____________________________________________________________________________
372 void
374 {
376  AliCodeTimerAuto("",0)
378  if ( explodedView )
379  {
380  ch = Exploded();
381  }
382  if (!ch)
383  {
384  AliError(Form("ContourHandler for %s view is not created yet !",explodedView ? "EXPLODED" : "REAL"));
385  }
386  else
387  {
388  if ( ch->GetContour(contour->GetName()) )
389  {
390  AliError(Form("Contour with name %s is already there",contour->GetName()));
391  return;
392  }
393  ch->Adopt(contour);
394  }
395 }
396 
397 //_____________________________________________________________________________
398 TString
399 AliMUONPainterHelper::ChamberName(Int_t chamberId) const
400 {
402  return Form("Chamber%1d",chamberId+1);
403 }
404 
405 //_____________________________________________________________________________
406 TString
407 AliMUONPainterHelper::StationName(Int_t stationId) const
408 {
410  return Form("Station%1d",stationId+1);
411 }
412 
413 //_____________________________________________________________________________
414 TString
415 AliMUONPainterHelper::DEName(Int_t detElemId) const
416 {
418  return Form("DE%04d",detElemId);
419 }
420 
421 //_____________________________________________________________________________
422 TString
424 {
426  return Form("MANU%04d",manuId);
427 }
428 
429 //_____________________________________________________________________________
430 TString
431 AliMUONPainterHelper::BusPatchName(Int_t busPatchId) const
432 {
434  return Form("BUSPATCH%04d",busPatchId);
435 }
436 
437 //_____________________________________________________________________________
438 TString
439 AliMUONPainterHelper::PCBName(Int_t pcbNumber) const
440 {
442  return Form("PCB%1d",pcbNumber);
443 }
444 
445 //_____________________________________________________________________________
446 TString
448 {
450  return Form("%s/%s",StationName(chamberId/2).Data(),ChamberName(chamberId).Data());
451 }
452 
453 //_____________________________________________________________________________
454 TString
456 {
458  return StationName(stationId);
459 }
460 
461 //_____________________________________________________________________________
462 TString
463 AliMUONPainterHelper::DEPathName(Int_t detElemId) const
464 {
466 
467  Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
468 
469  Int_t ddl(-1);
470 
472 
473  if ( de )
474  {
475  ddl = AliDAQ::DdlIDOffset("MUONTRK") + de->GetDdlId();
476  }
477 
478  return Form("%s/%s/%s(DDL%4d)",
479  StationName(chamberId/2).Data(),
480  ChamberName(chamberId).Data(),
481  DEName(detElemId).Data(),
482  ddl);
483 }
484 
485 //_____________________________________________________________________________
486 TString
487 AliMUONPainterHelper::ManuPathName(Int_t detElemId, Int_t manuId) const
488 {
490  return Form("%s/%s",DEPathName(detElemId).Data(),ManuName(manuId).Data());
491 }
492 
493 //_____________________________________________________________________________
494 TString
496 {
498  Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
499 
500  return Form("%s/%s",DEPathName(detElemId).Data(),BusPatchName(busPatchId).Data());
501 }
502 
503 //_____________________________________________________________________________
504 TString
505 AliMUONPainterHelper::PCBPathName(Int_t detElemId, Int_t pcbNumber) const
506 {
508  return Form("%s/%s",DEPathName(detElemId).Data(),PCBName(pcbNumber).Data());
509 }
510 
511 //_____________________________________________________________________________
512 TString
513 AliMUONPainterHelper::FormatValue(const char* name, Double_t value) const
514 {
517 
518  TString sname(name);
519 
520  sname.ToUpper();
521  if (sname.Contains("BIT"))
522  {
523  Int_t i = (Int_t)(value);
524  TString rv = Form("%s = 0x%x",name,i);
525  cout << rv << ":" << AliMUONPadStatusMaker::AsString(i) << endl;
526  return rv;
527  }
528  else
529  {
530  return Form("%s = %e",name,value);
531  }
532 }
533 
534 //_____________________________________________________________________________
535 TObjArray*
537 {
539 
540  if ( explodedView )
541  {
542  return Exploded()->AllContourArray();
543  }
544  else
545  {
546  return Real()->AllContourArray();
547  }
548 }
549 
550 
Int_t ColorFromValue(Double_t value, Double_t min, Double_t max) const
static AliMUONPainterHelper * Instance()
TString DEPathName(Int_t detElemId) const
AliMUONPainterEnv * fEnv
resources
station 1,2 (quadrants)
void Local2Global(Int_t detElemId, Double_t xl, Double_t yl, Double_t zl, Double_t &xg, Double_t &yg, Double_t &zg) const
TStyle * gStyle
TString PCBName(Int_t pcbNumber) const
static TString AsString(Int_t status)
static AliMpSegmentation * Instance(Bool_t warn=true)
#define TObjArray
static AliMp::CathodType GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
const AliMpSlat * GetSlatByElectronics(Int_t detElemId, Int_t elCardID, Bool_t warn=true) const
virtual void Print(Option_t *opt="") const
const AliMpSlat * GetSlat(const AliMpVSegmentation *kSegmentation, Bool_t warn=true) const
station 3,4,5 (slats)
A PCB for station 3,4 or 5.
Definition: AliMpPCB.h:46
Int_t GetDEfromBus(Int_t busPatchId) const
virtual AliMpMotifPosition * MotifPosition(Int_t manuId) const =0
Return the position of a given manu (aka motifPosition)
AliMpExMap * GetTransformations() const
Get detection element geometrical transformations.
TString StationPathName(Int_t stationId) const
AliMUONContour * MergeContour(const TObjArray &contours, const char *name=0x0) const
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
const AliMpVSegmentation * GetMpSegmentationByElectronics(Int_t detElemId, Int_t elCardID, Bool_t warn=true) const
const AliMpSector * GetSector(Int_t detElemId, AliMp::PlaneType planeType) const
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
The class defines the electronics properties of detection element.
TString ManuPathName(Int_t detElemId, Int_t manuId) const
void Print(Option_t *opt="") const
Resource file handling.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Bool_t Adopt(AliMUONContour *contour)
static AliMpDDLStore * Instance(Bool_t warn=true)
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
const AliMpSector * GetSector(const AliMpVSegmentation *kSegmentation, Bool_t warn=true) const
TObjArray * GetAllContoursAsArray(Bool_t explodedView=kTRUE) const
AliMpPCB * GetPCB(Int_t detElemId, AliMp::PlaneType planeType, Int_t pcbNumber) const
A placed motif.
void RegisterContour(AliMUONContour *contour, Bool_t explodedView=kTRUE)
AliMpPCB * GetPCB(Int_t i) const
Returns the i-th PCB of this slat.
Definition: AliMpSlat.cxx:435
AliMUONContourHandler * Exploded() const
AliMUONContour * GetContour(const char *contourName, Bool_t explodedGeometry=kTRUE) const
TString PCBPathName(Int_t detElemId, Int_t pcbNumber) const
AliMp::PlaneType GetPlaneType(Int_t manuId) const
non-bending plane
TObjArray * AllContourArray() const
Get all the contours as an array.
static AliMp::StationType GetStationType(Int_t detElemId)
Float_t range[5]
static AliMUONPainterHelper * fgInstance
global instance
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
AliMpMotifPosition * GetMotifPosition(Int_t detElemId, Int_t manuId) const
AliMUONContourHandler * Real() const
Holder for MUON tracker contours.
Utility class for the painters display.
AliMUONContour * MergeContours(const TObjArray &contours, const char *contourName, Bool_t explodedGeometry=kTRUE)
A sector (quadrant) of the MUON chamber of stations 1 and 2.
Definition: AliMpSector.h:34
TString BusPatchPathName(Int_t busPatchId) const
AliMUONContour * GetContour(const char *contourname) const
Int_t GetDdlId() const
Return DDL Id.
Creator/merger of AliMUONContour objects.
bending plane
const AliMpSlat * GetSlat(Int_t detElemId, AliMp::PlaneType planeType) const
void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, Double_t &xl, Double_t &yl, Double_t &zl) const
The abstract base class for the segmentation.
2D contour
AliMUONContourHandler * fReal
contours in real coordinates
TString StationName(Int_t stationId) const
TString BusPatchName(Int_t busPatchId) const
TString ChamberPathName(Int_t chamberId) const
AliMUONContourHandler * fExploded
contours in exploded coordinates
TString FormatValue(const char *name, Double_t value) const
TString ChamberName(Int_t chamberId) const
TString ManuName(Int_t manuId) const
TString DEName(Int_t detElemId) const
static Bool_t LoadMpSegmentation(Bool_t warn=false)
Definition: AliMpCDB.cxx:113
AliMp::CathodType GetCathodeType(Int_t detElemId, Int_t manuId) const
static Int_t ManuMask(AliMp::PlaneType planeType)