//*CMZ : 1.03/09 11/12/97 11.00.17 by Rene Brun
//*-- Author : Rene Brun 19/08/96
//______________________________________________________________________________
// Event and Track classes
// =======================
//
// The Event class is a naive/simple example of an event structure.
// public:
// Int_t fNtrack;
// Int_t fNseg;
// Int_t fNvertex;
// UInt_t fFlag;
// Float_t fTemperature;
// EventHeader fEvtHdr;
// TClonesArray *fTracks;
// TH1F *fH;
//
// The EventHeader class has 3 data members (integers):
// public:
// Int_t fEvtNum;
// Int_t fRun;
// Int_t fDate;
//
//
// The Event data member fTracks is a pointer to a TClonesArray.
// It is an array of a variable number of tracks per event.
// Each element of the array is an object of class Track with the members:
// private:
// Float_t fPx; //X component of the momentum
// Float_t fPy; //Y component of the momentum
// Float_t fPz; //Z component of the momentum
// Float_t fRandom; //A random track quantity
// Float_t fMass2; //The mass square of this particle
// Float_t fBx; //X intercept at the vertex
// Float_t fBy; //Y intercept at the vertex
// Float_t fMeanCharge; //Mean charge deposition of all hits of this track
// Float_t fXfirst; //X coordinate of the first point
// Float_t fXlast; //X coordinate of the last point
// Float_t fYfirst; //Y coordinate of the first point
// Float_t fYlast; //Y coordinate of the last point
// Float_t fZfirst; //Z coordinate of the first point
// Float_t fZlast; //Z coordinate of the last point
// Float_t fCharge; //Charge of this track
// Int_t fNpoint; //Number of points for this track
// Short_t fValid; //Validity criterion
//
// An example of a batch program to use the Event/Track classes is given
// in this directory: MainEvent.
// Look also in the same directory at the following macros:
// - eventa.C an example how to read the tree
// - eventb.C how to read events conditionally
//
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
#include "TRandom.h"
#include "Event.h"
ClassImp(EventHeader)
ClassImp(Event)
ClassImp(Track)
TClonesArray *gTracks;
TH1F *gHist;
TH1F *hNtrack,*hNseg, *hTemperature;
TH1F *hPx, *hPy, *hPz, *hRandom, *hMass2, *hBx, *hBy;
TH1F *hMeanCharge,*hXfirst,*hXlast,*hYfirst,*hYlast;
TH1F *hZfirst,*hZlast,*hCharge,*hNpoint,*hValid;
//______________________________________________________________________________
Event::Event()
{
// Create one Event object
// When the constructor is invoked for the first time, the global
// variable gTracks is NULL. The TClonesArray gTracks is created.
// The histogram fH is created.
//
fNtrack = 0;
if (!gTracks) gTracks = new TClonesArray("Track", 1000);
fTracks = gTracks;
fH = 0;
}
//______________________________________________________________________________
Event::~Event()
{
Clear();
}
//______________________________________________________________________________
void Event::AddTrack(Float_t random)
{
// Add a new track to the list of tracks for this event.
// To avoid calling the very time consuming operator new for each track,
// the standard but not well know C++ operator "new with placement" is called.
// if tracks[i] is NULL, a new Track object will be created
// otherwise the previous Track[i] will be overwritten.
TClonesArray &tracks = *fTracks;
new(tracks[fNtrack++]) Track(random);
}
//______________________________________________________________________________
void Event::Clear(Option_t *option)
{
fTracks->Clear(option);
}
//______________________________________________________________________________
void Event::Hcreate()
{
// Create histograms
hNtrack = new TH1F("hNtrack", "Ntrack",100,575,625);
hNseg = new TH1F("hNseg", "Nseg",100,5800,6200);
hTemperature = new TH1F("hTemperature","Temperature",100,19.5,20.5);
hPx = new TH1F("hPx", "Px",100,-4,4);
hPy = new TH1F("hPy", "Py",100,-4,4);
hPz = new TH1F("hPz", "Pz",100,0,5);
hRandom = new TH1F("hRandom", "Random",100,0,1000);
hMass2 = new TH1F("hMass2", "Mass2",100,0,12);
hBx = new TH1F("hBx", "Bx",100,-0.5,0.5);
hBy = new TH1F("hBy", "By",100,-0.5,0.5);
hMeanCharge = new TH1F("hMeanCharge","MeanCharge",100,0,0.01);
hXfirst = new TH1F("hXfirst", "Xfirst",100,-40,40);
hXlast = new TH1F("hXlast", "Xlast",100,-40,40);
hYfirst = new TH1F("hYfirst", "Yfirst",100,-40,40);
hYlast = new TH1F("hYlast", "Ylast",100,-40,40);
hZfirst = new TH1F("hZfirst", "Zfirst",100,0,80);
hZlast = new TH1F("hZlast", "Zlast",100,0,250);
hCharge = new TH1F("hCharge", "Charge",100,-1.5,1.5);
hNpoint = new TH1F("hNpoint", "Npoint",100,50,80);
hValid = new TH1F("hValid", "Valid",100,0,1.2);
}
//______________________________________________________________________________
void Event::Hfill()
{
// Fill histograms
hNtrack->Fill(fNtrack);
hNseg->Fill(fNseg);
hTemperature->Fill(fTemperature);
for (Int_t itrack=0;itrack<fNtrack;itrack++) {
Track *track = (Track*)fTracks->UncheckedAt(itrack);
hPx->Fill(track->GetPx());
hPy->Fill(track->GetPy());
hPz->Fill(track->GetPz());
hRandom->Fill(track->GetRandom());
hMass2->Fill(track->GetMass2());
hBx->Fill(track->GetBx());
hBy->Fill(track->GetBy());
hMeanCharge->Fill(track->GetMeanCharge());
hXfirst->Fill(track->GetXfirst());
hXlast->Fill(track->GetXlast());
hYfirst->Fill(track->GetYfirst());
hYlast->Fill(track->GetYlast());
hZfirst->Fill(track->GetZfirst());
hZlast->Fill(track->GetZlast());
hCharge->Fill(track->GetCharge());
hNpoint->Fill(track->GetNpoint());
hValid->Fill(track->GetValid());
}
}
//______________________________________________________________________________
void Event::SetHeader(Int_t i, Int_t run, Int_t date, Float_t random)
{
fNtrack = 0;
fEvtHdr.Set(i, run, date);
if (!gHist) gHist = new TH1F("hstat","Event Histogram",100,0,1);
fH = gHist;
fH->Fill(random);
}
//______________________________________________________________________________
Track::Track(Float_t random) :TObject()
{
//*-*-*-*-*-*-*-*-*-*-*Track normal constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-* =======================
// Note that in this example, data members do not have any physical meaning
Float_t a,b,px,py;
gRandom->Rannor(px,py);
fPx = px;
fPy = py;
fPz = TMath::Sqrt(px*px+py*py);
fRandom = 1000*random;
if (fRandom < 10) fMass2 = 0.08;
else if (fRandom < 100) fMass2 = 0.8;
else if (fRandom < 500) fMass2 = 4.5;
else if (fRandom < 900) fMass2 = 8.9;
else fMass2 = 9.8;
gRandom->Rannor(a,b);
fBx = 0.1*a;
fBy = 0.1*b;
fMeanCharge = 0.01*gRandom->Rndm(1);
gRandom->Rannor(a,b);
fXfirst = a*10;
fXlast = b*10;
gRandom->Rannor(a,b);
fYfirst = a*12;
fYlast = b*16;
gRandom->Rannor(a,b);
fZfirst = 50 + 5*a;
fZlast = 200 + 10*b;
fCharge = Float_t(Int_t(3*gRandom->Rndm(1)) - 1);
fNpoint = Int_t(60+10*gRandom->Rndm(1));
fValid = Int_t(0.6+gRandom->Rndm(1));
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.