New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turning on ClusterRepair for edge hits only #26263
Changes from 5 commits
6da4928
5b963b9
1bb9ed2
4eb37bd
f346656
013e8c3
2568492
7df3dad
8639f5f
bec1c24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,8 @@ class PixelCPEClusterRepair : public PixelCPEBase | |
SiPixelTemplateReco::ClusMatrix & clusterPayload, | ||
int ID) const; | ||
|
||
//Fill IDs for 2D template | ||
void fill2DTemplIDs(); | ||
|
||
|
||
|
||
|
@@ -104,13 +106,40 @@ class PixelCPEClusterRepair : public PixelCPEBase | |
int forwardTemplateID_ ; | ||
std::string templateDir_ ; | ||
|
||
const SiPixel2DTemplateDBObject * templateDBobject2D_; | ||
|
||
// Configure 2D reco. | ||
float minChargeRatio_; | ||
float maxSizeMismatchInY_ ; | ||
|
||
//bool DoCosmics_; | ||
//bool LoadTemplatesFromDB_; | ||
|
||
|
||
// read sub-detectors to recommend 2D | ||
class Rule { | ||
public: | ||
// parse a rule from a string | ||
Rule(const std::string &str) ; | ||
// check this DetId to recommend 2D or not (default false) | ||
bool recommend(DetId detid, const TrackerTopology &tTopo) const { | ||
// check detector | ||
if (detid.subdetId() == subdet_) { | ||
// check layer | ||
if ( (layer_ == 0) || (layer_ == int(tTopo.layer(detid))) ) { | ||
return true; | ||
} | ||
else return false; | ||
} | ||
else return false; | ||
} | ||
private: | ||
int subdet_; | ||
int layer_; | ||
}; | ||
std::vector<Rule> Recommend2D_; | ||
|
||
// run on damaged hits or not | ||
bool RunDamagedClusters_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please start local variables with lowercase letters, as per CMS code rules |
||
}; | ||
|
||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,11 @@ | |
// Commented for now (3/10/17) until we figure out how to resuscitate 2D template splitter | ||
/// #include "RecoLocalTracker/SiPixelRecHits/interface/SiPixelTemplateSplit.h" | ||
|
||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
#include <vector> | ||
#include "boost/multi_array.hpp" | ||
#include <boost/regex.hpp> | ||
#include <map> | ||
|
||
#include <iostream> | ||
|
||
|
@@ -59,8 +60,8 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, | |
// Initialize template store to the selected ID [Morris, 6/25/08] | ||
if ( !SiPixelTemplate2D::pushfile( *templateDBobject2D , thePixelTemp2D_) ) | ||
throw cms::Exception("PixelCPEClusterRepair") | ||
<< "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " | ||
<< (*templateDBobject_).version() << "\n\n"; | ||
<< "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject2D version " | ||
<< (*templateDBobject2D).version() << "\n\n"; | ||
} | ||
else | ||
{ | ||
|
@@ -80,6 +81,8 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, | |
<< "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n"; | ||
} | ||
|
||
templateDBobject2D_ = templateDBobject2D; | ||
fill2DTemplIDs(); | ||
speed_ = conf.getParameter<int>( "speed"); | ||
LogDebug("PixelCPEClusterRepair::PixelCPEClusterRepair:") << | ||
"Template speed = " << speed_ << "\n"; | ||
|
@@ -91,6 +94,55 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, | |
maxSizeMismatchInY_ = conf.getParameter<double>("MaxSizeMismatchInY"); | ||
minChargeRatio_ = conf.getParameter<double>("MinChargeRatio"); | ||
|
||
// read sub-detectors to recommend 2D | ||
// can be: | ||
// XYX (XYZ = PXB, PXE) | ||
// XYZ n (XYZ as above, n = layer, wheel or disk = 1 .. 6 ;) | ||
std::vector<std::string> str_Recommend2D = conf.getParameter<std::vector<std::string> >("Recommend2D"); | ||
Recommend2D_.reserve(str_Recommend2D.size()); | ||
for (std::vector<std::string>::const_iterator it = str_Recommend2D.begin(), ed = str_Recommend2D.end(); it != ed; ++it) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Range based for loop must be preferred here |
||
Recommend2D_.push_back(Rule(*it)); | ||
} | ||
|
||
// run CR on damaged clusters (and not only on edge hits) | ||
RunDamagedClusters_ = conf.existsAs<bool>("RunDamagedClusters")?conf.getParameter<bool>("RunDamagedClusters"):false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should you have defined a fillDescriptions() method in this class. this check wouldn't have been needed/ |
||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Fill all 2D template IDs | ||
//----------------------------------------------------------------------------- | ||
void PixelCPEClusterRepair::fill2DTemplIDs() | ||
{ | ||
auto const & dus = geom_.detUnits(); | ||
unsigned m_detectors = dus.size(); | ||
for(unsigned int i=1;i<7;++i) { | ||
LogDebug("PixelCPEClusterRepair:: LookingForFirstStrip") << "Subdetector " << i | ||
<< " GeomDetEnumerator " << GeomDetEnumerators::tkDetEnum[i] | ||
<< " offset " << geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) | ||
<< " is it strip? " << (geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() ? | ||
dus[geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip() : false); | ||
if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() && | ||
dus[geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip()) { | ||
if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) < m_detectors) m_detectors = geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]); | ||
} | ||
} | ||
LogDebug("LookingForFirstStrip") << " Chosen offset: " << m_detectors; | ||
|
||
|
||
m_DetParams.resize(m_detectors); | ||
LogDebug("PixelCPEClusterRepair::fillDetParams():") <<"caching "<<m_detectors<<" pixel detectors"<<endl; | ||
//Loop through detectors and store 2D template ID | ||
bool printed_info = false; | ||
for (unsigned i=0; i!=m_detectors;++i) { | ||
auto & p=m_DetParams[i]; | ||
|
||
p.detTemplateId2D = templateDBobject2D_->getTemplateID(p.theDet->geographicalId()); | ||
if(p.detTemplateId != p.detTemplateId2D && !printed_info){ | ||
edm::LogInfo("PixelCPEClusterRepair") << "different template ID between 1D and 2D " << p.detTemplateId << " " << p.detTemplateId2D << endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Marco. Yes I think if we want them to be printed out we should promote it to LogWarning. When I tested locally, just running a runTheMatrix workflow did not print out the message, but adding a messageLogger to the config file did produce the message. I will test right now that upgrading to LogWarning does print out a message for standard workflows There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I can confirm that upgrading to LogWarning does print out a message in the standard workflow. So I suggest we do that |
||
printed_info = true; | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
@@ -130,18 +182,18 @@ PixelCPEClusterRepair::localPosition(DetParam const & theDetParam, ClusterParam | |
<< "A non-pixel detector type in here?"; | ||
|
||
|
||
int ID = -9999; | ||
int ID1 = -9999; | ||
int ID2 = -9999; | ||
if ( LoadTemplatesFromDB_ ) { | ||
int ID0 = templateDBobject_->getTemplateID(theDetParam.theDet->geographicalId()); // just to comapre | ||
ID = theDetParam.detTemplateId; | ||
if(ID0!=ID) edm::LogError("PixelCPEClusterRepair") <<" different id"<< ID<<" "<<ID0<<endl; | ||
ID1 = theDetParam.detTemplateId; | ||
ID2 = theDetParam.detTemplateId2D; | ||
} else { // from asci file | ||
if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) ) | ||
ID = barrelTemplateID_ ; // barrel | ||
ID1 = ID2 = barrelTemplateID_ ; // barrel | ||
else | ||
ID = forwardTemplateID_ ; // forward | ||
ID1 = ID2 = forwardTemplateID_ ; // forward | ||
} | ||
//cout << "PixelCPEClusterRepair : ID = " << ID << endl; | ||
//cout << "PixelCPEClusterRepair : ID1 = " << ID1 << endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this commented out line |
||
|
||
// &&& PM, note for later: PixelCPEBase calculates minInX,Y, and maxInX,Y | ||
// Why can't we simply use that and save time with row_offset, col_offset | ||
|
@@ -232,15 +284,15 @@ PixelCPEClusterRepair::localPosition(DetParam const & theDetParam, ClusterParam | |
|
||
|
||
//--- Should we run the 2D reco? | ||
checkRecommend2D(theDetParam, theClusterParam, clusterPayload, ID); | ||
checkRecommend2D(theDetParam, theClusterParam, clusterPayload, ID1); | ||
if ( theClusterParam.recommended2D_ ) { | ||
//--- Call the Template Reco 2d with cluster repair | ||
filled_from_2d = true; | ||
callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID, lp ); | ||
callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID2, lp ); | ||
} | ||
else { | ||
//--- Call the vanilla Template Reco | ||
callTempReco1D( theDetParam, theClusterParam, clusterPayload, ID, lp ); | ||
callTempReco1D( theDetParam, theClusterParam, clusterPayload, ID1, lp ); | ||
filled_from_2d = false; | ||
} | ||
|
||
|
@@ -492,10 +544,15 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus | |
{ | ||
|
||
DetId id = (theDetParam.theDet->geographicalId()); | ||
bool isBarrel = GeomDetEnumerators::isBarrel(theDetParam.thePart); | ||
int layer=ttopo_.layer(id); | ||
if(!isBarrel){ | ||
//only run on barrel | ||
|
||
bool recommend = false; | ||
for (std::vector<Rule>::const_iterator itr = Recommend2D_.begin(), edr = Recommend2D_.end(); itr != edr; ++itr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Range based for loop must be preferred here |
||
recommend = itr->recommend(id, ttopo_); | ||
if(recommend) break; | ||
} | ||
|
||
// only run on those layers recommended by configuration | ||
if(!recommend) { | ||
theClusterParam.recommended2D_ = false; | ||
return; | ||
} | ||
|
@@ -534,8 +591,10 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus | |
theClusterParam.recommended2D_ = true; | ||
theClusterParam.hasBadPixels_ = true; | ||
|
||
//for now, don't try to fix any clusters in layer 1 | ||
if( layer == 1 ) theClusterParam.recommended2D_ = false; | ||
// if not RunDamagedClusters flag, don't try to fix any clusters | ||
if(!RunDamagedClusters_) { | ||
theClusterParam.recommended2D_ = false; | ||
} | ||
|
||
// Figure out what edge flags to set for truncated cluster | ||
// Truncated clusters usually come from dead double columns | ||
|
@@ -644,3 +703,24 @@ PixelCPEClusterRepair::localError(DetParam const & theDetParam, ClusterParam & | |
return LocalError(xerr*xerr, 0, yerr*yerr); | ||
} | ||
|
||
PixelCPEClusterRepair::Rule::Rule(const std::string &str) { | ||
static const boost::regex rule("([A-Z]+)(\\s+(\\d+))?"); | ||
boost::cmatch match; | ||
// match and check it works | ||
if (!regex_match(str.c_str(), match, rule)) | ||
throw cms::Exception("Configuration") << "Rule '" << str << "' not understood.\n"; | ||
|
||
// subdet | ||
subdet_ = -1; | ||
if (strncmp(match[1].first, "PXB", 3) == 0) subdet_ = PixelSubdetector::PixelBarrel; | ||
else if (strncmp(match[1].first, "PXE", 3) == 0) subdet_ = PixelSubdetector::PixelEndcap; | ||
if (subdet_ == -1) { | ||
throw cms::Exception("PixelCPEClusterRepair::Configuration") << "Detector '" << match[1].first << "' not understood. Should be PXB, PXE.\n"; | ||
} | ||
// layer (if present) | ||
if (match[3].first != match[3].second) { | ||
layer_ = atoi(match[3].first); | ||
} else { | ||
layer_ = 0; | ||
} | ||
}//end Rule::Rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please start local variables with lowercase letters, as per CMS code rules