CEDViewer  1.12.0
DDCEDViewer.h
1 /***********************************************************************************************
2 Single processor for drawing detector geometry and LCIO data; removed dependence on GEAR.
3 
4 author: Thorben Quast (CERN Summer Student 2015)
5 date: 10 August 2015
6 ***********************************************************************************************/
7 
8 #ifndef CEDViewer_h
9 #define CEDViewer_h 1
10 
11 #include "marlin/Processor.h"
12 #include "lcio.h"
13 #include <string>
14 #include <vector>
15 
16 using namespace lcio ;
17 using namespace marlin ;
18 namespace DD4hep{
19  namespace Geometry{
20  class LCDD ;
21  }
22 }
23 
24 
25 
28  DrawParameters(const std::string& colName, int size, int marker, int layer ) :
29  ColName( colName ),
30  Size( size ),
31  Marker( marker ),
32  Layer( layer ) {
33  }
34  std::string ColName ;
35  int Size ;
36  int Marker ;
37  int Layer ;
38 };
39 
40 
41 class DDCEDViewer : public Processor {
42 
43  public:
44  virtual Processor* newProcessor() { return new DDCEDViewer ; }
45 
46  DDCEDViewer() ;
50  virtual void init() ;
51 
54  virtual void processRunHeader( LCRunHeader* run ) ;
55 
58  virtual void processEvent( LCEvent * evt ) ;
59 
60 
61  virtual void check( LCEvent * evt ) ;
62 
63 
66  virtual void end() ;
67 
68  //helpers
69  void printParticle(int id, LCEvent * evt);
70  bool detailledDrawing(std::string detName);
71 
72 
87  void drawDD4LCIO(LCEvent * evt, DD4hep::Geometry::LCDD& lcdd);
88  //convenience function to improve readibility of main code
89  void drawCluster(DD4hep::Geometry::LCDD& lcdd, int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, int& size);
90  void drawTrack(DD4hep::Geometry::LCDD& lcdd, int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, int& size);
91  void drawMCParticle(DD4hep::Geometry::LCDD& lcdd, int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, int& size);
92  void drawSIMTrackerHit(int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, std::vector<int>& _colors, int& size);
93  void drawSIMCalorimeterHit(int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, std::vector<int>& _colors, int& size);
94  void drawTrackerHit(int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, int& size);
95  void drawCalorimeterHit(int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, int& size);
96  void drawReconstructedParticle(DD4hep::Geometry::LCDD& lcdd, int& layer, unsigned& np, std::string colName, int& marker, LCCollection* col, int& size);
97  void drawJets(DD4hep::Geometry::LCDD& lcdd, int layer, std::string colName, LCCollection* col);
98 
99  protected:
100 
101  static const int ncol = 20 ;
102  static const int nscheme = 10 ;
103  static const int Red = 0 ;
104  static const int Orange = 1 ;
105  static const int Plum = 2 ;
106  static const int Violet = 3 ;
107  static const int Blue = 4 ;
108  static const int LightBlue = 5 ;
109  static const int Aquamarine = 6 ;
110  static const int Green = 7 ;
111  static const int Olive = 8 ;
112  static const int Yellow = 9 ;
113 
114  static const int Dark = 10 ;
115  static const int Light = 11 ;
116  static const int Classic = 12 ;
117 
118  StringVec _drawCollections ;
119  StringVec _drawCollectionsLayer ;
120  std::vector< DrawParameters > drawParameters ;
121 
122  //general options
123  int _nRun ;
124  int _nEvt ;
125  //lcio options
126  bool _usingParticleGun ;
127  int _drawHelixForTracks ;
128  int _colorScheme ;
129  float _mcpECut ;
130  float _helix_max_r;
131  float _helix_max_z;
132  bool _useTrackerForLimitsOfHelix;
133  int _waitForKeyboard ;
134  int _drawHelixForPFOs;
135  int _useColorForHelixTracks ;
136  int _drawEllipsoidForPFOClusters ;
137  IntVec _colors ;
138 
139  //detector options
140  bool _begin;
141  StringVec _detailled;
142  StringVec _jets;
143  bool _surfaces;
144 } ;
145 
146 
147 /***********************************************************************************************
148 Helper or 'utility' functions & structures for DDCEDViewer processor.
149 
150 author: Thorben Quast (CERN Summer Student 2015)
151 date: 12 August 2015
152 ***********************************************************************************************/
153 
154 #include "marlin/Processor.h"
155 #include <string>
156 
157 //Includes for detector drawing
158 #include "DD4hep/LCDD.h"
159 #include "DDRec/DetectorData.h"
160 using namespace DD4hep::Geometry ;
161 
162 //structure for calculating the track length of given particles
164  double r_inner, delta_r, z_0, delta_z;
165 };
166 
167 /***lcio draw helpers***/
168 //get the outer extents of the tracker
169 double* getTrackerExtent(DD4hep::Geometry::LCDD& lcdd);
170 
171 //get the outer extents of the yoke
172 double* getYokeExtent(DD4hep::Geometry::LCDD& lcdd);
173 
174 //calculates and returns the relevant calorimeter parameters for track length calculations.
175 CalorimeterDrawParams getCalorimeterParameters(DD4hep::Geometry::LCDD& lcdd, std::string name, bool selfCall = false);
176 
177 //It suffices to perform the calculations in the first quadrant due to the detector's symmetry.
178 //The signs of the tracks' directions are ultimately determined by the momenta.
179 double calculateTrackLength(std::string type, DD4hep::Geometry::LCDD& lcdd, double x, double y, double z, double px, double py, double pz);
180 
181 int returnRGBClusterColor(float eneCluster, float cutoff_min, float cutoff_max, int color_steps, char scale, int colorMap);
182 
183 #endif
184 
185 
186 
Definition: DDCEDViewer.h:163
Definition: DDCEDViewer.h:41
Helper struct for drawing collections.
Definition: DDCEDViewer.h:27