CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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...
 
virtual void initialize (const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store) override
 Call at beginning of job. More...
 
virtual void run (const edm::EventSetup &setup, const EventInfo &eventInfo) override
 Run the algorithm. More...
 
virtual void terminate (const edm::EventSetup &iSetup) override
 Call at end of job. More...
 
virtual ~ApeSettingAlgorithm ()
 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::EventSetup &setup)
 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 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
< ConstTrajTrackPair
ConstTrajTrackPairCollection
 
typedef cond::RealTimeType
< cond::runnumber >::type 
RunNumber
 
typedef std::pair< RunNumber,
RunNumber
RunRange
 

Detailed Description

Definition at line 58 of file ApeSettingAlgorithm.cc.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 95 of file ApeSettingAlgorithm.cc.

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

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

Destructor.

Definition at line 112 of file ApeSettingAlgorithm.cc.

References theAlignableNavigator.

113 {
114  delete theAlignableNavigator;
115 }
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 119 of file ApeSettingAlgorithm.cc.

References AlignableNavigator::alignableFromDetId(), contentValuesFiles::fullPath, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), SequenceTypes::ignore(), readApeFromAscii_, readFullLocalMatrix_, readLocalNotGlobal_, setComposites_, theAlignableNavigator, theConfig, theTracker, patCandidatesForDimuonsSequences_cff::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().

122 {
123  theAlignableNavigator = new AlignableNavigator(tracker, muon);
125 
126  if (readApeFromAscii_)
127  { std::ifstream apeReadFile(theConfig.getParameter<edm::FileInPath>("apeASCIIReadFile").fullPath().c_str()); //requires <fstream>
128  if (!apeReadFile.good())
129  { edm::LogInfo("Alignment") << "@SUB=initialize" <<"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; double x11,x21,x22,x31,x32,x33,ignore;
137  { 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;}
138  else
139  { apeReadFile>>apeId>>x11>>x22>>x33>>std::ws;}
140  //idr What sanity checks do we need to put here?
141  if (apeId != 0) //read appears valid?
142  { if (apeList.find(apeId) == apeList.end()) //Not previously done
143  { DetId id(apeId);
145  if (alidet)
146  { if ((alidet->components().size()<1) || setComposites_) //the problem with glued dets...
147  { GlobalErrorExtended globErr;
149  { AlgebraicSymMatrix33 as;
151  { as[0][0]=x11; as[1][0]=x21; as[1][1]=x22;
152  as[2][0]=x31; as[2][1]=x32; as[2][2]=x33;
153  }
154  else
155  { as[0][0]=x11*x11; as[1][1]=x22*x22; as[2][2]=x33*x33;} //local cov.
156  align::RotationType rt=alidet->globalRotation();
158  am[0][0]=rt.xx(); am[0][1]=rt.xy(); am[0][2]=rt.xz();
159  am[1][0]=rt.yx(); am[1][1]=rt.yy(); am[1][2]=rt.yz();
160  am[2][0]=rt.zx(); am[2][1]=rt.zy(); am[2][2]=rt.zz();
161  globErr = GlobalErrorExtended(ROOT::Math::SimilarityT(am,as));
162  }
163  else
164  {
166  globErr = GlobalErrorExtended(x11,x21,x31,0,0,0,x22,x32,0,0,0,x33,0,0,0,0,0,0,0,0,0);
167  else {
168  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);
169  }
170  }
171  alidet->setAlignmentPositionError(globErr, false); // do not propagate down!
172  apeList.insert(apeId); //Flag it's been set
173  }
174  else
175  { edm::LogInfo("Alignment") << "@SUB=initialize" << "Not Setting APE for Composite DetId "<<apeId;
176  }
177  }
178  }
179  else
180  { edm::LogInfo("Alignment") << "@SUB=initialize" << "Skipping duplicate APE for DetId "<<apeId;
181  }
182  }
183  }
184  apeReadFile.close();
185  edm::LogInfo("Alignment") << "@SUB=initialize" << "Set "<<apeList.size()<<" APE values.";
186  }
187 }
GlobalErrorBaseExtended< double, ErrorMatrixTag > GlobalErrorExtended
Definition: GlobalError.h:13
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
Definition: DetId.h:18
T xz() const
std::string fullPath() const
Definition: FileInPath.cc:165
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 229 of file ApeSettingAlgorithm.cc.

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

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

Call at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 192 of file ApeSettingAlgorithm.cc.

References AlignableNavigator::alignableFromDetId(), AlignableTracker::alignmentErrors(), edm::ParameterSet::getUntrackedParameter(), i, j, relval_steps::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().

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

Member Data Documentation

bool ApeSettingAlgorithm::readApeFromAscii_
private

Definition at line 82 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

bool ApeSettingAlgorithm::readFullLocalMatrix_
private

Definition at line 82 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

bool ApeSettingAlgorithm::readLocalNotGlobal_
private

Definition at line 83 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

bool ApeSettingAlgorithm::saveApeToAscii_
private

Definition at line 82 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

bool ApeSettingAlgorithm::saveComposites_
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

bool ApeSettingAlgorithm::saveLocalNotGlobal_
private

Definition at line 83 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and terminate().

bool ApeSettingAlgorithm::setComposites_
private

Definition at line 84 of file ApeSettingAlgorithm.cc.

Referenced by ApeSettingAlgorithm(), and initialize().

AlignableNavigator* ApeSettingAlgorithm::theAlignableNavigator
private

Definition at line 80 of file ApeSettingAlgorithm.cc.

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

edm::ParameterSet ApeSettingAlgorithm::theConfig
private

Definition at line 79 of file ApeSettingAlgorithm.cc.

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

AlignableTracker* ApeSettingAlgorithm::theTracker
private

Definition at line 81 of file ApeSettingAlgorithm.cc.

Referenced by initialize(), and terminate().