CMS 3D CMS Logo

PPSModifySingularModes.cc
Go to the documentation of this file.
1 /****************************************************************************
2 * Authors:
3 * Jan Kašpar (jan.kaspar@gmail.com)
4 ****************************************************************************/
5 
13 
16 
20 
23 
28 public:
30 
31 private:
33 
35 
36  void beginRun(edm::Run const &, edm::EventSetup const &) override;
37 
38  void analyze(const edm::Event &e, const edm::EventSetup &es) override {}
39 };
40 
41 using namespace std;
42 using namespace edm;
43 
44 //----------------------------------------------------------------------------------------------------
45 
47  : ps_(ps), tokenRealGeometry_(esConsumes<edm::Transition::BeginRun>()) {}
48 
49 //----------------------------------------------------------------------------------------------------
50 
52  // get config parameters
53  const double z1 = ps_.getUntrackedParameter<double>("z1");
54  const double z2 = ps_.getUntrackedParameter<double>("z2");
55  const double de_x1 = ps_.getUntrackedParameter<double>("de_x1");
56  const double de_x2 = ps_.getUntrackedParameter<double>("de_x2");
57  const double de_y1 = ps_.getUntrackedParameter<double>("de_y1");
58  const double de_y2 = ps_.getUntrackedParameter<double>("de_y2");
59  const double de_rho1 = ps_.getUntrackedParameter<double>("de_rho1");
60  const double de_rho2 = ps_.getUntrackedParameter<double>("de_rho2");
61 
62  FileInPath inputFileInPath(ps_.getUntrackedParameter<string>("inputFile"));
63  const string inputFile = inputFileInPath.fullPath();
64  const string outputFile = ps_.getUntrackedParameter<string>("outputFile");
65 
66  // validate config parameters
67  if (z1 == z2)
68  throw cms::Exception("PPS") << "z1 equals z2";
69 
70  // calculate slopes and intercepts
71  const double a_x = (de_x2 - de_x1) / (z2 - z1), b_x = de_x1 - a_x * z1;
72  const double a_y = (de_y2 - de_y1) / (z2 - z1), b_y = de_y1 - a_y * z1;
73  const double a_rho = (de_rho2 - de_rho1) / (z2 - z1), b_rho = de_rho1 - a_rho * z1;
74 
75  // get geometry
76  const auto &geometry = es.getData(tokenRealGeometry_);
77 
78  // get input alignments
80  const auto &input = inputSequence.begin()->second;
81 
82  // modify the singular modes
84 
85  for (auto &it : input.getSensorMap()) {
86  const auto &sensorId = it.first;
87 
88  const auto &c = geometry.sensorTranslation(sensorId);
89 
90  // pixels cannot be described by one single value of z, but no better approxiamtion can be made
91  const double z = c.z();
92 
93  double de_ShX = a_x * z + b_x;
94  double de_ShY = a_y * z + b_y;
95  const double de_RotZ = a_rho * z + b_rho;
96 
97  // add the effect of global rotation (about origin, not sensor centre)
98  de_ShX -= +de_RotZ * (c.y() + de_ShY);
99  de_ShY -= -de_RotZ * (c.x() + de_ShX);
100 
101  CTPPSRPAlignmentCorrectionData d = it.second;
102  d.setShX(d.getShX() + de_ShX);
103  d.setShY(d.getShY() + de_ShY);
104  d.setRotZ(d.getRotZ() + de_RotZ);
105 
106  output.setSensorCorrection(sensorId, d);
107  }
108 
109  // build list of RPs
110  vector<unsigned int> rps;
111  unsigned int last_rp = 123456;
112  for (auto &it : input.getSensorMap()) {
113  CTPPSDetId senId(it.first);
114  unsigned int rpDecId = senId.arm() * 100 + senId.station() * 10 + senId.rp();
115 
116  if (last_rp != rpDecId) {
117  rps.push_back(rpDecId);
118  last_rp = rpDecId;
119  }
120  }
121 
122  // build alignment geometry (needed for the factorisation below)
123  AlignmentGeometry alignmentGeometry;
124  vector<unsigned int> excludePlanes;
125  AlignmentTask::buildGeometry(rps, excludePlanes, &geometry, 0., alignmentGeometry);
126 
127  // factorise output
128  CTPPSRPAlignmentCorrectionsData outputExpanded;
129  CTPPSRPAlignmentCorrectionsData outputFactored;
130 
131  const bool equalWeights = false;
132  factorRPFromSensorCorrections(output, outputExpanded, outputFactored, alignmentGeometry, equalWeights, 1);
133 
134  // save output
135  CTPPSRPAlignmentCorrectionsMethods::writeToXML(outputFactored, outputFile, false, false, true, true, true, true);
136 }
137 
138 //----------------------------------------------------------------------------------------------------
139 
CTPPSDetId::rp
uint32_t rp() const
Definition: CTPPSDetId.h:69
input
static const std::string input
Definition: EdmProvDump.cc:48
ESHandle.h
EDAnalyzer.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
PPSModifySingularModes::PPSModifySingularModes
PPSModifySingularModes(const edm::ParameterSet &ps)
Definition: PPSModifySingularModes.cc:46
geometry
Definition: geometry.py:1
PPSModifySingularModes::tokenRealGeometry_
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > tokenRealGeometry_
Definition: PPSModifySingularModes.cc:36
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
FileInPath.h
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
edm::FileInPath
Definition: FileInPath.h:64
PPSModifySingularModes::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: PPSModifySingularModes.cc:51
CTPPSGeometry.h
MakerMacros.h
CTPPSDetId::station
uint32_t station() const
Definition: CTPPSDetId.h:62
download_sqlite_cfg.outputFile
outputFile
Definition: download_sqlite_cfg.py:5
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
DDAxes::z
CTPPSRPAlignmentCorrectionsMethods::writeToXML
static void writeToXML(const CTPPSRPAlignmentCorrectionsDataSequence &seq, const std::string &fileName, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
writes sequence of alignment corrections into a single XML file
Definition: CTPPSRPAlignmentCorrectionsMethods.cc:310
CTPPSRPAlignmentCorrectionData.h
CTPPSDetId::arm
uint32_t arm() const
Definition: CTPPSDetId.h:55
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
edm::stream::EDAnalyzer
Definition: EDAnalyzer.h:33
Event.h
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
edm::EventSetup
Definition: EventSetup.h:58
Utilities.h
VeryForwardRealGeometryRecord.h
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
AlignmentTask.h
factorRPFromSensorCorrections
void factorRPFromSensorCorrections(const CTPPSRPAlignmentCorrectionsData &input, CTPPSRPAlignmentCorrectionsData &expanded, CTPPSRPAlignmentCorrectionsData &factored, const AlignmentGeometry &, bool equalWeights=false, unsigned int verbosity=0)
Definition: Utilities.cc:92
std
Definition: JetResolutionObject.h:76
PPSModifySingularModes::ps_
edm::ParameterSet ps_
Definition: PPSModifySingularModes.cc:34
edm::Transition::BeginRun
AlignmentTask::buildGeometry
static void buildGeometry(const std::vector< unsigned int > &rpDecIds, const std::vector< unsigned int > &excludedSensors, const CTPPSGeometry *, double z0, AlignmentGeometry &geometry)
builds the alignment geometry
Definition: AlignmentTask.cc:49
Exception
Definition: hltDiff.cc:245
CTPPSRPAlignmentCorrectionsMethods.h
CTPPSRPAlignmentCorrectionsData
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
Definition: CTPPSRPAlignmentCorrectionsData.h:24
EventSetup.h
AlignmentGeometry
Definition: AlignmentGeometry.h:55
CTPPSRPAlignmentCorrectionsData.h
ztail.d
d
Definition: ztail.py:151
CTPPSRPAlignmentCorrectionData
Alignment correction for an element of the CT-PPS detector. Within the geometry description,...
Definition: CTPPSRPAlignmentCorrectionData.h:58
ParameterSet.h
PPSModifySingularModes::analyze
void analyze(const edm::Event &e, const edm::EventSetup &es) override
Definition: PPSModifySingularModes.cc:40
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
CTPPSRPAlignmentCorrectionsMethods::loadFromXML
static CTPPSRPAlignmentCorrectionsDataSequence loadFromXML(const std::string &fileName)
loads sequence of alignment corrections from XML file
Definition: CTPPSRPAlignmentCorrectionsMethods.cc:104
PPSModifySingularModes
Modifies the alignment modes unconstrained by the track-based alignment.
Definition: PPSModifySingularModes.cc:27
CTPPSRPAlignmentCorrectionsDataSequence
Time sequence of alignment corrections. I/O methods have been factored out to: CondFormats/PPSObjects...
Definition: CTPPSRPAlignmentCorrectionsDataSequence.h:22
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37