Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion StRoot/StEvent/StFttCluster.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*
***************************************************************************/
#include "StEvent/StFttCluster.h"

#include "St_base/StMessMgr.h"
#include "StEvent/StFttRawHit.h"

StFttCluster::StFttCluster() :
mId(-1),
Expand All @@ -18,6 +19,11 @@ mNStrips(0),
mSumAdc(0.0),
mX(0.0),
mSigma(0.0),
mMaxADC(0),
mIndexMaxStrip(0),
mMaxStripCenter(0),
mMaxStripLeftEdge(0),
mMaxStripRightEdge(0),
mRawHits(0),
mNeighbors(0)
{
Expand Down Expand Up @@ -61,3 +67,13 @@ operator<<( std::ostream &os, const StFttCluster& rh )
os << ")" << endl;
return os;
}

void StFttCluster::print() {
LOG_INFO << " Cluster with " << this->nRawHits() << " Hits" << endm;
int i = 0;
for (auto rawhit : mRawHits )
{
LOG_INFO << "Hit " << i << " with strip center = " << rawhit->stripCenter() << " with ADC = " << rawhit->adc() << endm;
i++;
}
}
43 changes: 38 additions & 5 deletions StRoot/StEvent/StFttCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class StFttCluster : public StObject {
float x() const; // Mean x ("center of gravity") in local grid coordinate (1st moment).
float sigma() const; // Maximum 2nd moment (along major axis).

float maxADC() const;
int indexMaxStrip() const;
float maxStripCenter() const;
float maxStripLeftEdge() const;
float maxStripRightEdge() const;


void setId(int cluid);
void setPlane(UChar_t plane);
void setQuadrant(UChar_t quad);
Expand All @@ -38,6 +45,12 @@ class StFttCluster : public StObject {
void setX(float x0);
void setSigma(float sigma);

void setMaxADC(int theMaxADC);
void setIndexMaxStrip(int index);
void setMaxStripCenter(float sc);
void setMaxStripLeftEdge(float LEdge);
void setMaxStripRightEdge(float REdge);

StPtrVecFttRawHit& rawHits();
const StPtrVecFttRawHit& rawHits() const;
void addRawHit(StFttRawHit* p);
Expand All @@ -48,22 +61,28 @@ class StFttCluster : public StObject {
const StPtrVecFttPoint& points() const;
void addPoint(StFttPoint* p);
// void print(Option_t *option="") const;
void print();

private:
Int_t mId=-1; // Eventwise cluster ID
Int_t mId=-1; // Eventwise cluster ID
UChar_t mPlane;
UChar_t mQuadrant;
UChar_t mRow;
UChar_t mOrientation = kFttUnknownOrientation; // Orientation of cluster
Int_t mNStrips=0; // Number of strips
Int_t mNStrips=0; // Number of strips
Float_t mSumAdc=0.0; // Total ADC (0th moment)
Float_t mX=0.0; // Mean x ("center of gravity") in local grid coordinate (1st moment)
Float_t mSigma=0.0; // 2nd moment
Float_t mX=-999; // Mean x ("center of gravity") in local grid coordinate (1st moment)
Float_t mSigma=-999; // 2nd moment
Float_t mMaxADC = -999; // ADC of the strip with maximum ADC
Int_t mIndexMaxStrip = -999;// index of the strip with maximum ADC
Float_t mMaxStripCenter = -999;// Strip center of strip with maximum ADC
Float_t mMaxStripLeftEdge = -999;//left edge of the strip with maximum ADC
Float_t mMaxStripRightEdge = -999;//right edge of the strip with maximum ADC
StPtrVecFttRawHit mRawHits; // Tower hits of the current cluster
StPtrVecFttCluster mNeighbors; // Neighbor clusters
StPtrVecFttPoint mPoints; // Fitted points (photons) in the cluster

ClassDef(StFttCluster, 2)
ClassDef(StFttCluster, 3)
};

std::ostream& operator << ( std::ostream&, const StFttCluster& clu ); // Printing operator
Expand All @@ -82,6 +101,14 @@ inline float StFttCluster::sumAdc() const { return mSumAdc; }
inline float StFttCluster::x() const { return mX; } // Mean x ("center of gravity") in local grid coordinate (1st moment).
inline float StFttCluster::sigma() const { return mSigma; } // 2nd moment

inline float StFttCluster::maxADC() const{ return mMaxADC; }
inline int StFttCluster::indexMaxStrip() const { return mIndexMaxStrip; }
inline float StFttCluster::maxStripCenter() const { return mMaxStripCenter; }
inline float StFttCluster::maxStripLeftEdge() const { return mMaxStripLeftEdge; }
inline float StFttCluster::maxStripRightEdge() const { return mMaxStripRightEdge; }



inline void StFttCluster::setPlane(UChar_t plane) { mPlane = plane; }
inline void StFttCluster::setQuadrant(UChar_t quadrant) { mQuadrant = quadrant; }
inline void StFttCluster::setRow(UChar_t row) { mRow = row; }
Expand All @@ -91,6 +118,12 @@ inline void StFttCluster::setSumAdc(int theSumAdc) { mSumAdc = theSumAdc; }
inline void StFttCluster::setX(float x0) { mX = x0; }
inline void StFttCluster::setSigma(float sigma) { mSigma = sigma; }

inline void StFttCluster::setMaxADC(int theMaxADC) {mMaxADC = theMaxADC;}
inline void StFttCluster::setIndexMaxStrip( int index ) { mIndexMaxStrip = index; }
inline void StFttCluster::setMaxStripCenter( float sc ) { mMaxStripCenter = sc; }
inline void StFttCluster::setMaxStripLeftEdge( float LEdge ) { mMaxStripLeftEdge = LEdge; }
inline void StFttCluster::setMaxStripRightEdge( float REdge ) { mMaxStripRightEdge = REdge; }

inline void StFttCluster::setId(int cluid) { mId = cluid; }

inline StPtrVecFttRawHit& StFttCluster::rawHits() { return mRawHits; }
Expand Down
6 changes: 6 additions & 0 deletions StRoot/StEvent/StFttPoint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ StFttPoint::StFttPoint() : StObject(), mClusters{0,0,0,0} { /* no op */ }
StFttPoint::~StFttPoint() { /* no op */ }

void StFttPoint::print(int opt) {
LOG_INFO << "Point with " << this->nClusters() <<" clusters "
<< ",x = " << this->x() << ", y = " << this->y()
<< ", d1 = " << this->d1() << ", d2 = " << this->d2()
<< " at Plane : " << (int)this->plane()
<< " at Quad : " << (int)this->quadrant()
<< endm;
}


Expand Down
16 changes: 13 additions & 3 deletions StRoot/StEvent/StFttPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class StFttPoint : public StObject {
UChar_t quadrant() const; // detector quadrant.
float x() const; // x position in cell unit at which point intersects the sub-detector in local coordinate
float y() const; // y position in cell unit at which point intersects the sub-detector in local coordinate
float d1() const; // diagonal1
float d2() const; // diagonal2
int nClusters() const; // Number of points in the parent cluster.
StFttCluster* cluster( size_t i); // Parent cluster of the photon.
const StThreeVectorD& xyz() const; // XYZ position in global STAR coordinate
Expand All @@ -36,33 +38,41 @@ class StFttPoint : public StObject {
void setQuadrant(UChar_t quad);
void setX(float x);
void setY(float y);
void setD1(float d1);
void setD2(float d2);
void addCluster(StFttCluster* cluster, UChar_t dir);
void setXYZ(const StThreeVectorD& p3);


void print(int option=0);

private:
UChar_t mPlane;
UChar_t mQuadrant;
UChar_t mPlane=0;
UChar_t mQuadrant=0;
Float_t mX=0.0; // x-position in local coordinate
Float_t mY=0.0; // y-position in local coordinate
Float_t mD1=0.0;
Float_t mD2=0.0;
StFttCluster *mClusters[4];
StThreeVectorD mXYZ; // Photon position in STAR coordinate

ClassDef(StFttPoint, 1)
ClassDef(StFttPoint, 2)
};

inline UChar_t StFttPoint::plane() const { return mPlane; }
inline UChar_t StFttPoint::quadrant() const { return mQuadrant; }
inline float StFttPoint::x() const { return mX; } // x position (cm) in local coords.
inline float StFttPoint::y() const { return mY; } // y position (cm) in local coords.
inline float StFttPoint::d1() const { return mD1; } // x position (cm) in local coords.
inline float StFttPoint::d2() const { return mD2; } // y position (cm) in local coords.
inline StFttCluster* StFttPoint::cluster( size_t i ) { if ( i < 4 ) return mClusters[i]; return nullptr; } // Parent cluster of the photon.
inline const StThreeVectorD& StFttPoint::xyz() const { return mXYZ; }
inline void StFttPoint::setPlane(UChar_t plane) { mPlane = plane; }
inline void StFttPoint::setQuadrant(UChar_t quadrant) { mQuadrant = quadrant; }
inline void StFttPoint::setX(float xpos) { mX = xpos; }
inline void StFttPoint::setY(float ypos) { mY = ypos; }
inline void StFttPoint::setD1(float d1) { mD1 = d1; }
inline void StFttPoint::setD2(float d2) { mD2 = d2; }
inline void StFttPoint::addCluster(StFttCluster* cluster, UChar_t dir) { mClusters[dir] = (cluster); }
inline void StFttPoint::setXYZ(const StThreeVectorD& p3) { mXYZ = p3; }

Expand Down
10 changes: 9 additions & 1 deletion StRoot/StEvent/StFttRawHit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ mPlane(255),
mQuadrant(kFttUnknownQuadrant),
mRow(255),
mStrip(255),
mStripCenter(-999),
mStripLeftEdge(-999),
mStripRightEdge(-999),
mOrientation(kFttUnknownOrientation)
{ /*noop*/ }

Expand Down Expand Up @@ -59,7 +62,12 @@ void StFttRawHit::setMapping( UChar_t mPlane, UChar_t mQuadrant,
this->mOrientation = mOrientation;
}


void StFttRawHit::setStripEdges( Float_t mStripCenter, Float_t mStripLeftEdge, Float_t mStripRightEdge )
{
this->mStripCenter = mStripCenter;
this->mStripLeftEdge = mStripLeftEdge;
this->mStripRightEdge = mStripRightEdge;
}

ostream&
operator<<( ostream &os, const StFttRawHit& rh )
Expand Down
13 changes: 12 additions & 1 deletion StRoot/StEvent/StFttRawHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class StFttRawHit : public StObject {

void setMapping( UChar_t mPlane, UChar_t mQuadrant, UChar_t mRow, UChar_t mStrip, UChar_t mOrientation );

void setStripEdges( Float_t mStripCenter, Float_t mStripLeftEdge, Float_t mStripRightEdge );

void setTime( Short_t mTime ) { this->mTime = mTime; }
// consant getters

Expand All @@ -53,6 +55,9 @@ class StFttRawHit : public StObject {
UChar_t quadrant() const;
UChar_t row() const;
UChar_t strip() const;
Float_t stripCenter() const;
Float_t stripLeftEdge() const;
Float_t stripRightEdge() const;
UChar_t orientation() const;

protected:
Expand All @@ -72,12 +77,15 @@ class StFttRawHit : public StObject {
UChar_t mQuadrant;
UChar_t mRow;
UChar_t mStrip;
Float_t mStripCenter;
Float_t mStripLeftEdge;
Float_t mStripRightEdge;
UChar_t mOrientation;

// StFttCluster *mCluster;
// StFttPoint *mPoint;

ClassDef( StFttRawHit, 3 );
ClassDef( StFttRawHit, 4 );
};

ostream& operator << ( ostream&, const StFttRawHit& digi ); // Printing operator
Expand All @@ -98,6 +106,9 @@ inline UChar_t StFttRawHit::quadrant() const { return mQuadrant; };
inline UChar_t StFttRawHit::row() const { return mRow; };
inline UChar_t StFttRawHit::strip() const { return mStrip; };
inline UChar_t StFttRawHit::orientation() const { return mOrientation; };
inline Float_t StFttRawHit::stripCenter() const { return mStripCenter;};
inline Float_t StFttRawHit::stripLeftEdge() const { return mStripLeftEdge; };
inline Float_t StFttRawHit::stripRightEdge() const { return mStripRightEdge; };


#endif // STETOFDIGI_H
40 changes: 20 additions & 20 deletions StRoot/StFttClusterMaker/StFttClusterMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ StFttClusterMaker::StFttClusterMaker( const char* name )
mDebug( false ), /// print out of all full messages for debugging
mFttDb( nullptr )
{
LOG_DEBUG << "StFttClusterMaker::ctor" << endm;
}

//_____________________________________________________________
Expand All @@ -51,8 +50,6 @@ StFttClusterMaker::~StFttClusterMaker()
Int_t
StFttClusterMaker::Init()
{
LOG_INFO << "StFttClusterMaker::Init" << endm;

return kStOk;
}

Expand All @@ -62,7 +59,7 @@ StFttClusterMaker::InitRun( Int_t runnumber )
{
mRunYear = ( runnumber + 727000 ) / 1000000 + 1999;

LOG_INFO << "runnumber: " << runnumber << " --> year: " << mRunYear << endm;
LOG_DEBUG << "runnumber: " << runnumber << " --> year: " << mRunYear << endm;

return kStOk;
}
Expand Down Expand Up @@ -104,8 +101,6 @@ StFttClusterMaker::Make()
LOG_DEBUG << "Found " << mFttCollection->rawHits().size() << " Ftt Hits" << endm;
ApplyHardwareMap();



// InjectTestData();

// next we need to sort the hits into 1D projections
Expand Down Expand Up @@ -210,11 +205,12 @@ void StFttClusterMaker::InjectTestData(){


bool StFttClusterMaker::PassTimeCut( StFttRawHit * hit ){
int time_cut0 = -999;
int time_cut1 = 999;
int time_cutm = 0;
int time_cut0 = -40;
int time_cut1 = 150;
int time_cutm = 1;
// in principle it could vary VMM to VMM;
mFttDb->getTimeCut(hit, time_cutm, time_cut0, time_cut1);
// mFttDb->getTimeCut(hit, time_cutm, time_cut0, time_cut1);
// LOG_INFO << "Time Cut: " << time_cutm << " , " << time_cut0 << ", " << time_cut1 << endm;
if ( time_cutm == 0 ) // default, cut on bunch crossing
return (hit->time() <= time_cut1 && hit->time() >= time_cut0);

Expand All @@ -229,7 +225,7 @@ StFttRawHit * StFttClusterMaker::FindMaxAdc( std::vector<StFttRawHit *> hits, si
[](const StFttRawHit* a,const StFttRawHit* b) { return a->adc() < b->adc(); });

pos = (itMax - hits.begin());
if ( itMax == hits.end() ) return nullptr;
if ( itMax == hits.end() || pos >= hits.size() ) return nullptr;
return *itMax;
}

Expand Down Expand Up @@ -303,17 +299,16 @@ void StFttClusterMaker::CalculateClusterInfo( StFttCluster * clu ){
float m2Sum = 0;

std::for_each (clu->rawHits().begin(), clu->rawHits().end(), [&](const StFttRawHit *h) {
float x = ( h->strip() * 3.2 - 1.6 ); // replace with CONST

float x = h->stripCenter(); // ideal position is ( h->strip() * 3.2 - 1.6 );
m0Sum += h->adc();
m1Sum += (h->adc() * x);
m2Sum += ( h->adc() * x * x );
});

if ( mDebug ) {
LOG_INFO << "m0Sum = " << m0Sum << endm;
LOG_INFO << "m1Sum = " << m1Sum << endm;
LOG_INFO << "m2Sum = " << m2Sum << endm;
LOG_DEBUG << "m0Sum = " << m0Sum << endm;
LOG_DEBUG << "m1Sum = " << m1Sum << endm;
LOG_DEBUG << "m2Sum = " << m2Sum << endm;
}

// m0Sum = sumAdc
Expand All @@ -326,8 +321,6 @@ void StFttClusterMaker::CalculateClusterInfo( StFttCluster * clu ){
clu->setSigma( sqrt( var ) );
}



std::vector<StFttCluster*> StFttClusterMaker::FindClusters( std::vector< StFttRawHit * > hits ){
std::vector<StFttCluster*> clusters;

Expand Down Expand Up @@ -363,7 +356,7 @@ std::vector<StFttCluster*> StFttClusterMaker::FindClusters( std::vector< StFttRa
});

if ( mDebug ) {
LOG_INFO << "We have " << hits.size() << " hits after removing duplicates" << endm;
LOG_DEBUG << "We have " << hits.size() << " hits after removing duplicates" << endm;
}


Expand All @@ -389,6 +382,14 @@ std::vector<StFttCluster*> StFttClusterMaker::FindClusters( std::vector< StFttRa
clu->setQuadrant ( maxAdcHit->quadrant ( ) );
clu->setRow ( maxAdcHit->row ( ) );
clu->setOrientation ( maxAdcHit->orientation ( ) );
clu->setIndexMaxStrip
( maxAdcHit->strip() );
clu->setMaxStripCenter
( maxAdcHit->stripCenter() );
clu->setMaxStripLeftEdge
( maxAdcHit->stripLeftEdge() );
clu->setMaxStripRightEdge
( maxAdcHit->stripRightEdge() );

// Now find the cluster edges
size_t left = anchor, right = anchor;
Expand Down Expand Up @@ -423,6 +424,5 @@ void StFttClusterMaker::ApplyHardwareMap(){
for ( StFttRawHit* rawHit : mFttCollection->rawHits() ) {
mFttDb->hardwareMap( rawHit );
}

}

Loading