Skip to content
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

Removed CalibTracker/SiStripCommon dependency from CalibFormats/SiStripObjects #33888

Merged
merged 9 commits into from
Jun 9, 2021
1 change: 1 addition & 0 deletions Alignment/OfflineValidation/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<use name="CondFormats/BeamSpotObjects"/>
<use name="CondFormats/RunInfo"/>
<use name="CondFormats/SiPixelObjects"/>
<use name="CalibTracker/SiStripCommon"/>
<use name="DQM/TrackerRemapper"/>
<use name="DQMServices/Core"/>
<use name="DataFormats/BeamSpot"/>
Expand Down
1 change: 0 additions & 1 deletion CalibFormats/SiStripObjects/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<use name="FWCore/MessageLogger"/>
<use name="DataFormats/SiStripCommon"/>
<use name="CondFormats/SiStripObjects"/>
<use name="CalibTracker/SiStripCommon"/>
<use name="DataFormats/TrackerCommon"/>
<export>
<lib name="1"/>
Expand Down
71 changes: 71 additions & 0 deletions CalibFormats/SiStripObjects/interface/SiStripDetInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef CalibFormats_SiStripObjects_SiStripDetInfo_h
#define CalibFormats_SiStripObjects_SiStripDetInfo_h
// -*- C++ -*-
//
// Package: CalibFormats/SiStripObjects
// Class : SiStripDetInfo
//
/**\class SiStripDetInfo SiStripDetInfo.h "SiStripDetInfo.h"

Description: [one line class summary]

Usage:
<usage>

*/
//
// Original Author: Christopher Jones
// Created: Fri, 28 May 2021 20:02:00 GMT
//

// system include files

// user include files
#include <map>
#include <vector>

// forward declarations

class SiStripDetInfo {
public:
struct DetInfo {
DetInfo(){};
DetInfo(unsigned short _nApvs, double _stripLength, float _thickness)
: nApvs(_nApvs), stripLength(_stripLength), thickness(_thickness){};

unsigned short nApvs;
double stripLength;
float thickness;
};

SiStripDetInfo(std::map<uint32_t, DetInfo> iDetData, std::vector<uint32_t> iIDs) noexcept
: detData_{std::move(iDetData)}, detIds_{std::move(iIDs)} {}

SiStripDetInfo() = default;
~SiStripDetInfo() = default;

SiStripDetInfo(const SiStripDetInfo&) = default;
SiStripDetInfo& operator=(const SiStripDetInfo&) = default;
SiStripDetInfo(SiStripDetInfo&&) = default;
SiStripDetInfo& operator=(SiStripDetInfo&&) = default;

// ---------- const member functions ---------------------
const std::vector<uint32_t>& getAllDetIds() const noexcept { return detIds_; }

const std::pair<unsigned short, double> getNumberOfApvsAndStripLength(uint32_t detId) const;

const float& getThickness(uint32_t detId) const;

const std::map<uint32_t, DetInfo>& getAllData() const noexcept { return detData_; }

// ---------- static member functions --------------------

// ---------- member functions ---------------------------

private:
// ---------- member data --------------------------------
std::map<uint32_t, DetInfo> detData_;
std::vector<uint32_t> detIds_;
};

#endif
15 changes: 10 additions & 5 deletions CalibFormats/SiStripObjects/interface/SiStripGain.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <vector>

class TrackerTopology;
class SiStripDetInfo;

class SiStripGain {
public:
Expand All @@ -48,22 +49,25 @@ class SiStripGain {
const SiStripGain &operator=(const SiStripGain &) = delete;

/// Kept for compatibility
inline SiStripGain(const SiStripApvGain &apvgain, const double &factor) : apvgain_(nullptr) {
multiply(apvgain, factor, std::make_pair("", ""));
inline SiStripGain(const SiStripApvGain &apvgain, const double &factor, const SiStripDetInfo &detInfo)
: apvgain_(nullptr) {
multiply(apvgain, factor, std::make_pair("", ""), detInfo);
}

inline SiStripGain(const SiStripApvGain &apvgain,
const double &factor,
const std::pair<std::string, std::string> &recordLabelPair)
const std::pair<std::string, std::string> &recordLabelPair,
const SiStripDetInfo &detInfo)
: apvgain_(nullptr) {
multiply(apvgain, factor, recordLabelPair);
multiply(apvgain, factor, recordLabelPair, detInfo);
}

/// Used to input additional gain values that will be multiplied to the first
/// one
void multiply(const SiStripApvGain &apvgain,
const double &factor,
const std::pair<std::string, std::string> &recordLabelPair);
const std::pair<std::string, std::string> &recordLabelPair,
const SiStripDetInfo &detInfo);

// getters
// For the product of all apvGains
Expand Down Expand Up @@ -103,6 +107,7 @@ class SiStripGain {
private:
void fillNewGain(const SiStripApvGain *apvgain,
const double &factor,
SiStripDetInfo const &detInfo,
const SiStripApvGain *apvgain2 = nullptr,
const double &factor2 = 1.);

Expand Down
25 changes: 9 additions & 16 deletions CalibFormats/SiStripObjects/interface/SiStripQuality.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#include "CondFormats/RunInfo/interface/RunInfo.h"
#include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
#include <vector>

class SiStripDetCabling;
class SiStripDetInfoFileReader;
class SiStripDetInfo;
class TrackerTopology;

class SiStripQuality final : public SiStripBadStrip {
Expand All @@ -43,11 +43,12 @@ class SiStripQuality final : public SiStripBadStrip {
bool operator()(const BadComponent &p, const uint32_t i) const { return p.detid < i; }
};

SiStripQuality(); // takes default file for SiStripDetInfoFileReader
SiStripQuality(edm::FileInPath &);
SiStripQuality(const SiStripQuality &); // copy constructor
SiStripQuality() = delete;
explicit SiStripQuality(SiStripDetInfo);
SiStripQuality(const SiStripQuality &) = default;
SiStripQuality(SiStripQuality &&) = default;

~SiStripQuality() override;
~SiStripQuality() override = default;

void clear() {
v_badstrips.clear();
Expand Down Expand Up @@ -76,13 +77,7 @@ class SiStripQuality final : public SiStripBadStrip {

void ReduceGranularity(double);

SiStripQuality &operator+=(const SiStripQuality &);
SiStripQuality &operator-=(const SiStripQuality &);
const SiStripQuality operator-(const SiStripQuality &) const;
bool operator==(const SiStripQuality &) const;
bool operator!=(const SiStripQuality &) const;

edm::FileInPath getFileInPath() const { return FileInPath_; }
SiStripQuality difference(const SiStripQuality &) const;

//------- Interface for the user ----------//
bool IsModuleUsable(const uint32_t &detid) const;
Expand Down Expand Up @@ -149,10 +144,8 @@ class SiStripQuality final : public SiStripBadStrip {
const std::vector<int> &differentFeds,
const bool printDebug);

SiStripDetInfo info_;
bool toCleanUp;
edm::FileInPath FileInPath_;
SiStripDetInfoFileReader *reader;

std::vector<BadComponent> BadComponentVect;

const SiStripDetCabling *SiStripDetCabling_;
Expand Down
1 change: 0 additions & 1 deletion CalibFormats/SiStripObjects/src/SiStripDelay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Created: 26/10/2010

#include "CalibFormats/SiStripObjects/interface/SiStripDelay.h"
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/typelookup.h"
Expand Down
47 changes: 47 additions & 0 deletions CalibFormats/SiStripObjects/src/SiStripDetInfo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// -*- C++ -*-
//
// Package: CalibFormats/SiStripObjects
// Class : SiStripDetInfo
//
// Implementation:
// [Notes on implementation]
//
// Original Author: Christopher Jones
// Created: Fri, 28 May 2021 20:10:25 GMT
//

// system include files

// user include files
#include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

const std::pair<unsigned short, double> SiStripDetInfo::getNumberOfApvsAndStripLength(uint32_t detId) const {
std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detId);

if (it != detData_.end()) {
return std::pair<unsigned short, double>(it->second.nApvs, it->second.stripLength);

} else {
std::pair<unsigned short, double> defaultValue(0, 0.);
edm::LogWarning(
"SiStripDetInfoFileReader::getNumberOfApvsAndStripLength - Unable to find requested detid. Returning invalid "
"data ")
<< std::endl;
return defaultValue;
}
}

const float& SiStripDetInfo::getThickness(uint32_t detId) const {
std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detId);

if (it != detData_.end()) {
return it->second.thickness;

} else {
static const float defaultValue = 0;
edm::LogWarning("SiStripDetInfo::getThickness - Unable to find requested detid. Returning invalid data ")
<< std::endl;
return defaultValue;
}
}
16 changes: 8 additions & 8 deletions CalibFormats/SiStripObjects/src/SiStripGain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
// Created: Wed Mar 22 12:24:33 CET 2006

#include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
#include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/typelookup.h"
#include <sstream>

void SiStripGain::multiply(const SiStripApvGain &apvgain,
const double &factor,
const std::pair<std::string, std::string> &recordLabelPair) {
const std::pair<std::string, std::string> &recordLabelPair,
const SiStripDetInfo &detInfo) {
// When inserting the first ApvGain
if (apvgain_ == nullptr) {
if ((factor != 1) && (factor != 0)) {
fillNewGain(&apvgain, factor);
fillNewGain(&apvgain, factor, detInfo);
} else {
// If the normalization factor is one, no need to create a new
// SiStripApvGain
Expand All @@ -29,7 +30,7 @@ void SiStripGain::multiply(const SiStripApvGain &apvgain,
} else {
// There is already an ApvGain inside the SiStripGain. Multiply it by the
// new one and save the new pointer.
fillNewGain(apvgain_, 1., &apvgain, factor);
fillNewGain(apvgain_, 1., detInfo, &apvgain, factor);
}
recordLabelPair_.push_back(recordLabelPair);
apvgainVector_.push_back(&apvgain);
Expand All @@ -38,20 +39,19 @@ void SiStripGain::multiply(const SiStripApvGain &apvgain,

void SiStripGain::fillNewGain(const SiStripApvGain *apvgain,
const double &factor,
const SiStripDetInfo &detInfo,
const SiStripApvGain *apvgain2,
const double &factor2) {
SiStripApvGain *newApvGain = new SiStripApvGain;
edm::FileInPath fp("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
SiStripDetInfoFileReader reader(fp.fullPath());
const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo> &DetInfos = reader.getAllData();
const auto &DetInfos = detInfo.getAllData();

// Loop on the apvgain in input and fill the newApvGain with the
// values/factor.
std::vector<uint32_t> detIds;
apvgain->getDetIds(detIds);
std::vector<uint32_t>::const_iterator it = detIds.begin();
for (; it != detIds.end(); ++it) {
std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator detInfoIt = DetInfos.find(*it);
auto detInfoIt = DetInfos.find(*it);
if (detInfoIt != DetInfos.end()) {
std::vector<float> theSiStripVector;

Expand Down
Loading