File indexing completed on 2024-04-06 11:57:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021
0022
0023 #include "FWCore/ServiceRegistry/interface/Service.h"
0024 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0025
0026 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
0027
0028 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
0029 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0030 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h"
0031 #include "DataFormats/GeometryCommonDetAlgo/interface/AlignmentPositionError.h"
0032
0033 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0034
0035
0036 class ApeAdder : public edm::one::EDAnalyzer<> {
0037 public:
0038 explicit ApeAdder(const edm::ParameterSet&);
0039 ~ApeAdder() override = default;
0040
0041 void analyze(const edm::Event&, const edm::EventSetup&) override;
0042
0043 private:
0044
0045 void addApe(const align::Alignables& alignables);
0046
0047 private:
0048
0049 const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0050 const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkGeomToken_;
0051 std::string theErrorRecordName;
0052 std::vector<double> theApe;
0053 };
0054
0055 ApeAdder::ApeAdder(const edm::ParameterSet& iConfig)
0056 : tTopoToken_(esConsumes()), tkGeomToken_(esConsumes()), theErrorRecordName("TrackerAlignmentErrorExtendedRcd") {
0057
0058 theApe = iConfig.getUntrackedParameter<std::vector<double> >("apeVector");
0059 }
0060
0061
0062 void ApeAdder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
0063
0064 {
0065
0066 const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_);
0067
0068 const TrackerGeometry* trackerGeometry = &iSetup.getData(tkGeomToken_);
0069
0070
0071 AlignableTracker* theAlignableTracker = new AlignableTracker(&(*trackerGeometry), tTopo);
0072
0073
0074 if (theAlignableTracker->barrelGeomDets().size())
0075 this->addApe(theAlignableTracker->barrelGeomDets());
0076 if (theAlignableTracker->pixelHalfBarrelGeomDets().size())
0077 this->addApe(theAlignableTracker->pixelHalfBarrelGeomDets());
0078 if (theAlignableTracker->endcapGeomDets().size())
0079 this->addApe(theAlignableTracker->endcapGeomDets());
0080 if (theAlignableTracker->TIDGeomDets().size())
0081 this->addApe(theAlignableTracker->TIDGeomDets());
0082 if (theAlignableTracker->pixelEndcapGeomDets().size())
0083 this->addApe(theAlignableTracker->pixelEndcapGeomDets());
0084
0085
0086 AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors();
0087
0088
0089 edm::Service<cond::service::PoolDBOutputService> poolDbService;
0090 if (!poolDbService.isAvailable())
0091 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
0092
0093
0094 poolDbService->writeOneIOV<AlignmentErrorsExtended>(
0095 *alignmentErrors, poolDbService->beginOfTime(), theErrorRecordName);
0096
0097 delete theAlignableTracker;
0098 }
0099
0100 void ApeAdder::addApe(const align::Alignables& alignables) {
0101 AlignmentPositionError ape(theApe[0], theApe[1], theApe[2]);
0102 for (const auto& iDet : alignables) {
0103 iDet->setAlignmentPositionError(ape, true);
0104 }
0105 }
0106
0107
0108 DEFINE_FWK_MODULE(ApeAdder);