1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// -*- C++ -*-
//
//
// Description: Module to add a custom APE to the alignment object
//
//
// Original Author: Frederic Ronga
// Created: December 5, 2006
//
// system include files
// user include files
//#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
// Conditions database
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/AlignmentPositionError.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
// Class declaration
class ApeAdder : public edm::one::EDAnalyzer<> {
public:
explicit ApeAdder(const edm::ParameterSet&);
~ApeAdder() override = default;
void analyze(const edm::Event&, const edm::EventSetup&) override;
private:
// methods
void addApe(const align::Alignables& alignables);
private:
// members
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkGeomToken_;
std::string theErrorRecordName;
std::vector<double> theApe; // Amount of APE to add (from config.)
};
ApeAdder::ApeAdder(const edm::ParameterSet& iConfig)
: tTopoToken_(esConsumes()), tkGeomToken_(esConsumes()), theErrorRecordName("TrackerAlignmentErrorExtendedRcd") {
// The APE to set to all GeomDets
theApe = iConfig.getUntrackedParameter<std::vector<double> >("apeVector");
}
//__________________________________________________________________________________________________
void ApeAdder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
//Retrieve tracker topology from geometry
const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_);
// Get geometry from ES
const TrackerGeometry* trackerGeometry = &iSetup.getData(tkGeomToken_);
// Create the alignable hierarchy
AlignableTracker* theAlignableTracker = new AlignableTracker(&(*trackerGeometry), tTopo);
// Now loop on alignable dets and add alignment error
if (theAlignableTracker->barrelGeomDets().size())
this->addApe(theAlignableTracker->barrelGeomDets());
if (theAlignableTracker->pixelHalfBarrelGeomDets().size())
this->addApe(theAlignableTracker->pixelHalfBarrelGeomDets());
if (theAlignableTracker->endcapGeomDets().size())
this->addApe(theAlignableTracker->endcapGeomDets());
if (theAlignableTracker->TIDGeomDets().size())
this->addApe(theAlignableTracker->TIDGeomDets());
if (theAlignableTracker->pixelEndcapGeomDets().size())
this->addApe(theAlignableTracker->pixelEndcapGeomDets());
// Store to DB
AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors();
// Call service
edm::Service<cond::service::PoolDBOutputService> poolDbService;
if (!poolDbService.isAvailable()) // Die if not available
throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
// Save to DB (assuming that the delete below will also delete the concerned payload )
poolDbService->writeOneIOV<AlignmentErrorsExtended>(
*alignmentErrors, poolDbService->beginOfTime(), theErrorRecordName);
delete theAlignableTracker;
}
void ApeAdder::addApe(const align::Alignables& alignables) {
AlignmentPositionError ape(theApe[0], theApe[1], theApe[2]);
for (const auto& iDet : alignables) {
iDet->setAlignmentPositionError(ape, true); // true: propagate to components
}
}
//define this as a plug-in
DEFINE_FWK_MODULE(ApeAdder);
|