[ROOT] STL map pair problem.

From: Dongwook Jang (dwjang@fnal.gov)
Date: Mon Nov 17 2003 - 02:17:17 MET


Hi,

I've attached files.
The problem is to stream out the type of map<pair<int, int>,SomeObject>.
I did the following in root session :

.L RtgObject.cc+
TestRtgObject();

then got segmentaion fault.
The files I attached contains class definition and making a simple tree 
and read that tree.

Could you look into this?
I'm using root 3.10.01 with gcc 3.2.2 on redhat linux 9.0.

Thank you.
Dongwook Jang.


//--------------------------------------------------------------------------
// File and Version Information:
//      $Id: RtgObject.hh,v 1.2 2003/10/29 22:19:44 dwjang Exp $
//
// Description:
//      Class RtgObject for Ntuplizer
//------------------------------------------------------------------------

#ifndef RTGOBJECT_HH
#define RTGOBJECT_HH

#include <TObject.h>
#include <TVector3.h>
#include <TLorentzVector.h>
#include <TString.h>

#include <iostream>
#include <vector>
#include <map>
using namespace std;

#define NMET 3

class RtgEvent;
class RtgMet;
class RtgTrack;
class RtgTower;
class RtgPhoton;
class RtgElectron;
class RtgMuon;
class RtgTau;
class RtgPi0;
class RtgCesMatch;
class RtgJet;
class RtgBoson;

typedef pair<int, int> RtgTowerKey;

class RtgEvent : public TObject {

public:

  int runNumber;
  int eventNumber;
  int mcFlag;

  int primaryVertexFound;
  TVector3 beamSpot;
  TVector3 primaryVertex;
  TVector3 primaryVertexError;

  // L3 bits
  int l3_JET_20_v;
  int l3_JET_50_v;
  int l3_JET_70_v;
  int l3_JET_100_v;
  int l3_DITAU_v;
  int l3_TAU_CMUP8_TRACK5_ISO_v;
  int l3_TAU_CMX8_TRACK5_ISO_v;
  int l3_TAU_ELECTRON8_TRACK5_ISO_v;
  int l3_TAU_MET_v;
  int l3_ELECTRON_CENTRAL_8_NO_L2_v;
  int l3_ELECTRON_CENTRAL_8_v;
  int l3_ELECTRON_CENTRAL_PS1K_L1_CEM8_PT8_v;
  int l3_MUON_CMUP8_v;
  int l3_MET_L3PS100_L1_MET25_v;
  int l3_TEST_DITAU_v;
  int l3_PHOTON_15_TIGHT_v;
  int l3_PHOTON_25_ISO_TRACK_5_ISO_v;
  int l3_PHOTON_25_ISO_v;
  int l3_PHOTON_B_JET_v;
  int l3_SUPER_PHOTON70_L2_EM_v;
  int l3_SUPER_PHOTON70_L2_JET_v;
  int l3_ULTRA_PHOTON50_v;

  int l3Word;

  int cosmicWord;

  // Met index 0 : trigger raw MET
  // Met index 1 : offline raw MET
  // Met index 2 : offline vertex corrected MET

  RtgMet* rtgMet[NMET];
  map<int, RtgTrack> trackList;
  map<RtgTowerKey, RtgTower> towerList;
  map<int, RtgPhoton> photonList;
  map<int, RtgElectron> electronList;
  map<int, RtgMuon> muonList;
  map<int, RtgTau> tauList;
  map<int, RtgCesMatch> cesMatchList;
  map<int, RtgPi0> pi0List;
  map<int, RtgJet> jetList; // cone0.7
  map<int, RtgJet> jet4List; // cone0.4

  RtgBoson* rtgBoson;

  RtgEvent();
  ~RtgEvent();

  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(Option_t *option="") const;
  ClassDef(RtgEvent,1);
};


class RtgMet : public TObject {

public:
  float exSum;
  float eySum;
  float etSum;
  float eSum;

  RtgMet();
  ~RtgMet();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgMet,1);
};

  //---------------
  // tracks
  //---------------

class RtgTrack : public TObject {

public:
  int nSegAx;
  int nSegSt;
  int usedSI;
  TVector3 momentum;
  float curvature;
  float lambda;
  float z0;
  float phi0;
  float d0;
  float d0Sig;
  // extrapolated to calorimeter
  int iEta;
  int iPhi;
  float iEtaRel;
  float iPhiRel;
  float cesStripE;
  float cesStripChi2;
  float cesStripDelZ;
  float cesWireE;
  float cesWireChi2;
  float cesWireDelX;

  RtgTrack();
  ~RtgTrack();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgTrack,1);
};


class RtgTower : public TObject {

public:
  RtgTowerKey key; // (iEta, iPhi)
  float eta; // totEta
  float phi; // totPhi
  float emE;
  float emEta;
  float emPhi;
  float hadE;
  float hadEta;
  float hadPhi;

  RtgTower();
  ~RtgTower();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgTower,1);
};


class RtgPhoton : public TObject {

public:

  int trackIndex;
  int n3D;
  float etCorr;
  float eCorr;
  float hadEm;
  float cesChi2Mean;
  float trackPt;
  float isoEtCorr;
  float trackIso;
  float cesX;
  float cesZ;
  float cesE2;
  float cesEt2;
  float detEta;
  float detPhi;
  TLorentzVector momentum;
  vector<RtgTowerKey> towerList;

  RtgPhoton();
  ~RtgPhoton();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgPhoton,1);
};


class RtgElectron : public TObject {

public:

  int trackIndex;
  int fiducial;
  float et;
  float pt;
  float lshr;
  float eOverP;
  float hadEm;
  float calIsoEt;
  float qDeltaX;
  float deltaZ;
  float cesStripChi2;
  float cesWireChi2;
  float detEta;
  float detPhi;
  float d0Corrected;
  TLorentzVector momentum;
  vector<RtgTowerKey> towerList;

  RtgElectron();
  ~RtgElectron();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgElectron,1);
};


class RtgMuon : public TObject {

public:

  int type;
  int hasNoStubs;
  int bestTrackIndex;
  int secondBestTrackIndex;
  float emEnergy;
  float hadEnergy;
  float emEt;
  float hadEt;
  float coneR4EmEt;
  float coneR4HadEt;
  float cmuDx;
  float cmpDx;
  float cmxDx;
  float bmuDx;
  float d0Corrected;
  TLorentzVector momentum;
  vector<RtgTowerKey> towerList;

  RtgMuon();
  ~RtgMuon();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgMuon,1);
};


class RtgTau : public TObject {

public:
  int seedTrackIndex;
  int nTowers;
  int towerMatchedJetIndex;
  int towerMatchedJet4Index;
  float referenceVertexZ;
  float clusterDetEta;
  float emfraction;
  float clusterEt;
  float isoCalEt; // wrt tau vertex
  float isoEmEt; // wrt tau vertex
  float isoCalEtDefault;
  float isoEmEtDefault;
  float isoMaxTowerEt;
  int isoNTowers;
  float d0Corrected;
  int nMuonStubs;
  int nMuonHits;

  // Tau signal cone quantities
  int nTracks;
  int nPi0s;
  int charge;
  int triggerIsoFlag; // == 1 for satisfing trigger isolation (no tracks pt > 1.5GeV in 0.175 < dR < 0.524)
  float seedTrackZCes;
 
  // Tau isolation quantities
  int isoNTracks;
  int isoNTracks1030;
  int isoNPi0s;
  float isoPi0sEt;
  float isoScalarSumPt;
  float isoAlphaMinTrack;
  float isoAlphaMinPi0;
  float isoAlphaMinTrack2;
  float isoAlphaMinPi02;

  TLorentzVector clusterMomentum;
  vector<RtgTowerKey> towerList;

  RtgTau();
  ~RtgTau();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgTau,1);
};


class RtgPi0 : public TObject {

public:

  float phi;
  float eta;
  float e;

  RtgPi0();
  ~RtgPi0();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgPi0,1);
};


class RtgCesMatch : public TObject {

public:

  int type;
  int iEta;
  int iPhi;
  int iEtaRel;
  int iPhiRel;
  float e;
  float phi;
  float z;
  float xLocal;
  float zLocal;
  int side;
  int wedge;
  int halfWedge;
  int pi0Index;
  
  RtgCesMatch();
  ~RtgCesMatch();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgCesMatch,1);
};

class RtgJet : public TObject {

public:

  float vertexZ;
  int nTowers;
  int nTracks;
  float etaDetector;
  float emFraction;
  float chargeFraction;
  float et;
  float etaEta;
  float etaPhi;
  float phiPhi;
  float width;
  int triggered20[3]; // 0:L1, 1:L2, 2:L3
  int triggered50[3];
  int triggered70[3];
  int triggered100[3];
  TLorentzVector momentum;
  vector<RtgTowerKey> towerList;

  RtgJet();
  ~RtgJet();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgJet,1);
};


class RtgBoson : public TObject {

public:
  TLorentzVector boson;
  TLorentzVector tau[2];
  TLorentzVector radiation;
 
  TVector3 tauVertex[2];
  TLorentzVector tauNu[2];
  TLorentzVector tauVisibles[2];
  TLorentzVector tauTracks[2];
  TLorentzVector tauSeedTrack[2];
  TLorentzVector tauPi0s[2];
  int bosonID;
  int tauSeedTrackID[2];
  int tauCharge[2];
  int tauNVisibles[2];
  int tauNTracks[2];
  int tauSeedTrackCharge[2];
  int tauNPi0s[2];
  float tauMaxAlphaNu[2];
  float tauMaxAlphaTrack[2];
  float tauMaxAlphaPi0[2];
  float tauMaxAlphaVisibles[2];
  float tauSeedTrackZ0[2];

  RtgBoson();
  ~RtgBoson();
  void Init();
  virtual void Clear(const Option_t *option="");
  virtual void Print(const Option_t *option="") const;
  ClassDef(RtgBoson,1);
};

#endif


//--------------------------------------------------------------------------
// File and Version Information:
//      $Id: RtgObject.cc,v 1.2 2003/10/29 22:19:44 dwjang Exp $
//
// Description:
//      Class RtgObject for Ntuplizer
//------------------------------------------------------------------------

#include "RtgObject.hh"
#include <string>
#include <TRandom.h>
#include <TFile.h>
#include <TTree.h>

ClassImp(RtgEvent)
ClassImp(RtgMet)
ClassImp(RtgTrack)
ClassImp(RtgTower)
ClassImp(RtgPhoton)
ClassImp(RtgElectron)
ClassImp(RtgMuon)
ClassImp(RtgTau)
ClassImp(RtgCesMatch)
ClassImp(RtgPi0)
ClassImp(RtgJet)

void PrintVector(const TLorentzVector &p);
void PrintVector(const TVector3 &p);
void TestRtgObject();
void makeRtgTree();
void readRtgTree();

RtgEvent::RtgEvent() {
  Init();
}

RtgEvent::~RtgEvent(){}

void RtgEvent::Init(){
  runNumber = -1;
  eventNumber = -1;
  mcFlag = -1;

  primaryVertexFound = 0;
  beamSpot.SetXYZ(0,0,0);
  primaryVertex.SetXYZ(0,0,0);
  primaryVertexError.SetXYZ(0,0,0);

  // L3 bits
  l3_JET_20_v = 0;
  l3_JET_50_v = 0;
  l3_JET_70_v = 0;
  l3_JET_100_v = 0;
  l3_DITAU_v = 0;
  l3_TAU_CMUP8_TRACK5_ISO_v = 0;
  l3_TAU_CMX8_TRACK5_ISO_v = 0;
  l3_TAU_ELECTRON8_TRACK5_ISO_v = 0;
  l3_TAU_MET_v = 0;
  l3_ELECTRON_CENTRAL_8_NO_L2_v = 0;
  l3_ELECTRON_CENTRAL_8_v = 0;
  l3_ELECTRON_CENTRAL_PS1K_L1_CEM8_PT8_v = 0;
  l3_MUON_CMUP8_v = 0;
  l3_MET_L3PS100_L1_MET25_v = 0;
  l3_TEST_DITAU_v = 0;
  l3_PHOTON_15_TIGHT_v = 0;
  l3_PHOTON_25_ISO_TRACK_5_ISO_v = 0;
  l3_PHOTON_25_ISO_v = 0;
  l3_PHOTON_B_JET_v = 0;
  l3_SUPER_PHOTON70_L2_EM_v = 0;
  l3_SUPER_PHOTON70_L2_JET_v = 0;
  l3_ULTRA_PHOTON50_v = 0;

  l3Word = 0;

  cosmicWord = 0;

  for(int i=0; i<NMET; i++){
    rtgMet[i] = new RtgMet();
  }

  rtgBoson = 0; // Null pointer for now
}

void RtgEvent::Clear(const Option_t *option){
  trackList.clear();
  towerList.clear();
  photonList.clear();
  electronList.clear();
  muonList.clear();
  tauList.clear();
  pi0List.clear();
  cesMatchList.clear();
  jetList.clear();
  if(rtgBoson) rtgBoson->Clear();
}


void RtgEvent::Print(const Option_t *option) const {

  cout << "runNumber : " << runNumber << endl;
  cout << "eventNumber : " << eventNumber << endl;
  cout << "mcFlag : " << mcFlag << endl;

  cout << "beamSpot = "; PrintVector(beamSpot);
  cout << "primaryVertexFound : " << primaryVertexFound << endl;
  cout << "primaryVertex = "; PrintVector(primaryVertex);
  cout << "primaryVertexError = "; PrintVector(primaryVertexError);
 
  cout << "l3_JET_20_v : " << l3_JET_20_v << endl;
  cout << "l3_JET_50_v : " << l3_JET_50_v << endl;
  cout << "l3_JET_70_v : " << l3_JET_70_v << endl;
  cout << "l3_JET_100_v : " << l3_JET_100_v << endl;
  cout << "l3_DITAU_v : " << l3_DITAU_v << endl;
  cout << "l3_TAU_CMUP8_TRACK5_ISO_v : " << l3_TAU_CMUP8_TRACK5_ISO_v << endl;
  cout << "l3_TAU_CMX8_TRACK5_ISO_v : " << l3_TAU_CMX8_TRACK5_ISO_v << endl;
  cout << "l3_TAU_ELECTRON8_TRACK5_ISO_v : " << l3_TAU_ELECTRON8_TRACK5_ISO_v << endl;
  cout << "l3_TAU_MET_v : " << l3_TAU_MET_v << endl;
  cout << "l3_ELECTRON_CENTRAL_8_NO_L2_v : " << l3_ELECTRON_CENTRAL_8_NO_L2_v << endl;
  cout << "l3_ELECTRON_CENTRAL_8_v : " << l3_ELECTRON_CENTRAL_8_v << endl;
  cout << "l3_ELECTRON_CENTRAL_PS1K_L1_CEM8_PT8_v : " << l3_ELECTRON_CENTRAL_PS1K_L1_CEM8_PT8_v << endl;
  cout << "l3_MUON_CMUP8_v : " << l3_MUON_CMUP8_v << endl;
  cout << "l3_MET_L3PS100_L1_MET25_v : " << l3_MET_L3PS100_L1_MET25_v << endl;
  cout << "l3_TEST_DITAU_v : " << l3_TEST_DITAU_v << endl;
 
  cout << "l3_PHOTON_15_TIGHT_v : " << l3_PHOTON_15_TIGHT_v << endl;
  cout << "l3_PHOTON_25_ISO_TRACK_5_ISO_v : " << l3_PHOTON_25_ISO_TRACK_5_ISO_v << endl;
  cout << "l3_PHOTON_25_ISO_v : " << l3_PHOTON_25_ISO_v << endl;
  cout << "l3_PHOTON_B_JET_v : " << l3_PHOTON_B_JET_v << endl;
  cout << "l3_SUPER_PHOTON70_L2_EM_v : " << l3_SUPER_PHOTON70_L2_EM_v << endl;
  cout << "l3_SUPER_PHOTON70_L2_JET_v : " << l3_SUPER_PHOTON70_L2_JET_v << endl;
  cout << "l3_ULTRA_PHOTON50_v : " << l3_ULTRA_PHOTON50_v << endl;
 
  cout << "l3Word : " << l3Word << endl;
  cout << "cosmicWord : " << cosmicWord << endl;

  for(int i=0; i<NMET; i++){
    cout << "rtgMet["<<i<<"] -------------" << endl;
    rtgMet[i]->Print();
  }

  cout << "trackList.size() : " << trackList.size() << endl;
  cout << "towerList.size() : " << towerList.size() << endl;
  cout << "photonList.size() : " << photonList.size() << endl;
  cout << "electronList.size() : " << electronList.size() << endl;
  cout << "muonList.size() : " << muonList.size() << endl;
  cout << "tauList.size() : " << tauList.size() << endl;
  cout << "cesMatchList.size() : " << cesMatchList.size() << endl;
  cout << "pi0List.size() : " << pi0List.size() << endl;
  cout << "jetList.size() : " << jetList.size() << endl;

  for(map<int, RtgTrack>::const_iterator iter = trackList.begin();
      iter != trackList.end(); iter++){
    cout << "trackList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<RtgTowerKey, RtgTower>::const_iterator iter = towerList.begin();
      iter != towerList.end(); iter++){
    cout << "towerList key(index of map) : (" << iter->first.first << "," << iter->first.second << ")" << endl;
    iter->second.Print();
  }

  for(map<int, RtgPhoton>::const_iterator iter = photonList.begin();
      iter != photonList.end(); iter++){
    cout << "photonList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<int, RtgElectron>::const_iterator iter = electronList.begin();
      iter != electronList.end(); iter++){
    cout << "electronList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<int, RtgMuon>::const_iterator iter = muonList.begin();
      iter != muonList.end(); iter++){
    cout << "muonList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<int, RtgTau>::const_iterator iter = tauList.begin();
      iter != tauList.end(); iter++){
    cout << "tauList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<int, RtgCesMatch>::const_iterator iter = cesMatchList.begin();
      iter != cesMatchList.end(); iter++){
    cout << "cesMatchList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<int, RtgPi0>::const_iterator iter = pi0List.begin();
      iter != pi0List.end(); iter++){
    cout << "pi0List key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  for(map<int, RtgJet>::const_iterator iter = jetList.begin();
      iter != jetList.end(); iter++){
    cout << "jetList key(index of map) : " << iter->first << endl;
    iter->second.Print();
  }

  if(rtgBoson) rtgBoson->Print();

}


RtgMet::RtgMet(){
  Init();
}

RtgMet::~RtgMet(){}

void RtgMet::Init(){
  exSum = 0;
  eySum = 0;
  etSum = 0;
  eSum = 0;
}

void RtgMet::Clear(const Option_t *option){}

void RtgMet::Print(const Option_t *option) const{
  cout << "exSum : " << exSum << endl;
  cout << "eySum : " << eySum << endl;
  cout << "etSum : " << etSum << endl;
  cout << "eSum  : " << eSum << endl;
}

RtgTrack::RtgTrack(){
  Init();
}

RtgTrack::~RtgTrack(){}

void RtgTrack::Init(){
  nSegAx = 0;
  nSegSt = 0;
  usedSI = 0;
  momentum.SetXYZ(0,0,0);
  curvature = 0;
  lambda = 0;
  z0 = 0;
  phi0 = 0;
  d0 = 0;
  d0Sig = 0;
  // extrapolated to calorimeter
  iEta = 0;
  iPhi = 0;
  iEtaRel = 0;
  iPhiRel = 0;
  cesStripE = 0;
  cesStripChi2 = 0;
  cesStripDelZ = 0;
  cesWireE = 0;
  cesWireChi2 = 0;
  cesWireDelX = 0;
}


void RtgTrack::Clear(const Option_t *option){}

void RtgTrack::Print(const Option_t *option) const{
  cout << "nSegAx : " << nSegAx << endl;
  cout << "nSegSt : " << nSegSt << endl;
  cout << "usedSI : " << usedSI << endl;
  cout << "momentum = "; PrintVector(momentum);
  cout << "curvature : " << curvature << endl;
  cout << "lambda : " << lambda << endl;
  cout << "z0 : " << z0 << endl;
  cout << "phi0 : " << phi0 << endl;
  cout << "d0 : " << d0 << endl;
  cout << "d0Sig : " << d0Sig << endl;
  cout << "iEta : " << iEta << endl;
  cout << "iPhi : " << iPhi << endl;
  cout << "iEtaRel : " << iEtaRel << endl;
  cout << "iPhiRel : " << iPhiRel << endl;
  cout << "cesStripE : " << cesStripE << endl;
  cout << "cesStripChi2 : " << cesStripChi2 << endl;
  cout << "cesStripDelZ : " << cesStripDelZ << endl;
  cout << "cesWireE : " << cesWireE << endl;
  cout << "cesWireChi2 : " << cesWireChi2 << endl;
  cout << "cesWireDelX : " << cesWireDelX << endl;
}


RtgTower::RtgTower(){
  Init();
}

RtgTower::~RtgTower(){}

void RtgTower::Init(){
  key = make_pair(-1,-1);
  eta = 0;
  phi = 0;
  emE = 0;
  hadE = 0;
}

void RtgTower::Clear(const Option_t *option){}

void RtgTower::Print(const Option_t *option) const{
  cout << "key : (" << key.first << "," << key.second << ")" << endl;
  cout << "eta : " << eta << endl;
  cout << "phi : " << phi << endl;
  cout << "emE : " << emE << endl;
  cout << "hadE : " << hadE << endl;
}


RtgPhoton::RtgPhoton(){
  Init();
}

RtgPhoton::~RtgPhoton(){}

void RtgPhoton::Init(){
  trackIndex = -1;
  n3D = 0;
  etCorr = 0;
  eCorr = 0;
  hadEm = 0;
  cesChi2Mean = 0;
  trackPt = 0;
  isoEtCorr = 0;
  trackIso = 0;
  cesX = 0;
  cesZ = 0;
  cesE2 = 0;
  cesEt2 = 0;
  detEta = 0;
  detPhi = 0;
  momentum.SetXYZT(0,0,0,0);
  towerList.clear();
}

void RtgPhoton::Clear(const Option_t *option){
  towerList.clear();
}

void RtgPhoton::Print(const Option_t *option) const{
  cout << "trackIndex : " << trackIndex << endl;
  cout << "n3D : " << n3D << endl;
  cout << "etCorr : " << etCorr << endl;
  cout << "eCorr : " << eCorr << endl;
  cout << "hadEm : " << hadEm << endl;
  cout << "cesChi2Mean : " << cesChi2Mean << endl;
  cout << "trackPt : " << trackPt << endl;
  cout << "isoEtCorr : " << isoEtCorr << endl;
  cout << "trackIso : " << trackIso << endl;
  cout << "cesX : " << cesX << endl;
  cout << "cesZ : " << cesZ << endl;
  cout << "cesE2 : " << cesE2 << endl;
  cout << "cesEt2 : " << cesEt2 << endl;
  cout << "detEta : " << detEta << endl;
  cout << "detPhi : " << detPhi << endl;
  cout << "momentum = "; PrintVector(momentum);
  cout << "towerList :";
  for(int i=0; i<towerList.size(); i++)
    cout << " (" << towerList[i].first << "," << towerList[i].second << ")";
  cout << endl;
}


RtgElectron::RtgElectron(){
  Init();
}

RtgElectron::~RtgElectron(){}

void RtgElectron::Init(){
  trackIndex = -1;
  fiducial = 0;
  et = 0;
  pt = 0;
  lshr = 0;
  eOverP = 0;
  hadEm = 0;
  calIsoEt = 0;
  qDeltaX = 0;
  deltaZ = 0;
  cesStripChi2 = 0;
  cesWireChi2 = 0;
  detEta = 0;
  detPhi = 0;
  d0Corrected = 0;
  momentum.SetXYZT(0,0,0,0);
  towerList.clear();
}

void RtgElectron::Clear(const Option_t *option){
  towerList.clear();
}

void RtgElectron::Print(const Option_t *option) const{
  cout << "trackIndex : " << trackIndex << endl;
  cout << "fiducial : " << fiducial << endl;
  cout << "et : " << et << endl;
  cout << "pt : " << pt << endl;
  cout << "lshr : " << lshr << endl;
  cout << "eOverP : " << eOverP << endl;
  cout << "hadEm : " << hadEm << endl;
  cout << "calIsoEt : " << calIsoEt << endl;
  cout << "qDeltaX : " << qDeltaX << endl;
  cout << "deltaZ : " << deltaZ << endl;
  cout << "cesStripChi2 : " << cesStripChi2 << endl;
  cout << "cesWireChi2 : " << cesWireChi2 << endl;
  cout << "detEta : " << detEta << endl;
  cout << "detPhi : " << detPhi << endl;
  cout << "d0Corrected : " << d0Corrected << endl;
  cout << "momentum = "; PrintVector(momentum);
  cout << "towerList :";
  for(int i=0; i<towerList.size(); i++)
    cout << " (" << towerList[i].first << "," << towerList[i].second << ")";
  cout << endl;
}


RtgMuon::RtgMuon(){
  Init();
}

RtgMuon::~RtgMuon(){}

void RtgMuon::Init(){
  type = 0;
  hasNoStubs = 0;
  bestTrackIndex = -1;
  secondBestTrackIndex = -1;
  emEnergy = 0;
  hadEnergy = 0;
  emEt = 0;
  hadEt = 0;
  coneR4EmEt = 0;
  coneR4HadEt = 0;
  cmuDx = 0;
  cmpDx = 0;
  cmxDx = 0;
  bmuDx = 0;
  d0Corrected = 0;
  momentum.SetXYZT(0,0,0,0);
  towerList.clear();
}

void RtgMuon::Clear(const Option_t *option){
  towerList.clear();
}

void RtgMuon::Print(const Option_t *option) const{
  cout << "type : " << type << endl;
  cout << "hasNoStubs : " << hasNoStubs << endl;
  cout << "bestTrackIndex : " << bestTrackIndex << endl;
  cout << "secondBestTrackIndex : " << secondBestTrackIndex << endl;
  cout << "emEnergy : " << emEnergy << endl;
  cout << "hadEnergy : " << hadEnergy << endl;
  cout << "emEt : " << emEt << endl;
  cout << "hadEt : " << hadEt << endl;
  cout << "coneR4EmEt : " << coneR4EmEt << endl;
  cout << "coneR4HadEt : " << coneR4HadEt << endl;
  cout << "cmuDx : " << cmuDx << endl;
  cout << "cmpDx : " << cmpDx << endl;
  cout << "cmxDx : " << cmxDx << endl;
  cout << "bmuDx : " << bmuDx << endl;
  cout << "d0Corrected : " << d0Corrected << endl;
  cout << "momentum = "; PrintVector(momentum);
  cout << "towerList :";
  for(int i=0; i<towerList.size(); i++)
    cout << " (" << towerList[i].first << "," << towerList[i].second << ")";
  cout << endl;
}


RtgTau::RtgTau(){
  Init();
}

RtgTau::~RtgTau(){}

void RtgTau::Init(){
  seedTrackIndex = -1;
  nTowers = 0;
  towerMatchedJetIndex = -1;
  towerMatchedJet4Index = -1;
  referenceVertexZ = 0;
  clusterDetEta = 0;
  emfraction = 0;
  clusterEt = 0;
  isoCalEt = 0;
  isoEmEt = 0;
  isoCalEtDefault = 0;
  isoEmEtDefault = 0;
  isoMaxTowerEt = 0;
  isoNTowers = 0;
  d0Corrected = 0;
  nMuonStubs = 0;
  nMuonHits = 0;

  // Tau signal cone quantities
  nTracks = 0;
  nPi0s = 0;
  charge = 0;
  triggerIsoFlag = 0;
  seedTrackZCes = 0;
 
  isoNTracks = 0;
  isoNTracks1030 = 0;
  isoNPi0s = 0;
  isoPi0sEt = 0;
  isoScalarSumPt = 0;
  isoAlphaMinTrack = 0;
  isoAlphaMinPi0 = 0;
  isoAlphaMinTrack2 = 0;
  isoAlphaMinPi02 = 0;

  clusterMomentum.SetXYZT(0,0,0,0);
  towerList.clear();

}

void RtgTau::Clear(const Option_t *option){
  towerList.clear();
}

void RtgTau::Print(const Option_t *option) const{
  cout << "seedTrackIndex : " << seedTrackIndex << endl;
  cout << "nTowers : " << nTowers << endl;
  cout << "towerMatchedJetIndex : " << towerMatchedJetIndex << endl;
  cout << "towerMatchedJet4Index : " << towerMatchedJet4Index << endl;
  cout << "referenceVertexZ : " << referenceVertexZ << endl;
  cout << "clusterDetEta : " << clusterDetEta << endl;
  cout << "emfraction : " << emfraction << endl;
  cout << "clusterEt : " << clusterEt << endl;
  cout << "isoCalEt : " << isoCalEt << endl;
  cout << "isoEmEt : " << isoEmEt << endl;
  cout << "isoCalEtDefault : " << isoCalEtDefault << endl;
  cout << "isoEmEtDefault : " << isoEmEtDefault << endl;
  cout << "isoMaxTowerEt : " << isoMaxTowerEt << endl;
  cout << "isoNTowers : " << isoNTowers << endl;
  cout << "d0Corrected : " << d0Corrected << endl;
  cout << "nMuonStubs : " << nMuonStubs << endl;
  cout << "nMuonHits : " << nMuonHits << endl;

  cout << "nTracks : " << nTracks << endl;
  cout << "nPi0s : " << nPi0s << endl;
  cout << "charge : " << charge << endl;
  cout << "triggerIsoFlag : " << triggerIsoFlag << endl;
  cout << "seedTrackZCes : " << seedTrackZCes << endl;
 
  cout << "isoNTracks : " << isoNTracks << endl;
  cout << "isoNTracks1030 : " << isoNTracks1030 << endl;
  cout << "isoNPi0s : " << isoNPi0s << endl;
  cout << "isoPi0sEt : " << isoPi0sEt << endl;
  cout << "isoScalarSumPt : " << isoScalarSumPt << endl;
  cout << "isoAlphaMinTrack : " << isoAlphaMinTrack << endl;
  cout << "isoAlphaMinPi0 : " << isoAlphaMinPi0 << endl;
  cout << "isoAlphaMinTrack2 : " << isoAlphaMinTrack2 << endl;
  cout << "isoAlphaMinPi02 : " << isoAlphaMinPi02 << endl;

  cout << "clusterMomentum = "; PrintVector(clusterMomentum);
  cout << "towerList :";
  for(int i=0; i<towerList.size(); i++)
    cout << " (" << towerList[i].first << "," << towerList[i].second << ")";
  cout << endl;
}


RtgPi0::RtgPi0(){
  Init();
}

RtgPi0::~RtgPi0(){}

void RtgPi0::Init(){
  phi = 0;
  eta = 0;
  e = 0;
}

void RtgPi0::Clear(const Option_t *option){}

void RtgPi0::Print(const Option_t *option) const{
  cout << "phi : " << phi << endl;
  cout << "eta : " << eta << endl;
  cout << "e : " << e << endl;
}


RtgCesMatch::RtgCesMatch(){
  Init();
}

RtgCesMatch::~RtgCesMatch(){}

void RtgCesMatch::Init(){
  type = 0;
  iEta = -1;
  iPhi = -1;
  iEtaRel = -2;
  iPhiRel = -2;
  e = 0;
  phi = 0;
  z = 0;
  xLocal = 0;
  zLocal = 0;
  side = -1;
  wedge = -1;
  halfWedge = -1;
  pi0Index = -1;
}

void RtgCesMatch::Clear(const Option_t *option){}

void RtgCesMatch::Print(const Option_t *option) const{
  cout << "type : " << type << endl;
  cout << "iEta : " << iEta << endl;
  cout << "iPhi : " << iPhi << endl;
  cout << "iEtaRel : " << iEtaRel << endl;
  cout << "iPhiRel : " << iPhiRel << endl;
  cout << "e : " << e << endl;
  cout << "phi : " << phi << endl;
  cout << "z : " << z << endl;
  cout << "xLocal : " << xLocal << endl;
  cout << "zLocal : " << zLocal << endl;
  cout << "side : " << side << endl;
  cout << "wedge : " << wedge << endl;
  cout << "halfWedge : " << halfWedge << endl;
  cout << "pi0Index : " << pi0Index << endl;
}

RtgJet::RtgJet(){
  Init();
}

RtgJet::~RtgJet(){}

void RtgJet::Init(){
  vertexZ = 0;
  nTowers = 0;
  nTracks = 0;
  etaDetector = 0;
  emFraction = 0;
  chargeFraction = 0;
  et = 0;
  etaEta = 0;
  etaPhi = 0;
  phiPhi = 0;
  width = 0;

  // 0:L1, 1:L2, 2:L3
  for(int i=0; i<3; i++){
    triggered20[i] = 0;
    triggered50[i] = 0;
    triggered70[i] = 0;
    triggered100[i] = 0;
  }
  momentum.SetXYZT(0,0,0,0);
  towerList.clear();
}

void RtgJet::Clear(const Option_t *option){
  towerList.clear();
}

void RtgJet::Print(const Option_t *option) const{
  cout << "vertexZ : " << vertexZ << endl;
  cout << "nTowers : " << nTowers << endl;
  cout << "nTracks : " << nTracks << endl;
  cout << "etaDetector : " << etaDetector << endl;
  cout << "emFraction : " << emFraction << endl;
  cout << "chargeFraction : " << chargeFraction << endl;
  cout << "et : " << et << endl;
  cout << "etaEta : " << etaEta << endl;
  cout << "etaPhi : " << etaPhi << endl;
  cout << "phiPhi : " << phiPhi << endl;
  cout << "width : " << width << endl;

  // 0:L1, 1:L2, 2:L3
  for(int i=0; i<3; i++){
    cout << "triggered20["<<i<<"] : " << triggered20[i] << endl;
    cout << "triggered50["<<i<<"] : " << triggered50[i] << endl;
    cout << "triggered70["<<i<<"] : " << triggered70[i] << endl;
    cout << "triggered100["<<i<<"] : " << triggered100[i] << endl;
  }
  cout << "momentum = "; PrintVector(momentum);
  cout << "towerList :";
  for(int i=0; i<towerList.size(); i++)
    cout << " (" << towerList[i].first << "," << towerList[i].second << ")";
  cout << endl;
}


RtgBoson::RtgBoson(){
  Init();
}

RtgBoson::~RtgBoson(){}

void RtgBoson::Init(){
  bosonID = 0;
  boson.SetXYZT(0,0,0,0);
  for(int i=0;i<2;i++) tau[i].SetXYZT(0,0,0,0);
  radiation.SetXYZT(0,0,0,0);
 
  for(int i=0;i<2;i++){
    tauVertex[i].SetXYZ(0,0,0);
    tauNu[i].SetXYZT(0,0,0,0);
    tauVisibles[i].SetXYZT(0,0,0,0);
    tauTracks[i].SetXYZT(0,0,0,0);
    tauSeedTrack[i].SetXYZT(0,0,0,0);
    tauPi0s[i].SetXYZT(0,0,0,0);
    tauCharge[i] = 0;
    tauNVisibles[i] = 0;
    tauNTracks[i] = 0;
    tauSeedTrackCharge[i] = 0;
    tauNPi0s[i] = 0;
    tauSeedTrackID[i] = 0;
    tauMaxAlphaNu[i] = -999.0;
    tauMaxAlphaTrack[i] = -999.0;
    tauMaxAlphaPi0[i] = -999.0;
    tauMaxAlphaVisibles[i] = -999.0;
    tauSeedTrackZ0[i] = -999.0;
  }
}

void RtgBoson::Clear(const Option_t *option){}

void RtgBoson::Print(const Option_t *option) const{
  cout << "bosonID               : " << bosonID << endl;
  cout << "boson                 : "; PrintVector(boson);
  cout << "radiation             : "; PrintVector(radiation);

  for(int i=0; i<2; i++){
    cout << "tau["<<i<<"]                : "; PrintVector(tau[i]);
    cout << "tauVertex["<<i<<"]          : "; PrintVector(tauVertex[i]);
    cout << "tauNu["<<i<<"]              : "; PrintVector(tauNu[i]);
    cout << "tauVisibles["<<i<<"]        : "; PrintVector(tauVisibles[i]);
    cout << "tauTracks["<<i<<"]          : "; PrintVector(tauTracks[i]);
    cout << "tauSeedTrack["<<i<<"]       : "; PrintVector(tauSeedTrack[i]);
    cout << "tauPi0s["<<i<<"]            : "; PrintVector(tauPi0s[i]);
    cout << "tauCharge["<<i<<"]          : " << tauCharge[i] << endl;
    cout << "tauNVisibles["<<i<<"]       : " << tauNVisibles[i] << endl;
    cout << "tauNTracks["<<i<<"]         : " << tauNTracks[i] << endl;
    cout << "tauSeedTrackCharge["<<i<<"] : " << tauSeedTrackCharge[i] << endl;
    cout << "tauNPi0s["<<i<<"]           : " << tauNPi0s[i] << endl;
    cout << "tauSeedTrackID["<<i<<"]     : " << tauSeedTrackID[i] << endl;
    cout << "tauMaxAlphaNu["<<i<<"]      : " << tauMaxAlphaNu[i] << endl;
    cout << "tauMaxAlphaTrack["<<i<<"]   : " << tauMaxAlphaTrack[i] << endl;
    cout << "tauMaxAlphaPi0["<<i<<"]     : " << tauMaxAlphaPi0[i] << endl;
    cout << "tauMaxAlphaVisibles["<<i<<"]: " << tauMaxAlphaVisibles[i] << endl;
    cout << "tauSeedTrackZ0["<<i<<"]     : " << tauSeedTrackZ0[i] << endl;
  }
}


void PrintVector(const TLorentzVector &p) {
  cout << "(" << p.Px() << ", " << p.Py() << ", "
       << p.Pz() << "; " << p.E() << ")" << endl;
}

void PrintVector(const TVector3 &p) {
  cout << "(" << p.Px() << ", " << p.Py() << ", "
       << p.Pz() << ")" << endl;
}


void makeRtgTree(){

  TFile* f = new TFile("testRtgObject.root","RECREATE");
  TTree* t = new TTree("rtgTree","Rutgers Tau Group Tree");

  RtgEvent* evt = new RtgEvent();

  t->Branch("rtgBranch","RtgEvent",&evt,64000,1);

  TRandom* ran = new TRandom();

  for(int i=0; i<100; i++){

    evt->runNumber = (int) ran->Integer(1000);
    evt->eventNumber = (int) ran->Integer(1000);

    for(int j=0; j<NMET; j++) evt->rtgMet[j]->exSum = ran->Rndm();

    for(int j=0; j<ran->Integer(10); j++){
      RtgTrack rtgTrack;
      rtgTrack.nSegAx = ran->Integer(50);
      rtgTrack.momentum.SetXYZ(ran->Rndm(),ran->Rndm(),ran->Rndm());
      evt->trackList[j] = rtgTrack;
    }

    for(int j=0; j<ran->Integer(5); j++){
      RtgTower rtgTower;
      rtgTower.key = make_pair(ran->Integer(50),ran->Integer(50));
      rtgTower.hadPhi = ran->Rndm();
      evt->towerList[rtgTower.key] = rtgTower;
    }

    for(int j=0; j<ran->Integer(3); j++){
      RtgPhoton rtgPhoton;
      rtgPhoton.trackIndex = ran->Integer(10);
      rtgPhoton.momentum.SetXYZT(ran->Rndm(),ran->Rndm(),ran->Rndm(),ran->Rndm());
      evt->photonList[j] = rtgPhoton;
    }

    for(int j=0; j<ran->Integer(3); j++){
      RtgElectron rtgElectron;
      rtgElectron.trackIndex = ran->Integer(10);
      rtgElectron.momentum.SetXYZT(ran->Rndm(),ran->Rndm(),ran->Rndm(),ran->Rndm());
      evt->electronList[j] = rtgElectron;
    }

    for(int j=0; j<ran->Integer(3); j++){
      RtgMuon rtgMuon;
      rtgMuon.type = ran->Integer(10);
      rtgMuon.momentum.SetXYZT(ran->Rndm(),ran->Rndm(),ran->Rndm(),ran->Rndm());
      evt->muonList[j] = rtgMuon;
    }

    for(int j=0; j<ran->Integer(3); j++){
      RtgTau rtgTau;
      rtgTau.seedTrackIndex = ran->Integer(10);
      rtgTau.clusterMomentum.SetXYZT(ran->Rndm(),ran->Rndm(),ran->Rndm(),ran->Rndm());
      evt->tauList[j] = rtgTau;
    }

    for(int j=0; j<ran->Integer(3); j++){
      RtgPi0 rtgPi0;
      rtgPi0.e = ran->Rndm();
      evt->pi0List[j] = rtgPi0;
    }

    for(int j=0; j<ran->Integer(3); j++){
      RtgCesMatch rtgCesMatch;
      rtgCesMatch.type = ran->Integer(10);
      rtgCesMatch.e = ran->Rndm();
      evt->cesMatchList[j] = rtgCesMatch;
    }

    for(int j=0; j<ran->Integer(5); j++){
      RtgJet rtgJet;
      rtgJet.nTowers = ran->Integer(10);
      rtgJet.momentum.SetXYZT(ran->Rndm(),ran->Rndm(),ran->Rndm(),ran->Rndm());
      evt->jetList[j] = rtgJet;
    }

    t->Fill();
    evt->Clear();

  }// for i

  t->Write();
  f->Close();

  delete ran;
  delete evt;

  

}

void readRtgTree(){

  TFile* f = new TFile("testRtgObject.root","READ");
  TTree* t = (TTree*) f->Get("rtgTree");

  RtgEvent* rtgEvent = 0;
  t->SetBranchAddress("rtgBranch",&rtgEvent);

  int nmax = t->GetEntries();

  TRandom* ran = new TRandom();

  for(int i=0; i<nmax; i++){
    t->GetEntry(i);
    if(ran->Rndm() > 0.9) {
      rtgEvent->Print();
    }
  }

  delete ran;

  f->Close();

}

void TestRtgObject(){

  makeRtgTree();
  readRtgTree();

}



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET