CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SurveyInputTrackerFromDB Class Reference

#include <SurveyInputTrackerFromDB.h>

Inheritance diagram for SurveyInputTrackerFromDB:
SurveyInputBase edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 Read ideal tracker geometry from DB.
 SurveyInputTrackerFromDB (const edm::ParameterSet &)

Private Member Functions

void addSurveyInfo (Alignable *)
 Add survey info to an alignable.

Private Attributes

std::string textFileName
SurveyInputTextReader::MapType uIdMap

Detailed Description

Class to read ideal tracker from DB.

Date:
2010/01/07 14:36:23
Revision:
1.3
Author:
Chung Khim Lae

Definition at line 16 of file SurveyInputTrackerFromDB.h.


Constructor & Destructor Documentation

SurveyInputTrackerFromDB::SurveyInputTrackerFromDB ( const edm::ParameterSet cfg)

Definition at line 20 of file SurveyInputTrackerFromDB.cc.

                                                                            :
textFileName( cfg.getParameter<std::string>("textFileName") )
{
}

Member Function Documentation

void SurveyInputTrackerFromDB::addSurveyInfo ( Alignable ali) [private]

Add survey info to an alignable.

Definition at line 61 of file SurveyInputTrackerFromDB.cc.

References Alignable::alignableObjectId(), Alignable::components(), alignCSCRings::e, error, i, Alignable::id(), Basic3DVector< T >::mag(), Alignable::move(), Parameters::parameters, Alignable::rotateInLocalFrame(), idealTransformation::rotation, edm::second(), Alignable::setSurvey(), Alignable::surface(), AlignableSurface::toGlobal(), and uIdMap.

Referenced by analyze().

{
        const align::Alignables& comp = ali->components();
        unsigned int nComp = comp.size();
        
        for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
        
        align::ErrorMatrix error;

        SurveyInputTextReader::MapType::const_iterator it
          = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));

        if (it != uIdMap.end()){
                
                const align::Scalars& parameters = (it)->second;
                
                //move the surface
                //displacement
                align::LocalVector lvector (parameters[0], parameters[1], parameters[2]);
                align::GlobalVector gvector = ali->surface().toGlobal(lvector);
                ali->move(gvector);
                //rotation
                Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]);
                align::RotationType rotation(rot_aa, rot_aa.mag());
                ali->rotateInLocalFrame(rotation);
                
                //sets the errors for the hierarchy level
                double* errorData = error.Array();
                for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
                
                ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
        }
        else {
                error = ROOT::Math::SMatrixIdentity();
                ali->setSurvey( new SurveyDet(ali->surface(), error * 1e-6) );
        }
        
}
void SurveyInputTrackerFromDB::analyze ( const edm::Event ,
const edm::EventSetup setup 
) [virtual]

Read ideal tracker geometry from DB.

Implements SurveyInputBase.

Definition at line 25 of file SurveyInputTrackerFromDB.cc.

References SurveyInputBase::addComponent(), addSurveyInfo(), Alignable::alignmentErrors(), Alignable::alignments(), TrackerGeomBuilderFromGeometricDet::build(), SurveyInputBase::detector(), relativeConstraints::geom, edm::EventSetup::get(), edm::Service< T >::isAvailable(), SurveyInputTextReader::readFile(), textFileName, SurveyInputBase::theFirstEvent, patCandidatesForDimuonsSequences_cff::tracker, uIdMap, and SurveyInputTextReader::UniqueIdMap().

{
  if (theFirstEvent) {

        //  std::cout << "***************ENTERING INITIALIZATION******************" << std::endl;
        
        //Get map from textreader
        SurveyInputTextReader dataReader;
        dataReader.readFile( textFileName );
        uIdMap = dataReader.UniqueIdMap();
        
        edm::ESHandle<GeometricDet>  geom;
        setup.get<IdealGeometryRecord>().get(geom);      
        TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom);
        
        addComponent( new AlignableTracker( tracker ) );
        addSurveyInfo( detector() );
        
        //write out to a DB ...
        Alignments* myAlignments = detector()->alignments();
        AlignmentErrors* myAlignmentErrors = detector()->alignmentErrors();
        
        // 2. Store alignment[Error]s to DB
        edm::Service<cond::service::PoolDBOutputService> poolDbService;
        // Call service
        
        if( !poolDbService.isAvailable() ) // Die if not available
                throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
        
        poolDbService->writeOne<Alignments>( myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd" );
        poolDbService->writeOne<AlignmentErrors>( myAlignmentErrors, poolDbService->beginOfTime(), "TrackerAlignmentErrorRcd" );
        
        theFirstEvent = false;
  }
}

Member Data Documentation

Definition at line 35 of file SurveyInputTrackerFromDB.h.

Referenced by analyze().

Definition at line 33 of file SurveyInputTrackerFromDB.h.

Referenced by addSurveyInfo(), and analyze().