/*
 * PndLmd.h
 *
 *  Created on: Apr 28, 2009
 *      Author: huagen
  */

#ifndef PNDLMD_H
#define PNDLMD_H

//Root head files
#include "TClonesArray.h"
#include "TVector3.h"
#include "TString.h"
#include "TLorentzVector.h"

// Include base and geobase
#include "FairDetector.h"
#include "FairRun.h"
#include "FairVolume.h"
#include "FairRootManager.h"
#include "FairGeoLoader.h"
#include "FairGeoInterface.h"

//VMC
#include "TVirtualMC.h"
#include "TParticle.h"

//pandaroot includes
#include "PndStack.h"

// LM includes
#include "PndLmdGeo.h"
#include "PndLmdMCPoint.h"

class PndLmd : public FairDetector
{
public:
	//default constructor
	 PndLmd();

	 // constructor
    //  Name :  Detector Name
    //  Active: kTRUE for active detectors  (ProcessHits() will be called)
     //         kFALSE for inactive detectors

	PndLmd(const char* name, Bool_t active = kTRUE, Int_t verbose = 0);

	//destructor
	virtual ~PndLmd();

	//    Initialization of the detector is done here
//	virtual void Initialize();

	 //	      this method is called for each step during simulation (see FairMCApplication::Stepping())
	/** Define the action to be taken when a step is inside the
			active volume. Creates PndLmdPoints and adds them to the collection.
			\param vol  Pointer to the active volume
    */
	 virtual Bool_t ProcessHits( FairVolume* v=0); //Format modification May5

      /** If verbosity level is set, print hit collection at the
 	end of the event and reset it afterwards */
     virtual void EndOfEvent();

     //    Registers the produced collections in FAIRRootManager.
     virtual void Register()=0;

     /** Gets the produced collections **/
     virtual TClonesArray* GetCollection(Int_t iColl) const;

     // has to be called after each event to reset the containers
     virtual void Reset();

     /** Screen output of hit collection */
     virtual void Print() const;

     /** Virtual method CopyClones
       **
       ** Copies the hit collection with a given track index offset
       *@param cl1     Origin
       *@param cl2     Target
       *@param offset  Index offset
       **/
  //    virtual void CopyClones(TClonesArray* cl1, TClonesArray* cl2,
   // 			  Int_t offset);

      /** Virtual method Construct geometry
       ** Constructs the PndLmd geometry
       **/
      virtual void ConstructGeometry();
     // void ConstructRootGeometry();
    //  void ConstructASCIIGeometry();
     // void ExpandNode(TGeoNode *fN);

     //
private:
    /** Track information to be stored during tracking through a volume */
    Int_t          fTrackID;    	  // track index
    Int_t          fVolumeID;   	  // volume id
    TLorentzVector fPosIn;     		  // entry position in global frame
    TLorentzVector fPosOut;      	  // exit position in global frame
    TLorentzVector fMomIn;            // momentum at the entrance of one detector element
    TLorentzVector fMomOut;	          // momentum at the exit of one detector element
    Double32_t     fTime;             // time
    Double32_t     fLength;           // length
    Double32_t     fEnergyLoss;       // energy loss
    TString        fDetName;          // det name
    TClonesArray*  fPndLmdPointCollection;  // Pointer to hit collection

    /** Private method AddHit
      ** Adds a FairTrdPoint to the HitCollection
      **/

    PndLmdMCPoint* AddPoint(Int_t trackID, Int_t detID, TString detname,
    		TVector3 posIn, TVector3 posOut,
    		TVector3 momIn, TVector3 momOut,
    		Double_t time, Double_t length, Double_t eLoss)const;

    /** Resets the private members for the track parameters */
    void ResetParameters();

    ClassDef(PndLmd,3)
};

#endif /* LMDDECTECTOR_H_ */
