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 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Time sequence of alignment corrections. I/O methods have been factored out to: CondFormats/PPSObjects...
uint32_t arm() const
Definition: CTPPSDetId.h:51
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Modifies the alignment modes unconstrained by the track-based alignment.
void analyze(const edm::Event &e, const edm::EventSetup &es) override
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
static std::string const input
Definition: EdmProvDump.cc:47
T getUntrackedParameter(std::string const &, T const &) const
static CTPPSRPAlignmentCorrectionsDataSequence loadFromXML(const std::string &fileName)
loads sequence of alignment corrections from XML file
Transition
Definition: Transition.h:12
bool getData(T &iHolder) const
Definition: EventSetup.h:122
d
Definition: ztail.py:151
void factorRPFromSensorCorrections(const CTPPSRPAlignmentCorrectionsData &input, CTPPSRPAlignmentCorrectionsData &expanded, CTPPSRPAlignmentCorrectionsData &factored, const AlignmentGeometry &, bool equalWeights=false, unsigned int verbosity=0)
Definition: Utilities.cc:93
uint32_t rp() const
Definition: CTPPSDetId.h:65
PPSModifySingularModes(const edm::ParameterSet &ps)
uint32_t station() const
Definition: CTPPSDetId.h:58
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
HLT enums.
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
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > tokenRealGeometry_
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.
Definition: Run.h:45
void beginRun(edm::Run const &, edm::EventSetup const &) override