CMCGeantTrack.C
//-----------------------------------------------------------------------------
// $Header: /cool/project/RCS/CMCGeantTrack.C,v 2.2 1997/03/17 14:16:22 ceretto Exp $
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Implementation of class CMCGeantTrack.
//
//-----------------------------------------------------------------------------
#include <iostream.h>
#include "CRich.h"
#include "CMCGeantTrack.h"
#include "CRingFitter.h"
#include "CRingCandidate.h"
CMCGeantTrack::CMCGeantTrack()
{
index = 0;
trackNr = 0;
volume = "";
process = "";
nHitsUV1 = 0;
nHitsUV2 = 0;
for (int i=0; i<MaxDetectors; i++) { // do not destroy hits here,
digiHits[i].clear(); // this will be done by CMCServer
}
}
void CMCGeantTrack::print(ostream & os)
{
os << "index " << index << " GEANT type " << particle.getGeantId() << " track " << trackNr << " parent " << parent
<< " nr of hits in lists : " ;
for (int i=0; i<MaxDetectors; i++) os << digiHits[i].length() << "/" ;
os << endl;
os << "\tcreated by process '" << process << "' in volume '" << volume << "' nHits UV1/2: " << nHitsUV1 << "/" << nHitsUV2 << endl;
os << "\tat: (x/y/z) = " << origin << endl;
os << "\tmomentum " << getParticle().get4Momentum().getP().getAbs()
<< " pt " << getParticle().get4Momentum().getPerp()
<< " pseudorapidity eta = " << getParticle().get4Momentum().getEta() << endl;
}
CMCGeantTrack::~CMCGeantTrack()
{
for (int i=0; i<MaxDetectors; i++) { // do not destroy hits here,
digiHits[i].clear(); // this will be done by CMCServer
}
}
CMCGeantTrack::CMCGeantTrack(const CMCGeantTrack &)
{
}
CMCGeantTrack & CMCGeantTrack::operator = (const CMCGeantTrack &)
{
return *this;
}
CRichPadCoord CMCGeantTrack::fitRingOnGeantHits(CRich& rich)
{
CRichPadCoord center;
double x0 = 0, y0 = 0;
CRingFitter fit;
const RWTPtrOrderedVector<CMCDigiHit> *hits;
hits = &digiHits[rich.getDetectorId()];
int len = hits->length();
if (len < 4) { // not enough hits in list for this detector
return center;
}
fit.setRadius(rich.getSetup()->getAsymptoticRadius());
int j;
x0 = 0; y0 = 0; // get center of gravity for all hits
for (j=0; j<len; j++) { // loop all hits of this particle
x0 += (*hits)(j)->getGeantHit().getX();
y0 += (*hits)(j)->getGeantHit().getY();
}
fit.setXCenter(x0/len); // set start values for center to COG of hits
fit.setYCenter(y0/len);
for (j=0; j<len; j++) { // loop all hits of this particle
fit.addX((*hits)(j)->getGeantHit().getX());
fit.addY((*hits)(j)->getGeantHit().getY());
fit.addWeight(1.);
}
fit.chernov();
if (fit.getError() != 0) {
cerr << "CMCGeantTrack::fitRingOnGeantHits()\n";
cerr << "\tError\n\treturn code from robustFixedRadius() = " << fit.getError() << endl;
fit.printStatistics();
return center;
}
center.setX(fit.getXCenter());
center.setY(fit.getYCenter());
return center;
}
CRichPadCoord CMCGeantTrack::fitRingOnDigiHits(CRich& rich)
{
CRichPadCoord center;
double x0 = 0, y0 = 0;
CRingFitter fit;
const RWTPtrOrderedVector<CMCDigiHit> *hits;
hits = &digiHits[rich.getDetectorId()];
int len = hits->length();
if (len < 4) { // not enough hits in list for this detector
return center;
}
fit.setRadius(rich.getSetup()->getAsymptoticRadius());
int j;
x0 = 0; y0 = 0; // get center of gravity for all hits
for (j=0; j<len; j++) { // loop all hits of this particle
x0 += (*hits)(j)->getDigiHit().getX();
y0 += (*hits)(j)->getDigiHit().getY();
}
fit.setXCenter(x0/len); // set start values for center to COG of hits
fit.setYCenter(y0/len);
for (j=0; j<len; j++) { // loop all hits of this particle
fit.addX((*hits)(j)->getDigiHit().getX());
fit.addY((*hits)(j)->getDigiHit().getY());
fit.addWeight(1.);
}
fit.chernov();
if (fit.getError() != 0) {
cerr << "CMCGeantTrack::fitRingOnDigiHits()\n";
cerr << "\tError\n\treturn code from robustFixedRadius() = " << fit.getError() << endl;
fit.printStatistics();
return center;
}
center.setX(fit.getXCenter());
center.setY(fit.getYCenter());
return center;
}
CRingCandidate CMCGeantTrack::fitPionRingOnGeantHits(CRich& rich)
{
const double pionMass=0.1395685;
double radius = 0;
CRichPadCoord center;
CRingCandidate candidate;
double x0 = 0, y0 = 0;
CRingFitter fit;
double momentum = particle.get4Momentum().getP().getAbs();
double startRadius;
if(momentum > 4.5) {
startRadius= rich.getSetup()->getAsymptoticRadius()*sqrt(1-(rich.getSetup()->getGammaThreshold()*pionMass/momentum)
*(rich.getSetup()->getGammaThreshold()*pionMass/momentum));
}
else
return candidate;
const RWTPtrOrderedVector<CMCDigiHit> *hits;
hits = &digiHits[rich.getDetectorId()];
int len = hits->length();
if (len < 4) { // not enough hits in list for this detector
return candidate;
}
fit.setRadius(startRadius);
int j;
x0 = 0; y0 = 0; // get center of gravity for all hits
for (j=0; j<len; j++) { // loop all hits of this particle
x0 += (*hits)(j)->getGeantHit().getX();
y0 += (*hits)(j)->getGeantHit().getY();
}
fit.setXCenter(x0/len); // set start values for center to COG of hits
fit.setYCenter(y0/len);
for (j=0; j<len; j++) { // loop all hits of this particle
fit.addX((*hits)(j)->getGeantHit().getX());
fit.addY((*hits)(j)->getGeantHit().getY());
fit.addWeight(1.);
}
fit.chernov();
if (fit.getError() != 0) {
cerr << "CMCGeantTrack::fitRingOnGeantHits()\n";
cerr << "\tError\n\treturn code from robustFixedRadius() = " << fit.getError() << endl;
fit.printStatistics();
return candidate;
}
radius= fit.getRadius();
center.setX(fit.getXCenter());
center.setY(fit.getYCenter());
candidate.setCenter(center);
candidate.setRadius(radius);
return candidate;
}
CRingCandidate CMCGeantTrack::fitPionRingOnDigiHits(CRich& rich)
{
const double pionMass = 0.1395685;
double radius = 0;
CRichPadCoord center;
CRingCandidate candidate;
double x0 = 0, y0 = 0;
CRingFitter fit;
double momentum = particle.get4Momentum().getP().getAbs();
double startRadius;
if(momentum > 4.5) {
startRadius= rich.getSetup()->getAsymptoticRadius()*sqrt(1-(rich.getSetup()->getGammaThreshold()*pionMass/momentum)
*(rich.getSetup()->getGammaThreshold()*pionMass/momentum));
}
else
return candidate;
const RWTPtrOrderedVector<CMCDigiHit> *hits;
hits = &digiHits[rich.getDetectorId()];
int len = hits->length();
if (len < 4) { // not enough hits in list for this detector
return candidate;
}
fit.setRadius(startRadius);
int j;
x0 = 0; y0 = 0; // get center of gravity for all hits
for (j=0; j<len; j++) { // loop all hits of this particle
x0 += (*hits)(j)->getDigiHit().getX();
y0 += (*hits)(j)->getDigiHit().getY();
}
fit.setXCenter(x0/len); // set start values for center to COG of hits
fit.setYCenter(y0/len);
for (j=0; j<len; j++) { // loop all hits of this particle
fit.addX((*hits)(j)->getDigiHit().getX());
fit.addY((*hits)(j)->getDigiHit().getY());
fit.addWeight(1.);
}
fit.chernov();
if (fit.getError() != 0) {
cerr << "CMCGeantTrack::fitRingOnDigiHits()\n";
cerr << "\tError\n\treturn code from robustFixedRadius() = " << fit.getError() << endl;
fit.printStatistics();
return candidate;
}
radius= fit.getRadius();
center.setX(fit.getXCenter());
center.setY(fit.getYCenter());
candidate.setCenter(center);
candidate.setRadius(radius);
return candidate;
}