EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EtmDetector.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EtmDetector.h
1 
2 #include <map>
3 #include <vector>
4 
5 #include <TString.h>
6 #include <TColor.h>
7 
8 #ifndef _ETM_DETECTOR_
9 #define _ETM_DETECTOR_
10 
11 class EtmDetectorStack;
12 class G4VPhysicalVolume;
13 class G4LogicalVolume;
14 class TopoDS_Shape;
15 
16 #include <EtmPalette.h>
17 #include <EtmPolygonGroup.h>
18 
19 // For anything but the beam line edges;
20 #define _DEFAULT_TRIM_VALUE_ (0.7654321)
21 
23  friend class EicToyModel;
24  friend class EtmDetectorStack;
25 
26  public:
27  // Make ROOT streamer happy;
28  EtmDetector(const EtmDetectorStack *stack = 0, const char *label = 0,
29  int fillcolor = 0, int linecolor = 0, double length = 0.0);
31 
32  // == User commands === just the shortcuts for the "interactive" ones ==========================
33  //
34  //virtual EtmDetector *segments(unsigned segmentation) {
35  //mSegmentation = segmentation; return this;
36  //};
37  //
38  // For better vizualization may want either to align the detector edges with the
39  // respective eta lines, or with the arm alignment axis; can do this for two edges separately;
40  EtmDetector *trim(double etamin, double etamax, bool preserve_modified = false);
41  EtmDetector *trim(double value) { return trim(value, value, false); };
42  EtmDetector *brick( void ) { return trim(0.0); };
43  //
44  // May want to change the detector volume contour line;
45  EtmDetector *dashed( void ) { SetLineStyle(etm::dashed); return this; };
46  EtmDetector *dotted( void ) { SetLineStyle(etm::dotted); return this; };
47  EtmDetector *text(int value) { SetTextColor(value); return this; };
48  //
49  // May want to include subvolumes, recursively; this is only good for visualization purposes;
50  //EtmPolygonGroup *insert( int fillcolor, int linecolor = kBlack);
51  EtmPolygonGroup *insert(const char *tag, int linecolor = kBlack);
52  //EtmPolygonGroup *insert(const char *tag, int fillcolor, int linecolor = kBlack);
53 
54  // Returns the detector length along the alignment axis;
55  double length( void ) const { return mLength; };
56  void length(double value) { mLength = value; };
57 
58  // For bck() and fwd() stacks: absolute offset towards mid() stack, as counted from the
59  // alignment axis; perhaps relative to some other detector *upstream*side*, if specified;
60  // mid() stack requires neighbor stack specification, that's why more invocations provided;
61  EtmDetector *stretch(EtmDetector *refdet, double toffset, etm::Stretch how = etm::kRecess);
63  return stretch(refdet, 0.0, how);
64  };
65  EtmDetector *stretch( double tlength, etm::Stretch how = etm::kRecess);
66  EtmDetector *stretch(EtmDetectorStack *refstack, double tlength, etm::Stretch how = etm::kRecess);
67 
68  EtmDetector *highlight(double alpha = 1.0) { mColorAlpha = alpha; return this; };
69  // =============================================================================================
70 
71  double GetActualDistance( void ) const { return mActualDistance; };
72  bool IsDummy( void ) const { return !mLabel; };
73 
74  // Well, 'world' here means some 'parent' volume, actually;
75  G4VPhysicalVolume *PlaceG4Volume(G4LogicalVolume *world, const char *name = 0);
76  G4VPhysicalVolume *PlaceG4Volume(G4VPhysicalVolume *world, const char *name = 0);
77  G4VPhysicalVolume *GetG4Volume( void );// const { return mG4PhysicalVolume; };
78 
79  void Export(const char *fname);
80 
81  bool IsHighlighted( void ) const;// { return true; };
82  double GetColorAlpha( void ) const;// { return mColorAlpha; };
83 
84  private:
85  TString *GetLabel( void ) const { return mLabel; };
86 
87  void RegisterFillColor(std::map<TString, int> &legend);
88 
89  void Build( void );
90  std::vector<std::pair<const TColor*, const TopoDS_Shape*> > BuildCADmodel( void );
91 
92  unsigned GetOrder( void ) const;
93 
94  void ClearPolygonBuffer( void );
95  //void DrawMe( void ) const;
96  //void DrawMe(unsigned tb) const;
97 
99 
100  TString *mLabel;
101 
102  std::vector<EtmPolygonGroup*> mGraphicsElements;
103 
104  // May want to segment the volume;
105  //unsigned mSegmentation;
106 
107  // Detector length along the stack alignment axis;
108  double mLength, mOffset;
109 
111 
112  // Min & max eta edge alignment mode;
113  double mEdgeTrimming[2];
114 
115  // A tree of possible children; no overlap control here;
116  //std::vector<EtmDetector*> mChildren;
117 
118  G4VPhysicalVolume *mG4PhysicalVolume;
119 
120  // FIXME: use awkward ROOT teminology;
121  double mColorAlpha;
122 
123  ClassDef(EtmDetector, 1)
124 };
125 
126 #endif