CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ApeSettingAlgorithm Class Reference
Inheritance diagram for ApeSettingAlgorithm:
AlignmentAlgorithmBase

Public Member Functions

 ApeSettingAlgorithm (const edm::ParameterSet &cfg, const edm::ConsumesCollector &iC)
 Constructor. More...
 
void initialize (const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store) override
 Call at beginning of job. More...
 
void run (const edm::EventSetup &setup, const EventInfo &eventInfo) override
 Run the algorithm. More...
 
void terminate (const edm::EventSetup &iSetup) override
 Call at end of job. More...
 
 ~ApeSettingAlgorithm () override
 Destructor. More...
 
- Public Member Functions inherited from AlignmentAlgorithmBase
virtual bool addCalibrations (const Calibrations &)
 
bool addCalibrations (const CalibrationsOwner &cals)
 
 AlignmentAlgorithmBase (const edm::ParameterSet &, const edm::ConsumesCollector &)
 Constructor. More...
 
virtual void beginLuminosityBlock (const edm::EventSetup &setup)
 called at begin of luminosity block (no lumi block info passed yet) More...
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &, bool changed)
 called at begin of run More...
 
virtual void endLuminosityBlock (const edm::EventSetup &setup)
 called at end of luminosity block (no lumi block info passed yet) More...
 
virtual void endRun (const EndRunInfo &runInfo, const edm::EventSetup &setup)
 called at end of run - order of arguments like in EDProducer etc. More...
 
virtual bool processesEvents ()
 Returns whether algorithm proccesses events in current configuration. More...
 
virtual bool setParametersForRunRange (const RunRange &rr)
 
virtual void startNewLoop ()
 
virtual bool storeAlignments ()
 Returns whether algorithm produced results to be stored. More...
 
virtual bool supportsCalibrations ()
 
virtual void terminate ()
 Called at end of job (must be implemented in derived class) More...
 
virtual ~AlignmentAlgorithmBase ()
 Destructor. More...
 

Private Attributes

bool readApeFromAscii_
 
bool readFullLocalMatrix_
 
bool readLocalNotGlobal_
 
bool saveApeToAscii_
 
bool saveComposites_
 
bool saveLocalNotGlobal_
 
bool setComposites_
 
AlignableNavigatortheAlignableNavigator
 
edm::ParameterSet theConfig
 
AlignableTrackertheTracker
 

Additional Inherited Members

- Public Types inherited from AlignmentAlgorithmBase
typedef std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
 
typedef std::vector< ConstTrajTrackPairConstTrajTrackPairCollection
 
using RunNumber = align::RunNumber
 
using RunRange = align::RunRange
 

Detailed Description

Definition at line 61 of file ApeSettingAlgorithm.cc.

Constructor & Destructor Documentation

◆ ApeSettingAlgorithm()

ApeSettingAlgorithm::ApeSettingAlgorithm ( const edm::ParameterSet cfg,
const edm::ConsumesCollector iC 
)

Constructor.

Definition at line 98 of file ApeSettingAlgorithm.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), readApeFromAscii_, readFullLocalMatrix_, readLocalNotGlobal_, saveApeToAscii_, saveComposites_, saveLocalNotGlobal_, setComposites_, and theConfig.

100  edm::LogInfo("Alignment") << "@SUB=ApeSettingAlgorithm"
101  << "Start.";
102  saveApeToAscii_ = theConfig.getUntrackedParameter<bool>("saveApeToASCII");
103  saveComposites_ = theConfig.getUntrackedParameter<bool>("saveComposites");
104  saveLocalNotGlobal_ = theConfig.getUntrackedParameter<bool>("saveLocalNotGlobal");
105  readApeFromAscii_ = theConfig.getParameter<bool>("readApeFromASCII");
106  readLocalNotGlobal_ = theConfig.getParameter<bool>("readLocalNotGlobal");
107  readFullLocalMatrix_ = theConfig.getParameter<bool>("readFullLocalMatrix");
108  setComposites_ = theConfig.getParameter<bool>("setComposites");
109 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ParameterSet theConfig
T getUntrackedParameter(std::string const &, T const &) const
AlignableNavigator * theAlignableNavigator
AlignmentAlgorithmBase(const edm::ParameterSet &, const edm::ConsumesCollector &)
Constructor.
Log< level::Info, false > LogInfo

◆ ~ApeSettingAlgorithm()

ApeSettingAlgorithm::~ApeSettingAlgorithm ( )
override

Destructor.

Definition at line 113 of file ApeSettingAlgorithm.cc.

References theAlignableNavigator.

113 { delete theAlignableNavigator; }
AlignableNavigator * theAlignableNavigator

Member Function Documentation

◆ initialize()

void ApeSettingAlgorithm::initialize ( const edm::EventSetup setup,
AlignableTracker tracker,
AlignableMuon muon,
AlignableExtras extras,
AlignmentParameterStore store 
)
overridevirtual

Call at beginning of job.

Implements AlignmentAlgorithmBase.

Definition at line 117 of file ApeSettingAlgorithm.cc.

References AlignableNavigator::alignableFromDetId(), contentValuesFiles::fullPath, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), triggerObjects_cff::id, SequenceTypes::ignore(), readApeFromAscii_, readFullLocalMatrix_, readLocalNotGlobal_, hcal_runs::rt, setComposites_, theAlignableNavigator, theConfig, theTracker, PbPb_ZMuSkimMuonDPG_cff::tracker, and gpuVertexFinder::ws.

121  {
124 
125  if (readApeFromAscii_) {
126  std::ifstream apeReadFile(
127  theConfig.getParameter<edm::FileInPath>("apeASCIIReadFile").fullPath().c_str()); //requires <fstream>
128  if (!apeReadFile.good()) {
129  edm::LogInfo("Alignment") << "@SUB=initialize"
130  << "Problem opening APE file: skipping"
131  << theConfig.getParameter<edm::FileInPath>("apeASCIIReadFile").fullPath();
132  return;
133  }
134  std::set<int> apeList; //To avoid duplicates
135  while (!apeReadFile.eof()) {
136  int apeId = 0;
137  double x11, x21, x22, x31, x32, x33, ignore;
139  apeReadFile >> apeId >> x11 >> x21 >> x22 >> x31 >> x32 >> x33 >> ignore >> ignore >> ignore >> ignore >>
140  ignore >> ignore >> ignore >> ignore >> ignore >> ignore >> ignore >> ignore >> ignore >> ignore >>
141  ignore >> std::ws;
142  } else {
143  apeReadFile >> apeId >> x11 >> x22 >> x33 >> std::ws;
144  }
145  //idr What sanity checks do we need to put here?
146  if (apeId != 0) //read appears valid?
147  {
148  if (apeList.find(apeId) == apeList.end()) //Not previously done
149  {
150  DetId id(apeId);
152  if (alidet) {
153  if ((alidet->components().empty()) || setComposites_) //the problem with glued dets...
154  {
155  GlobalErrorExtended globErr;
156  if (readLocalNotGlobal_) {
158  if (readFullLocalMatrix_) {
159  as[0][0] = x11;
160  as[1][0] = x21;
161  as[1][1] = x22;
162  as[2][0] = x31;
163  as[2][1] = x32;
164  as[2][2] = x33;
165  } else {
166  as[0][0] = x11 * x11;
167  as[1][1] = x22 * x22;
168  as[2][2] = x33 * x33;
169  } //local cov.
170  align::RotationType rt = alidet->globalRotation();
172  am[0][0] = rt.xx();
173  am[0][1] = rt.xy();
174  am[0][2] = rt.xz();
175  am[1][0] = rt.yx();
176  am[1][1] = rt.yy();
177  am[1][2] = rt.yz();
178  am[2][0] = rt.zx();
179  am[2][1] = rt.zy();
180  am[2][2] = rt.zz();
181  globErr = GlobalErrorExtended(ROOT::Math::SimilarityT(am, as));
182  } else {
184  globErr =
185  GlobalErrorExtended(x11, x21, x31, 0, 0, 0, x22, x32, 0, 0, 0, x33, 0, 0, 0, 0, 0, 0, 0, 0, 0);
186  else {
187  globErr = GlobalErrorExtended(
188  x11 * x11, 0, 0, 0, 0, 0, x22 * x22, 0, 0, 0, 0, x33 * x33, 0, 0, 0, 0, 0, 0, 0, 0, 0);
189  }
190  }
191  alidet->setAlignmentPositionError(globErr, false); // do not propagate down!
192  apeList.insert(apeId); //Flag it's been set
193  } else {
194  edm::LogInfo("Alignment") << "@SUB=initialize"
195  << "Not Setting APE for Composite DetId " << apeId;
196  }
197  }
198  } else {
199  edm::LogInfo("Alignment") << "@SUB=initialize"
200  << "Skipping duplicate APE for DetId " << apeId;
201  }
202  }
203  }
204  apeReadFile.close();
205  edm::LogInfo("Alignment") << "@SUB=initialize"
206  << "Set " << apeList.size() << " APE values.";
207  }
208 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
AlignableTracker * theTracker
std::string fullPath() const
Definition: FileInPath.cc:161
edm::ParameterSet theConfig
auto &__restrict__ ws
AlignableNavigator * theAlignableNavigator
def ignore(seq)
GlobalErrorBaseExtended< double, ErrorMatrixTag > GlobalErrorExtended
Definition: GlobalError.h:14
Log< level::Info, false > LogInfo
Definition: DetId.h:17
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.

◆ run()

void ApeSettingAlgorithm::run ( const edm::EventSetup setup,
const EventInfo eventInfo 
)
overridevirtual

Run the algorithm.

Implements AlignmentAlgorithmBase.

Definition at line 255 of file ApeSettingAlgorithm.cc.

Referenced by DTWorkflow.DTWorkflow::all(), Types.EventID::cppID(), Types.LuminosityBlockID::cppID(), and o2olib.O2OTool::execute().

255  {
256  // nothing to do here?
257 }

◆ terminate()

void ApeSettingAlgorithm::terminate ( const edm::EventSetup iSetup)
overridevirtual

Call at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 212 of file ApeSettingAlgorithm.cc.

References AlignableNavigator::alignableFromDetId(), AlignableTracker::alignmentErrors(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, triggerObjects_cff::id, dqmiolumiharvest::j, dqmdumpme::k, AlignmentErrorsExtended::m_alignError, hcal_runs::rt, saveApeToAscii_, saveComposites_, saveLocalNotGlobal_, AlCaHLTBitMon_QueryRunRegistry::string, theAlignableNavigator, theConfig, and theTracker.

212  {
213  if (saveApeToAscii_) {
215  int theSize = aliErr->m_alignError.size();
216  std::ofstream apeSaveFile(
217  theConfig.getUntrackedParameter<std::string>("apeASCIISaveFile").c_str()); //requires <fstream>
218  for (int i = 0; i < theSize; ++i) {
219  int id = aliErr->m_alignError[i].rawId();
221  if (alidet && ((alidet->components().empty()) || saveComposites_)) {
222  apeSaveFile << id;
223  CLHEP::HepSymMatrix sm = aliErr->m_alignError[i].matrix();
224  if (saveLocalNotGlobal_) {
225  align::RotationType rt = alidet->globalRotation();
226  AlgebraicMatrix am(3, 3);
227  am[0][0] = rt.xx();
228  am[0][1] = rt.xy();
229  am[0][2] = rt.xz();
230  am[1][0] = rt.yx();
231  am[1][1] = rt.yy();
232  am[1][2] = rt.yz();
233  am[2][0] = rt.zx();
234  am[2][1] = rt.zy();
235  am[2][2] = rt.zz();
236  sm = sm.similarity(am); //symmetric matrix
237  } //transform to local
238  for (int j = 0; j < sm.num_row(); ++j)
239  for (int k = 0; k <= j; ++k)
240  apeSaveFile << " " << sm[j][k]; //always write full matrix
241 
242  apeSaveFile << std::endl;
243  }
244  }
245  delete aliErr;
246  apeSaveFile.close();
247  }
248  // clean up at end: // FIXME: should we delete here or in destructor?
249  delete theAlignableNavigator;
250  theAlignableNavigator = nullptr;
251 }
AlignableTracker * theTracker
edm::ParameterSet theConfig
T getUntrackedParameter(std::string const &, T const &) const
CLHEP::HepMatrix AlgebraicMatrix
AlignableNavigator * theAlignableNavigator
Definition: DetId.h:17
std::vector< AlignTransformErrorExtended > m_alignError
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.

Member Data Documentation

◆ readApeFromAscii_

bool ApeSettingAlgorithm::readApeFromAscii_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ readFullLocalMatrix_

bool ApeSettingAlgorithm::readFullLocalMatrix_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ readLocalNotGlobal_

bool ApeSettingAlgorithm::readLocalNotGlobal_
private

Definition at line 87 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ saveApeToAscii_

bool ApeSettingAlgorithm::saveApeToAscii_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

◆ saveComposites_

bool ApeSettingAlgorithm::saveComposites_
private

Definition at line 88 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

◆ saveLocalNotGlobal_

bool ApeSettingAlgorithm::saveLocalNotGlobal_
private

Definition at line 87 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

◆ setComposites_

bool ApeSettingAlgorithm::setComposites_
private

Definition at line 88 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ theAlignableNavigator

AlignableNavigator* ApeSettingAlgorithm::theAlignableNavigator
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by initialize(), terminate(), and ~ApeSettingAlgorithm().

◆ theConfig

edm::ParameterSet ApeSettingAlgorithm::theConfig
private

Definition at line 83 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), initialize(), and terminate().

◆ theTracker

AlignableTracker* ApeSettingAlgorithm::theTracker
private

Definition at line 85 of file ApeSettingAlgorithm.cc.

Referenced by initialize(), and terminate().