1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 ///////////////////////////////////////////////////////////////////////////////
22 // Interface to the HIGZ package for the GEANT drawing package //
26 <img src="picts/THIGZClass.gif">
31 ///////////////////////////////////////////////////////////////////////////////
39 #include "TPolyLine.h"
40 #include "TPolyMarker.h"
41 #include "TPaveLabel.h"
44 #include "AliCallf77.h"
45 #include "TPaveTree.h"
50 # define hplint hplint_
51 # define hplend hplend_
52 # define hplfra hplfra_
53 # define igmeta igmeta_
54 # define iselnt iselnt_
55 # define igiwty igiwty_
59 # define iclrwk iclrwk_
64 # define ightor ightor_
65 # define igpave igpave_
71 # define igterm igterm_
77 # define isfaci isfaci_
78 # define isfais isfais_
81 # define islwsc islwsc_
82 # define isplci isplci_
83 # define ispmci ispmci_
84 # define istxci istxci_
91 # define iclrwk ICLRWK
96 # define ightor IGHTOR
97 # define igpave IGPAVE
103 # define igterm IGTERM
109 # define isfaci ISFACI
110 # define isfais ISFAIS
113 # define islwsc ISLWSC
114 # define isplci ISPLCI
115 # define ispmci ISPMCI
116 # define istxci ISTXCI
122 static Int_t npid = 0;
123 static char cpar[1200];
124 static TGeant3 *geant3=(TGeant3*)gMC;
130 //_______________________________________________________________
136 //_______________________________________________________________
137 THIGZ::THIGZ(Int_t size)
138 :TCanvas("higz","higz",size,size)
144 //_______________________________________________________________
148 //_______________________________________________________________
149 Float_t THIGZ::Get(const char *name)
151 if (!strcmp(name,"FAIS")) return fFAIS;
152 if (!strcmp(name,"FASI")) return fFASI;
153 if (!strcmp(name,"LTYP")) return fLTYP;
154 if (!strcmp(name,"BASL")) return fBASL;
155 if (!strcmp(name,"LWID")) return fLWID;
156 if (!strcmp(name,"MTYP")) return fMTYP;
157 if (!strcmp(name,"MSCF")) return fMSCF;
158 if (!strcmp(name,"PLCI")) return fPLCI;
159 if (!strcmp(name,"PMCI")) return fPMCI;
160 if (!strcmp(name,"FACI")) return fFACI;
161 if (!strcmp(name,"TXCI")) return fTXCI;
162 if (!strcmp(name,"TXAL")) return fTXAL;
163 if (!strcmp(name,"CHHE")) return fCHHE*fY2;
164 if (!strcmp(name,"TANG")) return fTANG;
165 if (!strcmp(name,"TXFP")) return fTXFP;
166 if (!strcmp(name,"BORD")) return fBORD;
167 if (!strcmp(name,"NCOL")) return fNCOL;
168 if (!strcmp(name,"DRMD")) return fDRMD;
169 if (!strcmp(name,"SYNC")) return fSYNC;
170 if (!strcmp(name,"CLIP")) return fCLIP;
171 if (!strcmp(name,"2BUF")) return f2BUF;
174 //_______________________________________________________________
175 void THIGZ::Set(const char *name, Float_t val)
177 if (!strcmp(name,"FAIS")) {fFAIS = Int_t(val); return;}
178 if (!strcmp(name,"FASI")) {fFASI = Int_t(val); return;}
179 if (!strcmp(name,"LTYP")) {fLTYP = Int_t(val); return;}
180 if (!strcmp(name,"BASL")) {fBASL = val; return;}
181 if (!strcmp(name,"LWID")) {fLWID = val; if (val <= 0) fLWID=1; return;}
182 if (!strcmp(name,"MTYP")) {fMTYP = Int_t(val); return;}
183 if (!strcmp(name,"MSCF")) {fMSCF = val; return;}
184 if (!strcmp(name,"PLCI")) {fPLCI = Int_t(val); return;}
185 if (!strcmp(name,"PMCI")) {fPMCI = Int_t(val); return;}
186 if (!strcmp(name,"FACI")) {fFACI = Int_t(val)%1000; return;}
187 if (!strcmp(name,"TXCI")) {fTXCI = Int_t(val); return;}
188 if (!strcmp(name,"TXAL")) {
189 Int_t align = Int_t(val);
190 Int_t aligh = align/10;
191 Int_t aligv = align%10;
194 if (aligh == 0) ah = 1;
195 if (aligv == 1 || aligh == 2) av = 3;
196 if (aligv == 3) av = 2;
197 if (aligv == 0) av = 1;
201 if (!strcmp(name,"CHHE")) {fCHHE = val/fY2; if (fCHHE <= 0) fCHHE = 0.03; return;}
202 if (!strcmp(name,"TANG")) {fTANG = val; return;}
203 if (!strcmp(name,"TXFP")) {fTXFP = Int_t(val); return;}
204 if (!strcmp(name,"BORD")) {fBORD = Int_t(val); return;}
205 if (!strcmp(name,"NCOL")) {fNCOL = Int_t(val); return;}
206 if (!strcmp(name,"DRMD")) {fDRMD = Int_t(val); return;}
207 if (!strcmp(name,"SYNC")) {fSYNC = Int_t(val); return;}
208 if (!strcmp(name,"CLIP")) {fCLIP = Int_t(val); return;}
209 if (!strcmp(name,"2BUF")) {f2BUF = Int_t(val); return;}
211 //_______________________________________________________________
212 void THIGZ::Reset(Option_t *)
238 //___________________________________________
239 void THIGZ::Gsatt(const char *name, const char *att, Int_t val)
242 // IOPT Name of the attribute to be set
243 // IVAL Value to which the attribute is to be set
245 // name= "*" stands for all the volumes.
246 // iopt can be chosen among the following :
247 // see TGeant3::Gsatt for more details
250 gMC->Gsatt(name,att,val);
253 //___________________________________________
254 void THIGZ::Gdopt(const char *name,const char *value)
257 // VALUE Option value
259 // To set/modify the drawing options.
260 // see TGeant3::Gdopt for more details
262 gMC->Gdopt(name,value);
266 //___________________________________________
267 void THIGZ::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t psi,Float_t u0,Float_t v0,Float_t ul,Float_t vl)
271 // THETA Viewing angle theta (for 3D projection)
272 // PHI Viewing angle phi (for 3D projection)
273 // PSI Viewing angle psi (for 2D rotation)
274 // U0 U-coord. (horizontal) of volume origin
275 // V0 V-coord. (vertical) of volume origin
276 // SU Scale factor for U-coord.
277 // SV Scale factor for V-coord.
278 // see TGeant3::Gdraw for more details
281 gMC->Gdraw(name,theta,phi,psi,u0,v0,ul,vl);
285 //___________________________________________
286 void THIGZ::Gdrawc(const char *name,Int_t axis, Float_t cut,Float_t u0,Float_t v0,Float_t ul,Float_t vl)
290 // CUTVAL Cut plane distance from the origin along the axis
292 // U0 U-coord. (horizontal) of volume origin
293 // V0 V-coord. (vertical) of volume origin
294 // SU Scale factor for U-coord.
295 // SV Scale factor for V-coord.
296 // see TGeant3::Gdrawc for more details
299 geant3->Gdrawc(name,axis,cut,u0,v0,ul,vl);
303 //___________________________________________
304 void THIGZ::Gdspec(const char *name)
308 // Shows 3 views of the volume (two cut-views and a 3D view), together with
309 // its geometrical specifications. The 3D drawing will
310 // be performed according the current values of the options HIDE and
311 // SHAD and according the current CVOL clipping parameters for that
313 // see TGeant3::Gdspec for more details
316 geant3->Gdspec(name);
320 //___________________________________________
321 void THIGZ::Gdtree(const char *name,Int_t levmax, Int_t isel)
324 // LEVMAX Depth level
327 // This function draws the logical tree,
328 // Each volume in the tree is represented by a TPaveTree object.
329 // Double-clicking on a TPaveTree draws the specs of the corresponding volume.
330 // Use TPaveTree pop-up menu to select:
333 // - drawing tree of parent
336 geant3->Gdtree(name,levmax,isel);
340 //______________________________________________________________________________
341 void THIGZ::SetBOMB(Float_t boom)
343 // BOOM : Exploding factor for volumes position
345 // To 'explode' the detector. If BOOM is positive (values smaller
346 // than 1. are suggested, but any value is possible)
347 // all the volumes are shifted by a distance
348 // proportional to BOOM along the direction between their centre
349 // and the origin of the MARS; the volumes which are symmetric
350 // with respect to this origin are simply not shown.
351 // BOOM equal to 0 resets the normal mode.
352 // A negative (greater than -1.) value of
353 // BOOM will cause an 'implosion'; for even lower values of BOOM
354 // the volumes' positions will be reflected respect to the origin.
355 // This command can be useful to improve the 3D effect for very
356 // complex detectors. The following commands will make explode the
359 geant3->SetBOMB(boom);
362 //_______________________________________________________________
363 extern "C" void type_of_call iacwk(Int_t &)
365 // printf("iacwk called,wid=%d\n",wid);
368 //_______________________________________________________________
369 extern "C" void type_of_call iclrwk(Int_t &,Int_t &)
371 // printf("iclrwk called\n");
375 //_______________________________________________________________
376 extern "C" void type_of_call iclwk(Int_t &,Int_t &)
378 // printf("iclwk called\n");
382 //_______________________________________________________________
383 extern "C" void type_of_call idawk(Int_t &)
385 // printf("idawk called\n");
388 //_______________________________________________________________
389 extern "C" void type_of_call ifa(Int_t &n,Float_t *x, Float_t *y)
391 // printf("ifa called, n=%d, pname=%s, pid=%d, x1=%f, y1=%f,x2=%f, y2=%f, x3=%f, y3=%f\n",n,higz->fPname.Data(),higz->fPID,x[0],y[0],x[1],y[1],x[2],y[2]);
392 TGraph *gr = new TGraph(n,x,y);
393 gr->SetFillColor(higz->fFACI);
397 //_______________________________________________________________
398 extern "C" void type_of_call igbox(Float_t &x1,Float_t &x2,Float_t &y1,Float_t &y2)
400 printf("igbox called, x1=%f, y1=%f, x2=%f, y2=%f\n",x1,y1,x2,y2);
401 TBox *box = new TBox(x1,y1,x2,y2);
402 box->SetLineColor(higz->fPLCI);
403 box->SetFillColor(higz->fFACI);
404 box->SetFillStyle(higz->fFASI);
408 //_______________________________________________________________
409 extern "C" void type_of_call ightor(Float_t &h,Float_t &l,Float_t &s,Float_t &r,Float_t &g,Float_t &b)
411 // printf("ightor called\n");
412 TColor *col1 = gROOT->GetColor(1);
413 if (col1) col1->HLStoRGB(h,l,s,r,g,b);
416 //_______________________________________________________________
417 extern "C" void type_of_call igpave(Float_t &x1,Float_t &x2,Float_t &yy1,Float_t &yy2,Float_t &,Int_t &isbox,Int_t &isfram,const char *, const Int_t)
420 strncpy(text,(char*)&higz->fPID,4);
424 if (y1 > y2) { y1 = yy2; y2 = yy1;}
425 Float_t y = 0.5*(y1+y2);
426 Float_t dymax = 0.06*(higz->GetY2()-higz->GetY1());
427 Float_t dymin = -higz->PixeltoY(12);
436 TPaveTree *pt = new TPaveTree(x1,y1,x2,y2,text);
438 pt->SetFillColor(isbox%1000);
439 pt->SetLineColor(isfram%1000);
441 // printf("igpave called, text=%s, Pname=%s, x1=%f, y1=%f, x2=%f, y2=%f, isbox=%d, isfram=%d\n",text,higz->fPname.Data(),x1,y1,x2,y2,isbox,isfram);
444 //_______________________________________________________________
446 extern "C" void type_of_call igpid(Int_t &,const char *name,Int_t &pid,const char *, const Int_t l1, const Int_t)
448 extern "C" void type_of_call igpid(Int_t &,const char *name,const Int_t l1, Int_t &pid,const char *, const Int_t)
452 // if(npid&100 == 0) printf("igpid called, npid=%d\n",npid);
453 strncpy(cpar,name,l1); cpar[l1] = 0;
458 // strncpy(text,(char*)&higz->fPID,4);
460 // printf("igpid called, level=%d, name=%s, pid=%d, cpid=%s\n",level,cpar,pid,text);
463 //_______________________________________________________________
465 extern "C" void type_of_call igq(const char *name,Float_t &rval, const Int_t l1)
467 extern "C" void type_of_call igq(const char *name,const Int_t l1, Float_t &rval)
470 strncpy(cpar,name,l1); cpar[l1] = 0;
471 // printf("igq called, name=%s\n",cpar);
472 rval = higz->Get(cpar);
475 //_______________________________________________________________
476 extern "C" void type_of_call igrng(Float_t &xsize,Float_t &ysize)
478 // printf("igrng called, xsize=%f, ysize=%f\n",xsize,ysize);
479 higz->Range(0,0,xsize,ysize);
482 //_______________________________________________________________
483 extern "C" void type_of_call igsa(Int_t &)
485 // printf("igsa called, iwk=%d\n",iwk);
488 //_______________________________________________________________
490 extern "C" void type_of_call igset(const char *name,Float_t &rval, const Int_t l1)
492 extern "C" void type_of_call igset(const char *name, const Int_t l1,Float_t &rval)
495 strncpy(cpar,name,l1); cpar[l1] = 0;
496 // printf("igset called, name=%s, rval=%f\n",cpar,rval);
497 higz->Set(cpar,rval);
500 //_______________________________________________________________
501 extern "C" void type_of_call igterm()
503 printf("igterm called\n");
506 //_______________________________________________________________
507 extern "C" void type_of_call iopwk(Int_t &iwkid,Int_t &iconid,Int_t &iwtypi)
509 printf("iopwk called, iwkid=%d, iconid=%d, iwtypi=%d\n",iwkid,iconid,iwtypi);
512 //_______________________________________________________________
513 extern "C" void type_of_call ipl(Int_t &n,Float_t *x,Float_t *y)
515 // printf("ipl called, n=%d, x[0]=%f,y[0]=%f, x[1]=%f, y[1]=%f\n",n,x[0],y[0],x[1],y[1]);
517 TLine *l = new TLine(x[0],y[0],x[1],y[1]);
518 l->SetLineColor(higz->fPLCI);
519 l->SetLineStyle(higz->fLTYP);
520 l->SetLineWidth(Short_t(higz->fLWID));
523 TPolyLine *pl = new TPolyLine(n,x,y);
524 pl->SetLineColor(higz->fPLCI);
525 pl->SetLineStyle(higz->fLTYP);
526 pl->SetLineWidth(Short_t(higz->fLWID));
531 //_______________________________________________________________
532 extern "C" void type_of_call ipm(Int_t &n,Float_t *x,Float_t *y)
534 printf("ipm called, n=%d\n",n);
535 TPolyMarker *pm = new TPolyMarker(n,x,y);
536 pm->SetMarkerColor(higz->fPMCI);
537 pm->SetMarkerStyle(higz->fMTYP);
538 pm->SetMarkerSize(higz->fMSCF);
542 //_______________________________________________________________
543 extern "C" void type_of_call irqlc(Int_t&, Int_t&, Int_t&, Int_t&, Float_t&, Float_t&)
546 printf("irqlc called\n");
549 //_______________________________________________________________
550 extern "C" void type_of_call iscr(Int_t &,Int_t &ici,Float_t &r,Float_t &g,Float_t &b)
552 // printf("iscr called, ici=%d, r=%f, g=%f, b=%f\n",ici,r,g,b);
554 // if (color > 10) color += 35;
555 TColor *col = gROOT->GetColor(color);
557 col = new TColor(color,r,g,b);
564 //_______________________________________________________________
565 extern "C" void type_of_call isfaci(Int_t &col)
567 // printf("isfaci called, col=%d\n",col);
568 Int_t color = col%1000;
569 // if (color > 10) color += 35;
573 //_______________________________________________________________
574 extern "C" void type_of_call isfais(Int_t &is)
576 // printf("isfais called, is=%d\n",is);
580 //_______________________________________________________________
581 extern "C" void type_of_call isln(Int_t &ln)
583 // printf("isln called, ln=%d\n",ln);
587 //_______________________________________________________________
588 extern "C" void type_of_call ismk(Int_t &mk)
590 // printf("ismk called, mk=%d\n",mk);
594 //_______________________________________________________________
595 extern "C" void type_of_call islwsc(Float_t &wl)
597 // printf("islwsc called, wl=%f\n",wl);
601 //_______________________________________________________________
602 extern "C" void type_of_call isplci(Int_t &col)
604 // printf("isplci called, col=%d\n",col);
605 Int_t color = col%1000;
606 // if (color > 10) color += 35;
610 //_______________________________________________________________
611 extern "C" void type_of_call ispmci(Int_t &col)
613 // printf("ispmci called, col=%d\n",col);
614 Int_t color = col%1000;
615 // if (color > 10) color += 35;
619 //_______________________________________________________________
620 extern "C" void type_of_call istxci(Int_t &col)
622 // printf("istxci called, col=%d\n",col);
623 Int_t color = col%1000;
624 // if (color > 10) color += 35;
628 //_______________________________________________________________
629 extern "C" void type_of_call isvp(Int_t &,Float_t &,Float_t &,Float_t &,Float_t &)
631 // printf("isvp called, nt=%d, x1=%f, y1=%f, x2=%f, y2=%f\n",nt,x1,y1,x2,y2);
634 //_______________________________________________________________
635 extern "C" void type_of_call iswn(Int_t &,Float_t &x1,Float_t &x2,Float_t &y1,Float_t &y2)
638 // printf("iswn called, nt=%d, x1=%f, y1=%f, x2=%f, y2=%f\n",nt,x1,y1,x2,y2);
639 higz->Range(x1,y1,x2,y2);
642 //_______________________________________________________________
643 extern "C" void type_of_call itx(Float_t &x,Float_t &y,const char *ptext, const Int_t l1p)
645 if (higz->fPname == "Tree") return;
647 strncpy(cpar,ptext,l1); cpar[l1] = 0;
648 //printf("itx called, x=%f, y=%f, text=%s, l1=%d\n",x,y,cpar,l1);
650 if (cpar[l1-1] != ' ' && cpar[l1-1] != '$') break;
654 char *small = strstr(cpar,"<");
655 while(small && *small) {
656 small[0] = tolower(small[1]);
659 TText *text = new TText(x,y,cpar);
660 text->SetTextColor(higz->fTXCI);
661 text->SetTextSize(higz->fCHHE);
662 text->SetTextFont(higz->fTXFP);
663 text->SetTextAlign(higz->fTXAL);
664 text->SetTextAngle(higz->fTANG);
668 //_______________________________________________________________
669 extern "C" void type_of_call hplint(Int_t &)
671 printf("hplint called\n");
675 //_______________________________________________________________
676 extern "C" void type_of_call hplend()
678 printf("hplend called\n");
681 //_______________________________________________________________
682 extern "C" void type_of_call hplfra(Float_t &x1,Float_t &x2,Float_t &y1, Float_t &y2,const char *, const Int_t)
684 // printf("hplfra called, x1=%f, y1=%f, x2=%f, y2=%f\n",x1,y1,x2,y2);
686 higz->Range(x1,y1,x2,y2);
689 //_______________________________________________________________
690 extern "C" void type_of_call igmeta(Int_t &, Int_t &)
692 printf("igmeta called\n");
695 //_______________________________________________________________
696 extern "C" void type_of_call iselnt(Int_t &)
698 // printf("iselnt called, nt=%d\n",nt);
701 //_______________________________________________________________
702 extern "C" Int_t type_of_call igiwty(Int_t &)
704 // printf("igiwty called, wid=%d\n",wid);
708 //_______________________________________________________________
709 extern "C" void type_of_call igqwk(Int_t &, const char *name, Float_t &rval, const Int_t l1)
711 strncpy(cpar,name,l1); cpar[l1] = 0;
712 // printf("igqwk called, wid=%d, pname=%s\n",wid,cpar);
713 rval = higz->Get(cpar);