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 &)
 
 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 ( const edm::ParameterSet cfg)

Constructor.

Definition at line 97 of file ApeSettingAlgorithm.cc.

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

97  :
99  theAlignableNavigator(nullptr)
100 {
101  edm::LogInfo("Alignment") << "@SUB=ApeSettingAlgorithm" << "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 
110 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet theConfig
AlignmentAlgorithmBase(const edm::ParameterSet &)
Constructor.
AlignableNavigator * theAlignableNavigator
ApeSettingAlgorithm::~ApeSettingAlgorithm ( )
override

Destructor.

Definition at line 114 of file ApeSettingAlgorithm.cc.

References theAlignableNavigator.

115 {
116  delete theAlignableNavigator;
117 }
AlignableNavigator * theAlignableNavigator

Member Function Documentation

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

References AlignableNavigator::alignableFromDetId(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), triggerObjects_cff::id, SequenceTypes::ignore(), readApeFromAscii_, readFullLocalMatrix_, readLocalNotGlobal_, setComposites_, theAlignableNavigator, theConfig, theTracker, mixOne_simraw_on_sim_cfi::tracker, TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

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

Run the algorithm.

Implements AlignmentAlgorithmBase.

Definition at line 231 of file ApeSettingAlgorithm.cc.

References DEFINE_EDM_PLUGIN.

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

232 {
233  // nothing to do here?
234 }
void ApeSettingAlgorithm::terminate ( const edm::EventSetup iSetup)
overridevirtual

Call at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 194 of file ApeSettingAlgorithm.cc.

References AlignableNavigator::alignableFromDetId(), AlignableTracker::alignmentErrors(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, triggerObjects_cff::id, gen::k, AlignmentErrorsExtended::m_alignError, saveApeToAscii_, saveComposites_, saveLocalNotGlobal_, AlCaHLTBitMon_QueryRunRegistry::string, theAlignableNavigator, theConfig, theTracker, TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

195 {
196  if (saveApeToAscii_)
198  int theSize=aliErr->m_alignError.size();
199  std::ofstream apeSaveFile(theConfig.getUntrackedParameter<std::string>("apeASCIISaveFile").c_str()); //requires <fstream>
200  for (int i=0; i < theSize; ++i)
201  { int id= aliErr->m_alignError[i].rawId();
203  if (alidet && ((alidet->components().empty()) || saveComposites_))
204  { apeSaveFile<<id;
205  CLHEP::HepSymMatrix sm = aliErr->m_alignError[i].matrix();
207  { align::RotationType rt=alidet->globalRotation();
208  AlgebraicMatrix am(3,3);
209  am[0][0]=rt.xx(); am[0][1]=rt.xy(); am[0][2]=rt.xz();
210  am[1][0]=rt.yx(); am[1][1]=rt.yy(); am[1][2]=rt.yz();
211  am[2][0]=rt.zx(); am[2][1]=rt.zy(); am[2][2]=rt.zz();
212  sm=sm.similarity(am); //symmetric matrix
213  } //transform to local
214  for (int j=0; j < sm.num_row(); ++j)
215  for (int k=0; k <= j; ++k)
216  apeSaveFile<<" "<<sm[j][k]; //always write full matrix
217 
218  apeSaveFile<<std::endl;
219  }
220  }
221  delete aliErr;
222  apeSaveFile.close();
223  }
224  // clean up at end: // FIXME: should we delete here or in destructor?
225  delete theAlignableNavigator;
226  theAlignableNavigator = nullptr;
227 }
T xx() const
T getUntrackedParameter(std::string const &, T const &) const
AlignableTracker * theTracker
T yx() const
edm::ParameterSet theConfig
T zx() const
T xy() const
T zz() const
CLHEP::HepMatrix AlgebraicMatrix
T zy() const
AlignableNavigator * theAlignableNavigator
T yy() const
int k[5][pyjets_maxn]
Definition: DetId.h:18
std::vector< AlignTransformErrorExtended > m_alignError
T xz() const
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
T yz() const

Member Data Documentation

bool ApeSettingAlgorithm::readApeFromAscii_
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

bool ApeSettingAlgorithm::readFullLocalMatrix_
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

bool ApeSettingAlgorithm::readLocalNotGlobal_
private

Definition at line 85 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

bool ApeSettingAlgorithm::saveApeToAscii_
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

bool ApeSettingAlgorithm::saveComposites_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

bool ApeSettingAlgorithm::saveLocalNotGlobal_
private

Definition at line 85 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

bool ApeSettingAlgorithm::setComposites_
private

Definition at line 86 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

AlignableNavigator* ApeSettingAlgorithm::theAlignableNavigator
private

Definition at line 82 of file ApeSettingAlgorithm.cc.

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

edm::ParameterSet ApeSettingAlgorithm::theConfig
private

Definition at line 81 of file ApeSettingAlgorithm.cc.

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

AlignableTracker* ApeSettingAlgorithm::theTracker
private

Definition at line 83 of file ApeSettingAlgorithm.cc.

Referenced by initialize(), and terminate().