Skip to content

Commit

Permalink
key mistmatches
Browse files Browse the repository at this point in the history
  • Loading branch information
bazinski committed Jun 7, 2024
1 parent a9cc104 commit 6d1c2c0
Show file tree
Hide file tree
Showing 8 changed files with 615 additions and 50 deletions.
25 changes: 20 additions & 5 deletions Detectors/TRD/qc/include/TRDQC/CoordinateTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
///

#include "DataFormatsTRD/Hit.h"
#include "DataFormatsTRD/HelperMethods.h"
#include "SimulationDataFormat/TrackReference.h"

#include <array>

Expand All @@ -36,7 +38,7 @@ class ChamberSpacePoint
ChamberSpacePoint(int det = -999) : mDetector(det){};
ChamberSpacePoint(int id, int detector, float x, float y, float z, std::array<float, 3> rct, bool inDrift)
: mID(id), mDetector(detector), mX(x), mY(y), mZ(z), mPadrow(rct[0]), mPadcol(rct[1]), mTimebin(rct[2]), mInDrift(inDrift){};

//ChamberSpacePoint(o2::TrackReference &ref): mID(ref->getTrackID()), mDetector(ref->getDetectorId()), mX(ref->X()),mY(ref->Y()), mZ(ref->Z()),
/// check if the space point has been initialized
bool isValid() const { return mDetector >= 0; }

Expand Down Expand Up @@ -74,10 +76,10 @@ class ChamberSpacePoint
bool isInMCM(int detector, int padrow, int mcmcol) const;

/// calculate MCM corresponding to pad row/column
// int getMCM() const { return o2::trd::HelperMethods::getMCMfromPad(mPadrow, mPadcol); }
int getMCM() const { return o2::trd::HelperMethods::getMCMfromPad(mPadrow, mPadcol); }

/// calculate readout board corresponding to pad row/column
// int getROB() const { return o2::trd::HelperMethods::getROBfromPad(mPadrow, mPadcol); }
int getROB() const { return o2::trd::HelperMethods::getROBfromPad(mPadrow, mPadcol); }

protected:
float mX, mY, mZ;
Expand All @@ -98,17 +100,23 @@ std::ostream& operator<<(std::ostream& os, const ChamberSpacePoint& p);
class HitPoint : public ChamberSpacePoint
{
public:
HitPoint(ChamberSpacePoint position, float charge)
: ChamberSpacePoint(position), mCharge(charge)
HitPoint(ChamberSpacePoint position, float charge=0., int trackid=0)
: ChamberSpacePoint(position), mCharge(charge), mTrackID(trackid)
{
}

HitPoint(){};

float getCharge() { return mCharge; }
const uint32_t getUserId()const { return mUserId; }
void setUserId(uint32_t userid){ mUserId=userid; }
const uint32_t getTrackID()const { return mTrackID; }
void setTrackID(uint32_t trackid){ mTrackID=trackid; }

private:
float mCharge{0.0};
uint32_t mUserId{0}; // pulled in from a trackref.
uint32_t mTrackID{0};
};

/// A track segment: a straight line connecting two points. The points are generally given in spatial coordinates,
Expand All @@ -124,6 +132,11 @@ class TrackSegment
{
assert(start.getDetector() == end.getDetector());
}
/* TrackSegment(o2::TrackReference start, o2::TrackReference end, int id, int det)
: mStartPoint(start), mEndPoint(end), mTrackID(id)
{
assert(start.getDetector() == end.getDetector());
}*/

/// check if the space point has been initialized
bool isValid() const { return mStartPoint.isValid(); }
Expand Down Expand Up @@ -187,6 +200,8 @@ class CoordinateTransformer

o2::trd::ChamberSpacePoint MakeSpacePoint(o2::trd::Hit& hit);

o2::trd::ChamberSpacePoint MakeSpacePoint(o2::TrackReference& ref);

/// Legacy, less accurate method to convert local spatial to row/column/time coordinate.
/// This method is only included for comparision, and should be removed in the future.
std::array<float, 3> OrigLocal2RCT(int det, float x, float y, float z);
Expand Down
63 changes: 59 additions & 4 deletions Detectors/TRD/qc/include/TRDQC/RawDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "DataFormatsTRD/Tracklet64.h"
#include "DataFormatsTRD/TriggerRecord.h"
#include "DataFormatsTRD/Hit.h"
#include "TRDBase/Geometry.h"

#include "TRDQC/CoordinateTransformer.h"

Expand All @@ -44,6 +45,40 @@ class TTree;
namespace o2::trd
{

class MCTrackletSegmentInfo {
// simply a place to store the geant entry and exit points and the associated trd tracklet
public:
MCTrackletSegmentInfo(){};
MCTrackletSegmentInfo(o2::TrackReference &in, o2::TrackReference &out, int trackid, int det)
: mEnter(in), mExit(out), mTrackId(trackid), mDet(det) {};
void setEntry(o2::TrackReference& entry){mEnter=entry;mHasEnter=true;}
void setExit(o2::TrackReference& exit){mExit=exit;mHasExit=true;}
void setMidPoint(){/*std::cout << "setting midpoint " << mEnter << " :: " << mExit << "\n";*/ mMidPoint[0]=(mEnter.X()+mExit.X())/2.; mMidPoint[1]=(mEnter.Y()+mExit.Y())/2.; mMidPoint[2]=(mEnter.Z()+mExit.Z())/2.;/* std::cout << "set midpoint\n";*/} // contract the enter and exit points to guarantee both are with in UJ UK;
o2::TrackReference mEnter;
ChamberSpacePoint mEnterSpace;
o2::TrackReference mExit;
ChamberSpacePoint mExitSpace;
std::array<double,3> mMidPoint; // store the mid point of the segment for purposes of figuring out the position in the geometry
o2::trd::Tracklet64 mTracklet; // enables us to match against a tracklet as last resort.
int mTrackId;
int mDet;
int mcmid;
bool mHasEnter{false};
bool mHasExit{false};
//methods for satisfying templates using the exit point (pad side)
int getDetector()const{return mDet;}
int getPadRow()const;//{return 1;}
int getPadCol()const;//{return 1;}
float getROBf()const;//{return 1;}
float getMCMf()const;//{return 1;}
int getROB()const;//{return 1;}
int getMCM()const;//{return 1;}
bool isGood(){ if (mEnter.getLength() >0.1 && mExit.getLength()>0.1) return true; else return false;}
};


std::ostream& operator<<(std::ostream& os, const MCTrackletSegmentInfo& p);

/// RawDataSpan holds ranges pointing to parts of other containers
/// This class helps with restricting the view of digits/trackets/... to part
/// of a timeframe, e.g. data from one event, detector, padrow or MCM.
Expand All @@ -54,7 +89,8 @@ struct RawDataSpan {
boost::iterator_range<std::vector<o2::trd::Digit>::iterator> digits;
boost::iterator_range<std::vector<o2::trd::Tracklet64>::iterator> tracklets;
boost::iterator_range<std::vector<HitPoint>::iterator> hits;
boost::iterator_range<std::vector<o2::TrackReference>::iterator> trackrefs;
// boost::iterator_range<std::vector<o2::TrackReference>::iterator> trackrefs;
boost::iterator_range<std::vector<o2::trd::MCTrackletSegmentInfo>::iterator> trackrefsegments;

/// Sort digits, tracklets and space points by detector, pad row, column
/// The digits, tracklets, hits and other future data members must be sorted
Expand All @@ -77,9 +113,19 @@ struct RawDataSpan {
std::vector<RawDataSpan> iterateByPadRow();
// std::vector<RawDataSpan> iterateDetector();

std::vector<TrackSegment> makeMCTrackSegments();
std::vector<TrackSegment> makeMCTrackSegments(); // this is based on hits
// std::vector<o2::TrackReference> makeMCTrackSegmentsEntryExit();
//this one is based on TrackReferences.
std::vector<TrackSegment> makeMCTrackSegmentsEntryExit();
//std::vector<MCTrackletInfo> makeMCTrackSegmentsEntryExit();
std::vector<o2::TrackReference> makeMCTrackReferences();

// std::vector<MCTrackletSegmentInfo> makeMCTrackSegmentsGeant();
std::vector<TrackSegment> makeMCTrackSegmentsGeant();

//convert a track ref to a hit so that the global and local coordinates are kept togther.
Hit convertTrackReferenceToHit(o2::TrackReference &ref, int trackid, int detector);

// pair<int, int> getMaxADCsumAndChannel();
// int getMaxADCsum(){ return getMaxADCsumAndChannel().first; }

Expand Down Expand Up @@ -162,16 +208,25 @@ class RawDataManager
TFile* mMCFile{0};
TTree* mMCTree{0};
// TTreeReader* mMCReader{0};
std::vector<o2::dataformats::MCEventHeader>* mMCEventHeader{0};
//std::vector<o2::dataformats::MCEventHeader>* mMCEventHeader{0};
o2::dataformats::MCEventHeader* mMCEventHeader{0};
std::vector<o2::MCTrackT<Float_t>>* mMCTracks{0};
std::vector<o2::TrackReference>* mMCTrackReferences{0};
std::vector<o2::TrackReference> mFilteredMCTrackReferences{0};
std::vector<MCTrackletSegmentInfo> mMCTrackletSegmentInfo{0};
std::vector<o2::trd::Hit>* mHits{0};

// MC hits, converted to chamber coordinates
std::vector<o2::trd::HitPoint> mHitPoints;

// process the MC Trackreferences into MCTrackletSegmentInfo
void processTrackReferences();

// MC track references, converted to chamber coordinates
std::vector<o2::TrackReference> mTrackReferences;
std::vector<o2::trd::HitPoint> mTrackReferences;

// MC track references, converted to chamber coordinates, for those matching entry and exit of a chamber.
std::vector<o2::trd::MCTrackletSegmentInfo> mMatchedTrackReferences;

// time frame information (for data only)
std::vector<o2::dataformats::TFIDInfo>* mTFIDs{0};
Expand Down
1 change: 1 addition & 0 deletions Detectors/TRD/qc/include/TRDQC/RawDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RawDisplay
void drawMCTrackSegments();
void drawMCTrackReferences();
void drawTrackRef();
void drawMCTrackRefEntryExit();

void draw()
{
Expand Down
1 change: 0 additions & 1 deletion Detectors/TRD/qc/macros/DrawMCMs.C
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void DrawMCMs(std::string dirname = ".")
disp.drawDigits("text,same");
disp.drawClusters();
disp.drawTracklets();

disp.drawHits();
disp.drawMCTrackSegments();
}
Expand Down
4 changes: 0 additions & 4 deletions Detectors/TRD/qc/macros/PlotTrackRef.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@

using namespace o2::detectors;

/*std::vector<float> transformtracklet(o2::trd::Tracklet64 tracklet) {
// this is ported kind of from tracklettransformer but that needs ccdb
// connections and other stuff.
}*/
class MCTracklet {
public:
MCTracklet(o2::TrackReference &in, o2::TrackReference &out, int trackid,
Expand Down
15 changes: 12 additions & 3 deletions Detectors/TRD/qc/src/CoordinateTransformer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ std::array<float, 3> CoordinateTransformer::OrigLocal2RCT(int det, float x, floa
double lengthCorr = padPlane->getLengthOPad() / padPlane->getLengthIPad();

// calculate position based on inner pad length
rct[0] = -z / padPlane->getLengthIPad() + padPlane->getNrows() / 2;
rct[0] = -z / padPlane->getLengthIPad() + padPlane->getNrows() / 2.0;

// correct row for outer pad rows
if (rct[0] <= 1.0) {
Expand Down Expand Up @@ -125,7 +125,7 @@ std::array<float, 3> CoordinateTransformer::OrigLocal2RCT(int det, float x, floa
// anode region: very rough guess
rct[2] = mT0 - 1.0 + fabs(x);
}

LOGP(info," rct after OrigLocal2RCT : x:y:z {}:{}:{} => {}:{}:{}",x,y,z,rct[0], rct[1], rct[2]);
return rct;
}

Expand All @@ -138,6 +138,15 @@ o2::trd::ChamberSpacePoint CoordinateTransformer::MakeSpacePoint(o2::trd::Hit& h
return o2::trd::ChamberSpacePoint(hit.GetTrackID(), hit.GetDetectorID(), x, y, y, rct, hit.isFromDriftRegion());
}

o2::trd::ChamberSpacePoint CoordinateTransformer::MakeSpacePoint(o2::TrackReference& ref)
{
float x = ref.X();
float y = ref.Y();
float z = ref.Z();
auto rct = Local2RCT(ref.getDetectorId(), x, y, z);
return o2::trd::ChamberSpacePoint(ref.getTrackID(), ref.getDetectorId(), x, y, z, rct, true);
}

namespace o2::trd
{
std::ostream& operator<<(std::ostream& os, const ChamberSpacePoint& p)
Expand All @@ -154,4 +163,4 @@ std::ostream& operator<<(std::ostream& os, const ChamberSpacePoint& p)
<< " pad " << std::setprecision(5) << p.getPadCol() << "]";
return os;
}
}; // namespace o2::trd
}; // namespace o2::trd
Loading

0 comments on commit 6d1c2c0

Please sign in to comment.