source: trunk/examples/advanced/Rich/src/RichTbGraphics.cc @ 1321

Last change on this file since 1321 was 807, checked in by garnier, 16 years ago

update

File size: 17.1 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// Rich advanced example for Geant4
27// RichTbGraphics.cc for Rich of LHCb
28// History:
29// Created: Sajan Easo (Sajan.Easo@cern.ch)
30// Revision and changes: Patricia Mendez (Patricia.Mendez@cern.ch)
31/////////////////////////////////////////////////////////////////////////////
32#include <iostream>
33#include "RichTbDetectorConstruction.hh"
34#include "RichTbHall.hh"
35#include "RichTbComponent.hh"
36#include "RichTbGeometryParameters.hh"
37#include "RichTbPhotoDetector.hh"
38#include "RichTbHpd.hh"
39#include "RichTbSiDet.hh"
40#include "RichTbGraphics.hh"
41#include "G4LogicalVolume.hh"
42#include "G4VisAttributes.hh"
43#include "G4Colour.hh"
44#include "RichTbRunConfig.hh"
45RichTbGraphics::RichTbGraphics(){ ; }
46RichTbGraphics::RichTbGraphics(RichTbHall* RTbHall,
47    RichTbComponent* RTbComponent,
48    RichTbPhotoDetector* RTbPhotoDetector, 
49    RichTbROGeometry* RTbROGeom,
50    RichTbRunConfig* RConfig){
51
52  //For Following variables 0 means make the volume invisible;
53  //                        1 means make it visible as a solid.
54  //                        2 means make it visible as a wireframe.
55  G4int RichTbHall_vis= RConfig->getRichTbHall_visib(); 
56  G4int RichTbEnclosure_vis = RConfig->getRichTbEnclosure_visib() ;
57  G4int RichTbRadFrame_vis = RConfig->getRichTbRadFrame_visib() ;
58  G4int RichTbRadUpW_vis = RConfig->getRichTbRadUpW_visib() ;
59  G4int RichTbRadDnW_vis = RConfig->getRichTbRadDnW_visib() ;
60  G4int RichTbAerogel_vis = RConfig->getRichTbAerogel_visib() ;
61  G4int RichTbAerogelWrap_vis = RConfig->getRichTbAerogelWrap_visib() ;
62  G4int RichTbAerogelWrapTop_vis = RichTbAerogelWrap_vis;
63  G4int RichTbAerogelWrapBot_vis =  RichTbAerogelWrap_vis;
64  G4int RichTbFilter_vis = RConfig->getRichTbFilter_visib() ;
65  G4int RichTbMirror_vis =   RConfig->getRichTbMirror_visib();
66  G4int RichTbHpdMaster_vis=  RConfig->getRichTbHpdMaster_visib() ;
67  G4int RichTbHpdEnvelopeTube_vis=  RConfig->getRichTbHpdEnvelopeTube_visib();
68  G4int RichTbHpdQuartzW_vis= RConfig->getRichTbHpdQuartzW_visib() ;
69  G4int RichTbHpdPhCathode_vis= RConfig->getRichTbHpdPhCathode_visib() ;
70  G4int RichTbHpdSiDet_vis= RConfig->getRichTbHpdSiDet_visib() ;
71  G4int RichTbHpdSectCoat_vis =RConfig->getRichTbHpdSectCoat_visib() ;
72  G4int RichTbHpdSiPx_vis= RConfig->getRichTbHpdSiPx_visib() ;
73 
74  //
75  //Now for the RichTbHall
76
77  G4LogicalVolume* RichTbHall_LV = RTbHall->getRichTbHallLogicalVolume();
78  if(RichTbHall_vis == 0 ) {
79     RichTbHall_LV->SetVisAttributes(G4VisAttributes::Invisible);
80  }else {
81     G4VisAttributes* RichTbHall_logVisAtt
82     = new G4VisAttributes(G4Colour(0.,1.,1.));
83     if(RichTbHall_vis == 2 ){
84        RichTbHall_logVisAtt->SetForceWireframe(true);
85     }
86     RichTbHall_logVisAtt->SetVisibility(true);
87     RichTbHall_LV->SetVisAttributes(RichTbHall_logVisAtt);
88  //
89  }
90  //
91  //
92  //Now for the RichTbEnclosure
93
94  G4LogicalVolume* RichTbEnclosure_LV = 
95           RTbComponent->getEnclosureLogicalVolume();
96
97  if(RichTbEnclosure_vis == 0 ){
98     RichTbEnclosure_LV->SetVisAttributes (G4VisAttributes::Invisible);
99  }else {
100
101     G4VisAttributes* RichTbEnclosure_logVisAtt
102      = new G4VisAttributes(G4Colour(1.,1.,0.));
103     if( RichTbEnclosure_vis == 2) {
104        RichTbEnclosure_logVisAtt->SetForceWireframe(true);
105     }else {
106        RichTbEnclosure_logVisAtt->SetForceSolid(true);
107     }
108     RichTbEnclosure_logVisAtt->SetVisibility(true);
109     RichTbEnclosure_LV->
110               SetVisAttributes(RichTbEnclosure_logVisAtt);
111  } 
112  //
113  //Now for the Radiator frame
114
115  G4LogicalVolume* RichTbRadFrame_LV = 
116           RTbComponent->getRadFrameLogicalVolume();
117
118  if(RichTbRadFrame_vis == 0 ){
119     RichTbRadFrame_LV->SetVisAttributes (G4VisAttributes::Invisible);
120  }else {
121
122     G4VisAttributes* RichTbRadFrame_logVisAtt
123      = new G4VisAttributes(G4Colour(1.,1.,0.));
124     if( RichTbRadFrame_vis == 2) {
125        RichTbRadFrame_logVisAtt->SetForceWireframe(true);
126     }else {
127        RichTbRadFrame_logVisAtt->SetForceSolid(true);
128     }
129     RichTbRadFrame_logVisAtt->SetVisibility(true);
130     RichTbRadFrame_LV->
131               SetVisAttributes(RichTbRadFrame_logVisAtt);
132  } 
133  //
134  //Now for the upstream window of the radiator frame
135
136  G4LogicalVolume* RichTbRadUpW_LV = 
137           RTbComponent->getRadUpWLogicalVolume();
138
139  if(RichTbRadUpW_vis == 0 ){
140     RichTbRadUpW_LV->SetVisAttributes (G4VisAttributes::Invisible);
141  }else {
142
143     G4VisAttributes* RichTbRadUpW_logVisAtt
144      = new G4VisAttributes(G4Colour(0.0,0.3,0.7));
145     if( RichTbRadUpW_vis == 2) {
146        RichTbRadUpW_logVisAtt->SetForceWireframe(true);
147     }else {
148        RichTbRadUpW_logVisAtt->SetForceSolid(true);
149     }
150     RichTbRadUpW_logVisAtt->SetVisibility(true);
151     RichTbRadUpW_LV->
152               SetVisAttributes(RichTbRadUpW_logVisAtt);
153  } 
154  //
155  // Now for the downstream window of the radiator frame
156  G4LogicalVolume* RichTbRadDnW_LV = 
157           RTbComponent->getRadDnWLogicalVolume();
158
159  if(RichTbRadDnW_vis == 0 ){
160     RichTbRadDnW_LV->SetVisAttributes (G4VisAttributes::Invisible);
161  }else {
162
163     G4VisAttributes* RichTbRadDnW_logVisAtt
164      = new G4VisAttributes(G4Colour(0.0,0.2,0.8));
165     if( RichTbRadDnW_vis == 2) {
166        RichTbRadDnW_logVisAtt->SetForceWireframe(true);
167     }else {
168        RichTbRadDnW_logVisAtt->SetForceSolid(true);
169     }
170     RichTbRadDnW_logVisAtt->SetVisibility(true);
171     RichTbRadDnW_LV->
172               SetVisAttributes(RichTbRadDnW_logVisAtt);
173  } 
174  //
175  //
176  //Now for the Aerogel
177
178  G4int NumTiles=RConfig->GetNumberOfAerogelTiles();
179  for (G4int ng=0; ng< NumTiles; ng++ ) {
180  G4LogicalVolume* RichTbAerogel_LV = 
181           RTbComponent->getAgelLogicalVolume(ng);
182
183  if(RichTbAerogel_vis == 0 ){
184     RichTbAerogel_LV->SetVisAttributes (G4VisAttributes::Invisible);
185  }else {
186
187    G4VisAttributes* RichTbAerogel_logVisAtt;
188    if(ng == 0 || ng == 2 || ng || 4 ) {
189     RichTbAerogel_logVisAtt = new G4VisAttributes(G4Colour(1.,0.2,0.8));
190    }else {
191
192    RichTbAerogel_logVisAtt = new G4VisAttributes(G4Colour(0.7,0.6,0.9));
193
194    } 
195
196     if( RichTbAerogel_vis == 2) {
197        RichTbAerogel_logVisAtt->SetForceWireframe(true);
198     }else {
199        RichTbAerogel_logVisAtt->SetForceSolid(true);
200     }
201     RichTbAerogel_logVisAtt->SetVisibility(true);
202     RichTbAerogel_LV->
203               SetVisAttributes(RichTbAerogel_logVisAtt);
204  }
205
206  //Now for the top Wrap of the Aerogel tile.
207
208  if( RTbComponent->getAgelWrapTopLogicalVolume(ng)) {
209  G4LogicalVolume* RichTbAerogelWrapTop_LV = 
210           RTbComponent->getAgelWrapTopLogicalVolume(ng);
211
212  if(RichTbAerogelWrapTop_vis == 0 ){
213     RichTbAerogelWrapTop_LV->SetVisAttributes (G4VisAttributes::Invisible);
214  }else {
215
216    G4VisAttributes* RichTbAerogelWrapTop_logVisAtt;
217    if(ng == 0 || ng == 2 || ng || 4 ) {
218     RichTbAerogelWrapTop_logVisAtt = 
219              new G4VisAttributes(G4Colour(0.2,0.2,0.6));
220    }else {
221
222    RichTbAerogelWrapTop_logVisAtt = 
223          new G4VisAttributes(G4Colour(0.2,0.4,0.8));
224
225    } 
226
227     if( RichTbAerogelWrapTop_vis == 2) {
228        RichTbAerogelWrapTop_logVisAtt->SetForceWireframe(true);
229     }else {
230        RichTbAerogelWrapTop_logVisAtt->SetForceSolid(true);
231     }
232     RichTbAerogelWrapTop_logVisAtt->SetVisibility(true);
233     RichTbAerogelWrapTop_LV->
234               SetVisAttributes(RichTbAerogelWrapTop_logVisAtt);
235  }
236  }
237  //Now for the Bottom Wrap of the Aerogel tile.
238
239  if(RTbComponent->getAgelWrapBotLogicalVolume(ng)){
240  G4LogicalVolume* RichTbAerogelWrapBot_LV = 
241           RTbComponent->getAgelWrapBotLogicalVolume(ng);
242
243  if(RichTbAerogelWrapBot_vis == 0 ){
244     RichTbAerogelWrapBot_LV->SetVisAttributes (G4VisAttributes::Invisible);
245  }else {
246
247    G4VisAttributes* RichTbAerogelWrapBot_logVisAtt;
248    if(ng == 0 || ng == 2 || ng || 4 ) {
249     RichTbAerogelWrapBot_logVisAtt = 
250              new G4VisAttributes(G4Colour(0.2,0.2,0.6));
251    }else {
252
253    RichTbAerogelWrapBot_logVisAtt = 
254          new G4VisAttributes(G4Colour(0.2,0.4,0.8));
255
256    } 
257
258     if( RichTbAerogelWrapBot_vis == 2) {
259        RichTbAerogelWrapBot_logVisAtt->SetForceWireframe(true);
260     }else {
261        RichTbAerogelWrapBot_logVisAtt->SetForceSolid(true);
262     }
263     RichTbAerogelWrapBot_logVisAtt->SetVisibility(true);
264     RichTbAerogelWrapBot_LV->
265               SetVisAttributes(RichTbAerogelWrapBot_logVisAtt);
266  }
267
268  }
269 
270}
271  //
272  //
273  //Now for the Filter
274  // First verify that the filter exists.
275   G4int Filnum=RConfig->GetFilterTNumber() ;
276   if(Filnum >=0 ) {
277 
278  G4LogicalVolume* RichTbFilter_LV = 
279           RTbComponent->getFilterLogicalVolume();
280
281  if(RichTbFilter_vis == 0 ){
282     RichTbFilter_LV->SetVisAttributes (G4VisAttributes::Invisible);
283  }else {
284
285     G4VisAttributes* RichTbFilter_logVisAtt
286      = new G4VisAttributes(G4Colour(0.3,0.9,0.4));
287     if( RichTbFilter_vis == 2) {
288        RichTbFilter_logVisAtt->SetForceWireframe(true);
289     }else {
290        RichTbFilter_logVisAtt->SetForceSolid(true);
291     }
292     RichTbFilter_logVisAtt->SetVisibility(true);
293     RichTbFilter_LV->
294               SetVisAttributes(RichTbFilter_logVisAtt);
295  } 
296   }
297  //
298  //
299  //
300  //Now for the Mirror
301  G4LogicalVolume* RichTbMirror_LV = 
302           RTbComponent->getMirrorLogicalVolume();
303
304  if(RichTbMirror_vis == 0 ){
305      RichTbMirror_LV->
306           SetVisAttributes (G4VisAttributes::Invisible);
307  }else {
308     G4VisAttributes* RichTbMirror_logVisAtt =
309      new G4VisAttributes(G4Colour(0.,0.5,0.5));
310     if(RichTbMirror_vis == 2 ){
311       RichTbMirror_logVisAtt->SetForceWireframe(true);
312     }else{
313       RichTbMirror_logVisAtt->SetForceWireframe(false);
314       RichTbMirror_logVisAtt->SetForceSolid(true);
315     }
316     RichTbMirror_logVisAtt->SetVisibility(true);
317
318     RichTbMirror_LV->
319            SetVisAttributes(RichTbMirror_logVisAtt);
320  }
321
322  //Now for the HPDs.
323  G4int numhpd= RTbPhotoDetector->getNumberOfHpds();
324  for(G4int ihpd=0; ihpd<numhpd; ihpd++){
325       //Now for the HPD master volume
326      G4LogicalVolume* RichTbHpdMaster_LV = 
327           RTbPhotoDetector->getRichHPD(ihpd)->getHpdLogicalVolume();
328
329     if(RichTbHpdMaster_vis == 0 ){
330      RichTbHpdMaster_LV->
331           SetVisAttributes (G4VisAttributes::Invisible);
332     }else {
333 
334       G4VisAttributes* RichTbHpdMaster_logVisAtt =
335        new G4VisAttributes(G4Colour(0.8,0.6,0.2));
336       if(RichTbHpdMaster_vis == 2 ){
337         RichTbHpdMaster_logVisAtt->SetForceWireframe(true);
338       }else{
339         RichTbHpdMaster_logVisAtt->SetForceWireframe(false);
340         RichTbHpdMaster_logVisAtt->SetForceSolid(true);
341       }
342       RichTbHpdMaster_logVisAtt->SetVisibility(true);
343
344       RichTbHpdMaster_LV->
345            SetVisAttributes(RichTbHpdMaster_logVisAtt);
346
347
348     }
349     //hpd Envelope Tube
350      G4LogicalVolume* RichTbHpdEnvelopeTube_LV = 
351      RTbPhotoDetector->getRichHPD(ihpd)->getHpdEnvelopeTubeGrandLogicalVolume();
352
353
354     if(RichTbHpdEnvelopeTube_vis == 0 ){
355      RichTbHpdEnvelopeTube_LV->
356           SetVisAttributes (G4VisAttributes::Invisible);
357     }else {
358 
359       G4VisAttributes* RichTbHpdEnvelopeTube_logVisAtt =
360        new G4VisAttributes(G4Colour(0.2,0.2,0.8));
361       if(RichTbHpdEnvelopeTube_vis == 2 ){
362         RichTbHpdEnvelopeTube_logVisAtt->SetForceWireframe(true);
363       }else{
364         RichTbHpdEnvelopeTube_logVisAtt->SetForceWireframe(false);
365         RichTbHpdEnvelopeTube_logVisAtt->SetForceSolid(true);
366       }
367       RichTbHpdEnvelopeTube_logVisAtt->SetVisibility(true);
368
369       RichTbHpdEnvelopeTube_LV->
370            SetVisAttributes(RichTbHpdEnvelopeTube_logVisAtt);
371
372     }
373
374     //hpd quartz window
375      G4LogicalVolume* RichTbHpdQuartzW_LV = 
376       RTbPhotoDetector->getRichHPD(ihpd)->getHpdQuartzWLogicalVolume();
377
378
379     if(RichTbHpdQuartzW_vis == 0 ){
380      RichTbHpdQuartzW_LV->
381           SetVisAttributes (G4VisAttributes::Invisible);
382     }else {
383 
384       G4VisAttributes* RichTbHpdQuartzW_logVisAtt =
385        new G4VisAttributes(G4Colour(0.8,0.8,0.8));
386       if(RichTbHpdQuartzW_vis == 2 ){
387         RichTbHpdQuartzW_logVisAtt->SetForceWireframe(true);
388       }else{
389         RichTbHpdQuartzW_logVisAtt->SetForceWireframe(false);
390         RichTbHpdQuartzW_logVisAtt->SetForceSolid(true);
391       }
392       RichTbHpdQuartzW_logVisAtt->SetVisibility(true);
393
394       RichTbHpdQuartzW_LV->
395            SetVisAttributes(RichTbHpdQuartzW_logVisAtt);
396
397     }
398
399     //hpd Ph Cathode
400      G4LogicalVolume* RichTbHpdPhCathode_LV = 
401       RTbPhotoDetector->getRichHPD(ihpd)->getHpdPhCathodeLogicalVolume();
402
403
404     if(RichTbHpdPhCathode_vis == 0 ){
405      RichTbHpdPhCathode_LV->
406           SetVisAttributes (G4VisAttributes::Invisible);
407     }else {
408 
409       G4VisAttributes* RichTbHpdPhCathode_logVisAtt =
410        new G4VisAttributes(G4Colour(0.2,0.3,0.3));
411       if(RichTbHpdPhCathode_vis == 2 ){
412         RichTbHpdPhCathode_logVisAtt->SetForceWireframe(true);
413       }else{
414         RichTbHpdPhCathode_logVisAtt->SetForceWireframe(false);
415         RichTbHpdPhCathode_logVisAtt->SetForceSolid(true);
416       }
417       RichTbHpdPhCathode_logVisAtt->SetVisibility(true);
418
419       RichTbHpdPhCathode_LV->
420            SetVisAttributes(RichTbHpdPhCathode_logVisAtt);
421
422     }
423
424
425     //Hpd Silicon Detector sectors
426     for(G4int isect=0; isect<NumberOfSiDetSectors; isect++) {
427      G4LogicalVolume* RichTbHpdSiDet_LV = 
428      RTbPhotoDetector->getRichHPD(ihpd)->getRichHpdSiDetSect(isect)->
429               getHpdSiSectLogicalVolume();
430
431     if(RichTbHpdSiDet_vis == 0 ){
432      RichTbHpdSiDet_LV->
433           SetVisAttributes (G4VisAttributes::Invisible);
434     }else {
435 
436       G4VisAttributes* RichTbHpdSiDet_logVisAtt =
437        new G4VisAttributes(G4Colour(0.6,0.6,0.9));
438       if(RichTbHpdSiDet_vis == 2 ){
439         RichTbHpdSiDet_logVisAtt->SetForceWireframe(true);
440       }else{
441         RichTbHpdSiDet_logVisAtt->SetForceWireframe(false);
442         RichTbHpdSiDet_logVisAtt->SetForceSolid(true);
443       }
444       RichTbHpdSiDet_logVisAtt->SetVisibility(true);
445
446       RichTbHpdSiDet_LV->
447            SetVisAttributes(RichTbHpdSiDet_logVisAtt);
448
449     }
450
451     //Coating on the silicon sector
452
453
454       G4LogicalVolume* RichTbHpdSectCoat_LV = 
455       RTbPhotoDetector->getRichHPD(ihpd)->getRichHpdSiDetSect(isect)->
456               getHpdSectCoatLogicalVolume();
457
458     if(RichTbHpdSectCoat_vis == 0 ){
459      RichTbHpdSectCoat_LV->
460           SetVisAttributes (G4VisAttributes::Invisible);
461     }else {
462 
463       G4VisAttributes* RichTbHpdSectCoat_logVisAtt =
464        new G4VisAttributes(G4Colour(0.8,0.3,0.9));
465       if(RichTbHpdSectCoat_vis == 2 ){
466         RichTbHpdSectCoat_logVisAtt->SetForceWireframe(true);
467       }else{
468         RichTbHpdSectCoat_logVisAtt->SetForceWireframe(false);
469         RichTbHpdSectCoat_logVisAtt->SetForceSolid(true);
470       }
471       RichTbHpdSectCoat_logVisAtt->SetVisibility(true);
472
473       RichTbHpdSectCoat_LV->
474            SetVisAttributes(RichTbHpdSectCoat_logVisAtt);
475
476     }
477      G4int numPix=RTbROGeom ->  getROPhotDet()-> getRichHPD(ihpd) ->
478                                   getRichHpdSiDetSect(isect) ->getNumSiPixels();
479
480
481      for(G4int ipixel=0; ipixel<numPix ; ipixel++){
482
483
484          G4LogicalVolume* RichTbHpdSiPx_LV= 
485                 RTbROGeom ->  getROPhotDet() -> getRichHPD(ihpd) ->
486                getRichHpdSiDetSect(isect) -> getHpdSiPx(ipixel) ->
487                getHpdSiPixelLogicalVolume();
488
489
490          if(RichTbHpdSiPx_vis == 0 ){
491            RichTbHpdSiPx_LV->SetVisAttributes (G4VisAttributes::Invisible);
492          }else {
493 
494            G4VisAttributes* RichTbHpdSiPx_logVisAtt =
495                    new G4VisAttributes(G4Colour(0.0,0.7,0.6));
496            if(RichTbHpdSiPx_vis == 2 ){
497              RichTbHpdSiPx_logVisAtt->SetForceWireframe(true);
498            }else{
499              RichTbHpdSiPx_logVisAtt->SetForceWireframe(false);
500              RichTbHpdSiPx_logVisAtt->SetForceSolid(true);
501            }
502            RichTbHpdSiPx_logVisAtt->SetVisibility(true);
503
504            RichTbHpdSiPx_LV->  SetVisAttributes(RichTbHpdSiPx_logVisAtt);
505
506          }
507
508
509
510
511      }
512
513     }
514  }
515
516
517}
518RichTbGraphics::~RichTbGraphics(){;}
519
520
521
522
523
524
525
Note: See TracBrowser for help on using the repository browser.