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)
 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 &)
 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 60 of file ApeSettingAlgorithm.cc.

Constructor & Destructor Documentation

◆ ApeSettingAlgorithm()

ApeSettingAlgorithm::ApeSettingAlgorithm ( const edm::ParameterSet cfg)

Constructor.

Definition at line 97 of file ApeSettingAlgorithm.cc.

99  edm::LogInfo("Alignment") << "@SUB=ApeSettingAlgorithm"
100  << "Start.";
101  saveApeToAscii_ = theConfig.getUntrackedParameter<bool>("saveApeToASCII");
102  saveComposites_ = theConfig.getUntrackedParameter<bool>("saveComposites");
103  saveLocalNotGlobal_ = theConfig.getUntrackedParameter<bool>("saveLocalNotGlobal");
104  readApeFromAscii_ = theConfig.getParameter<bool>("readApeFromASCII");
105  readLocalNotGlobal_ = theConfig.getParameter<bool>("readLocalNotGlobal");
106  readFullLocalMatrix_ = theConfig.getParameter<bool>("readFullLocalMatrix");
107  setComposites_ = theConfig.getParameter<bool>("setComposites");
108 }

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

◆ ~ApeSettingAlgorithm()

ApeSettingAlgorithm::~ApeSettingAlgorithm ( )
override

Destructor.

Definition at line 112 of file ApeSettingAlgorithm.cc.

112 { delete theAlignableNavigator; }

References 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 116 of file ApeSettingAlgorithm.cc.

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

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, and PbPb_ZMuSkimMuonDPG_cff::tracker.

◆ run()

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

Run the algorithm.

Implements AlignmentAlgorithmBase.

Definition at line 254 of file ApeSettingAlgorithm.cc.

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

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

◆ terminate()

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

Call at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 211 of file ApeSettingAlgorithm.cc.

211  {
212  if (saveApeToAscii_) {
214  int theSize = aliErr->m_alignError.size();
215  std::ofstream apeSaveFile(
216  theConfig.getUntrackedParameter<std::string>("apeASCIISaveFile").c_str()); //requires <fstream>
217  for (int i = 0; i < theSize; ++i) {
218  int id = aliErr->m_alignError[i].rawId();
220  if (alidet && ((alidet->components().empty()) || saveComposites_)) {
221  apeSaveFile << id;
222  CLHEP::HepSymMatrix sm = aliErr->m_alignError[i].matrix();
223  if (saveLocalNotGlobal_) {
224  align::RotationType rt = alidet->globalRotation();
225  AlgebraicMatrix am(3, 3);
226  am[0][0] = rt.xx();
227  am[0][1] = rt.xy();
228  am[0][2] = rt.xz();
229  am[1][0] = rt.yx();
230  am[1][1] = rt.yy();
231  am[1][2] = rt.yz();
232  am[2][0] = rt.zx();
233  am[2][1] = rt.zy();
234  am[2][2] = rt.zz();
235  sm = sm.similarity(am); //symmetric matrix
236  } //transform to local
237  for (int j = 0; j < sm.num_row(); ++j)
238  for (int k = 0; k <= j; ++k)
239  apeSaveFile << " " << sm[j][k]; //always write full matrix
240 
241  apeSaveFile << std::endl;
242  }
243  }
244  delete aliErr;
245  apeSaveFile.close();
246  }
247  // clean up at end: // FIXME: should we delete here or in destructor?
248  delete theAlignableNavigator;
249  theAlignableNavigator = nullptr;
250 }

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.

Member Data Documentation

◆ readApeFromAscii_

bool ApeSettingAlgorithm::readApeFromAscii_
private

Definition at line 85 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ readFullLocalMatrix_

bool ApeSettingAlgorithm::readFullLocalMatrix_
private

Definition at line 85 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ readLocalNotGlobal_

bool ApeSettingAlgorithm::readLocalNotGlobal_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ saveApeToAscii_

bool ApeSettingAlgorithm::saveApeToAscii_
private

Definition at line 85 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

◆ saveComposites_

bool ApeSettingAlgorithm::saveComposites_
private

Definition at line 87 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

◆ saveLocalNotGlobal_

bool ApeSettingAlgorithm::saveLocalNotGlobal_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

◆ setComposites_

bool ApeSettingAlgorithm::setComposites_
private

Definition at line 87 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

◆ theAlignableNavigator

AlignableNavigator* ApeSettingAlgorithm::theAlignableNavigator
private

Definition at line 83 of file ApeSettingAlgorithm.cc.

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

◆ theConfig

edm::ParameterSet ApeSettingAlgorithm::theConfig
private

Definition at line 82 of file ApeSettingAlgorithm.cc.

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

◆ theTracker

AlignableTracker* ApeSettingAlgorithm::theTracker
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by initialize(), and terminate().

TkRotation< Scalar >
ApeSettingAlgorithm::theTracker
AlignableTracker * theTracker
Definition: ApeSettingAlgorithm.cc:84
AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Definition: AlgebraicROOTObjects.h:21
mps_fire.i
i
Definition: mps_fire.py:355
ApeSettingAlgorithm::readFullLocalMatrix_
bool readFullLocalMatrix_
Definition: ApeSettingAlgorithm.cc:85
muon
Definition: MuonCocktails.h:17
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
hcal_runs.rt
rt
Definition: hcal_runs.py:76
edm::LogInfo
Definition: MessageLogger.h:254
ApeSettingAlgorithm::readLocalNotGlobal_
bool readLocalNotGlobal_
Definition: ApeSettingAlgorithm.cc:86
AlgebraicMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
Definition: AlgebraicROOTObjects.h:41
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
GlobalErrorExtended
GlobalErrorBaseExtended< double, ErrorMatrixTag > GlobalErrorExtended
Definition: GlobalError.h:14
AlignmentAlgorithmBase::AlignmentAlgorithmBase
AlignmentAlgorithmBase(const edm::ParameterSet &)
Constructor.
Definition: AlignmentAlgorithmBase.h:114
AlignableDetOrUnitPtr
Definition: AlignableDetOrUnitPtr.h:30
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
AlignableTracker::alignmentErrors
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
Definition: AlignableTracker.cc:59
ApeSettingAlgorithm::readApeFromAscii_
bool readApeFromAscii_
Definition: ApeSettingAlgorithm.cc:85
ApeSettingAlgorithm::saveComposites_
bool saveComposites_
Definition: ApeSettingAlgorithm.cc:87
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlignableNavigator
Definition: AlignableNavigator.h:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
ApeSettingAlgorithm::theAlignableNavigator
AlignableNavigator * theAlignableNavigator
Definition: ApeSettingAlgorithm.cc:83
ApeSettingAlgorithm::saveApeToAscii_
bool saveApeToAscii_
Definition: ApeSettingAlgorithm.cc:85
ApeSettingAlgorithm::setComposites_
bool setComposites_
Definition: ApeSettingAlgorithm.cc:87
SequenceTypes.ignore
def ignore(seq)
Definition: SequenceTypes.py:630
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
looper.cfg
cfg
Definition: looper.py:297
ApeSettingAlgorithm::theConfig
edm::ParameterSet theConfig
Definition: ApeSettingAlgorithm.cc:82
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
AlignableNavigator::alignableFromDetId
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
Definition: AlignableNavigator.cc:91
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
AlignmentErrorsExtended::m_alignError
std::vector< AlignTransformErrorExtended > m_alignError
Definition: AlignmentErrorsExtended.h:19
GlobalErrorBaseExtended< double, ErrorMatrixTag >
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
ApeSettingAlgorithm::saveLocalNotGlobal_
bool saveLocalNotGlobal_
Definition: ApeSettingAlgorithm.cc:86