Skip to content

Commit de14258

Browse files
committed
Clean up the CTPPS local reconstruction code
1 parent dcf7c99 commit de14258

File tree

7 files changed

+184
-219
lines changed

7 files changed

+184
-219
lines changed

RecoPPS/Local/interface/CTPPSPixelClusterProducer.h

Lines changed: 0 additions & 64 deletions
This file was deleted.

RecoPPS/Local/interface/CTPPSPixelRecHitProducer.h

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
#ifndef RecoPPS_Local_interface_RPixClusterToHit_h
2+
#define RecoPPS_Local_interface_RPixClusterToHit_h
3+
14
/**********************************************************************
25
*
36
* Author: F.Ferro - INFN Genova
47
*
58
**********************************************************************/
6-
#ifndef RecoPPS_Local_RPixClusterToHit_H
7-
#define RecoPPS_Local_RPixClusterToHit_H
89

9-
#include "FWCore/ParameterSet/interface/ParameterSet.h"
10-
#include "DataFormats/Common/interface/DetSetVector.h"
10+
#include "CondFormats/PPSObjects/interface/PPSPixelTopology.h"
1111
#include "DataFormats/CTPPSReco/interface/CTPPSPixelCluster.h"
1212
#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h"
13-
#include "CondFormats/PPSObjects/interface/PPSPixelTopology.h"
13+
#include "DataFormats/Common/interface/DetSetVector.h"
14+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1415

1516
class RPixClusterToHit {
1617
public:
@@ -19,12 +20,12 @@ class RPixClusterToHit {
1920
void buildHits(unsigned int detId,
2021
const std::vector<CTPPSPixelCluster> &clusters,
2122
std::vector<CTPPSPixelRecHit> &hits,
22-
const PPSPixelTopology &ppt);
23-
void make_hit(CTPPSPixelCluster aCluster, std::vector<CTPPSPixelRecHit> &hits, const PPSPixelTopology &ppt);
24-
~RPixClusterToHit();
23+
const PPSPixelTopology &ppt) const;
2524

2625
private:
27-
int verbosity_;
26+
void makeHit(CTPPSPixelCluster cluster, std::vector<CTPPSPixelRecHit> &hits, PPSPixelTopology const &ppt) const;
27+
28+
const int verbosity_;
2829
};
2930

30-
#endif
31+
#endif // RecoPPS_Local_interface_RPixClusterToHit_h

RecoPPS/Local/plugins/CTPPSPixelClusterProducer.cc

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,69 @@
1+
/**********************************************************************
2+
*
3+
* Author: F.Ferro [email protected] - INFN Genova - 2017
4+
*
5+
**********************************************************************/
16

7+
#include <memory>
8+
#include <vector>
9+
10+
#include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"
11+
#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
12+
#include "CondFormats/DataRecord/interface/CTPPSPixelGainCalibrationsRcd.h"
13+
#include "CondFormats/PPSObjects/interface/CTPPSPixelAnalysisMask.h"
14+
#include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
15+
#include "CondFormats/PPSObjects/interface/CTPPSPixelGainCalibrations.h"
16+
#include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h"
17+
#include "DataFormats/CTPPSDigi/interface/CTPPSPixelDigi.h"
18+
#include "DataFormats/CTPPSReco/interface/CTPPSPixelCluster.h"
19+
#include "DataFormats/Common/interface/DetSet.h"
20+
#include "DataFormats/Common/interface/DetSetVector.h"
21+
#include "DataFormats/Common/interface/Handle.h"
22+
#include "DataFormats/DetId/interface/DetId.h"
23+
#include "FWCore/Framework/interface/ESHandle.h"
24+
#include "FWCore/Framework/interface/Event.h"
25+
#include "FWCore/Framework/interface/EventSetup.h"
26+
#include "FWCore/Framework/interface/stream/EDProducer.h"
227
#include "FWCore/MessageLogger/interface/MessageLogger.h"
3-
#include "RecoPPS/Local/interface/CTPPSPixelClusterProducer.h"
28+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
29+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
30+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
31+
#include "FWCore/Utilities/interface/ESGetToken.h"
32+
#include "FWCore/Utilities/interface/EDGetToken.h"
33+
#include "FWCore/Utilities/interface/EDPutToken.h"
34+
#include "FWCore/Utilities/interface/InputTag.h"
35+
#include "RecoPPS/Local/interface/RPixDetClusterizer.h"
36+
37+
class CTPPSPixelClusterProducer : public edm::stream::EDProducer<> {
38+
public:
39+
explicit CTPPSPixelClusterProducer(const edm::ParameterSet &param);
40+
41+
~CTPPSPixelClusterProducer() override = default;
42+
43+
void produce(edm::Event &, const edm::EventSetup &) override;
44+
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
45+
46+
private:
47+
const edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelDigi>> tokenCTPPSPixelDigi_;
48+
const edm::EDPutTokenT<edm::DetSetVector<CTPPSPixelCluster>> tokenCTPPSPixelCluster_;
49+
const edm::ESGetToken<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd> tokenCTPPSPixelAnalysisMask_;
50+
const edm::ESGetToken<CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd> tokenGainCalib_;
51+
const int verbosity_;
52+
RPixDetClusterizer clusterizer_;
53+
54+
void run(const edm::DetSetVector<CTPPSPixelDigi> &input,
55+
edm::DetSetVector<CTPPSPixelCluster> &output,
56+
const CTPPSPixelAnalysisMask &mask,
57+
const CTPPSPixelGainCalibrations &gainCalibration);
58+
};
459

560
CTPPSPixelClusterProducer::CTPPSPixelClusterProducer(const edm::ParameterSet &conf)
6-
: tokenCTPPSPixelDigi_(consumes<edm::DetSetVector<CTPPSPixelDigi> >(conf.getParameter<edm::InputTag>("tag"))),
61+
: tokenCTPPSPixelDigi_(consumes<edm::DetSetVector<CTPPSPixelDigi>>(conf.getParameter<edm::InputTag>("tag"))),
62+
tokenCTPPSPixelCluster_(produces()),
763
tokenCTPPSPixelAnalysisMask_(esConsumes()),
864
tokenGainCalib_(esConsumes()),
965
verbosity_(conf.getUntrackedParameter<int>("RPixVerbosity")),
10-
clusterizer_(conf) {
11-
produces<edm::DetSetVector<CTPPSPixelCluster> >();
12-
}
13-
14-
CTPPSPixelClusterProducer::~CTPPSPixelClusterProducer() {}
66+
clusterizer_(conf) {}
1567

1668
void CTPPSPixelClusterProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
1769
edm::ParameterSetDescription desc;
@@ -26,23 +78,23 @@ void CTPPSPixelClusterProducer::fillDescriptions(edm::ConfigurationDescriptions
2678
descriptions.add("ctppsPixelClusters", desc);
2779
}
2880

29-
void CTPPSPixelClusterProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
30-
/// get inputs
31-
edm::Handle<edm::DetSetVector<CTPPSPixelDigi> > rpd;
32-
iEvent.getByToken(tokenCTPPSPixelDigi_, rpd);
81+
void CTPPSPixelClusterProducer::produce(edm::Event &event, const edm::EventSetup &setup) {
82+
// get inputs
83+
edm::DetSetVector<CTPPSPixelDigi> const &rpd = event.get(tokenCTPPSPixelDigi_);
3384

3485
edm::DetSetVector<CTPPSPixelCluster> output;
3586

36-
if (!rpd->empty()) {
87+
if (not rpd.empty()) {
3788
// get analysis mask to mask channels
38-
const auto &mask = iSetup.getData(tokenCTPPSPixelAnalysisMask_);
89+
const auto &mask = setup.getData(tokenCTPPSPixelAnalysisMask_);
3990
// get calibration DB
40-
const auto &gainCalibrations = iSetup.getData(tokenGainCalib_);
91+
const auto &gainCalibrations = setup.getData(tokenGainCalib_);
4192
// run clusterisation
42-
run(*rpd, output, mask, gainCalibrations);
93+
run(rpd, output, mask, gainCalibrations);
4394
}
95+
4496
// write output
45-
iEvent.put(std::make_unique<edm::DetSetVector<CTPPSPixelCluster> >(output));
97+
event.emplace(tokenCTPPSPixelCluster_, std::move(output));
4698
}
4799

48100
void CTPPSPixelClusterProducer::run(const edm::DetSetVector<CTPPSPixelDigi> &input,
@@ -64,4 +116,5 @@ void CTPPSPixelClusterProducer::run(const edm::DetSetVector<CTPPSPixelDigi> &inp
64116
}
65117
}
66118

119+
#include "FWCore/Framework/interface/MakerMacros.h"
67120
DEFINE_FWK_MODULE(CTPPSPixelClusterProducer);
Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,79 @@
1-
#include "RecoPPS/Local/interface/CTPPSPixelRecHitProducer.h"
2-
3-
CTPPSPixelRecHitProducer::CTPPSPixelRecHitProducer(const edm::ParameterSet &conf) : param_(conf), cluster2hit_(conf) {
4-
src_ = conf.getParameter<edm::InputTag>("RPixClusterTag");
5-
verbosity_ = conf.getUntrackedParameter<int>("RPixVerbosity");
6-
tokenCTPPSPixelCluster_ = consumes<edm::DetSetVector<CTPPSPixelCluster> >(src_);
7-
produces<edm::DetSetVector<CTPPSPixelRecHit> >();
8-
pixelTopologyToken_ = esConsumes<PPSPixelTopology, PPSPixelTopologyRcd>();
9-
}
1+
/**********************************************************************
2+
*
3+
* Author: F.Ferro - INFN Genova
4+
*
5+
**********************************************************************/
106

11-
CTPPSPixelRecHitProducer::~CTPPSPixelRecHitProducer() {}
7+
#include "CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h"
8+
#include "CondFormats/PPSObjects/interface/PPSPixelTopology.h"
9+
#include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h"
10+
#include "DataFormats/CTPPSReco/interface/CTPPSPixelCluster.h"
11+
#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h"
12+
#include "DataFormats/Common/interface/DetSet.h"
13+
#include "DataFormats/Common/interface/DetSetVector.h"
14+
#include "DataFormats/Common/interface/Handle.h"
15+
#include "DataFormats/DetId/interface/DetId.h"
16+
#include "FWCore/Framework/interface/ESHandle.h"
17+
#include "FWCore/Framework/interface/Event.h"
18+
#include "FWCore/Framework/interface/EventSetup.h"
19+
#include "FWCore/Framework/interface/global/EDProducer.h"
20+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
21+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
22+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
23+
#include "FWCore/Utilities/interface/EDGetToken.h"
24+
#include "FWCore/Utilities/interface/EDPutToken.h"
25+
#include "FWCore/Utilities/interface/ESGetToken.h"
26+
#include "FWCore/Utilities/interface/InputTag.h"
27+
#include "RecoPPS/Local/interface/RPixClusterToHit.h"
1228

13-
void CTPPSPixelRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
14-
edm::ParameterSetDescription desc;
15-
desc.addUntracked<int>("RPixVerbosity", 0);
16-
desc.add<edm::InputTag>("RPixClusterTag", edm::InputTag("ctppsPixelClusters"));
17-
descriptions.add("ctppsPixelRecHits", desc);
18-
}
29+
class CTPPSPixelRecHitProducer : public edm::global::EDProducer<> {
30+
public:
31+
explicit CTPPSPixelRecHitProducer(const edm::ParameterSet &param);
32+
33+
~CTPPSPixelRecHitProducer() override = default;
1934

20-
void CTPPSPixelRecHitProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
21-
edm::Handle<edm::DetSetVector<CTPPSPixelCluster> > rpCl;
22-
iEvent.getByToken(tokenCTPPSPixelCluster_, rpCl);
35+
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override;
2336

24-
edm::ESHandle<PPSPixelTopology> thePixelTopology = iSetup.getHandle(pixelTopologyToken_);
37+
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
2538

26-
edm::DetSetVector<CTPPSPixelRecHit> output;
39+
private:
40+
const edm::ESGetToken<PPSPixelTopology, PPSPixelTopologyRcd> pixelTopologyToken_;
41+
const edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelCluster>> clustersToken_;
42+
const edm::EDPutTokenT<edm::DetSetVector<CTPPSPixelRecHit>> rechitsToken_;
43+
const RPixClusterToHit clusterToHit_;
44+
};
2745

28-
// run reconstruction
29-
if (!rpCl->empty())
30-
run(*rpCl, output, *thePixelTopology);
46+
CTPPSPixelRecHitProducer::CTPPSPixelRecHitProducer(const edm::ParameterSet &config)
47+
: pixelTopologyToken_(esConsumes<PPSPixelTopology, PPSPixelTopologyRcd>()),
48+
clustersToken_(
49+
consumes<edm::DetSetVector<CTPPSPixelCluster>>(config.getParameter<edm::InputTag>("RPixClusterTag"))),
50+
rechitsToken_(produces<edm::DetSetVector<CTPPSPixelRecHit>>()),
51+
clusterToHit_(config) {}
3152

32-
iEvent.put(std::make_unique<edm::DetSetVector<CTPPSPixelRecHit> >(output));
53+
void CTPPSPixelRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
54+
edm::ParameterSetDescription desc;
55+
desc.add<edm::InputTag>("RPixClusterTag", edm::InputTag("ctppsPixelClusters"));
56+
desc.addUntracked<int>("RPixVerbosity", 0); // used by RPixClusterToHit
57+
descriptions.add("ctppsPixelRecHits", desc);
3358
}
3459

35-
void CTPPSPixelRecHitProducer::run(const edm::DetSetVector<CTPPSPixelCluster> &input,
36-
edm::DetSetVector<CTPPSPixelRecHit> &output,
37-
const PPSPixelTopology &ppt) {
38-
for (const auto &ds_cluster : input) {
39-
edm::DetSet<CTPPSPixelRecHit> &ds_rechit = output.find_or_insert(ds_cluster.id);
60+
void CTPPSPixelRecHitProducer::produce(edm::StreamID, edm::Event &event, edm::EventSetup const &setup) const {
61+
PPSPixelTopology const &thePixelTopology = setup.getData(pixelTopologyToken_);
62+
edm::DetSetVector<CTPPSPixelCluster> const &clusters = event.get(clustersToken_);
63+
edm::DetSetVector<CTPPSPixelRecHit> rechits;
64+
rechits.reserve(clusters.size());
65+
66+
// run the reconstruction
67+
for (auto const &cluster : clusters) {
68+
edm::DetSet<CTPPSPixelRecHit> &rechit = rechits.find_or_insert(cluster.id);
69+
rechit.data.reserve(cluster.data.size());
4070

41-
//calculate the cluster parameters and convert it into a rechit
42-
cluster2hit_.buildHits(ds_cluster.id, ds_cluster.data, ds_rechit.data, ppt);
71+
// calculate the cluster parameters and convert it into a rechit
72+
clusterToHit_.buildHits(cluster.id, cluster.data, rechit.data, thePixelTopology);
4373
}
74+
75+
event.emplace(rechitsToken_, std::move(rechits));
4476
}
4577

78+
#include "FWCore/Framework/interface/MakerMacros.h"
4679
DEFINE_FWK_MODULE(CTPPSPixelRecHitProducer);

0 commit comments

Comments
 (0)