Index: trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h
===================================================================
--- trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 251)
+++ trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 264)
@@ -13,6 +13,6 @@
  *  present in the data members of the Block TRoot class.
  *
- *  $Date: 2009-02-02 11:32:12 $
- *  $Revision: 1.11 $
+ *  $Date: 2009-02-11 09:19:14 $
+ *  $Revision: 1.12 $
  *
  *  
@@ -24,4 +24,6 @@
 #include "TObject.h"
 #include "BlockCompare.h"
+#include "interface/D_Constants.h"
+#include "interface/CaloUtil.h"
 
 class TSortableObject: public TObject
@@ -147,12 +149,25 @@
   float Pz; // particle momentum vector (z component) in GeV
 
-  float PT; // particle transverse momentum in GeV
   float Eta; // particle pseudorapidity  
   float Phi; // particle azimuthal angle in rad 
 
+  float EtaCalo; // particle pseudorapidity when entering the calo, 
+  float PhiCalo; // particle azimuthal angle in rad when entering the calo
+
   void Set(const TLorentzVector& momentum);
   void Set(const float px, const float py, const float pz, const float e);
-  static TCompare *fgCompare; //!
-  const TCompare *GetCompare() const { return fgCompare; }
+  void SetEtaPhi(const float eta, const float phi) {Eta=eta; Phi=phi;};
+  void SetEtaPhiCalo(const float eta, const float phi) {EtaCalo=eta; PhiCalo=phi;};
+  void SetEtaPhiEET(const float eta, const float phi, const float e, const float et);
+  static TCompare *fgCompare; //!
+  const TCompare *GetCompare() const { return fgCompare; }
+  //void SetEem_Ehad(const float sE_em, const float sE_had) {} ; // sets E_em and E_had, computes E and ET
+  float PT; // particle transverse momentum in GeV
+  //const float getEtaGen() const {return _EtaGen;}
+  //const float getPhiGen() const {return _PhiGen;}
+
+
+//protected:
+  //float EGen, _EtaGen, _PhiGen; // from the generator: energy, eta, phi
 
   ClassDef(TRootParticle, 1)
@@ -165,5 +180,5 @@
 
 public:
-  TRootGenParticle() {};
+  TRootGenParticle() {_initialised=false;}
   int PID; // particle HEP ID number [RawHepEventParticle::pid()]
   int Status; // particle status [RawHepEventParticle::status()]
@@ -172,5 +187,4 @@
   int D1; // particle 1st daughter [RawHepEventParticle::daughter1() - 1]
   int D2; // particle 2nd daughter [RawHepEventParticle::daughter2() - 1]
-  float Charge; // electrical charge
 
   float T; // particle vertex position (t component) [RawHepEventParticle::t()]
@@ -179,8 +193,18 @@
   float Z; // particle vertex position (z component) [RawHepEventParticle::z()]
   float M;
-  static TCompare *fgCompare; //!
-
+  void setFractions();
+  const float getCharge() const {return Charge;};
+  const float getFem()  {if(!_initialised) setFractions(); return _Fem;}
+  const float getFhad() {if(!_initialised) setFractions(); return _Fhad;}
+
+  float Charge;      // electrical charge
+
+  static TCompare *fgCompare; //!
+ protected:
+  float _Fem, _Fhad; // fractions of energy deposit
+  bool _initialised;
   ClassDef(TRootGenParticle, 1)
 };
+
 
 //------------------------------------------------------------------------------
@@ -225,13 +249,51 @@
 //---------------------------------------------------------------------------
 
-class TRootTracks: public TRootParticle
-{
-public:
-  TRootTracks() : Etaout(0), Phiout(0) {};
-  static TCompare *fgCompare; //!
- 
+class D_Track : public TSortableObject {
+//class D_Track : public TRootParticle {
+ public:
+    D_Track(); // needed for storage in ExRootAnalysis
+    D_Track(const D_Track& track);
+    D_Track(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt);
+    D_Track& operator=(const D_Track& track);
+    void Set(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt);
+    const TLorentzVector GetFourVector() const;
+    const float getEta() const {return Eta;}
+    const float getPhi() const {return Phi;}
+    const float getEtaOuter() const {return EtaOuter;}
+    const float getPhiOuter() const {return PhiOuter;}
+    const float getE() const {return E;}
+    const float getPx() const {return Px;}
+    const float getPy() const {return Py;}
+    const float getPz() const {return Pz;}
+    const float getPT() const {return PT;}
+
+  static TCompare *fgCompare; //!
+  const TCompare *GetCompare() const { return fgCompare; }
+ protected:
+    float Eta, Phi; // (eta,phi) at the beginning of the track
+    float EtaOuter, PhiOuter; // (eta,phi) at the end of the track
+    float PT, E, Px, Py, Pz;  // transverse momentum
+ ClassDef(D_Track, 1)
+};
+
+
+class TRootTracks: public TRootParticle  {
+public:
+  TRootTracks() {} // : Etaout(0), Phiout(0) {};
+  static TCompare *fgCompare; //!
+  TRootTracks(const D_Track& track);
+  float E;  // particle energy in GeV
+  float Px; // particle momentum vector (x component) in GeV
+  float Py; // particle momentum vector (y component) in GeV
+  float Pz; // particle momentum vector (z component) in GeV
+
+  float Eta; // particle pseudorapidity
+  float Phi; // particle azimuthal angle in rad
+
+  float EtaCalo; // particle pseudorapidity when entering the calo,
+  float PhiCalo; // particle azimuthal angle in rad when entering the calo 
 //  float X, Y, Z; // coordinates of the beginning of the track
 //  float Xout, Yout, Zout; // coordinates of the end of the track
-  float Etaout, Phiout; // coordinates of the end of the track
+  //float Etaout, Phiout; // coordinates of the end of the track
 //  void SetPosition(const float x, const float y, const float z) {X=x; Y=y; Z=z;}
 //  void SetPositionOut(const float x, const float y, const float z) {Xout=x; Yout=y; Zout=z;}
@@ -241,6 +303,5 @@
 //---------------------------------------------------------------------------
 
-class TRootCalo: public TRootParticle
-{
+/*class TRootCalo: public TRootParticle
 public:
   TRootCalo() {};
@@ -248,4 +309,24 @@
 
   ClassDef(TRootCalo, 1)
+};
+*/
+
+//class TRootCalo: public TSortableObject {
+class TRootCalo: public TRootParticle {
+ public:
+   TRootCalo() ;
+   TRootCalo(const TRootCalo& cal);
+   TRootCalo& operator=(const TRootCalo& cal);
+   void set(const D_CaloTower&  cal);
+   static TCompare *fgCompare; //!
+ //  const TCompare *GetCompare() const { return fgCompare; }
+   const float getET() const {return ET;}
+ 
+ protected:
+    //float Eta, Phi;    // segmented eta, phi
+    float E_em, E_had; // electromagnetic and hadronic components of the tower energy
+    //float E;
+    float ET;       // total energy and transverse energy   
+   ClassDef(TRootCalo, 1)
 };
 
@@ -340,6 +421,4 @@
 };
 
-//---------------------------------------------------------------------------
-
 #endif // BLOCKCLASSES_H
 
Index: trunk/Utilities/ExRootAnalysis/src/BlockClasses.cc
===================================================================
--- trunk/Utilities/ExRootAnalysis/src/BlockClasses.cc	(revision 251)
+++ trunk/Utilities/ExRootAnalysis/src/BlockClasses.cc	(revision 264)
@@ -11,6 +11,6 @@
  *  to preserve mother-dautherlinks between particles.
  *
- *  $Date: 2009-02-02 11:32:01 $
- *  $Revision: 1.7 $
+ *  $Date: 2009-02-11 09:19:14 $
+ *  $Revision: 1.8 $
  *
  *  
@@ -22,4 +22,5 @@
 #include "BlockCompare.h"
 #include "TLorentzVector.h"
+#include <cmath>
 
 TCompare *TRootGenParticle::fgCompare = 0;
@@ -38,4 +39,6 @@
 TCompare *TRootRomanPotHits::fgCompare =0;
 TCompare *TRootTrigger::fgCompare =0;
+//TCompare *D_CaloTower::fgCompare=0;
+TCompare *D_Track::fgCompare=0;
 
 void TRootParticle::Set(const TLorentzVector& momentum) {
@@ -61,3 +64,98 @@
 }
 
+void TRootParticle::SetEtaPhiEET(const float eta, const float phi, const float e, const float et) {
+   Eta = eta; Phi = phi; E = e; PT = et;
+   //float theta = 2* atan(exp(-Eta);
+   Px = PT*cos(Phi);
+   Py = PT*sin(Phi);
+}
 
+
+void TRootGenParticle::setFractions() {
+  switch(abs(PID)) {
+    default:  _Fem = 0; _Fhad=1; break;
+    case(pE):
+    case(pGAMMA):
+    case(pPI0):
+        _Fem = 1; _Fhad=0; break;
+    case(pNU1):
+    case(pNU2):
+    case(pNU3):
+    case(pMU):
+        _Fem =0; _Fhad=0; break;
+    case(pK0S):
+    case(pLAMBDA):
+	_Fem=0.3; _Fhad=0.7; break;
+  }
+  _initialised=true;
+}
+
+    float Eta, Phi; // (eta,phi) at the beginning of the track
+    float EtaOuter, PhiOuter; // (eta,phi) at the end of the track
+    float PT, E, Px, Py, Pz; 
+
+D_Track::D_Track() :
+	Eta(UNDEFINED), Phi(UNDEFINED), EtaOuter(UNDEFINED), PhiOuter(UNDEFINED), 
+        PT(UNDEFINED), E(UNDEFINED), Px(UNDEFINED), Py(UNDEFINED), Pz(UNDEFINED) {}
+
+D_Track::D_Track(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt) :
+	Eta(inEta), Phi(inPhi), EtaOuter(outEta), PhiOuter(outPhi), 
+        PT(pt) {
+	TLorentzVector p; p.SetPtEtaPhiE(PT,Eta,Phi,PT*cosh(Eta));
+        Px = p.Px(); Py = p.Py(); Pz = p.Pz();  E=p.E();
+}
+
+D_Track::D_Track(const D_Track& track) :
+	Eta(track.Eta), Phi(track.Phi), 
+        EtaOuter(track.EtaOuter), PhiOuter(track.PhiOuter), 
+	PT(track.PT), E(track.E), Px(track.Px), Py(track.Py), Pz(track.Pz) {}
+
+D_Track& D_Track::operator=(const D_Track& track) {
+  if(this == &track) return *this;
+	Eta = track.Eta;             Phi = track.Phi; 
+        EtaOuter = track.EtaOuter;   PhiOuter = track.PhiOuter; 
+        PT = track.PT; E = track.E;  Px = track.Px;  Py= track.Py; Pz =track.Pz; 
+  return *this;
+}
+
+void D_Track::Set(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt) {
+	Eta= inEta; Phi=inPhi;  EtaOuter=outEta; PhiOuter=outPhi; PT=pt; 
+	TLorentzVector p; p.SetPtEtaPhiE(PT,Eta,Phi,PT*cosh(Eta));
+	Px = p.Px(); Py = p.Py(); Pz = p.Pz();  E=p.E();
+}
+
+const TLorentzVector D_Track::GetFourVector() const {
+	TLorentzVector v;
+	v.SetPtEtaPhiE(PT,Eta,Phi,PT*cosh(Eta));
+	return TLorentzVector(v);
+}
+
+TRootCalo::TRootCalo() :
+	E_em(UNDEFINED), E_had(UNDEFINED), ET(UNDEFINED) {}
+	//Eta(UNDEFINED), Phi(UNDEFINED), E_em(UNDEFINED), E_had(UNDEFINED), E(UNDEFINED), ET(UNDEFINED) {}
+
+TRootCalo::TRootCalo(const TRootCalo& cal) {
+        E_em=cal.E_em; E_had=cal.E_had;  ET=cal.ET;
+        //Eta =cal.Eta;  Phi=cal.Phi; E_em=cal.E_em; E_had=cal.E_had;  E=cal.E;   ET=cal.ET;
+}
+
+TRootCalo& TRootCalo::operator=(const TRootCalo& cal) {
+   if(this==&cal) return *this;
+        Eta =cal.Eta;  Phi=cal.Phi; E_em=cal.E_em; E_had=cal.E_had;  E=cal.E;   ET=cal.ET;
+   return *this;
+}
+
+void TRootCalo::set(const D_CaloTower& cal) {
+	Eta =cal.getEta(); Phi=cal.getPhi(); 
+        E_em=cal.getEem(); E_had=cal.getEhad();
+        E   =cal.getE();   ET   =cal.getET();
+	EtaCalo = cal.getEta();
+	PhiCalo = cal.getPhi();
+}
+
+
+TRootTracks::TRootTracks(const D_Track& track) :
+   E(track.getE()), Px(track.getPx()), Py(track.getPy()), Pz(track.getPz()),
+   Eta(track.getEta()), Phi(track.getPhi()),
+   /*Etaout(track.getEtaOuter()),*/ EtaCalo(track.getEtaOuter()), /*Phiout(track.getPhiOuter()),*/ PhiCalo(track.getPhiOuter()) {}
+
Index: trunk/Utilities/ExRootAnalysis/src/BlockClassesLinkDef.h
===================================================================
--- trunk/Utilities/ExRootAnalysis/src/BlockClassesLinkDef.h	(revision 251)
+++ trunk/Utilities/ExRootAnalysis/src/BlockClassesLinkDef.h	(revision 264)
@@ -4,6 +4,6 @@
  *  Lists classes to be included in cint dicitonary
  *
- *  $Date: 2008-12-02 11:14:45 $
- *  $Revision: 1.2 $
+ *  $Date: 2009-02-11 09:19:14 $
+ *  $Revision: 1.3 $
  *
  *  
@@ -13,4 +13,5 @@
 
 #include "Utilities/ExRootAnalysis/interface/BlockClasses.h"
+#include "interface/D_Constants.h"
 
 #ifdef __CINT__
@@ -39,4 +40,6 @@
 #pragma link C++ class TRootLHEFEvent+;
 #pragma link C++ class TRootLHEFParticle+;
+#pragma link C++ class D_Track+;
+//#pragma link C++ class D_CaloTower+;
 
 
