Skip to content

Commit

Permalink
Defined recoInfo parameter for OOT tracks and its computation.
Browse files Browse the repository at this point in the history
Added propagation of track angles, Chi2OverNDF, number of planes used for reconstruction and reco_Info to tracklites
  • Loading branch information
AndreaBellora committed Dec 22, 2018
1 parent b8365c6 commit 3466462
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 27 deletions.
84 changes: 73 additions & 11 deletions DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,99 @@
class CTPPSLocalTrackLite
{
public:
CTPPSLocalTrackLite() : rpId(0), x(0.), x_unc(-1.), y(0.), y_unc(-1.), time(0.), time_unc(-1.)
CTPPSLocalTrackLite() : rpId(0), x(0.), x_unc(-1.), y(0.), y_unc(-1.), tx(999.), tx_unc(-1.), ty(999.), ty_unc(-1.), chiSquaredOverNDF(-1.), reco_info(4), numberOfPointUsedForFit(0), time(0.), time_unc(-1.)
{
}

CTPPSLocalTrackLite(uint32_t pid, float px, float pxu, float py, float pyu, float pt=0., float ptu=-1.)
: rpId(pid), x(px), x_unc(pxu), y(py), y_unc(pyu), time(pt), time_unc(ptu)
{
CTPPSLocalTrackLite(uint32_t pid, float px, float pxu, float py, float pyu, float ptx=999., float ptxu=-1., float pty=999., float ptyu=-1., float pchiSquaredOverNDF=-1., unsigned short preco_info=4, unsigned short pNumberOfPointUsedForFit=-1, float pt=0., float ptu=-1.)
: rpId(pid), x(px), x_unc(pxu), y(py), y_unc(pyu), tx(ptx), tx_unc(ptxu), ty(pty), ty_unc(ptyu), chiSquaredOverNDF(pchiSquaredOverNDF), reco_info(preco_info), numberOfPointUsedForFit(pNumberOfPointUsedForFit), time(pt), time_unc(ptu)
{
}

/// returns the RP id
uint32_t getRPId() const
inline uint32_t getRPId() const
{
return rpId;
}

/// returns the horizontal track position
float getX() const
inline float getX() const
{
return x;
}

/// returns the horizontal track position uncertainty
float getXUnc() const
inline float getXUnc() const
{
return x_unc;
}

/// returns the vertical track position
float getY() const
inline float getY() const
{
return y;
}

/// returns the vertical track position uncertainty
float getYUnc() const
inline float getYUnc() const
{
return y_unc;
}

/// returns the track time
float getTime() const
inline float getTime() const
{
return time;
}

/// returns the track time uncertainty
float getTimeUnc() const
inline float getTimeUnc() const
{
return time_unc;
}

/// returns the track horizontal angle
inline float getTx() const
{
return tx;
}

/// returns the track horizontal angle uncertainty
inline float getTxUnc() const
{
return tx_unc;
}

/// returns the track vertical angle
inline float getTy() const
{
return ty;
}

/// returns the track vertical angle uncertainty
inline float getTyUnc() const
{
return ty_unc;
}

/// returns the track fit chi Squared over NDF
inline float getChiSquaredOverNDF() const
{
return chiSquaredOverNDF;
}

/// returns the track reconstruction info byte
inline unsigned int getReco_info() const
{
return reco_info;
}

/// returns the number of points used for fit
inline unsigned short getNumberOfPointsUsedForFit() const
{
return numberOfPointUsedForFit;
}

protected:
/// RP id
uint32_t rpId;
Expand All @@ -78,8 +120,28 @@ class CTPPSLocalTrackLite
/// vertical hit position and uncertainty, mm
float y, y_unc;

/// horizontal angle and uncertainty, x = x0 + tx*(z-z0)
float tx, tx_unc;

/// vertical angle and uncertainty, y = y0 + ty*(z-z0)
float ty, ty_unc;

/// fit chi^2 over NDF
float chiSquaredOverNDF;

/// Track information byte for bx-shifted runs:
/// reco_info = 0 -> Default value for tracks reconstructed in non-bx-shifted ROCs
/// reco_info = 1 -> Track reconstructed in a bx-shifted ROC with bx-shifted planes only
/// reco_info = 2 -> Track reconstructed in a bx-shifted ROC with non-bx-shifted planes only
/// reco_info = 3 -> Track reconstructed in a bx-shifted ROC both with bx-shifted and non-bx-shifted planes
unsigned short reco_info;

/// number of points used for fit
unsigned short numberOfPointUsedForFit;

/// time information and uncertainty
float time, time_unc;

};

#endif
13 changes: 12 additions & 1 deletion DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CTPPSPixelLocalTrack
}

CTPPSPixelLocalTrack(float z0, const ParameterVector & track_params_vector,
const CovarianceMatrix &par_covariance_matrix, float chiSquared);
const CovarianceMatrix &par_covariance_matrix, float chiSquared, unsigned short recoInfo_=0);

~CTPPSPixelLocalTrack() {}

Expand Down Expand Up @@ -159,6 +159,10 @@ class CTPPSPixelLocalTrack
inline void setValid(bool valid) { valid_ = valid; }

bool operator< (const CTPPSPixelLocalTrack &r);

inline unsigned short getRecoInfo() const { return recoInfo_; }

inline unsigned short getNumberOfPointUsedForFit() const { return (unsigned short) numberOfPointUsedForFit_; }

private:
edm::DetSetVector<CTPPSPixelFittedRecHit> track_hits_vector_;
Expand All @@ -178,8 +182,15 @@ class CTPPSPixelLocalTrack
/// fit valid?
bool valid_;

/// number of points used for the track fit
int numberOfPointUsedForFit_;

/// Track information byte for bx-shifted runs:
/// reco_info = 0 -> Default value for tracks reconstructed in non-bx-shifted ROCs
/// reco_info = 1 -> Track reconstructed in a bx-shifted ROC with bx-shifted planes only
/// reco_info = 2 -> Track reconstructed in a bx-shifted ROC with non-bx-shifted planes only
/// reco_info = 3 -> Track reconstructed in a bx-shifted ROC both with bx-shifted and non-bx-shifted planes
unsigned short recoInfo_;
};

#endif
Expand Down
4 changes: 2 additions & 2 deletions DataFormats/CTPPSReco/src/CTPPSPixelLocalTrack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ AlgebraicSymMatrix22 CTPPSPixelLocalTrack::trackPointInterpolationCovariance(flo
//----------------------------------------------------------------------------------------------------

CTPPSPixelLocalTrack::CTPPSPixelLocalTrack(float z0, const ParameterVector & track_params_vector,
const CovarianceMatrix &par_covariance_matrix, float chiSquared)
const CovarianceMatrix &par_covariance_matrix, float chiSquared, unsigned short recoInfo_)
: track_params_vector_(track_params_vector), z0_(z0), par_covariance_matrix_(par_covariance_matrix),
chiSquared_(chiSquared), valid_(true), numberOfPointUsedForFit_(0)
chiSquared_(chiSquared), valid_(true), numberOfPointUsedForFit_(0), recoInfo_(0)
{

}
Expand Down
6 changes: 4 additions & 2 deletions DataFormats/CTPPSReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
<class name="edm::DetSetVector<CTPPSPixelRecHit>"/>
<class name="edm::Wrapper<edm::DetSetVector<CTPPSPixelRecHit> >"/>

<class name="CTPPSPixelLocalTrack" ClassVersion="3">
<class name="CTPPSPixelLocalTrack" ClassVersion="4">
<version ClassVersion="4" checksum="4102658864"/>
<version ClassVersion="3" checksum="4150373475"/>
</class>
<class name="edm::DetSet<CTPPSPixelLocalTrack>"/>
Expand All @@ -135,7 +136,8 @@

<!-- common objects -->

<class name="CTPPSLocalTrackLite" ClassVersion="3">
<class name="CTPPSLocalTrackLite" ClassVersion="4">
<version ClassVersion="4" checksum="1924864446"/>
<version ClassVersion="3" checksum="3838813906"/>
</class>
<class name="std::vector<CTPPSLocalTrackLite>"/>
Expand Down
1 change: 1 addition & 0 deletions RecoCTPPS/PixelLocal/interface/RPixDetTrackFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class RPixDetTrackFinder{
void setHits(std::map<CTPPSPixelDetId, std::vector<RPixDetPatternFinder::PointInPlane> > *hitMap) {hitMap_ = hitMap; }
virtual void findTracks()=0;
virtual void initialize()=0;
virtual void addRecoInfo(int run)=0;
void clear(){
localTrackVector_.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RPixPlaneCombinatoryTracking : public RPixDetTrackFinder{
~RPixPlaneCombinatoryTracking() override;
void initialize() override;
void findTracks() override;
void addRecoInfo(int run) override;

private:
typedef std::vector<std::vector<uint32_t> > PlaneCombinations;
Expand Down
5 changes: 2 additions & 3 deletions RecoCTPPS/PixelLocal/plugins/CTPPSPixelLocalTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event& iEvent, const edm::EventS
for(const auto & hit : pattern){
CTPPSPixelDetId hitDetId = CTPPSPixelDetId(hit.detId);
CTPPSPixelDetId tmpRomanPotId = hitDetId.getRPId();


if(tmpRomanPotId!=romanPotId){ //check that the hits belong to the same tracking station
throw cms::Exception("CTPPSPixelLocalTrackProducer") << "Hits in the pattern must belong to the same tracking station";
Expand All @@ -251,6 +250,7 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event& iEvent, const edm::EventS
trackFinder_->setGeometry(&geometry);
trackFinder_->setZ0(geometry.getRPTranslation(romanPotId).z());
trackFinder_->findTracks();
trackFinder_->addRecoInfo(iEvent.getRun().id().run());
std::vector<CTPPSPixelLocalTrack> tmpTracksVector = trackFinder_->getLocalTracks();

if(verbosity_>2)edm::LogInfo("CTPPSPixelLocalTrackProducer")<<"tmpTracksVector = "<<tmpTracksVector.size();
Expand All @@ -259,7 +259,6 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event& iEvent, const edm::EventS
continue;
}


for(const auto & track : tmpTracksVector){
++numberOfTracks;
edm::DetSet<CTPPSPixelLocalTrack> &tmpDetSet = foundTracks.find_or_insert(romanPotId);
Expand All @@ -274,7 +273,7 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event& iEvent, const edm::EventS
for(const auto & track : foundTracks){
if(verbosity_>1) edm::LogInfo("CTPPSPixelLocalTrackProducer")<<"Track found in detId = "<<track.detId()<< " number = " << track.size() ;
if(maxTrackPerRomanPot_>=0 && track.size()>(uint32_t)maxTrackPerRomanPot_){
if(verbosity_>1) edm::LogInfo("CTPPSPixelLocalTrackProducer")<<" ---> To many tracks in the pot, cleared";
if(verbosity_>1) edm::LogInfo("CTPPSPixelLocalTrackProducer")<<" ---> Too many tracks in the pot, cleared";
CTPPSPixelDetId tmpRomanPotId = CTPPSPixelDetId(track.detId());
edm::DetSet<CTPPSPixelLocalTrack> &tmpDetSet = foundTracks[tmpRomanPotId];
tmpDetSet.clear();
Expand Down
99 changes: 93 additions & 6 deletions RecoCTPPS/PixelLocal/src/RPixPlaneCombinatoryTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <algorithm>
#include <cmath>

#include "DataFormats/Math/interface/Error.h"
#include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelIndices.h"
#include "TMath.h"
#include <cmath>
#include <algorithm>


//------------------------------------------------------------------------------------------------//

Expand Down Expand Up @@ -177,7 +178,7 @@ void RPixPlaneCombinatoryTracking::findTracks(){
//and the key keeps the reference of which planes and which hit numbers form the combination
PointAndReferenceMap mapOfAllMinRequiredPoint;
//I produce the map for all cominations of all hits with all trackMinNumberOfPoints_ plane combinations
mapOfAllMinRequiredPoint =produceAllHitCombination(possiblePlaneCombinations_);
mapOfAllMinRequiredPoint = produceAllHitCombination(possiblePlaneCombinations_);

//Fit all the possible combinations with minimum number of planes required and find the track with minimum chi2
double theMinChiSquaredOverNDF = maximumChi2OverNDF_+1.; //in order to break the loop in case no track is found;
Expand Down Expand Up @@ -282,9 +283,9 @@ void RPixPlaneCombinatoryTracking::findTracks(){

//search for hit on the other planes which may belong to the same track
//even if they did not contributed to the track
// in case of multiple hit, the closest one to the track will be considered
//If an hit is found these will not be erased from the list of all hits
//If not hit is found, the point on the plane intersecting the track will be saved by a CTPPSPixelFittedRecHit
//in case of multiple hit, the closest one to the track will be considered
//If a hit is found these will not be erased from the list of all hits
//If no hit is found, the point on the plane intersecting the track will be saved by a CTPPSPixelFittedRecHit
//with the isRealHit_ flag set to false
for(const auto & plane : listOfPlaneNotUsedForFit){
CTPPSPixelDetId tmpPlaneId = romanPotId_; //in order to avoid to modify the data member
Expand Down Expand Up @@ -353,6 +354,8 @@ void RPixPlaneCombinatoryTracking::findTracks(){
<< pointOnTrack<<" points belonging to the track\n";
}



} //close of the while loop on all the hits

return;
Expand Down Expand Up @@ -504,6 +507,90 @@ std::vector<RPixPlaneCombinatoryTracking::PointAndReferencePair >
return sortedVector;

}
//------------------------------------------------------------------------------------------------//

// The method sets the tracks recoInfo_ value for localTrackVector_ tracks
void RPixPlaneCombinatoryTracking::addRecoInfo(int run)
{
// Hardcoded shift periods:
// 0 -> Before starting bx shifts.
// 1 -> Starting from run 300802: Sec45 St2 Rp3 Pl 0,2,3 ROC 0 shifted.
// 2 -> Starting from run 303338: No shift.
// 3 -> Starting from run 305169: Sec45 St2 Rp3 Pl 1,3,5 ROC 0 shifted.
// 4 -> Starting from run 305965: Sec45 St2 Rp3 Pl 1,3,5 ROC 0 shifted & Sec56 St2 Rp3 Pl 2,4,5 ROC 5 shifted.

unsigned short shiftPeriod = 0;
unsigned short recoInfo = 0;

std::vector<CTPPSPixelLocalTrack> localTrackVectorWithRecoInfo;
std::vector<int> periodLimits = {300802,303338,305169,305965};
std::map< unsigned short, std::map< CTPPSPixelDetId,std::vector<bool> > > isPlaneShifted;
unsigned short shiftedROC = -1;
CTPPSPixelIndices pixelIndices;

// Selecting the shifted ROC
if(romanPotId_.arm() == 0) shiftedROC = 0;
else shiftedROC = 5;

// Setting the shifted planes during Shift Periods
isPlaneShifted[0][CTPPSPixelDetId(0,2,3)] = {0,0,0,0,0,0}; // Shift Period 0 Sec45
isPlaneShifted[0][CTPPSPixelDetId(1,2,3)] = {0,0,0,0,0,0}; // Shift Period 0 Sec56
isPlaneShifted[1][CTPPSPixelDetId(0,2,3)] = {1,0,1,1,0,0}; // Shift Period 1 Sec45
isPlaneShifted[1][CTPPSPixelDetId(1,2,3)] = {0,0,0,0,0,0}; // Shift Period 1 Sec56
isPlaneShifted[2][CTPPSPixelDetId(0,2,3)] = {0,0,0,0,0,0}; // Shift Period 2 Sec45
isPlaneShifted[2][CTPPSPixelDetId(1,2,3)] = {0,0,0,0,0,0}; // Shift Period 2 Sec56
isPlaneShifted[3][CTPPSPixelDetId(0,2,3)] = {0,1,0,1,0,1}; // Shift Period 3 Sec45
isPlaneShifted[3][CTPPSPixelDetId(1,2,3)] = {0,0,0,0,0,0}; // Shift Period 3 Sec56
isPlaneShifted[4][CTPPSPixelDetId(0,2,3)] = {0,1,0,1,0,1}; // Shift Period 4 Sec45
isPlaneShifted[4][CTPPSPixelDetId(1,2,3)] = {0,0,1,0,1,1}; // Shift Period 4 Sec56

for(const auto & limit : periodLimits){
if (run >= limit) shiftPeriod++;
}

if(verbosity_>=2){
edm::LogInfo("RPixPlaneCombinatoryTracking")<<"Analyzing run: "<<run;
edm::LogInfo("RPixPlaneCombinatoryTracking")<<"Shift period: "<<shiftPeriod;
edm::LogInfo("RPixPlaneCombinatoryTracking")<<"Tracks belong to Arm "<<romanPotId_.arm()<<" Station "<<romanPotId_.station();
edm::LogInfo("RPixPlaneCombinatoryTracking")<<"The shifted ROC is ROC"<<shiftedROC;
}

// Loop over found tracks to set recoInfo_
for(const auto & track : localTrackVector_){
unsigned short bxShiftedPlanesUsed = 0;
unsigned short bxNonShiftedPlanesUsed = 0;
unsigned short hitInShiftedROC = 0;

edm::DetSetVector<CTPPSPixelFittedRecHit> fittedHits = track.getHits();

for(const auto & planeHits : fittedHits){
unsigned short plane = CTPPSPixelDetId(planeHits.detId()).plane();
for(const auto & hit : planeHits){
if(hit.getIsUsedForFit()){
if(pixelIndices.getROCId(hit.minPixelCol(),hit.minPixelRow()) == shiftedROC) hitInShiftedROC++; // Count how many hits are in the shifted ROC
if(isPlaneShifted[shiftPeriod][romanPotId_].at(plane)) bxShiftedPlanesUsed++; // Count how many bx-shifted planes are used
else bxNonShiftedPlanesUsed++; // Count how many non-bx-shifted planes are used
}
}
}

// Set recoInfo_ value
if(bxShiftedPlanesUsed == 3 && bxNonShiftedPlanesUsed == 0 && hitInShiftedROC > 3) recoInfo= 1;
if(bxShiftedPlanesUsed == 0 && bxNonShiftedPlanesUsed == 3 && hitInShiftedROC > 3) recoInfo= 2;
if(bxShiftedPlanesUsed > 0 && bxNonShiftedPlanesUsed > 0 && hitInShiftedROC > 3) recoInfo= 3;

if(bxShiftedPlanesUsed + bxNonShiftedPlanesUsed > 6) {
edm::LogError("RPixPlaneCombinatoryTracking") << "Error in RPixPlaneCombinatoryTracking::addRecoInfo -> " << "More than 6 points found for a track, skipping.";
continue;
}

if(verbosity_>=2)edm::LogInfo("RPixePlaneCombinatoryTracking")<<"Track reconstructed with: "<<bxShiftedPlanesUsed<<" bx-shifted planes, "<<bxNonShiftedPlanesUsed<<" non-bx-shifted planes, "<<hitInShiftedROC<<" hits in the bx-shifted ROC";

// Create new track with recoInfo_, put it in localTrackVectorWithRecoInfo and assign localTrackVectorWithRecoInfo to localTrackVector_
localTrackVectorWithRecoInfo.push_back(CTPPSPixelLocalTrack(track.getZ0(), track.getParameterVector(), track.getCovarianceMatrix(), track.getChiSquared(), recoInfo));
}

localTrackVector_ = localTrackVectorWithRecoInfo;

return;
}
Loading

0 comments on commit 3466462

Please sign in to comment.