Skip to content

Commit 2c77c10

Browse files
committed
revert change of ShallowGainCalibration from stream to global module
1 parent 3da8316 commit 2c77c10

File tree

2 files changed

+34
-53
lines changed

2 files changed

+34
-53
lines changed

CalibTracker/SiStripCommon/plugins/ShallowGainCalibration.cc

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <memory>
21
#include "ShallowGainCalibration.h"
32

43
using namespace edm;
@@ -8,8 +7,9 @@ using namespace std;
87
ShallowGainCalibration::ShallowGainCalibration(const edm::ParameterSet& iConfig)
98
: tracks_token_(consumes<edm::View<reco::Track>>(iConfig.getParameter<edm::InputTag>("Tracks"))),
109
association_token_(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("Tracks"))),
11-
geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
12-
gainToken_(esConsumes<SiStripGain, SiStripGainRcd>()),
10+
trackerGeometry_token_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
11+
gain_token_(esConsumes<SiStripGain, SiStripGainRcd>()),
12+
tkGeom_token_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
1313
Suffix(iConfig.getParameter<std::string>("Suffix")),
1414
Prefix(iConfig.getParameter<std::string>("Prefix")) {
1515
produces<std::vector<int>>(Prefix + "trackindex" + Suffix);
@@ -32,7 +32,7 @@ ShallowGainCalibration::ShallowGainCalibration(const edm::ParameterSet& iConfig)
3232
produces<std::vector<double>>(Prefix + "gainusedTick" + Suffix);
3333
}
3434

35-
void ShallowGainCalibration::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
35+
void ShallowGainCalibration::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
3636
auto trackindex = std::make_unique<std::vector<int>>();
3737
auto rawid = std::make_unique<std::vector<unsigned int>>();
3838
auto localdirx = std::make_unique<std::vector<double>>();
@@ -52,14 +52,13 @@ void ShallowGainCalibration::produce(edm::StreamID, edm::Event& iEvent, const ed
5252
auto gainused = std::make_unique<std::vector<double>>();
5353
auto gainusedTick = std::make_unique<std::vector<double>>();
5454

55-
edm::ESHandle<SiStripGain> gainHandle = iSetup.getHandle(gainToken_);
55+
m_tracker = &iSetup.getData(trackerGeometry_token_);
56+
edm::ESHandle<SiStripGain> gainHandle = iSetup.getHandle(gain_token_);
5657
edm::Handle<edm::View<reco::Track>> tracks;
5758
iEvent.getByToken(tracks_token_, tracks);
5859
edm::Handle<TrajTrackAssociationCollection> associations;
5960
iEvent.getByToken(association_token_, associations);
6061

61-
auto bundle = *runCache(iEvent.getRun().index());
62-
6362
for (TrajTrackAssociationCollection::const_iterator association = associations->begin();
6463
association != associations->end();
6564
association++) {
@@ -112,8 +111,7 @@ void ShallowGainCalibration::produce(edm::StreamID, edm::Event& iEvent, const ed
112111
bool Saturation = false;
113112
bool Overlapping = false;
114113
unsigned int Charge = 0;
115-
auto thicknessMap = bundle.getThicknessMap();
116-
double Path = (10.0 * thicknessMap[DetId]) / fabs(cosine);
114+
double Path = (10.0 * thickness(DetId)) / fabs(cosine);
117115
double PrevGain = -1;
118116
double PrevGainTick = -1;
119117
int FirstStrip = 0;
@@ -201,7 +199,7 @@ void ShallowGainCalibration::produce(edm::StreamID, edm::Event& iEvent, const ed
201199
nstrips->push_back(NStrips);
202200
saturation->push_back(Saturation);
203201
overlapping->push_back(Overlapping);
204-
farfromedge->push_back(StripCluster ? isFarFromBorder(&trajState, DetId, bundle.getTrackerGeometry()) : true);
202+
farfromedge->push_back(StripCluster ? isFarFromBorder(&trajState, DetId, &iSetup) : true);
205203
charge->push_back(Charge);
206204
path->push_back(Path);
207205
#ifdef ExtendedCALIBTree
@@ -235,7 +233,9 @@ void ShallowGainCalibration::produce(edm::StreamID, edm::Event& iEvent, const ed
235233

236234
bool ShallowGainCalibration::isFarFromBorder(TrajectoryStateOnSurface* trajState,
237235
const uint32_t detid,
238-
const TrackerGeometry* tkGeom) const {
236+
const edm::EventSetup* iSetup) {
237+
edm::ESHandle<TrackerGeometry> tkGeom = iSetup->getHandle(tkGeom_token_);
238+
239239
LocalPoint HitLocalPos = trajState->localPosition();
240240
LocalError HitLocalError = trajState->localError().positionError();
241241

@@ -266,26 +266,23 @@ bool ShallowGainCalibration::isFarFromBorder(TrajectoryStateOnSurface* trajState
266266
return true;
267267
}
268268

269-
std::shared_ptr<shallowGainCalibration::bundle> ShallowGainCalibration::globalBeginRun(
270-
edm::Run const& iRun, edm::EventSetup const& iSetup) const {
271-
edm::ESHandle<TrackerGeometry> theTrackerGeometry = iSetup.getHandle(geomToken_);
272-
auto bundle = std::make_shared<shallowGainCalibration::bundle>(theTrackerGeometry.product());
273-
274-
for (const auto& it : theTrackerGeometry->detUnits()) {
269+
double ShallowGainCalibration::thickness(DetId id) {
270+
map<DetId, double>::iterator th = m_thicknessMap.find(id);
271+
if (th != m_thicknessMap.end())
272+
return (*th).second;
273+
else {
275274
double detThickness = 1.;
276-
auto id = (it->geographicalId()).rawId();
277-
275+
//compute thickness normalization
276+
const GeomDetUnit* it = m_tracker->idToDetUnit(DetId(id));
278277
bool isPixel = dynamic_cast<const PixelGeomDetUnit*>(it) != nullptr;
279278
bool isStrip = dynamic_cast<const StripGeomDetUnit*>(it) != nullptr;
280-
281279
if (!isPixel && !isStrip) {
282280
throw cms::Exception("Logic Error") << "\t\t this detID doesn't seem to belong to the Tracker";
283281
} else {
284282
detThickness = it->surface().bounds().thickness();
285283
}
286-
bundle.get()->updateMap(id, detThickness);
284+
285+
m_thicknessMap[id] = detThickness; //computed value
286+
return detThickness;
287287
}
288-
return bundle;
289288
}
290-
291-
void ShallowGainCalibration::globalEndRun(edm::Run const&, edm::EventSetup const&) const {}

CalibTracker/SiStripCommon/plugins/ShallowGainCalibration.h

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SHALLOW_GAINCALIBRATION_PRODUCER
22
#define SHALLOW_GAINCALIBRATION_PRODUCER
33

4-
#include "FWCore/Framework/interface/global/EDProducer.h"
4+
#include "FWCore/Framework/interface/stream/EDProducer.h"
55
#include "FWCore/Framework/interface/Frameworkfwd.h"
66

77
#include "CalibTracker/SiStripCommon/interface/ShallowTools.h"
@@ -16,8 +16,6 @@
1616
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
1717
#include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h"
1818
#include "CondFormats/DataRecord/interface/SiStripLorentzAngleRcd.h"
19-
#include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
20-
#include "CalibTracker/Records/interface/SiStripGainRcd.h"
2119
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
2220
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
2321
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
@@ -50,41 +48,27 @@
5048
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
5149
#include "DataFormats/DetId/interface/DetId.h"
5250
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
53-
#include "FWCore/Utilities/interface/ESGetToken.h"
54-
55-
using DetIdMap = std::map<uint32_t, double>;
56-
57-
namespace shallowGainCalibration {
58-
struct bundle {
59-
bundle(const TrackerGeometry* trackerG) : tkGeo_(trackerG), value_({{0, 0.}}) {}
60-
void updateMap(uint32_t id, double thickness) { value_.insert(std::make_pair(id, thickness)); }
61-
DetIdMap getThicknessMap() { return value_; }
62-
const TrackerGeometry* getTrackerGeometry() { return tkGeo_; }
6351

64-
private:
65-
const TrackerGeometry* tkGeo_;
66-
DetIdMap value_;
67-
};
68-
} // namespace shallowGainCalibration
69-
70-
class ShallowGainCalibration : public edm::global::EDProducer<edm::RunCache<shallowGainCalibration::bundle> > {
52+
class ShallowGainCalibration : public edm::stream::EDProducer<> {
7153
public:
7254
explicit ShallowGainCalibration(const edm::ParameterSet&);
73-
std::shared_ptr<shallowGainCalibration::bundle> globalBeginRun(edm::Run const&,
74-
edm::EventSetup const&) const override;
75-
void globalEndRun(edm::Run const&, edm::EventSetup const&) const override;
7655

7756
private:
7857
const edm::EDGetTokenT<edm::View<reco::Track> > tracks_token_;
7958
const edm::EDGetTokenT<TrajTrackAssociationCollection> association_token_;
80-
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
81-
const edm::ESGetToken<SiStripGain, SiStripGainRcd> gainToken_;
59+
60+
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometry_token_;
61+
const edm::ESGetToken<SiStripGain, SiStripGainRcd> gain_token_;
62+
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkGeom_token_;
63+
8264
std::string Suffix;
8365
std::string Prefix;
8466

85-
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
86-
bool isFarFromBorder(TrajectoryStateOnSurface* trajState,
87-
const uint32_t detid,
88-
const TrackerGeometry* trackerG) const;
67+
void produce(edm::Event&, const edm::EventSetup&) override;
68+
bool isFarFromBorder(TrajectoryStateOnSurface* trajState, const uint32_t detid, const edm::EventSetup* iSetup);
69+
double thickness(DetId id);
70+
71+
const TrackerGeometry* m_tracker;
72+
std::map<DetId, double> m_thicknessMap;
8973
};
9074
#endif

0 commit comments

Comments
 (0)