// ----------------------------------------------------------------------------
// $Id: LCDEventDisplay.cxx,v 1.4 2001/06/21 04:29:00 toshi Exp $
// ----------------------------------------------------------------------------
//
// $Log: LCDEventDisplay.cxx,v $
// Revision 1.4 2001/06/21 04:29:00 toshi
// A Bug fix. Remove SetClusterParam().
//
// Revision 1.3 2001/06/21 04:25:12 toshi
// Changes according to updated LCDCalHit and LCDCalHitUtil.
//
// Revision 1.2 2001/06/20 03:38:12 toshi
// Changes to prevent compilar error on windows.
//
// Revision 1.1 2001/05/10 19:32:03 toshi
// C++ file name convention has been changed from .C to .cxx .
//
//
#include <iostream.h>
#include "LCDEventDisplay.h"
#include "TArrayD.h"
#include "TPolyMarker3D.h"
#include "TMarker3DBox.h"
#include "TBRIK.h"
#include "THelix.h"
#include "TView.h"
#include "LCDTrack.h"
#include "LCDTracker_Hit.h"
#include "LCDVXD_Hit.h"
#include "LCDCluster.h"
#include "LCDCalHit.h"
#include "LCDCalHitUtil.h"
#define N_BARREL 1
#define N_ENDCAP 0
////////////////////////////////////////////////////////////
//
// LCDEventDisplay
//
ClassImp(LCDEventDisplay)
LCDEventDisplay::LCDEventDisplay() {
Init();
}
LCDEventDisplay::LCDEventDisplay(LCDGetParameters* gp) {
Init();
SetDetectorParameters(gp);
}
LCDEventDisplay::~LCDEventDisplay() {
}
void LCDEventDisplay::Init() {
m_gp=0;
m_COIL =1;
m_EMCAL =1;
m_EMCALHit =0;
m_ENDCAL =0;
m_ENDCALHit=0;
m_HDCAL =1;
m_HDCALHit =0;
m_MUCAL =1;
m_MUCALHit =0;
m_LMCAL =0;
m_LMCALHit =0;
m_TRK =1;
m_TRKHit =0;
m_VXD =0;
m_Gismo=0;
m_BW=0;
m_Theta=-90.;
m_Phi=0.;
m_TrackList = 0;
m_ClusterList = 0;
m_CalHitList = 0;
m_TrackerHitsList=0;
m_VXDHitsList=0;
pInnerVolume = pVolumes = new LCDDetectorVolume [20];
nVolumes = 0;
LCDDetectorVolume* pCur; // the one we're working on
nVolumes = N_BARREL + N_ENDCAP;
pCur = pVolumes;
for (Int_t i = 0; i < nVolumes; i++) {
pCur->barrel = (i < N_BARREL);
// Will be overwritten when appropriate
pCur->iLenPerCm = 0.0;
pCur->radLenPerCm = 0.0;
pCur++;
}
pCur = pVolumes;
pCur->volKind = VOL_AIR;
pCur->innerR = 0;
pCur->outerR = 0;
pCur->innerZ = 0;
pCur->outerZ = 0;
pCur->pNextR = 0;
pCur->pPrevR = 0;
pCur->pNextZ = 0;
pInnerVolume = pCur;
pCur->field = 0.0;
m_canvas =0;
m_viewpad =0;
m_beampipe =0;
m_tracker =0;
m_barrel_EM =0;
m_coil =0;
m_barrel_HAD=0;
m_barrel_MU =0;
node0=0;
node1=0;
node2=0;
node3=0;
node4=0;
node5=0;
}
void LCDEventDisplay::SetDetectorParameters(LCDGetParameters* gp) {
m_gp = gp;
LCDDetectorVolume* pCur; // the one we're working on
nVolumes = N_BARREL + N_ENDCAP;
pCur = pVolumes;
for (Int_t i = 0; i < nVolumes; i++) {
pCur->barrel = (i < N_BARREL);
// Will be overwritten when appropriate
pCur->iLenPerCm = 0.0;
pCur->radLenPerCm = 0.0;
pCur++;
}
pCur = pVolumes;
pCur->volKind = VOL_AIR;
pCur->innerR = 0;
pCur->outerR = m_gp->GetEMBarrelInnerR();
pCur->innerZ = 0.0;
pCur->outerZ = m_gp->GetEMBarrelOuterZ();
pCur->pNextR = 0;
pCur->pPrevR = 0;
pCur->pNextZ = 0;
pInnerVolume = pCur;
pCur->field = m_gp->GetMagneticField();
}
void LCDEventDisplay::Delete() {
if (m_canvas) {
delete m_canvas;
m_canvas=0;
}
if (m_viewpad) {
delete m_viewpad;
m_viewpad=0;
}
if (m_TrackList != 0) {
m_TrackList->Delete();
delete m_TrackList;
m_TrackList=0;
}
if (m_ClusterList != 0) {
m_ClusterList->Delete();
delete m_ClusterList;
m_ClusterList=0;
}
if (m_TrackerHitsList != 0) {
m_TrackerHitsList->Delete();
delete m_TrackerHitsList;
m_TrackerHitsList=0;
}
if (m_VXDHitsList != 0) {
m_VXDHitsList->Delete();
delete m_VXDHitsList;
m_VXDHitsList=0;
}
if (m_CalHitList != 0) {
m_CalHitList->Delete();
delete m_CalHitList;
m_CalHitList=0;
}
if (m_beampipe) {
delete m_beampipe;
m_beampipe=0;
}
if (m_tracker) {
delete m_tracker;
m_tracker=0;
}
if (m_barrel_EM) {
delete m_barrel_EM;
m_barrel_EM=0;
}
if (m_coil) {
delete m_coil;
m_coil=0;
}
if (m_barrel_HAD) {
delete m_barrel_HAD;
m_barrel_HAD=0;
}
if (m_barrel_MU) {
delete m_barrel_MU;
m_barrel_MU=0;
}
if (node1) {
delete node1;
node1=0;
}
if (node2) {
delete node2;
node2=0;
}
if (node3) {
delete node3;
node3=0;
}
if (node4) {
delete node4;
node4=0;
}
if (node5) {
delete node5;
node5=0;
}
}
void LCDEventDisplay::Draw(LCDEvent* event) {
if (m_canvas==0)
m_canvas = new TCanvas("c1","LCD Event Display",500,500);
m_canvas->cd();
if (m_viewpad==0)
m_viewpad = new TPad("viewpad","LCD Display",0.05,0.05,0.95,0.95,18);
m_viewpad->Draw();
m_viewpad->SetTheta(m_Theta);
m_viewpad->SetPhi(m_Phi);
m_viewpad->cd();
// delete the old stuff
if (m_TrackList == 0) {
m_TrackList = new TObjArray();
} else {
m_TrackList->Delete();
}
if (m_ClusterList == 0) {
m_ClusterList = new TObjArray();
} else {
m_ClusterList->Delete();
}
if (m_TrackerHitsList == 0) {
m_TrackerHitsList = new TObjArray();
} else {
m_TrackerHitsList->Delete();
}
if (m_VXDHitsList == 0) {
m_VXDHitsList = new TObjArray();
} else {
m_VXDHitsList->Delete();
}
if (m_CalHitList == 0) {
m_CalHitList = new TObjArray();
} else {
m_CalHitList->Delete();
}
// Get detector size
Double_t CoilrInner = m_gp -> GetCoilInnerR();
Double_t CoilrOuter = CoilrInner + m_gp->GetCoilThick();
Double_t CoilLength = m_gp->GetCoilOuterZ();
Double_t EMbrInner = m_gp->GetEMBarrelInnerR();
Double_t EMbrOuter = m_gp->GetEMBarrelOuterR();
Double_t EMbLength = m_gp->GetEMBarrelOuterZ();
Double_t HADbrInner = m_gp->GetHADBarrelInnerR();
Double_t HADbrOuter = m_gp->GetHADBarrelOuterR();
Double_t HADbLength = m_gp->GetHADBarrelOuterZ();
Double_t MUbrInner = m_gp->GetMUBarrelInnerR();
Double_t MUbrOuter = m_gp->GetMUBarrelOuterR();
Double_t MUbLength = m_gp->GetMUBarrelOuterZ();
// Define some volumes
if (m_beampipe == 0)
m_beampipe = new TTUBE("BMPP","TUBE","void",
0.7,0.8,EMbLength);
if (m_tracker == 0)
m_tracker = new TTUBE("TRK","TUBE","void",
10,EMbrInner,EMbLength);
if (m_barrel_EM == 0)
m_barrel_EM = new TTUBE("BEM","TUBE","void",
EMbrInner,EMbrOuter,EMbLength);
if (m_coil == 0)
m_coil = new TTUBE("COIL","TUBE","void",
CoilrInner,CoilrOuter,CoilLength);
if (m_barrel_HAD == 0)
m_barrel_HAD = new TTUBE("BHAD","TUBE","void",
HADbrInner,HADbrOuter,HADbLength);
if (m_barrel_MU == 0)
m_barrel_MU = new TTUBE("BMU","TUBE","void",
MUbrInner,MUbrOuter,MUbLength);
// Set shapes attributes
if (m_BW == 0){
m_beampipe ->SetLineColor(kBlack);
m_tracker ->SetLineColor(kGreen);
m_barrel_EM ->SetLineColor(kMagenta);
m_coil ->SetLineColor(kYellow);
m_barrel_HAD->SetLineColor(kBlue);
m_barrel_MU ->SetLineColor(kGreen);
}
// Draw this geometry in the current canvas
// Build the geometry hierarchy
if (node0 == 0)
node0 = new TNode("NODE0","NODE0","BMPP",0,0,0);
if (node1 == 0 && m_EMCAL == 0 && m_EMCALHit == 0)
node1 = new TNode("NODE1","NODE1","TRK" ,0,0,0);
if ((m_EMCAL || m_EMCALHit) && node2 == 0)
node2 = new TNode("NODE2","NODE2","BEM" ,0,0,0);
if (m_COIL && node3 == 0)
node3 = new TNode("NODE3","NODE3","COIL",0,0,0);
if ((m_HDCAL || m_HDCALHit) && node4 == 0 )
node4 = new TNode("NODE4","NODE4","BHAD",0,0,0);
if ((m_MUCAL || m_MUCALHit) && node5 == 0 )
node5 = new TNode("NODE5","NODE5","BMU" ,0,0,0);
node0->cd();
Double_t BField = m_gp->GetMagneticField();
Double_t ptor = 333.567/ BField;
Double_t xyz0[3], v0[3], range[2];
Double_t baxis[]={0.0,0.0,1.0};
LCDTrack* track;
TVector3 pos0;
TVector3 mom0;
Double_t pt;
Double_t r;
Double_t w;
Double_t vt;
Double_t vz;
Int_t charge;
Double_t decrS;
TVector3 pPos;
LCDDetectorVolume* pCur;
LCDSwimTraj::PropagateRet status;
THelix* tH;
Float_t energy;
Float_t phi ;
Float_t theta ;
Float_t rt ;
Float_t x,dx=0.0;
Float_t y,dy=0.0;
Float_t z,dz=0.0;
TMarker3DBox* clus;
// VXD hits
if (m_VXD) {
Int_t nVXDHits = event->VXD()->GetEntries();
if (nVXDHits != 0) {
TArrayD vx(3*nVXDHits);
LCDVXD_Hit* hV;
for (Int_t vxd=0 ; vxd < nVXDHits; vxd++) {
hV = (LCDVXD_Hit*)event->VXD()->At(vxd);
vx.AddAt(hV->GetPosition()[0],3*vxd+0);
vx.AddAt(hV->GetPosition()[1],3*vxd+1);
vx.AddAt(hV->GetPosition()[2],3*vxd+2);
}
TPolyMarker3D* VXDHits = new TPolyMarker3D(nVXDHits,vx.GetArray(),6);
//if (m_BW == 0) VXDHits->SetMarkerColor(41);
if (m_BW == 0) VXDHits->SetMarkerColor(kMagenta);
VXDHits->SetMarkerSize(1);
VXDHits->Draw("same");
m_VXDHitsList->Add(VXDHits);
}
}
// Tracker hits
if (m_TRKHit) {
Int_t nTrkHits = event->Tracker()->GetEntries();
if (nTrkHits != 0) {
TArrayD tx(3*nTrkHits);
for (Int_t trk=0; trk<nTrkHits; trk++) {
LCDTracker_Hit* hT = (LCDTracker_Hit*)event->Tracker()->At(trk);
tx.AddAt(hT->GetPosition()[0],3*trk+0);
tx.AddAt(hT->GetPosition()[1],3*trk+1);
tx.AddAt(hT->GetPosition()[2],3*trk+2);
}
TPolyMarker3D* TrackerHits = new TPolyMarker3D(nTrkHits,tx.GetArray(),7);
if (m_BW == 0) TrackerHits->SetMarkerColor(kYellow);
TrackerHits->SetMarkerSize(1);
TrackerHits->Draw("same");
m_TrackerHitsList->Add(TrackerHits);
}
}
LCDCalHitUtil chutil(m_gp);
// Cal Hit
if (m_EMCALHit || m_HDCALHit || m_MUCALHit || m_LMCALHit) {
LCDCalHit* cE;
Int_t sysid;
Int_t fcol;
Int_t nCal = event->CAL()->GetEntries();
if (nCal > 0) {
for (int i_em=0; i_em<nCal; i_em++) {
cE = (LCDCalHit*)event->CAL()->At(i_em);
phi = chutil.GetPhi(cE);
theta = chutil.GetTheta(cE);
sysid=cE->GetTower()->GetSystem();
switch(sysid) {
case 10: // EM Barrel
if (m_EMCALHit == 0) continue;
fcol=kGreen;
rt = chutil.GetR(cE)*TMath::Sin(theta);
dx = m_gp->GetEMphiSeg()/2.0*rt;
dy = m_gp->GetEMThetaSeg()/2.0*rt;
dz = m_gp->GetEMBarrelThick()/2.0;
rt*= (1.0 + dz/rt);
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
break;
case 11: // EM EndCap
if (m_EMCALHit == 0) continue;
if (m_ENDCALHit == 0) continue;
fcol=29;
rt = chutil.GetR(cE)*TMath::Sin(theta);
dx = m_gp->GetEMphiSeg()/2.0*rt;
dy = m_gp->GetEMThetaSeg()/2.0*rt;
dz = m_gp->GetEMBarrelThick()/2.0;
rt*= (1.0 + dz/rt);
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
break;
case 12: // HAD Barrel
if (m_HDCALHit == 0) continue;
fcol=kBlue;
rt = chutil.GetR(cE)*TMath::Sin(theta);
dx = m_gp->GetHADphiSeg()/2.0*rt;
dy = m_gp->GetHADThetaSeg()/2.0*rt;
dz = m_gp->GetHADBarrelThick()/2.0;
rt*= (1.0 + dz/rt);
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
break;
case 13: // HAD EndCap
if (m_HDCALHit == 0) continue;
if (m_ENDCALHit == 0) continue;
fcol=38;
rt = chutil.GetR(cE)*TMath::Sin(theta);
dx = m_gp->GetHADphiSeg()/2.0*rt;
dy = m_gp->GetHADThetaSeg()/2.0*rt;
dz = m_gp->GetHADBarrelThick()/2.0;
rt*= (1.0 + dz/rt);
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
break;
case 14: // MU Barrel
if (m_MUCALHit == 0) continue;
fcol=kBlue;
rt = chutil.GetR(cE)*TMath::Sin(theta);
dx = m_gp->GetMUphiSeg()/2.0*rt;
dy = m_gp->GetMUThetaSeg()/2.0*rt;
dz = m_gp->GetMUBarrelThick()/2.0;
rt*= (1.0 + dz/rt);
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
break;
case 15: // MU EndCap
if (m_MUCALHit == 0) continue;
if (m_ENDCALHit == 0) continue;
fcol=38;
rt = chutil.GetR(cE)*TMath::Sin(theta);
dx = m_gp->GetMUphiSeg()/2.0*rt;
dy = m_gp->GetMUThetaSeg()/2.0*rt;
dz = m_gp->GetMUBarrelThick()/2.0;
rt*= (1.0 + dz/rt);
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
break;
default:
continue;
break;
}
theta*=180.0/TMath::Pi();
phi *=180.0/TMath::Pi();
clus = new TMarker3DBox(x,y,z,dx,dy,dz,theta,phi);
clus->SetLineColor(fcol);
clus->Draw("same");
m_CalHitList->Add(clus);
}
}
}
// Tracks
if (m_TRK) {
int nTracks = event->Tracks()->GetEntries();
for (int itrk=0; itrk < nTracks; itrk++){
track = (LCDTrack*)event->Tracks()->At(itrk);
pos0=track->GetPositionVector(0.0);
mom0=track->GetMomentumVector(0.0);
charge = (Int_t)(track->GetCharge());
if (m_Gismo) charge*=-1; //Gismo bug workaround...
if (pos0.Perp() > EMbrInner ) continue;
if (TMath::Abs(pos0.Z()) > EMbLength ) continue;
pt = mom0.Pt();
r = ptor * pt;
w = pt / r ;
vt = r * w;
vz = mom0.Z()* ptor * w;
v0[0] = vt* mom0.X() / pt;
v0[1] = vt* mom0.Y() / pt;
v0[2] = vz;
w *= charge;
traj.SetParticleParams(pos0, mom0, charge);
pCur = (LCDDetectorVolume *) pInnerVolume;
status= traj.HelixToCyl(pCur, &decrS);
pos0.GetXYZ(xyz0);
pPos=traj.GetNewPos();
if (status == LCDSwimTraj::INTERSECT_ZPLUS) {
range[0] = pos0[2]; range[1] = EMbLength;
} else if (status == LCDSwimTraj::INTERSECT_ZMINUS){
range[1] = pos0[2]; range[0] =-EMbLength;
} else if (pPos.Z() < pos0[2]){
range[0] = pPos.Z(); range[1] = pos0[2];
} else if (pPos.Z() > pos0[2]){
range[1] = pPos.Z(); range[0] = pos0[2];
} else {
range[0] = pos0[2]; range[1] = pos0[2];
}
tH = new THelix(xyz0, v0, w, range, kHelixZ, baxis);
if (m_BW==0) tH->SetLineColor(kCyan);
tH->Draw("same");
m_TrackList->Add(tH);
}
}
// Cluster
LCDCluster* cls;
if (m_EMCAL || m_HDCAL || m_MUCAL || m_LMCAL) {
Int_t nCluster = event->ClusterLst()->GetEntries();
for (int iClus=0; iClus<nCluster; iClus++) {
cls = (LCDCluster*)event->ClusterLst()->At(iClus);
energy = cls->GetEnergy();
phi = cls->GetEnergyPhi();
theta = cls->GetEnergyTheta();
rt = cls->GetEnergyR()*TMath::Sin(theta);
if (m_EMCAL == 0) {
if (cls->GetSystem() == 0) continue; //Barrel Hit
dx = m_gp->GetEMphiSeg()/2.0*rt;
dy = m_gp->GetEMThetaSeg()/2.0*rt;
}
if (m_HDCAL == 0) {
if (cls->GetSystem() == 1) continue; //Not EM Cluster
dx = m_gp->GetHADphiSeg()/2.0*rt;
dy = m_gp->GetHADThetaSeg()/2.0*rt;
}
if (m_MUCAL == 0) {
if (cls->GetSystem() == 2) continue; //Not EM Cluster
dx = m_gp->GetMUphiSeg()/2.0*rt;
dy = m_gp->GetMUThetaSeg()/2.0*rt;
}
if (m_LMCAL == 0) {
if (cls->GetSystem() == 3) continue; //Not EM Cluster
dx = m_gp->GetLUMphiSeg()/2.0*rt;
dy = m_gp->GetLUMThetaSeg()/2.0*rt;
}
if (m_ENDCAL == 0) {
if (cls->GetBarEnd() != 0) continue; //Endcap Hit
switch(cls->GetSystem()) {
case 0:
dx = m_gp->GetMUphiSeg()/2.0*rt;
dy = m_gp->GetMUThetaSeg()/2.0*rt;
break;
case 1:
dx = m_gp->GetHADphiSeg()/2.0*rt;
dy = m_gp->GetHADThetaSeg()/2.0*rt;
break;
case 2:
dx = m_gp->GetMUphiSeg()/2.0*rt;
dy = m_gp->GetMUThetaSeg()/2.0*rt;
break;
case 3:
dx = m_gp->GetLUMphiSeg()/2.0*rt;
dy = m_gp->GetLUMThetaSeg()/2.0*rt;
break;
}
}
dz = energy/2.0;
energy=TMath::Power(energy,0.5);
rt+= energy/2.0;
x = rt*TMath::Cos(phi);
y = rt*TMath::Sin(phi);
z = rt*TMath::Cos(theta)/TMath::Sin(theta);
theta*=180.0/TMath::Pi();
phi *=180.0/TMath::Pi();
clus = new TMarker3DBox(x,y,z,dx,dy,energy,theta,phi);
if (m_BW == 0) {
if (cls->GetBarEnd() == 0) {//Barrel
if (cls->GetSystem() == 0) {//Em
clus->SetLineColor(kRed);
} else {
clus->SetLineColor(kYellow);
}
} else {//Endcap
clus->SetLineColor(45);
}
}
clus->Draw("same");
m_ClusterList->Add(clus);
}
}
node0->Draw("same");
m_canvas->Update();
//m_viewpad->x3d();
}
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.