CEDRIC  Revision_backup-2009-02
VisCaloCluster.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 2008 Boris Iven, Max Hermann
4  *
5  * This file is part of the "CEDRIC Event Display" application.
6  *
7  *****************************************************************************/
8 
9 #ifndef VISCALOCLUSTER_H
10 #define VISCALOCLUSTER_H
11 
12 #include "FilterVis.h"
13 #include "PhastInterface.h"
14 #include "QPhastInterface.h"
15 #include "PhastNode.h"
16 #include "EDException.h"
17 #include <Phast.h>
18 
19 #include <iostream>
20 
21 class VisCaloCluster : public FilterVis
22 {
23 public:
24  VisCaloCluster( int mode, std::string caloName )
25  : FilterVis(mode), m_caloName(caloName)
26  {
27  //~ std::cout << "VisCaloCluster: Constructed vis " << this << " for calorimeter \"" << m_caloName << "\"" << std::endl;
28  }
29 
31  {
32  //~ std::cout << "VisCaloCluster: Creating visualization node for calorimeter \"" << m_caloName << "\"" << std::endl;
33 
34  PhastNode* node = new PhastNode;
35 
36  // add all clusters belonging to calorimeter
37  const PaEvent& event = PhastInterface::ref().phast()->event;
38  try
39  {
40  const PaCalorimeter& calo = QPhastInterface::getCalorimeter( m_caloName );
41 
42  for( int i=0; i < event.NCaloClus(); ++i )
43  {
44  const PaCaloClus& cluster = event.vCaloClus(i);
45 
46  #if 1 //-- determine corresponding cluster by z-position
47  if( calo.IsMyCluster( cluster ) )
48  #else //-- determine corresponding cluster by name (PROBLEMATIC: sometimes names don't match!)
49  if( cluster.CalorimName().compare( m_caloName ) == 0 )
50  #endif
51  {
52  node->addChild( new PhastNode(cluster) );
53  }
54  }
55  }
56  catch(EDException e)
57  {
58  std::cout << e.getInfo() << std::endl;
59  return node;
60  }
61 
62 
63  return node;
64  }
65 
66  void filter( PhastScene* scene, std::list<PhastNode*>& nodes )
67  {
68  nodes.push_back( scene->getDetector( m_caloName ) );
69  nodes.push_back( scene->eventNode() );
70  }
71 
72 protected:
73  std::string m_caloName;
74 };
75 
76 #endif
const PaCalorimeter & getCalorimeter(const QString &name)
Definition: QPhastInterface.cpp:83
Definition: VisCaloCluster.h:21
std::string getInfo()
Definition: EDException.h:16
PhastNode * getDetector(std::string name)
Definition: PhastScene.cpp:64
Graphical representation of Phast objects (e.g. PaDetector, PaTrack, ...) as OpenSceneGraph node...
Definition: PhastNode.h:32
PhastNode * visNode()
Definition: VisCaloCluster.h:30
int mode()
Definition: FilterVis.h:35
VisCaloCluster(int mode, std::string caloName)
Definition: VisCaloCluster.h:24
Definition: EDException.h:12
Phast * phast()
Definition: PhastInterface.h:44
PhastNode * eventNode()
Definition: PhastScene.h:50
virtual bool addChild(osg::Node *child)
Definition: TypedTransform.h:41
void filter(PhastScene *scene, std::list< PhastNode * > &nodes)
Definition: VisCaloCluster.h:66
Scenegraph holding static and dynamic Phast geometry.
Definition: PhastScene.h:32
static PhastInterface & ref()
Definition: PhastInterface.h:62
std::string m_caloName
Definition: VisCaloCluster.h:73
Definition: FilterVis.h:16