12 #define DDMarlinCED_h 1
20 #include "marlin/Processor.h"
21 #include "marlin/Global.h"
26 #include <UTIL/LCTypedVector.h>
27 #include <UTIL/LCTOOLS.h>
28 #include <UTIL/Operators.h>
29 #include <EVENT/LCCollection.h>
30 #include <EVENT/MCParticle.h>
31 #include <EVENT/Track.h>
32 #include <EVENT/Cluster.h>
33 #include <EVENT/Vertex.h>
34 #include <EVENT/ReconstructedParticle.h>
35 #include <EVENT/SimTrackerHit.h>
36 #include <EVENT/SimCalorimeterHit.h>
37 #include <EVENT/TrackerHit.h>
38 #include <EVENT/CalorimeterHit.h>
40 #include "IMPL/ClusterImpl.h"
42 #include <MarlinDrawUtil.h>
43 #include <Trajectory.h>
48 using namespace marlin ;
51 #include "DD4hep/LCDD.h"
52 #include "DD4hep/DD4hepUnits.h"
53 #include "DDRec/DetectorData.h"
54 #include "DDRec/SurfaceManager.h"
55 #include "DDRec/Surface.h"
56 using namespace DD4hep::Geometry ;
57 using namespace DD4hep;
58 using namespace DD4hep::DDRec ;
68 typedef std::map<const int, DDCEDMapParticleObject> DDCEDPickingMap;
69 typedef std::map<std::string, void (*)(const LCObject *)> DDCEDFunctionMap;
73 void printDefault(
const LCObject *raw){
const T* obj = (T*) raw; std::cout << obj;}
90 static DDCEDPickingMap map;
95 static DDCEDFunctionMap funcMap;
115 streamlog_out(MESSAGE) <<
" Picked object " << obj <<
" with id " << obj->id() << std::endl;
116 streamlog_out(MESSAGE) << *(T*)obj;
123 static int kbhit(
void);
140 void update(LCEvent *);
150 void registerFunction(std::string,
void (*)(
const LCObject *));
168 static void init( Processor* proc ) ;
170 static void newEvent( Processor* proc , LCEvent* evt=0 ) ;
176 static void draw( Processor* proc ,
int waitForKeyboard=1 ) ;
178 static void getParticleFromID(
int, LCEvent*);
185 static void drawObjectsWithPosition(In first, In last,
int marker,
int size ,
unsigned int color,
unsigned int layer=0,
const char * PickingMessage=
"") {
186 while( first != last ) {
187 int id = (*first)->id();
188 ced_hit_ID( (*first)->getPosition()[0],
189 (*first)->getPosition()[1],
190 (*first)->getPosition()[2],
191 marker,layer, size , color, id ) ;
200 static void drawObjectsWithPositionID(LCCollection* col,In first, In last,
int marker,
int size ,
unsigned int color,
unsigned int layer=0) {
202 while( first != last ) {
203 int id = (*first)->id();
204 std::cout <<
"test!!! " << std::endl;
205 ced_hit_ID( (*first)->getPosition()[0],
206 (*first)->getPosition()[1],
207 (*first)->getPosition()[2],
208 marker, layer, size , color, id ) ;
218 static void drawHelix(
float b,
float charge,
float x,
float y,
float z,
219 float px,
float py,
float pz,
int marker,
int size,
221 float rmin=10.0,
float rmax=3000.0,
float zmax=4500.0,
unsigned int id = 0);
224 static int getIDfromIndex(LCCollection* col,
int index);
226 static void set_layer_description(
const std::string& desc,
int layerID);
227 static void add_layer_description(
const std::string& desc,
int layerID);
228 static void write_layer_description(
void);
241 static void drawDD4hepDetector( DD4hep::Geometry::LCDD& lcdd,
bool _surfaces, StringVec _detailled);
244 static int _int_count;
245 static std::vector<std::string> _descs;
251 DDMarlinCED() : _first(0) , _last(0){ _currEvent=0; }
258 static void drawHitCollectionsByType(LCEvent* event,
const char* type,
int marker,
int size,
259 unsigned int color,
unsigned int layer=0) {
263 std::vector< std::string >::const_iterator iter;
264 const std::vector< std::string >* ColNames =
event->getCollectionNames();
266 for( iter = ColNames->begin() ; iter != ColNames->end() ; iter++) {
268 LCCollection* col =
event->getCollection( *iter ) ;
270 if ( col->getTypeName() == type ) {
272 if ( type == LCIO::SIMTRACKERHIT ) {
274 LCTypedVector<SimTrackerHit> v(col);
275 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
279 if ( type == LCIO::SIMCALORIMETERHIT ) {
281 LCTypedVector<SimCalorimeterHit> v(col);
282 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
286 if ( type == LCIO::TRACKERHIT ) {
288 LCTypedVector<TrackerHit> v(col);
289 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
293 if ( type == LCIO::CALORIMETERHIT ) {
295 LCTypedVector<CalorimeterHit> v(col);
296 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
302 catch(DataNotAvailableException &e){}
308 static void drawHitCollectionsByMCContribution(LCEvent* event, MCParticle* MCP,
int marker,
int size,
309 unsigned int color,
unsigned int layer=0) {
311 std::vector< std::string >::const_iterator iter;
312 const std::vector< std::string >* ColNames =
event->getCollectionNames();
314 for( iter = ColNames->begin() ; iter != ColNames->end() ; iter++) {
316 LCCollection* col =
event->getCollection( *iter ) ;
318 if ( col->getTypeName() == LCIO::SIMTRACKERHIT ) {
320 int n = col->getNumberOfElements();
322 for (
int i = 0; i < n; ++i) {
324 SimTrackerHit* hit =
dynamic_cast<SimTrackerHit*
>(col->getElementAt(i));
326 if (hit->getMCParticle() == MCP) {
327 double x = hit->getPosition()[0];
328 double y = hit->getPosition()[1];
329 double z = hit->getPosition()[2];
330 ced_hit_ID(x,y,z,marker, layer,size,color, MCP->id());
337 if ( col->getTypeName() == LCIO::SIMCALORIMETERHIT ) {
339 int n = col->getNumberOfElements();
341 for (
int i = 0; i < n; ++i) {
343 SimCalorimeterHit* hit =
dynamic_cast<SimCalorimeterHit*
>(col->getElementAt(i));
345 int nMC = hit->getNMCContributions();
348 for (
int j = 0; j < nMC; ++j) {
349 if (hit->getParticleCont(j) == MCP) {
356 double x = hit->getPosition()[0];
357 double y = hit->getPosition()[1];
358 double z = hit->getPosition()[2];
359 ced_hit_ID(x,y,z,marker,layer,size,color, MCP->id());
368 void DDdraw_helix(
float b,
float charge,
float x,
float y,
float z,
369 float px,
float py,
float pz,
370 int marker,
int size,
unsigned int col,
371 float rmin=10.0,
float rmax=3000.0,
float zmax=4500.0,
unsigned int id = 0) ;
377 bool detailledDrawing(StringVec _detailled, std::string detName);
387 double Rmax;
double Rmin;
double inner_symmetry;
double outer_symmetry;
double phi0;
double delta_phi;
double delta_z;
double z0;
395 std::vector<CEDGeoBox> staves;
400 void getVisAttributes(DD4hep::Geometry::DetElement det,
unsigned &color,
bool &visible);
406 CEDGeoTubeParams CalorimeterParameterConversion (LayeredCalorimeterData *calo);
410 CEDGeoTubeParams PetalParameterConversion (std::vector<DDRec::ZDiskPetalsData::LayerLayout>::iterator thisLayer);
414 CEDGeoTubeParams CalorimeterLayerParameterConversion(std::vector<DDRec::LayeredCalorimeterData::Layer>::iterator thisLayer);
422 LayerGeometry TrackerLayerParameterConversion(std::vector<DDRec::ZPlanarData::LayerLayout>::iterator thisLayer);
425 bool DrawSurfaces(
const DD4hep::DDRec::SurfaceManager &surfMan, std::string detName,
unsigned color,
int layer);
Definition: DDMarlinCED.h:393
Singleton class to manage access to CED from several processors.
Definition: DDMarlinCED.h:159
Definition: DDMarlinCED.h:380
static void drawObjectsWithPosition(In first, In last, int marker, int size, unsigned int color, unsigned int layer=0, const char *PickingMessage="")
Draw all objects in iterator range [first,last) which have a method getPosition() with the given colo...
Definition: DDMarlinCED.h:185
Definition: DDMarlinCED.h:386
Bring the feature to print a LCIO-Objekt given by his ID.
Definition: DDMarlinCED.h:81
Definition: DDMarlinCED.h:66
static void defaultOutputFunction(const LCObject *obj)
The default print method for all LCIO objects.
Definition: DDMarlinCED.h:113