Skip to content

Commit

Permalink
Allow also pixel input from tracks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-kaspar committed Sep 21, 2020
1 parent a6d8d38 commit 9c31d33
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Alignment/PPSTrackBased/interface/StraightTrackAlignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h"
#include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h"
#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h"
#include "DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h"

#include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"

Expand Down Expand Up @@ -54,7 +55,8 @@ class StraightTrackAlignment
virtual void begin(const edm::EventSetup&);

virtual void processEvent(const edm::EventID &eventId, const edm::DetSetVector<TotemRPUVPattern> &uvPatternsStrip,
const edm::DetSetVector<CTPPSDiamondRecHit> &hitsDiamond, const edm::DetSetVector<CTPPSPixelRecHit> &hitsPixel);
const edm::DetSetVector<CTPPSDiamondRecHit> &hitsDiamond, const edm::DetSetVector<CTPPSPixelRecHit> &hitsPixel,
const edm::DetSetVector<CTPPSPixelLocalTrack> &tracksPixel);

/// performs analyses and fill results variable
virtual void finish();
Expand Down
16 changes: 15 additions & 1 deletion Alignment/PPSTrackBased/plugins/PPSStraightTrackAligner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h"
#include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h"
#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h"
#include "DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h"

/**
*\brief An EDAnalyzer that runs StraightTrackAlignment.
Expand All @@ -38,10 +39,12 @@ class PPSStraightTrackAligner : public edm::EDAnalyzer
edm::InputTag tagUVPatternsStrip;
edm::InputTag tagDiamondHits;
edm::InputTag tagPixelHits;
edm::InputTag tagPixelLocalTracks;

edm::EDGetTokenT<edm::DetSetVector<TotemRPUVPattern>> tokenUVPatternsStrip;
edm::EDGetTokenT<edm::DetSetVector<CTPPSDiamondRecHit>> tokenDiamondHits;
edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelRecHit>> tokenPixelHits;
edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelLocalTrack>> tokenPixelLocalTracks;

bool worker_initialized;
StraightTrackAlignment worker;
Expand All @@ -68,10 +71,12 @@ PPSStraightTrackAligner::PPSStraightTrackAligner(const ParameterSet &ps) :
tagUVPatternsStrip(ps.getParameter<edm::InputTag>("tagUVPatternsStrip")),
tagDiamondHits(ps.getParameter<edm::InputTag>("tagDiamondHits")),
tagPixelHits(ps.getParameter<edm::InputTag>("tagPixelHits")),
tagPixelLocalTracks(ps.getParameter<edm::InputTag>("tagPixelLocalTracks")),

tokenUVPatternsStrip(consumes<DetSetVector<TotemRPUVPattern>>(tagUVPatternsStrip)),
tokenDiamondHits(consumes<DetSetVector<CTPPSDiamondRecHit>>(tagDiamondHits)),
tokenPixelHits(consumes<DetSetVector<CTPPSPixelRecHit>>(tagPixelHits)),
tokenPixelLocalTracks(consumes<DetSetVector<CTPPSPixelLocalTrack>>(tagPixelLocalTracks)),

worker_initialized(false),
worker(ps)
Expand Down Expand Up @@ -131,8 +136,17 @@ void PPSStraightTrackAligner::analyze(const edm::Event &event, const edm::EventS
pPixelHits = &(*inputPixelHits);
}

DetSetVector<CTPPSPixelLocalTrack> defaultPixelLocalTracks;
const DetSetVector<CTPPSPixelLocalTrack> *pPixelLocalTracks = &defaultPixelLocalTracks;
Handle<DetSetVector<CTPPSPixelLocalTrack>> inputPixelLocalTracks;
if (!tagPixelLocalTracks.label().empty())
{
event.getByToken(tokenPixelLocalTracks, inputPixelLocalTracks);
pPixelLocalTracks = &(*inputPixelLocalTracks);
}

// feed worker
worker.processEvent(event.id(), *pStripUVPatterns, *pDiamondHits, *pPixelHits);
worker.processEvent(event.id(), *pStripUVPatterns, *pDiamondHits, *pPixelHits, *pPixelLocalTracks);
}

//----------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

tagUVPatternsStrip = cms.InputTag("totemRPUVPatternFinder"),
tagDiamondHits = cms.InputTag("ctppsFastLocalSimulation"),
tagPixelHits = cms.InputTag("ctppsFastLocalSimulation"),
tagPixelLocalTracks = cms.InputTag("ctppsFastLocalSimulation"),

# list of RPs for which the alignment parameters shall be optimized
rpIds = cms.vuint32(),
Expand Down
70 changes: 68 additions & 2 deletions Alignment/PPSTrackBased/src/StraightTrackAlignment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ void StraightTrackAlignment::begin(const EventSetup &es)
//----------------------------------------------------------------------------------------------------

void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const DetSetVector<TotemRPUVPattern> &uvPatternsStrip,
const DetSetVector<CTPPSDiamondRecHit> &hitsDiamond, const DetSetVector<CTPPSPixelRecHit> &hitsPixel)
const DetSetVector<CTPPSDiamondRecHit> &hitsDiamond, const edm::DetSetVector<CTPPSPixelRecHit> &hitsPixel,
const DetSetVector<CTPPSPixelLocalTrack> &tracksPixel)
{
eventsTotal++;

Expand Down Expand Up @@ -395,7 +396,7 @@ void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const Det
hitSelection.emplace_back(Hit(pv.detId(), 1, h.x(), h.xWidth() / sqrt(12.), z));
}

// pixels
// pixels: data from rec hits
map<unsigned int, unsigned int> pixelPlaneMultiplicity;
for (const auto &pv : hitsPixel)
pixelPlaneMultiplicity[pv.detId()] += pv.size();
Expand Down Expand Up @@ -428,6 +429,8 @@ void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const Det
double x_unc = sqrt(h.error().xx());
double y_unc = sqrt(h.error().yy());

// TODO: Check this

if (x_unc <= 0.)
x_unc = 10E-3; // mm
if (y_unc <= 0.)
Expand All @@ -438,6 +441,69 @@ void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const Det
}
}

// pixels: data from tracks
for (const auto &pv : tracksPixel)
{
const CTPPSDetId rpId(pv.detId());
const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp();

// skip if RP not selected
if (find(rpIds.begin(), rpIds.end(), rpDecId) == rpIds.end())
continue;

// skip if more than 1 (valid) track in the RP
unsigned int n_valid_tracks = 0;
for (const auto &tr : pv)
{
if (tr.isValid())
n_valid_tracks++;
}

if (n_valid_tracks > 1)
continue;

// go through all valid tracks
for (const auto &tr : pv)
{
if (!tr.isValid())
continue;

// go through all associated rec hits
for (const auto &hv : tr.hits())
{
const CTPPSPixelDetId senId(hv.detId());
const unsigned int senDecId = senId.arm()*1000 + senId.station()*100 + senId.rp()*10 + senId.plane();

// skip if sensor not in geometry
if (! task.geometry.isValidSensorId(senId))
continue;

for (const auto &h : hv)
{
// skip hit if not used for fit
if (!h.isUsedForFit())
continue;

const auto &dg = task.geometry.get(senId);
const double dz1 = dg.getDirectionData(1).dz;
const double dz2 = dg.getDirectionData(2).dz;
const double z = dg.z + h.point().x() * dz1 + h.point().y() * dz2;

double x_unc = sqrt(h.error().xx());
double y_unc = sqrt(h.error().yy());

if (x_unc <= 0.)
x_unc = 10E-3; // mm
if (y_unc <= 0.)
y_unc = 10E-3; // mm

hitSelection.emplace_back(Hit(senId, 1, h.point().x(), x_unc, z));
hitSelection.emplace_back(Hit(senId, 2, h.point().y(), y_unc, z));
}
}
}
}

if (hitSelection.empty())
return;

Expand Down

0 comments on commit 9c31d33

Please sign in to comment.