Skip to content

Commit

Permalink
Merge pull request #40683 from fabferro/allBadPots_130
Browse files Browse the repository at this point in the history
PPS pixel track reco in bad pots
  • Loading branch information
cmsbuild authored Feb 10, 2023
2 parents cd4e36d + b71c4b7 commit 8e150d4
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 47 deletions.
2 changes: 1 addition & 1 deletion RecoPPS/Local/interface/RPixDetPatternFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RPixDetPatternFinder {
typedef std::vector<PointInPlane> Road;

void setHits(const edm::DetSetVector<CTPPSPixelRecHit> *hitVector) { hitVector_ = hitVector; }
virtual void findPattern(bool isbadpot) = 0;
virtual void findPattern(bool *is2planepot) = 0;
void clear() { patternVector_.clear(); }
std::vector<Road> const &getPatterns() const { return patternVector_; }
void setGeometry(const CTPPSGeometry *geometry) { geometry_ = geometry; }
Expand Down
2 changes: 1 addition & 1 deletion RecoPPS/Local/interface/RPixRoadFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RPixRoadFinder : public RPixDetPatternFinder {
public:
explicit RPixRoadFinder(const edm::ParameterSet &param);
~RPixRoadFinder() override;
void findPattern(bool isbadpot) override;
void findPattern(bool *is2planepot) override;

private:
int verbosity_;
Expand Down
58 changes: 45 additions & 13 deletions RecoPPS/Local/plugins/CTPPSPixelLocalTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ void CTPPSPixelLocalTrackProducer::fillDescriptions(edm::ConfigurationDescriptio
desc.add<double>("roadRadius", 1.0)->setComment("radius of pattern search window");
desc.add<int>("minRoadSize", 3)->setComment("minimum number of points in a pattern");
desc.add<int>("maxRoadSize", 20)->setComment("maximum number of points in a pattern");
//parameter for bad pot reconstruction patch 45-220-fr 2022
desc.add<double>("roadRadiusBadPot", 0.5)->setComment("radius of pattern search window for bad Pot");
//parameter for 2-plane-pot reconstruction patch in run 3
desc.add<double>("roadRadiusBadPot", 0.5)->setComment("radius of pattern search window for 2 plane pot");

descriptions.add("ctppsPixelLocalTracks", desc);
}
Expand All @@ -170,30 +170,62 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event &iEvent, const edm::EventS
geometryWatcher_.check(iSetup);

// get mask
bool isBadPot_45_220 = false;

// 2 planes pot flag vector 0=45-220, 1=45-210, 2=56-210, 3=56-220
bool is2PlanePotV[4] = {false};

if (!recHits->empty()) {
const auto &mask = iSetup.getData(tokenCTPPSPixelAnalysisMask_);

// Read Mask checking if 45-220-far is masked as bad and needs special treatment
// Read Mask checking if 4 planes are masked and pot needs special treatment
std::map<uint32_t, CTPPSPixelROCAnalysisMask> const &maschera = mask.analysisMask;

bool mask_45_220[6][6] = {{false}};
// vector of masked rocs
bool maskV[4][6][6] = {{{false}}};

for (auto const &det : maschera) {
CTPPSPixelDetId detId(det.first);
unsigned int rocNum = (det.first & rocMask) >> rocOffset;
if (rocNum > 5 || detId.plane() > 5)
throw cms::Exception("InvalidRocOrPlaneNumber") << "roc number from mask: " << rocNum;

if (detId.arm() == 0 && detId.station() == 2 && detId.rp() == 3) { // pot 45-220-far
if (det.second.maskedPixels.size() == rocSizeInPixels) { // roc fully masked
mask_45_220[detId.plane()][rocNum] = true;
if (detId.arm() == 0 && detId.rp() == 3) {
if (detId.station() == 2) { // pot 45-220-far
if (det.second.maskedPixels.size() == rocSizeInPixels || det.second.fullMask == true) { // roc fully masked
maskV[0][detId.plane()][rocNum] = true;
}
} else if (detId.station() == 0) { // pot 45-210-far
if (det.second.maskedPixels.size() == rocSizeInPixels || det.second.fullMask == true) { // roc fully masked
maskV[1][detId.plane()][rocNum] = true;
}
}
} else if (detId.arm() == 1 && detId.rp() == 3) {
if (detId.station() == 0) { // pot 56-210-far
if (det.second.maskedPixels.size() == rocSizeInPixels || det.second.fullMask == true) { // roc fully masked
maskV[2][detId.plane()][rocNum] = true;
}
} else if (detId.station() == 2) { // pot 56-220-far
if (det.second.maskedPixels.size() == rocSizeInPixels || det.second.fullMask == true) { // roc fully masked
maskV[3][detId.plane()][rocNum] = true;
}
}
}
}
// search for specific pattern that requires special reconstruction (use of two plane tracks)

// search for specific pattern that requires special reconstruction (isBadPot)
isBadPot_45_220 = mask_45_220[1][4] && mask_45_220[1][5] && mask_45_220[2][4] && mask_45_220[2][5] &&
mask_45_220[3][4] && mask_45_220[3][5] && mask_45_220[4][4] && mask_45_220[4][5];
for (unsigned int i = 0; i < 4; i++) {
unsigned int numberOfMaskedPlanes = 0;
for (unsigned int j = 0; j < 6; j++) {
if (maskV[i][j][0] && maskV[i][j][1] && maskV[i][j][4] && maskV[i][j][5])
numberOfMaskedPlanes++;
}
if (numberOfMaskedPlanes == 4)
is2PlanePotV[i] = true; // search for exactly 4 planes fully masked
edm::LogInfo("CTPPSPixelLocalTrackProducer") << " Masked planes in Pot #" << i << " = " << numberOfMaskedPlanes;
if (is2PlanePotV[i])
edm::LogInfo("CTPPSPixelLocalTrackProducer")
<< " Enabling 2 plane track reconstruction for pot #" << i << " (0=45-220, 1=45-210, 2=56-210, 3=56-220) ";
}
}
std::vector<CTPPSPixelDetId> listOfPotWithHighOccupancyPlanes;
std::map<CTPPSPixelDetId, uint32_t> mapHitPerPot;
Expand All @@ -215,7 +247,7 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event &iEvent, const edm::EventS
if (maxHitPerPlane_ >= 0 && hitOnPlane > (uint32_t)maxHitPerPlane_) {
if (verbosity_ > 2)
edm::LogInfo("CTPPSPixelLocalTrackProducer")
<< " ---> To many hits in the plane, pot will be excluded from tracking cleared";
<< " ---> Too many hits in the plane, pot will be excluded from tracking cleared";
listOfPotWithHighOccupancyPlanes.push_back(tmpRomanPotId);
}
}
Expand All @@ -240,7 +272,7 @@ void CTPPSPixelLocalTrackProducer::produce(edm::Event &iEvent, const edm::EventS
patternFinder_->clear();
patternFinder_->setHits(&recHitVector);
patternFinder_->setGeometry(&geometry);
patternFinder_->findPattern(isBadPot_45_220);
patternFinder_->findPattern(is2PlanePotV);
std::vector<RPixDetPatternFinder::Road> patternVector = patternFinder_->getPatterns();

//loop on all the patterns
Expand Down
12 changes: 11 additions & 1 deletion RecoPPS/Local/src/RPixDetClusterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ void RPixDetClusterizer::buildClusters(unsigned int detId,
std::map<uint32_t, CTPPSPixelROCAnalysisMask> const &mask = maskera->analysisMask;
std::set<std::pair<unsigned char, unsigned char> > maskedPixels;

bool fullyMaskedRoc[6][6] = {{false}};
CTPPSPixelDetId currentId(detId);

// read and store masked pixels after converting ROC numbering into module numbering
CTPPSPixelIndices pI;
for (auto const &det : mask) {
Expand All @@ -42,6 +45,8 @@ void RPixDetClusterizer::buildClusters(unsigned int detId,
unsigned int rocNum = (det.first & rocMask) >> rocOffset;
if (rocNum > 5)
throw cms::Exception("InvalidRocNumber") << "roc number from mask: " << rocNum;
if (det.second.fullMask)
fullyMaskedRoc[currentId.plane()][rocNum] = true;
for (auto const &paio : det.second.maskedPixels) {
std::pair<unsigned char, unsigned char> pa = paio;
int modCol, modRow;
Expand Down Expand Up @@ -76,7 +81,12 @@ void RPixDetClusterizer::buildClusters(unsigned int detId,

// check if pixel is noisy or dead (i.e. in the mask)
const bool is_in = maskedPixels.find(pixel) != maskedPixels.end();
if (!is_in) {

// check if pixel inside a fully masked roc
int piano = currentId.plane();
int rocId = pI.getROCId(column, row);

if (!is_in && !fullyMaskedRoc[piano][rocId]) {
//calibrate digi and store the new ones
electrons = calibrate(detId, adc, row, column, pcalibrations);
if (electrons < SeedADCThreshold_ * ElectronADCGain_)
Expand Down
4 changes: 2 additions & 2 deletions RecoPPS/Local/src/RPixPlaneCombinatoryTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void RPixPlaneCombinatoryTracking::findTracks(int run) {
//The loop stops when the number of planes with recorded hits is less than the minimum number of planes required
//or if the track with minimum chiSquare found has a chiSquare higher than the maximum required

// bad Pot patch 45-220-fr 2022 -- beginning
// bad Pot patch -- beginning
// check number of hits in road
unsigned int hitNum = 0;
for (const auto &plane : *hitMap_) {
Expand Down Expand Up @@ -213,7 +213,7 @@ void RPixPlaneCombinatoryTracking::findTracks(int run) {
// save track in collection
localTrackVector_.push_back(track);
}
// bad Pot patch 45-220-fr 2022 -- end
// bad Pot patch -- end

while (hitMap_->size() >= trackMinNumberOfPoints_) {
if (verbosity_ >= 1)
Expand Down
65 changes: 36 additions & 29 deletions RecoPPS/Local/src/RPixRoadFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ RPixRoadFinder::~RPixRoadFinder() {}

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

void RPixRoadFinder::findPattern(bool isBadPot) {
void RPixRoadFinder::findPattern(bool* is2PlanePot) {
Road temp_all_hits;
temp_all_hits.clear();

Road temp_all_hits_badPot;
temp_all_hits_badPot.clear();
Road temp_all_hits_2PlanePot[4];

// convert local hit sto global and push them to a vector
for (const auto& ds_rh2 : *hitVector_) {
Expand Down Expand Up @@ -69,14 +66,19 @@ void RPixRoadFinder::findPattern(bool isBadPot) {

math::Error<3>::type globalError = ROOT::Math::SimilarityT(theRotationTMatrix, localError);

// create new collection for planes 0 and 5 of pot 45-220-fr

if (isBadPot == true && myid.arm() == 0 && myid.station() == 2 && localV.x() > 0 &&
(myid.plane() == 0 || myid.plane() == 5)) { // 45-220-far
// create new collections for bad (2 planes) and good pots

temp_all_hits_badPot.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
if (is2PlanePot[0] == true && myid.arm() == 0 && myid.station() == 2) { // 45-220
temp_all_hits_2PlanePot[0].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
} else if (is2PlanePot[1] == true && myid.arm() == 0 && myid.station() == 0) { // 45-210
temp_all_hits_2PlanePot[1].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
} else if (is2PlanePot[2] == true && myid.arm() == 1 && myid.station() == 0) { // 56-210
temp_all_hits_2PlanePot[2].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
} else if (is2PlanePot[3] == true && myid.arm() == 1 && myid.station() == 2) { // 56-220
temp_all_hits_2PlanePot[3].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
} else {
temp_all_hits.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
}
temp_all_hits.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
}
}

Expand Down Expand Up @@ -115,30 +117,35 @@ void RPixRoadFinder::findPattern(bool isBadPot) {
}
// end of algorithm

// badPot algorithm
Road::iterator it_gh1_bP = temp_all_hits_badPot.begin();
Road::iterator it_gh2_bP;
// 2PlanePot algorithm

while (it_gh1_bP != temp_all_hits_badPot.end() && temp_all_hits_badPot.size() >= 2) {
Road temp_road;
for (unsigned int i = 0; i < 4; i++) {
if (is2PlanePot[i]) {
Road::iterator it_gh1_bP = temp_all_hits_2PlanePot[i].begin();
Road::iterator it_gh2_bP;

it_gh2_bP = it_gh1_bP;
while (it_gh1_bP != temp_all_hits_2PlanePot[i].end() && temp_all_hits_2PlanePot[i].size() >= 2) {
Road temp_road;

const auto currPoint = it_gh1_bP->globalPoint;
it_gh2_bP = it_gh1_bP;

while (it_gh2_bP != temp_all_hits_badPot.end()) {
const auto subtraction = currPoint - it_gh2_bP->globalPoint;
const auto currPoint = it_gh1_bP->globalPoint;

if (subtraction.Rho() < roadRadiusBadPot_) {
temp_road.push_back(*it_gh2_bP);
temp_all_hits_badPot.erase(it_gh2_bP);
} else {
++it_gh2_bP;
}
}
while (it_gh2_bP != temp_all_hits_2PlanePot[i].end()) {
const auto subtraction = currPoint - it_gh2_bP->globalPoint;

if (temp_road.size() == 2) { // look for isolated tracks
patternVector_.push_back(temp_road);
if (subtraction.Rho() < roadRadiusBadPot_) {
temp_road.push_back(*it_gh2_bP);
temp_all_hits_2PlanePot[i].erase(it_gh2_bP);
} else {
++it_gh2_bP;
}
}

if (temp_road.size() == 2) { // look for isolated tracks
patternVector_.push_back(temp_road);
}
}
}
}
}

0 comments on commit 8e150d4

Please sign in to comment.