CMS 3D CMS Logo

Public Member Functions | Private Attributes

MuonScenarioBuilder Class Reference

Builds a scenario from configuration and applies it to the alignable Muon. More...

#include <MuonScenarioBuilder.h>

Inheritance diagram for MuonScenarioBuilder:
MisalignmentScenarioBuilder

List of all members.

Public Member Functions

void applyScenario (const edm::ParameterSet &scenario)
 Apply misalignment scenario to the Muon.
align::Scalars extractParameters (const edm::ParameterSet &, const char *)
void moveChamberInSector (Alignable *, align::Scalars, align::Scalars, align::Scalars, align::Scalars)
void moveCSCSectors (const edm::ParameterSet &scenario)
 this special method allows to move a CSCsector by a same amount
void moveDTSectors (const edm::ParameterSet &scenario)
 This special method allows to move a DTsector by a same amount.
void moveMuon (const edm::ParameterSet &scenario)
 this special method allows to move the complete muon system by a same amount
 MuonScenarioBuilder (Alignable *alignable)
 Constructor.
 ~MuonScenarioBuilder ()
 Destructor.

Private Attributes

AlignableMuontheAlignableMuon
 Pointer to alignable Muon object.
AlignableModifier theMuonModifier

Detailed Description

Builds a scenario from configuration and applies it to the alignable Muon.

The misalignment scenario builder.

Date:
2011/06/07 19:28:47
Revision:
1.6
Author:
Andre Sznajder - UERJ(Brazil)

Definition at line 21 of file MuonScenarioBuilder.h.


Constructor & Destructor Documentation

MuonScenarioBuilder::MuonScenarioBuilder ( Alignable alignable) [explicit]

Constructor.

Definition at line 25 of file MuonScenarioBuilder.cc.

References Exception, and theAlignableMuon.

{

  theAlignableMuon = dynamic_cast<AlignableMuon*>( alignable );

  if ( !theAlignableMuon )
    throw cms::Exception("TypeMismatch") << "Argument is not an AlignableMuon";

}
MuonScenarioBuilder::~MuonScenarioBuilder ( ) [inline]

Destructor.

Definition at line 30 of file MuonScenarioBuilder.h.

{};

Member Function Documentation

void MuonScenarioBuilder::applyScenario ( const edm::ParameterSet scenario) [virtual]

Apply misalignment scenario to the Muon.

Implements MisalignmentScenarioBuilder.

Definition at line 37 of file MuonScenarioBuilder.cc.

References AlignableMuon::CSCEndcaps(), MisalignmentScenarioBuilder::decodeMovements_(), AlignableMuon::DTBarrel(), Exception, edm::ParameterSet::getParameter(), MisalignmentScenarioBuilder::hasParameter_(), moveCSCSectors(), moveDTSectors(), moveMuon(), AlignableModifier::setSeed(), theAlignableMuon, MisalignmentScenarioBuilder::theModifier, MisalignmentScenarioBuilder::theModifierCounter, and MisalignmentScenarioBuilder::theScenario.

Referenced by MuonGeometryDBConverter::analyze(), AlignmentProducer::beginOfJob(), and MisalignedMuonESProducer::produce().

{
  // Apply the scenario to all main components of Muon.
  theScenario = scenario;
  theModifierCounter = 0;

  // Seed is set at top-level, and is mandatory
  if ( this->hasParameter_( "seed", theScenario ) )
        theModifier.setSeed( static_cast<long>(theScenario.getParameter<int>("seed")) );
  else
        throw cms::Exception("BadConfig") << "No generator seed defined!";  



  // DT Barrel
  std::vector<Alignable*> dtBarrel = theAlignableMuon->DTBarrel();
  this->decodeMovements_( theScenario, dtBarrel, "DTBarrel" );
  // CSC Endcap
  std::vector<Alignable*> cscEndcaps = theAlignableMuon->CSCEndcaps();
  this->decodeMovements_( theScenario, cscEndcaps, "CSCEndcap" );

  this->moveDTSectors(theScenario);
  this->moveCSCSectors(theScenario);
  this->moveMuon(theScenario);
  
  edm::LogInfo("TrackerScenarioBuilder") 
        << "Applied modifications to " << theModifierCounter << " alignables";
}
align::Scalars MuonScenarioBuilder::extractParameters ( const edm::ParameterSet pSet,
const char *  blockId 
)

Definition at line 68 of file MuonScenarioBuilder.cc.

References error, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), MisalignmentScenarioBuilder::getParameterSet_(), and edm::ParameterSet::retrieve().

Referenced by moveCSCSectors(), moveDTSectors(), and moveMuon().

{
  double scale_ = 0, scaleError_ = 0, phiX_ = 0, phiY_ = 0, phiZ_ = 0;
  double dX_ = 0, dY_ = 0, dZ_ = 0;
  std::string distribution_;
  std::ostringstream error;
  edm::ParameterSet Parameters = this->getParameterSet_((std::string)blockId, pSet);
  std::vector<std::string> parameterNames = Parameters.getParameterNames();
  for ( std::vector<std::string>::iterator iParam = parameterNames.begin(); iParam != parameterNames.end(); iParam++ ) {
    if ( (*iParam) == "scale" )    scale_ = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "distribution" ) distribution_ = Parameters.getParameter<std::string>( *iParam );
    else if ( (*iParam) == "scaleError" ) scaleError_ = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "phiX" )     phiX_     = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "phiY" )     phiY_     = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "phiZ" )     phiZ_     = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "dX" )       dX_       = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "dY" )       dY_       = Parameters.getParameter<double>( *iParam );
    else if ( (*iParam) == "dZ" )       dZ_       = Parameters.getParameter<double>( *iParam );
    else if ( Parameters.retrieve( *iParam ).typeCode() != 'P' )
      { // Add unknown parameter to list
        if ( !error.str().length() ) error << "Unknown parameter name(s): ";
        error << " " << *iParam;
      }
  }
  align::Scalars param;
  param.push_back(scale_); param.push_back(scaleError_);
  param.push_back(phiX_); param.push_back(phiY_);
  param.push_back(phiZ_); param.push_back(dX_);
  param.push_back(dY_); param.push_back(dZ_);
  if( distribution_ == "gaussian" )
    param.push_back(0);
  else if ( distribution_ == "flat" )
    param.push_back(1);
  else if ( distribution_ == "fix" )
    param.push_back(2);
  
  return param;
}
void MuonScenarioBuilder::moveChamberInSector ( Alignable chamber,
align::Scalars  disp,
align::Scalars  rotation,
align::Scalars  dispError,
align::Scalars  rotationError 
)

Definition at line 301 of file MuonScenarioBuilder.cc.

References AlignableModifier::addAlignmentPositionError(), AlignableModifier::addAlignmentPositionErrorFromRotation(), PV3DBase< T, PVType, FrameType >::basicVector(), Alignable::globalPosition(), AlignableModifier::moveAlignable(), pos, makeMuonMisalignmentScenario::rot, AlignableModifier::rotateAlignable(), theMuonModifier, and PV3DBase< T, PVType, FrameType >::x().

Referenced by moveCSCSectors(), and moveDTSectors().

{
    align::RotationType rotx( Basic3DVector<double>(1.0, 0.0, 0.0), rotation[0] );
    align::RotationType roty( Basic3DVector<double>(0.0, 1.0, 0.0), rotation[1] );
    align::RotationType rotz( Basic3DVector<double>(0.0, 0.0, 1.0), rotation[2] );
    align::RotationType rot = rotz * roty * rotx;
    align::GlobalPoint pos = chamber->globalPosition();
    align::GlobalPoint dispRot(pos.basicVector()-rot*pos.basicVector());
    disp[0] += dispRot.x(); disp[1] += dispRot.y(); disp[2] += dispRot.z();
    theMuonModifier.moveAlignable( chamber, false, true, disp[0], disp[1], disp[2] );
    theMuonModifier.rotateAlignable( chamber, false, true, rotation[0],  rotation[1], rotation[2] );
    theMuonModifier.addAlignmentPositionError( chamber, dispError[0], dispError[1], dispError[2] );
    theMuonModifier.addAlignmentPositionErrorFromRotation( chamber,  rotationError[0], rotationError[1], rotationError[2] );
}
void MuonScenarioBuilder::moveCSCSectors ( const edm::ParameterSet scenario)

this special method allows to move a CSCsector by a same amount

Definition at line 170 of file MuonScenarioBuilder.cc.

References AlignableMuon::CSCChambers(), Reference_intrackfit_cff::endcap, extractParameters(), AlignableModifier::flatRandomVector(), AlignableModifier::gaussianRandomVector(), getHLTprescales::index, moveChamberInSector(), relativeConstraints::ring, idealTransformation::rotation, CSCTriggerNumbering::sectorFromTriggerLabels(), relativeConstraints::station, theAlignableMuon, theMuonModifier, CSCTriggerNumbering::triggerSectorFromLabels(), and CSCTriggerNumbering::triggerSubSectorFromLabels().

Referenced by applyScenario().

{
  std::vector<Alignable *> CSCchambers = theAlignableMuon->CSCChambers();
  //Take Parameters
  align::Scalars param = this->extractParameters(pSet, "CSCSectors");
  double scale_ = param[0]; double scaleError_ = param[1];
  double phiX_ = param[2]; double phiY_ = param[3]; double phiZ_ = param[4];
  double dX_ = param[5]; double dY_ = param[6]; double dZ_ = param[7];
  double dist_ = param[8];
  
  double dx = scale_*dX_; double dy = scale_*dY_; double dz = scale_*dZ_;
  double phix = scale_*phiX_; double phiy = scale_*phiY_; double phiz = scale_*phiZ_;
  double errorx = scaleError_*dX_; double errory = scaleError_*dY_; double errorz = scaleError_*dZ_;
  double errorphix = scaleError_*phiX_; double errorphiy = scaleError_*phiY_; double errorphiz = scaleError_*phiZ_;
  align::Scalars errorDisp;
  errorDisp.push_back(errorx); errorDisp.push_back(errory); errorDisp.push_back(errorz);
  align::Scalars errorRotation;
  errorRotation.push_back(errorphix); errorRotation.push_back(errorphiy); errorRotation.push_back(errorphiz);
  
  int index[2][4][4][36];
  int sector_index[2][4][4][36];
  int counter = 0;
  //Create an index for the chambers in the alignable vector
  for(std::vector<Alignable *>::iterator iter = CSCchambers.begin(); iter != CSCchambers.end(); ++iter) {
    CSCDetId myId((*iter)->geomDetId().rawId());
    index[myId.endcap()-1][myId.station()-1][myId.ring()-1][myId.chamber()-1] = counter;
    sector_index[myId.endcap()-1][myId.station()-1][myId.ring()-1][myId.chamber()-1] = CSCTriggerNumbering::sectorFromTriggerLabels(CSCTriggerNumbering::triggerSectorFromLabels(myId),CSCTriggerNumbering::triggerSubSectorFromLabels(myId) , myId.station());
    counter++;
  }
  for(int endcap = 0; endcap < 2; endcap++) {
    for(int ring = 0; ring < 2; ring++) {
      for(int sector = 1; sector < 7; sector++) {
        align::Scalars disp;
        align::Scalars rotation;
        if( dist_ == 0 ) {
          const std::vector<float> disp_ = theMuonModifier.gaussianRandomVector(dx, dy, dz);
          const std::vector<float> rotation_ = theMuonModifier.gaussianRandomVector(phix, phiy, phiz);
          disp.push_back(disp_[0]); disp.push_back(disp_[1]); disp.push_back(disp_[2]);
          rotation.push_back(rotation_[0]); rotation.push_back(rotation_[1]); rotation.push_back(rotation_[2]);
        } else if (dist_ == 1) {
          const std::vector<float> disp_ = theMuonModifier.flatRandomVector(dx, dy, dz);
          const std::vector<float> rotation_ = theMuonModifier.flatRandomVector(phix, phiy, phiz);
          disp.push_back(disp_[0]); disp.push_back(disp_[1]); disp.push_back(disp_[2]);
          rotation.push_back(rotation_[0]); rotation.push_back(rotation_[1]); rotation.push_back(rotation_[2]);
        } else {
          disp.push_back(dx); disp.push_back(dy); disp.push_back(dz);
          rotation.push_back(phix); rotation.push_back(phiy); rotation.push_back(phiz);
        }
        //Different cases are considered in order to fit endcap geometry
        for(int station = 0; station < 4; station++) {
          if(station == 0) {
            int r_ring[2];
            if(ring == 0) {
              r_ring[0] = 0; r_ring[1] = 3;
            } else {
              r_ring[0] = 1; r_ring[1] = 2;
            }
            for(int r_counter = 0; r_counter < 2; r_counter++) {
              for(int chamber = 0; chamber < 36; chamber++) {
                if(sector == (sector_index[endcap][station][r_ring[r_counter]][chamber]+1)/2) {
                  Alignable *myAlign = CSCchambers.at(index[endcap][station][r_ring[r_counter]][chamber]);
                  this->moveChamberInSector(myAlign, disp, rotation, errorDisp, errorRotation);
                }
              }
            }
          } else if(station == 3 && ring == 1) {
            continue;
          } else {
            for(int chamber = 0; chamber < 36; chamber++) {
              if(ring == 0 && chamber > 17) continue;
              if(sector == sector_index[endcap][station][ring][chamber]) {
                Alignable *myAlign = CSCchambers.at(index[endcap][station][ring][chamber]);
                this->moveChamberInSector(myAlign, disp, rotation, errorDisp, errorRotation);
              }
            }
          }
        }
      }
    }
  }
}
void MuonScenarioBuilder::moveDTSectors ( const edm::ParameterSet scenario)

This special method allows to move a DTsector by a same amount.

Definition at line 108 of file MuonScenarioBuilder.cc.

References AlignableMuon::DTChambers(), extractParameters(), AlignableModifier::flatRandomVector(), AlignableModifier::gaussianRandomVector(), getHLTprescales::index, moveChamberInSector(), idealTransformation::rotation, relativeConstraints::station, theAlignableMuon, and theMuonModifier.

Referenced by applyScenario().

{
  std::vector<Alignable *> DTchambers = theAlignableMuon->DTChambers();
  //Take parameters
  align::Scalars param = this->extractParameters(pSet, "DTSectors");
  double scale_ = param[0]; double scaleError_ = param[1];
  double phiX_ = param[2]; double phiY_ = param[3]; double phiZ_ = param[4];
  double dX_ = param[5]; double dY_ = param[6]; double dZ_ = param[7];
  double dist_ = param[8];

  double dx = scale_*dX_; double dy = scale_*dY_; double dz = scale_*dZ_;
  double phix = scale_*phiX_; double phiy = scale_*phiY_; double phiz = scale_*phiZ_;
  double errorx = scaleError_*dX_; double errory = scaleError_*dY_; double errorz = scaleError_*dZ_;
  double errorphix = scaleError_*phiX_; double errorphiy = scaleError_*phiY_; double errorphiz = scaleError_*phiZ_;
  align::Scalars errorDisp;
  errorDisp.push_back(errorx); errorDisp.push_back(errory); errorDisp.push_back(errorz);
  align::Scalars errorRotation;
  errorRotation.push_back(errorphix); errorRotation.push_back(errorphiy); errorRotation.push_back(errorphiz);
 
  int index[5][4][14];
  int counter = 0;
  //Create and index for the chambers in the Alignable vector
  for(std::vector<Alignable *>::iterator iter = DTchambers.begin(); iter != DTchambers.end(); ++iter) {
    DTChamberId myId((*iter)->geomDetId().rawId());
    index[myId.wheel()+2][myId.station()-1][myId.sector()-1] = counter;
    counter++;
  }
  for(int wheel = 0; wheel < 5; wheel++) {
    for(int sector = 0; sector < 12; sector++) {
      align::Scalars disp;
      align::Scalars rotation;
      if( dist_ == 0 ) {
        const std::vector<float> disp_ = theMuonModifier.gaussianRandomVector(dx, dy, dz);
        const std::vector<float> rotation_ = theMuonModifier.gaussianRandomVector(phix, phiy, phiz);
        disp.push_back(disp_[0]); disp.push_back(disp_[1]); disp.push_back(disp_[2]);
        rotation.push_back(rotation_[0]); rotation.push_back(rotation_[1]); rotation.push_back(rotation_[2]);
      } else if (dist_ == 1) {
        const std::vector<float> disp_ = theMuonModifier.flatRandomVector(dx, dy, dz);
        const std::vector<float> rotation_ = theMuonModifier.flatRandomVector(phix, phiy, phiz);
        disp.push_back(disp_[0]); disp.push_back(disp_[1]); disp.push_back(disp_[2]);
        rotation.push_back(rotation_[0]); rotation.push_back(rotation_[1]); rotation.push_back(rotation_[2]);
      } else {
        disp.push_back(dx); disp.push_back(dy); disp.push_back(dz);
        rotation.push_back(phix); rotation.push_back(phiy); rotation.push_back(phiz);
      }
      for(int station = 0; station < 4; station++) {
        Alignable *myAlign = DTchambers.at(index[wheel][station][sector]);
        this->moveChamberInSector(myAlign, disp, rotation, errorDisp, errorRotation);
        if(sector == 3 && station == 3) {
          Alignable *myAlignD = DTchambers.at(index[wheel][station][12]);
          this->moveChamberInSector(myAlignD, disp, rotation, errorDisp, errorRotation);
        } else if(sector == 9 && station == 3) {
          Alignable *myAlignD = DTchambers.at(index[wheel][station][13]);
          this->moveChamberInSector(myAlignD, disp, rotation, errorDisp, errorRotation);
        }
      }
    }
  } 
}
void MuonScenarioBuilder::moveMuon ( const edm::ParameterSet scenario)

this special method allows to move the complete muon system by a same amount

Definition at line 254 of file MuonScenarioBuilder.cc.

References AlignableModifier::addAlignmentPositionError(), AlignableModifier::addAlignmentPositionErrorFromRotation(), AlignableMuon::CSCEndcaps(), AlignableMuon::DTBarrel(), extractParameters(), AlignableModifier::flatRandomVector(), AlignableModifier::gaussianRandomVector(), AlignableModifier::moveAlignable(), AlignableModifier::rotateAlignable(), idealTransformation::rotation, theAlignableMuon, and theMuonModifier.

Referenced by applyScenario().

{
  std::vector<Alignable *> DTbarrel = theAlignableMuon->DTBarrel();     
  std::vector<Alignable *> CSCendcaps = theAlignableMuon->CSCEndcaps();  
  //Take Parameters
  align::Scalars param = this->extractParameters(pSet, "Muon");
  double scale_ = param[0]; double scaleError_ = param[1];
  double phiX_ = param[2]; double phiY_ = param[3]; double phiZ_ = param[4];
  double dX_ = param[5]; double dY_ = param[6]; double dZ_ = param[7];
  double dist_ = param[8]; 
  double dx = scale_*dX_; double dy = scale_*dY_; double dz = scale_*dZ_;
  double phix = scale_*phiX_; double phiy = scale_*phiY_; double phiz = scale_*phiZ_;
  double errorx = scaleError_*dX_; double errory = scaleError_*dY_; double errorz = scaleError_*dZ_;
  double errorphix = scaleError_*phiX_; double errorphiy = scaleError_*phiY_; double errorphiz = scaleError_*phiZ_;
  //Create an index for the chambers in the alignable vector
  align::Scalars disp;
  align::Scalars rotation;
  if( dist_ == 0 ) {
    const std::vector<float> disp_ = theMuonModifier.gaussianRandomVector(dx, dy, dz);
    const std::vector<float> rotation_ = theMuonModifier.gaussianRandomVector(phix, phiy, phiz);
    disp.push_back(disp_[0]); disp.push_back(disp_[1]); disp.push_back(disp_[2]);
    rotation.push_back(rotation_[0]); rotation.push_back(rotation_[1]); rotation.push_back(rotation_[2]);
  } else if (dist_ == 1) {
    const std::vector<float> disp_ = theMuonModifier.flatRandomVector(dx, dy, dz);
    const std::vector<float> rotation_ = theMuonModifier.flatRandomVector(phix, phiy, phiz);
    disp.push_back(disp_[0]); disp.push_back(disp_[1]); disp.push_back(disp_[2]);
    rotation.push_back(rotation_[0]); rotation.push_back(rotation_[1]); rotation.push_back(rotation_[2]);
  } else {
    disp.push_back(dx); disp.push_back(dy); disp.push_back(dz);
    rotation.push_back(phix); rotation.push_back(phiy); rotation.push_back(phiz);
  }
  for(std::vector<Alignable *>::iterator iter = DTbarrel.begin(); iter != DTbarrel.end(); ++iter) {
    theMuonModifier.moveAlignable( *iter, false, true, disp[0], disp[1], disp[2] );
    theMuonModifier.rotateAlignable( *iter, false, true, rotation[0],  rotation[1], rotation[2] );
    theMuonModifier.addAlignmentPositionError( *iter, errorx, errory, errorz );
    theMuonModifier.addAlignmentPositionErrorFromRotation( *iter,  errorphix, errorphiy, errorphiz ); 
  }
  for(std::vector<Alignable *>::iterator iter = CSCendcaps.begin(); iter != CSCendcaps.end(); ++iter) {
    theMuonModifier.moveAlignable( *iter, false, true, disp[0], disp[1], disp[2] );
    theMuonModifier.rotateAlignable( *iter, false, true, rotation[0],  rotation[1], rotation[2] );
    theMuonModifier.addAlignmentPositionError( *iter, errorx, errory, errorz );
    theMuonModifier.addAlignmentPositionErrorFromRotation( *iter,  errorphix, errorphiy, errorphiz ); 
  }
}

Member Data Documentation

Pointer to alignable Muon object.

Definition at line 49 of file MuonScenarioBuilder.h.

Referenced by applyScenario(), moveCSCSectors(), moveDTSectors(), moveMuon(), and MuonScenarioBuilder().

Definition at line 51 of file MuonScenarioBuilder.h.

Referenced by moveChamberInSector(), moveCSCSectors(), moveDTSectors(), and moveMuon().