Skip to content

Commit 6c6436e

Browse files
authored
Merge pull request cms-sw#33888 from Dr15Jones/improveCalibFormatsSiStripObjects
Removed CalibTracker/SiStripCommon dependency from CalibFormats/SiStripObjects
2 parents 7207b0d + f589717 commit 6c6436e

File tree

41 files changed

+296
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+296
-199
lines changed

Alignment/OfflineValidation/plugins/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<use name="CondFormats/BeamSpotObjects"/>
1111
<use name="CondFormats/RunInfo"/>
1212
<use name="CondFormats/SiPixelObjects"/>
13+
<use name="CalibTracker/SiStripCommon"/>
1314
<use name="DQM/TrackerRemapper"/>
1415
<use name="DQMServices/Core"/>
1516
<use name="DataFormats/BeamSpot"/>

CalibFormats/SiStripObjects/BuildFile.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<use name="FWCore/MessageLogger"/>
22
<use name="DataFormats/SiStripCommon"/>
33
<use name="CondFormats/SiStripObjects"/>
4-
<use name="CalibTracker/SiStripCommon"/>
54
<use name="DataFormats/TrackerCommon"/>
65
<export>
76
<lib name="1"/>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef CalibFormats_SiStripObjects_SiStripDetInfo_h
2+
#define CalibFormats_SiStripObjects_SiStripDetInfo_h
3+
// -*- C++ -*-
4+
//
5+
// Package: CalibFormats/SiStripObjects
6+
// Class : SiStripDetInfo
7+
//
8+
/**\class SiStripDetInfo SiStripDetInfo.h "SiStripDetInfo.h"
9+
10+
Description: [one line class summary]
11+
12+
Usage:
13+
<usage>
14+
15+
*/
16+
//
17+
// Original Author: Christopher Jones
18+
// Created: Fri, 28 May 2021 20:02:00 GMT
19+
//
20+
21+
// system include files
22+
23+
// user include files
24+
#include <map>
25+
#include <vector>
26+
27+
// forward declarations
28+
29+
class SiStripDetInfo {
30+
public:
31+
struct DetInfo {
32+
DetInfo(){};
33+
DetInfo(unsigned short _nApvs, double _stripLength, float _thickness)
34+
: nApvs(_nApvs), stripLength(_stripLength), thickness(_thickness){};
35+
36+
unsigned short nApvs;
37+
double stripLength;
38+
float thickness;
39+
};
40+
41+
SiStripDetInfo(std::map<uint32_t, DetInfo> iDetData, std::vector<uint32_t> iIDs) noexcept
42+
: detData_{std::move(iDetData)}, detIds_{std::move(iIDs)} {}
43+
44+
SiStripDetInfo() = default;
45+
~SiStripDetInfo() = default;
46+
47+
SiStripDetInfo(const SiStripDetInfo&) = default;
48+
SiStripDetInfo& operator=(const SiStripDetInfo&) = default;
49+
SiStripDetInfo(SiStripDetInfo&&) = default;
50+
SiStripDetInfo& operator=(SiStripDetInfo&&) = default;
51+
52+
// ---------- const member functions ---------------------
53+
const std::vector<uint32_t>& getAllDetIds() const noexcept { return detIds_; }
54+
55+
const std::pair<unsigned short, double> getNumberOfApvsAndStripLength(uint32_t detId) const;
56+
57+
const float& getThickness(uint32_t detId) const;
58+
59+
const std::map<uint32_t, DetInfo>& getAllData() const noexcept { return detData_; }
60+
61+
// ---------- static member functions --------------------
62+
63+
// ---------- member functions ---------------------------
64+
65+
private:
66+
// ---------- member data --------------------------------
67+
std::map<uint32_t, DetInfo> detData_;
68+
std::vector<uint32_t> detIds_;
69+
};
70+
71+
#endif

CalibFormats/SiStripObjects/interface/SiStripGain.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <vector>
4141

4242
class TrackerTopology;
43+
class SiStripDetInfo;
4344

4445
class SiStripGain {
4546
public:
@@ -48,22 +49,25 @@ class SiStripGain {
4849
const SiStripGain &operator=(const SiStripGain &) = delete;
4950

5051
/// Kept for compatibility
51-
inline SiStripGain(const SiStripApvGain &apvgain, const double &factor) : apvgain_(nullptr) {
52-
multiply(apvgain, factor, std::make_pair("", ""));
52+
inline SiStripGain(const SiStripApvGain &apvgain, const double &factor, const SiStripDetInfo &detInfo)
53+
: apvgain_(nullptr) {
54+
multiply(apvgain, factor, std::make_pair("", ""), detInfo);
5355
}
5456

5557
inline SiStripGain(const SiStripApvGain &apvgain,
5658
const double &factor,
57-
const std::pair<std::string, std::string> &recordLabelPair)
59+
const std::pair<std::string, std::string> &recordLabelPair,
60+
const SiStripDetInfo &detInfo)
5861
: apvgain_(nullptr) {
59-
multiply(apvgain, factor, recordLabelPair);
62+
multiply(apvgain, factor, recordLabelPair, detInfo);
6063
}
6164

6265
/// Used to input additional gain values that will be multiplied to the first
6366
/// one
6467
void multiply(const SiStripApvGain &apvgain,
6568
const double &factor,
66-
const std::pair<std::string, std::string> &recordLabelPair);
69+
const std::pair<std::string, std::string> &recordLabelPair,
70+
const SiStripDetInfo &detInfo);
6771

6872
// getters
6973
// For the product of all apvGains
@@ -103,6 +107,7 @@ class SiStripGain {
103107
private:
104108
void fillNewGain(const SiStripApvGain *apvgain,
105109
const double &factor,
110+
SiStripDetInfo const &detInfo,
106111
const SiStripApvGain *apvgain2 = nullptr,
107112
const double &factor2 = 1.);
108113

CalibFormats/SiStripObjects/interface/SiStripQuality.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
#include "CondFormats/RunInfo/interface/RunInfo.h"
2323
#include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
2424
#include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
25-
#include "FWCore/ParameterSet/interface/FileInPath.h"
25+
#include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
2626
#include <vector>
2727

2828
class SiStripDetCabling;
29-
class SiStripDetInfoFileReader;
29+
class SiStripDetInfo;
3030
class TrackerTopology;
3131

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

46-
SiStripQuality(); // takes default file for SiStripDetInfoFileReader
47-
SiStripQuality(edm::FileInPath &);
48-
SiStripQuality(const SiStripQuality &); // copy constructor
46+
SiStripQuality() = delete;
47+
explicit SiStripQuality(SiStripDetInfo);
48+
SiStripQuality(const SiStripQuality &) = default;
49+
SiStripQuality(SiStripQuality &&) = default;
4950

50-
~SiStripQuality() override;
51+
~SiStripQuality() override = default;
5152

5253
void clear() {
5354
v_badstrips.clear();
@@ -76,13 +77,7 @@ class SiStripQuality final : public SiStripBadStrip {
7677

7778
void ReduceGranularity(double);
7879

79-
SiStripQuality &operator+=(const SiStripQuality &);
80-
SiStripQuality &operator-=(const SiStripQuality &);
81-
const SiStripQuality operator-(const SiStripQuality &) const;
82-
bool operator==(const SiStripQuality &) const;
83-
bool operator!=(const SiStripQuality &) const;
84-
85-
edm::FileInPath getFileInPath() const { return FileInPath_; }
80+
SiStripQuality difference(const SiStripQuality &) const;
8681

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

147+
SiStripDetInfo info_;
152148
bool toCleanUp;
153-
edm::FileInPath FileInPath_;
154-
SiStripDetInfoFileReader *reader;
155-
156149
std::vector<BadComponent> BadComponentVect;
157150

158151
const SiStripDetCabling *SiStripDetCabling_;

CalibFormats/SiStripObjects/src/SiStripDelay.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// Created: 26/10/2010
99

1010
#include "CalibFormats/SiStripObjects/interface/SiStripDelay.h"
11-
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
1211
#include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
1312
#include "FWCore/MessageLogger/interface/MessageLogger.h"
1413
#include "FWCore/Utilities/interface/typelookup.h"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// -*- C++ -*-
2+
//
3+
// Package: CalibFormats/SiStripObjects
4+
// Class : SiStripDetInfo
5+
//
6+
// Implementation:
7+
// [Notes on implementation]
8+
//
9+
// Original Author: Christopher Jones
10+
// Created: Fri, 28 May 2021 20:10:25 GMT
11+
//
12+
13+
// system include files
14+
15+
// user include files
16+
#include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
17+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
18+
19+
const std::pair<unsigned short, double> SiStripDetInfo::getNumberOfApvsAndStripLength(uint32_t detId) const {
20+
std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detId);
21+
22+
if (it != detData_.end()) {
23+
return std::pair<unsigned short, double>(it->second.nApvs, it->second.stripLength);
24+
25+
} else {
26+
std::pair<unsigned short, double> defaultValue(0, 0.);
27+
edm::LogWarning(
28+
"SiStripDetInfoFileReader::getNumberOfApvsAndStripLength - Unable to find requested detid. Returning invalid "
29+
"data ")
30+
<< std::endl;
31+
return defaultValue;
32+
}
33+
}
34+
35+
const float& SiStripDetInfo::getThickness(uint32_t detId) const {
36+
std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detId);
37+
38+
if (it != detData_.end()) {
39+
return it->second.thickness;
40+
41+
} else {
42+
static const float defaultValue = 0;
43+
edm::LogWarning("SiStripDetInfo::getThickness - Unable to find requested detid. Returning invalid data ")
44+
<< std::endl;
45+
return defaultValue;
46+
}
47+
}

CalibFormats/SiStripObjects/src/SiStripGain.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88
// Created: Wed Mar 22 12:24:33 CET 2006
99

1010
#include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
11-
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
11+
#include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
1212
#include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
1313
#include "FWCore/MessageLogger/interface/MessageLogger.h"
1414
#include "FWCore/Utilities/interface/typelookup.h"
1515
#include <sstream>
1616

1717
void SiStripGain::multiply(const SiStripApvGain &apvgain,
1818
const double &factor,
19-
const std::pair<std::string, std::string> &recordLabelPair) {
19+
const std::pair<std::string, std::string> &recordLabelPair,
20+
const SiStripDetInfo &detInfo) {
2021
// When inserting the first ApvGain
2122
if (apvgain_ == nullptr) {
2223
if ((factor != 1) && (factor != 0)) {
23-
fillNewGain(&apvgain, factor);
24+
fillNewGain(&apvgain, factor, detInfo);
2425
} else {
2526
// If the normalization factor is one, no need to create a new
2627
// SiStripApvGain
@@ -29,7 +30,7 @@ void SiStripGain::multiply(const SiStripApvGain &apvgain,
2930
} else {
3031
// There is already an ApvGain inside the SiStripGain. Multiply it by the
3132
// new one and save the new pointer.
32-
fillNewGain(apvgain_, 1., &apvgain, factor);
33+
fillNewGain(apvgain_, 1., detInfo, &apvgain, factor);
3334
}
3435
recordLabelPair_.push_back(recordLabelPair);
3536
apvgainVector_.push_back(&apvgain);
@@ -38,20 +39,19 @@ void SiStripGain::multiply(const SiStripApvGain &apvgain,
3839

3940
void SiStripGain::fillNewGain(const SiStripApvGain *apvgain,
4041
const double &factor,
42+
const SiStripDetInfo &detInfo,
4143
const SiStripApvGain *apvgain2,
4244
const double &factor2) {
4345
SiStripApvGain *newApvGain = new SiStripApvGain;
44-
edm::FileInPath fp("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
45-
SiStripDetInfoFileReader reader(fp.fullPath());
46-
const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo> &DetInfos = reader.getAllData();
46+
const auto &DetInfos = detInfo.getAllData();
4747

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

0 commit comments

Comments
 (0)