Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:35

0001 /** \file AlignableExtras
0002  *
0003  *  Original author: Andreas Mussgiller, August 2010
0004  *
0005  *  $Date: 2010/09/10 10:26:20 $
0006  *  $Revision: 1.1 $
0007  *  (last update by $Author: mussgill $)
0008  */
0009 
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 
0013 // Alignment
0014 #include "Alignment/CommonAlignment/interface/AlignableBeamSpot.h"
0015 
0016 #include "CondFormats/Alignment/interface/Alignments.h"
0017 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0018 
0019 #include "Alignment/CommonAlignment/interface/AlignableExtras.h"
0020 
0021 //__________________________________________________________________________________________________
0022 AlignableExtras::AlignableExtras() {
0023   align::Alignables& alis = alignableLists_.get("BeamSpot");
0024   alis.push_back(new AlignableBeamSpot());
0025   components_.push_back(alis.back());
0026 }
0027 
0028 //__________________________________________________________________________________________________
0029 void AlignableExtras::dump(void) const {
0030   Alignables comp = this->components();
0031 
0032   // Dump this
0033   edm::LogInfo("AlignableDump") << " AlignableExtras knows " << comp.size() << " alignable(s)" << std::endl;
0034 
0035   // Dump components
0036   for (Alignables::iterator i = comp.begin(); i != comp.end(); ++i)
0037     (*i)->dump();
0038 }
0039 
0040 //__________________________________________________________________________________________________
0041 Alignments* AlignableExtras::alignments(void) const {
0042   align::Alignables comp = this->components();
0043   Alignments* m_alignments = new Alignments();
0044   // Add components recursively
0045   for (align::Alignables::iterator i = comp.begin(); i != comp.end(); ++i) {
0046     Alignments* tmpAlignments = (*i)->alignments();
0047     std::copy(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), std::back_inserter(m_alignments->m_align));
0048     delete tmpAlignments;
0049   }
0050 
0051   // sort by rawId
0052   std::sort(m_alignments->m_align.begin(), m_alignments->m_align.end());
0053 
0054   return m_alignments;
0055 }
0056 
0057 //__________________________________________________________________________________________________
0058 AlignmentErrorsExtended* AlignableExtras::alignmentErrors(void) const {
0059   align::Alignables comp = this->components();
0060   AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
0061 
0062   // Add components recursively
0063   for (align::Alignables::iterator i = comp.begin(); i != comp.end(); ++i) {
0064     AlignmentErrorsExtended* tmpAlignmentErrorsExtended = (*i)->alignmentErrors();
0065     std::copy(tmpAlignmentErrorsExtended->m_alignError.begin(),
0066               tmpAlignmentErrorsExtended->m_alignError.end(),
0067               std::back_inserter(m_alignmentErrors->m_alignError));
0068     delete tmpAlignmentErrorsExtended;
0069   }
0070 
0071   // sort by rawId
0072   std::sort(m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end());
0073 
0074   return m_alignmentErrors;
0075 }
0076 
0077 //______________________________________________________________________________
0078 void AlignableExtras::initializeBeamSpot(double x, double y, double z, double dxdz, double dydz) {
0079   align::Alignables& alis = beamSpot();
0080   AlignableBeamSpot* aliBS = dynamic_cast<AlignableBeamSpot*>(alis.back());
0081   if (aliBS) {
0082     aliBS->initialize(x, y, z, dxdz, dydz);
0083   } else {
0084     edm::LogError("AlignableExtras") << " AlignableBeamSpot not available. Cannot initialize!" << std::endl;
0085   }
0086 }
0087 
0088 //______________________________________________________________________________
0089 void AlignableExtras::resetBeamSpot() {
0090   align::Alignables& alis = beamSpot();
0091   AlignableBeamSpot* aliBS = dynamic_cast<AlignableBeamSpot*>(alis.back());
0092   if (aliBS) {
0093     aliBS->reset();
0094   } else {
0095     edm::LogWarning("AlignableExtras") << "@SUB=AlignableExtras::resetBeamSpot"
0096                                        << "AlignableBeamSpot not available. Cannot reset!" << std::endl;
0097   }
0098 }