#ifndef TwigTk2DSimTracks_H
#define TwigTk2DSimTracks_H

#include <Inventor/SbString.h>
#include "CommonDet/BasicDet/interface/DetUnit.h"
#include "Visualisation/OrcaVis/interface/AutoTwig.h"

#include "CARF/G3Event/interface/G3EventProxy.h"
#include "Utilities/Notification/interface/LazyObserver.h" 


#include <set>
using namespace std; 


/**
*      Draw simulated tracks in the tracker.
*
*      Tracks are drawn by splining together the creation
*      point (SimVertex) of the track and the associated 
*      SimHits (ordered by time-of-flight). 
*
*      The trajectory is based on entry and exit points
*      of sensitive volumes for both accuracy of the 
*      intersection with the surfaces and to get the 
*      direction correct at the sensitive volumes.
*
*      Markers are also drawn to represent the SimHit's.
*
*      \author Lucas Taylor   2/07/1999
*/

class TwigTk2DSimTracks : public AutoTwig, private LazyObserver< G3EventProxy * > {

public:
    SbVec3f axis;
    float xa, ya, za, angle; 
    float posx, posy, posz;
    float hbotedge, htopedge, hapothem, hthickness; 
    int layer, anello, nmod ;
    int modulo, bar_fow, numod;
    ifstream* infile1;
    int nsimhits,lay;
   typedef set<const DetUnit *,less<const DetUnit *> > CrossedDetUnitSet;
    void updateSet(bool,CrossedDetUnitSet);
    
    
    typedef AutoTwig inherited;

    explicit TwigTk2DSimTracks( IgQtTwig* parent, SbString nm, bool b = true, bool c = false ) : 
	AutoTwig(parent, nm, b, c), theCurrentEvent(0) { 
   }

    /** Draw the simulated tracks.
     */
    void drawMe();

protected:

protected:

    void lazyUpDate( G3EventProxy * ev ) { theCurrentEvent = ev; };
 
private:
    
    G3EventProxy * theCurrentEvent;  
    
    void createRotation(const DetUnit* det, SbVec3f& axis, float& angle);
     void addWafer (SoSeparator* separator, const DetUnit* det);
};

#endif














