9 #include "marlin/Processor.h"
10 #include "marlin/Global.h"
15 #include <UTIL/LCTypedVector.h>
16 #include <UTIL/LCTOOLS.h>
17 #include <UTIL/Operators.h>
18 #include <EVENT/LCCollection.h>
19 #include <EVENT/MCParticle.h>
20 #include <EVENT/Track.h>
21 #include <EVENT/Cluster.h>
22 #include <EVENT/Vertex.h>
23 #include <EVENT/ReconstructedParticle.h>
24 #include <EVENT/SimTrackerHit.h>
25 #include <EVENT/SimCalorimeterHit.h>
26 #include <EVENT/TrackerHit.h>
27 #include <EVENT/CalorimeterHit.h>
29 #include "IMPL/ClusterImpl.h"
31 #include <MarlinDrawUtil.h>
32 #include <Trajectory.h>
37 using namespace marlin ;
41 typedef std::map<const int, CEDMapParticleObject> CEDPickingMap;
42 typedef std::map<std::string, void (*)(const LCObject *)> CEDFunctionMap;
46 void printDefault(
const LCObject *raw){
const T* obj = (T*) raw; std::cout << obj;}
63 static CEDPickingMap map;
68 static CEDFunctionMap funcMap;
88 streamlog_out(MESSAGE) <<
" Picked object " << obj <<
" with id " << obj->id() << std::endl;
89 streamlog_out(MESSAGE) << *(T*)obj;
96 static int kbhit(
void);
113 void update(LCEvent *);
123 void registerFunction(std::string,
void (*)(
const LCObject *));
141 static void init( Processor* proc ) ;
152 static void newEvent( Processor* proc ,
int modelID=0, LCEvent* evt=0 ) ;
158 static void draw( Processor* proc ,
int waitForKeyboard=1 ) ;
160 static void getParticleFromID(
int, LCEvent*);
162 static void printMCParticle(MCParticle* mcp,
int daughterIndent=0,
int motherIndent=0);
163 void printMCFamily(MCParticle* part,
unsigned int daughterBranches,
unsigned int motherBranches,
164 unsigned int daughterIndent=0,
unsigned int motherIndent=0);
165 void printAndDrawMCFamily(MCParticle* part, LCEvent * evt,
unsigned int daughterBranches,
unsigned int motherBranches,
166 unsigned int daughterIndent=0,
unsigned int motherIndent=0);
174 static void drawObjectsWithPosition(In first, In last,
int marker,
int size ,
unsigned int color,
unsigned int layer=0,
const char * PickingMessage=
"") {
177 while( first != last ) {
183 int id = (*first)->id();
184 ced_hit_ID( (*first)->getPosition()[0],
185 (*first)->getPosition()[1],
186 (*first)->getPosition()[2],
188 marker,layer, size , color, id ) ;
197 static void drawObjectsWithPositionID(LCCollection* col,In first, In last,
int marker,
int size ,
unsigned int color,
unsigned int layer=0) {
199 while( first != last ) {
200 int id = (*first)->id();
201 std::cout <<
"test!!! " << std::endl;
203 ced_hit_ID( (*first)->getPosition()[0],
204 (*first)->getPosition()[1],
205 (*first)->getPosition()[2],
207 marker, layer, size , color, id ) ;
217 static void drawHelix(
float b,
float charge,
float x,
float y,
float z,
218 float px,
float py,
float pz,
int marker,
int size,
220 float rmin=10.0,
float rmax=3000.0,
float zmax=4500.0,
unsigned int id = 0);
225 static void drawTrajectory(
const Trajectory* t,
const int marker,
226 const int size,
const unsigned int col,
227 const float rmin=10.0,
const float rmax=3000.0,
228 const float zmax=4500.0,
unsigned int id=0) ;
232 static void drawSpike(
float x0,
float y0,
float z0,
float x1,
float y1,
float z1,
unsigned int color,
unsigned int layer,
unsigned int id=0);
235 static void drawGEARDetector() ;
236 static void drawDetectorFromGear( gear::GearMgr* gearMgr ) ;
239 static void drawGEARTelescope() ;
254 static CED_GeoCylinder geoCylindersLDC[] = {
256 { 380.0, 24, 0.0, 2658.5, -2658.5, 0xff },
257 { 1840.0, 8, 22.5, 2700.0, -2700.0, 0x7f7f1f },
258 { 2045.7, 8, 22.5, 2700.0, -2700.0, 0x7f7f1f },
259 { 2045.7, 8, 22.5, 101.00, 2820.0, 0x7f7f1f },
260 { 2045.7, 8, 22.5, 101.00, -3022.0, 0x7f7f1f },
261 { 3000.0, 16, 0.0, 2658.5, -2658.5, 0xcf00 },
262 { 3000.0, 8, 22.5, 702.25, 2826.0, 0xcf00 },
263 { 3000.0, 8, 22.5, 702.25, -4230.5, 0xcf00 },
267 static CED_GeoCylinder geoCylindersSiD[] = {
269 { 186.35, 20, 0.0, 271.0, -271.0, 0xff },
270 { 448.85, 20, 0.0, 621.0, -621.0, 0xff },
271 { 711.35, 20, 0.0, 971.0, -971.0, 0xff },
272 { 973.85, 20, 0.0, 1321.0, -1321.0, 0xff },
273 { 1236.35, 20, 0.0, 1649.4, -1649.4, 0xff },
274 { 1270.00, 30, 0.0, 1682.5, -1682.5, 0x7f7f1f },
275 { 1385.00, 30, 0.0, 1682.5, -1682.5, 0x7f7f1f },
276 { 1385.00, 30, 0.0, 562.5, 1682.5, 0x7f7f1f },
277 { 1385.00, 30, 0.0, 562.5, -2807.5, 0x7f7f1f },
278 { 2500.00, 30, 0.0, 1795.0, -1795.0, 0xcf00 },
279 { 2500.00, 30, 0.0, 487.25 , 1795.0, 0xcf00 },
280 { 2500.00, 30, 0.0, 487.25 ,-2770.0, 0xcf00 },
284 static CED_GeoCylinder geoCylindersGLD[] = {
286 { 400.0, 24, 0.0, 2600.0, -2600.0, 0xff },
287 { 2100.0, 30, 22.5, 2700.0, -2700.0, 0x7f7f1f },
288 { 3405.0, 30, 22.5, 2700.0, -2700.0, 0x7f7f1f },
289 { 3405.0, 30, 22.5, 737.5, 2700.0, 0x7f7f1f },
290 { 3405.0, 30, 22.5, 737.5, -4175.0, 0x7f7f1f },
298 static CED_GeoCylinder geoCylindersCaliceTestBeam[] = {
299 { float( 192.25*sqrt(2.0) ), 4, 45.0, 101.35, -2.0*101.35 , 0x7f7f1f },
300 { float( 450.00*sqrt(2.0) ), 4, 45.0, 572.87, 0.00 , 0xcf00 },
301 { float( 500.00*sqrt(2.0) ), 4, 45.0, 457.60, 2.0*572.87+250.0, 0xcf00 },
306 ced_geocylinders(
sizeof(geoCylindersLDC)/
sizeof(CED_GeoCylinder),geoCylindersLDC);
308 else if (modelID == 1) {
309 ced_geocylinders(
sizeof(geoCylindersSiD)/
sizeof(CED_GeoCylinder),geoCylindersSiD);
311 else if (modelID == 2) {
312 ced_geocylinders(
sizeof(geoCylindersGLD)/
sizeof(CED_GeoCylinder),geoCylindersGLD);
314 else if (modelID == 3) {
315 ced_geocylinders(
sizeof(geoCylindersCaliceTestBeam)/
sizeof(CED_GeoCylinder),geoCylindersCaliceTestBeam);
326 static void drawMCParticle(MCParticle* MCP,
bool drawSimHits, LCEvent* event,
int marker,
int size,
327 unsigned int color,
unsigned int layer=0,
double bField = 4.0,
328 double rmin = 0.0,
double zmin = 0.0,
double rmax = 3000.0,
double zmax = 4500.0,
329 bool drawOnDifferentLayers =
true);
338 static void drawMCParticleTree(LCEvent* event, std::string colNameMC,
double energyCut,
339 double bField = 4.0,
double rIn = 0.0,
double zIn = 0.0,
340 double rOut = 3000.0 ,
double zOut = 4500.0);
344 static void drawSimTrackerHits(LCEvent* event,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
348 static void drawSimCalorimeterHits(LCEvent* event,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
352 static void drawSimHits(LCEvent* event,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
356 static void drawTrackerHits(LCEvent* event,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
360 static void drawCalorimeterHits(LCEvent* event,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
364 static void drawHits(LCEvent* event,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
368 static void drawTrack(Track* track,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
372 static void drawCluster(Cluster* cluster,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
376 static void drawClusterImpl(
const ClusterImpl* cluster,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
380 static void drawRecoParticle(ReconstructedParticle* reco,
int marker,
int size,
unsigned int color,
unsigned int layer=0);
384 static int getIDfromIndex(LCCollection* col,
int index);
391 static void set_layer_description(
const std::string& desc,
int layerID);
392 static void add_layer_description(
const std::string& desc,
int layerID);
393 static void write_layer_description(
void);
396 static int _int_count;
397 static std::vector<std::string> _descs;
403 MarlinCED() : _first(0) , _last(0){ _currEvent=0; }
410 static void drawHitCollectionsByType(LCEvent* event,
const char* type,
int marker,
int size,
411 unsigned int color,
unsigned int layer=0) {
415 std::vector< std::string >::const_iterator iter;
416 const std::vector< std::string >* ColNames =
event->getCollectionNames();
418 for( iter = ColNames->begin() ; iter != ColNames->end() ; iter++) {
420 LCCollection* col =
event->getCollection( *iter ) ;
422 if ( col->getTypeName() == type ) {
424 if ( type == LCIO::SIMTRACKERHIT ) {
426 LCTypedVector<SimTrackerHit> v(col);
427 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
431 if ( type == LCIO::SIMCALORIMETERHIT ) {
433 LCTypedVector<SimCalorimeterHit> v(col);
434 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
438 if ( type == LCIO::TRACKERHIT ) {
440 LCTypedVector<TrackerHit> v(col);
441 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
445 if ( type == LCIO::CALORIMETERHIT ) {
447 LCTypedVector<CalorimeterHit> v(col);
448 drawObjectsWithPosition(v.begin(),v.end(),marker,size,color,layer);
454 catch(DataNotAvailableException &e){}
461 static void drawHitCollectionsByMCContribution(LCEvent* event, MCParticle* MCP,
int marker,
int size,
462 unsigned int color,
unsigned int layer=0) {
464 std::vector< std::string >::const_iterator iter;
465 const std::vector< std::string >* ColNames =
event->getCollectionNames();
467 for( iter = ColNames->begin() ; iter != ColNames->end() ; iter++) {
469 LCCollection* col =
event->getCollection( *iter ) ;
471 if ( col->getTypeName() == LCIO::SIMTRACKERHIT ) {
473 int n = col->getNumberOfElements();
475 for (
int i = 0; i < n; ++i) {
477 SimTrackerHit* hit =
dynamic_cast<SimTrackerHit*
>(col->getElementAt(i));
479 if (hit->getMCParticle() == MCP) {
480 double x = hit->getPosition()[0];
481 double y = hit->getPosition()[1];
482 double z = hit->getPosition()[2];
484 ced_hit_ID(x,y,z,marker, layer,size,color, MCP->id());
491 if ( col->getTypeName() == LCIO::SIMCALORIMETERHIT ) {
493 int n = col->getNumberOfElements();
495 for (
int i = 0; i < n; ++i) {
497 SimCalorimeterHit* hit =
dynamic_cast<SimCalorimeterHit*
>(col->getElementAt(i));
499 int nMC = hit->getNMCContributions();
502 for (
int j = 0; j < nMC; ++j) {
503 if (hit->getParticleCont(j) == MCP) {
511 double x = hit->getPosition()[0];
512 double y = hit->getPosition()[1];
513 double z = hit->getPosition()[2];
515 ced_hit_ID(x,y,z,marker,layer,size,color, MCP->id());
534 void drawDetectorFromGearFile(
const char* fname ) ;
537 void draw_helix(
float b,
float charge,
float x,
float y,
float z,
538 float px,
float py,
float pz,
539 int marker,
int size,
unsigned int col,
540 float rmin=10.0,
float rmax=3000.0,
float zmax=4500.0,
unsigned int id = 0) ;
static void defaultOutputFunction(const LCObject *obj)
The default print method for all LCIO objects.
Definition: MarlinCED.h:86
Abstract trajectory interface describing a geometrical path in 3D space.
Definition: Trajectory.h:13
Bring the feature to print a LCIO-Objekt given by his ID.
Definition: MarlinCED.h:54
Singleton class to manage access to CED from several processors.
Definition: MarlinCED.h:132
Definition: MarlinCED.h:39
static void drawDetector(int modelID)
Draws the detector only.
Definition: MarlinCED.h:246
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: MarlinCED.h:174