CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TrackerGeometryIntoNtuples Class Reference

#include <TrackerGeometryIntoNtuples.cc>

Inheritance diagram for TrackerGeometryIntoNtuples:
edm::EDAnalyzer

List of all members.

Public Member Functions

 TrackerGeometryIntoNtuples (const edm::ParameterSet &)
 ~TrackerGeometryIntoNtuples ()

Private Member Functions

void addBranches ()
virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)

Private Attributes

double m_alpha
double m_beta
TFile * m_file
double m_gamma
std::string m_outputFile
std::string m_outputTreename
uint32_t m_rawid
int m_subdetid
TTree * m_tree
TTree * m_treeErrors
double m_x
double m_xx
double m_xy
double m_xz
double m_y
double m_yy
double m_yz
double m_z
double m_zz
AlignableTrackertheCurrentTracker

Detailed Description

Description: Takes a set of alignment constants and turns them into a ROOT file

Implementation: <Notes on="" implementation>="">

Definition at line 53 of file TrackerGeometryIntoNtuples.cc.


Constructor & Destructor Documentation

TrackerGeometryIntoNtuples::TrackerGeometryIntoNtuples ( const edm::ParameterSet iConfig) [explicit]

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

References edm::ParameterSet::getUntrackedParameter(), m_file, m_outputFile, m_outputTreename, m_tree, and m_treeErrors.

                                                                                     :
  theCurrentTracker(0),
  m_rawid(0),
  m_x(0.), m_y(0.), m_z(0.),
  m_alpha(0.), m_beta(0.), m_gamma(0.),
  m_subdetid(0),
  m_xx(0.), m_xy(0.), m_yy(0.), m_xz(0.), m_yz(0.), m_zz(0.)
{
        m_outputFile = iConfig.getUntrackedParameter< std::string > ("outputFile");
        m_outputTreename = iConfig.getUntrackedParameter< std::string > ("outputTreename");
        m_file = new TFile(m_outputFile.c_str(),"RECREATE");
        m_tree = new TTree(m_outputTreename.c_str(),m_outputTreename.c_str());
        //char errorTreeName[256];
        //snprintf(errorTreeName, sizeof(errorTreeName), "%sErrors", m_outputTreename);
        //m_treeErrors = new TTree(errorTreeName,errorTreeName);
        m_treeErrors = new TTree("alignTreeErrors","alignTreeErrors");
        
}
TrackerGeometryIntoNtuples::~TrackerGeometryIntoNtuples ( )

Definition at line 112 of file TrackerGeometryIntoNtuples.cc.

References theCurrentTracker.

{
  delete theCurrentTracker;
}

Member Function Documentation

void TrackerGeometryIntoNtuples::addBranches ( ) [private]

Definition at line 209 of file TrackerGeometryIntoNtuples.cc.

References m_alpha, m_beta, m_gamma, m_rawid, m_subdetid, m_tree, m_treeErrors, m_x, m_xx, m_xy, m_xz, m_y, m_yy, m_yz, m_z, and m_zz.

Referenced by analyze().

                                             {
        
        m_tree->Branch("rawid", &m_rawid, "rawid/I");
        m_tree->Branch("x", &m_x, "x/D");
        m_tree->Branch("y", &m_y, "y/D");
        m_tree->Branch("z", &m_z, "z/D");
        m_tree->Branch("alpha", &m_alpha, "alpha/D");
        m_tree->Branch("beta", &m_beta, "beta/D");
        m_tree->Branch("gamma", &m_gamma, "gamma/D");
        
        
        m_treeErrors->Branch("rawid", &m_rawid, "rawid/I");
        m_treeErrors->Branch("subdetid", &m_subdetid, "subdetid/I");
        m_treeErrors->Branch("xx", &m_xx, "xx/D");
        m_treeErrors->Branch("yy", &m_yy, "yy/D");
        m_treeErrors->Branch("zz", &m_zz, "zz/D");
        m_treeErrors->Branch("xy", &m_xy, "xy/D");
        m_treeErrors->Branch("xz", &m_xz, "xz/D");
        m_treeErrors->Branch("yz", &m_yz, "yz/D");
                
}
void TrackerGeometryIntoNtuples::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 123 of file TrackerGeometryIntoNtuples.cc.

References addBranches(), GeometryAligner::applyAlignments(), TrackerGeomBuilderFromGeometricDet::build(), align::DetectorGlobalPosition(), cond::rpcobgas::detid, edm::EventSetup::get(), edm::eventsetup::EventSetupRecord::get(), i, Alignments::m_align, m_alpha, m_beta, m_file, m_gamma, m_rawid, m_subdetid, m_tree, m_treeErrors, m_x, m_xx, m_xy, m_xz, m_y, m_yy, m_yz, m_z, m_zz, idealTransformation::rotation, DetId::subdetId(), theCurrentTracker, and DetId::Tracker.

{
        edm::LogInfo("beginJob") << "Begin Job" << std::endl;
        
        //accessing the initial geometry
        edm::ESHandle<GeometricDet> theGeometricDet;
        iSetup.get<IdealGeometryRecord>().get(theGeometricDet);
        TrackerGeomBuilderFromGeometricDet trackerBuilder;
        //currernt tracker
        TrackerGeometry* theCurTracker = trackerBuilder.build(&*theGeometricDet); 
        
        
        //build the tracker
        edm::ESHandle<Alignments> alignments;
        edm::ESHandle<AlignmentErrors> alignmentErrors;
        
        iSetup.get<TrackerAlignmentRcd>().get(alignments);
        iSetup.get<TrackerAlignmentErrorRcd>().get(alignmentErrors);
        
        //apply the latest alignments
        edm::ESHandle<Alignments> globalPositionRcd;
        iSetup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get(globalPositionRcd);
        GeometryAligner aligner;
        aligner.applyAlignments<TrackerGeometry>( &(*theCurTracker), &(*alignments), &(*alignmentErrors),
                                                                                         align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
        
        
        theCurrentTracker = new AlignableTracker(&(*theCurTracker));    
        
        Alignments* theAlignments = theCurrentTracker->alignments();
        //AlignmentErrors* theAlignmentErrors = theCurrentTracker->alignmentErrors();   
        
        //alignments
        addBranches();
        for (std::vector<AlignTransform>::const_iterator i = theAlignments->m_align.begin(); i != theAlignments->m_align.end(); ++i){
                
                m_rawid = i->rawId();
                CLHEP::Hep3Vector translation = i->translation();
                m_x = translation.x();
                m_y = translation.y();
                m_z = translation.z();
                
        
                CLHEP::HepRotation rotation = i->rotation();
                m_alpha = rotation.getPhi();
                m_beta = rotation.getTheta();
                m_gamma = rotation.getPsi();
                m_tree->Fill();
                
                //DetId detid(m_rawid);
                //if (detid.subdetId() > 2){
                //PXFDetId pxfid( m_rawid );
                //std::cout << " panel: " << pxfid.panel() << ", module: " << pxfid.module() << std::endl;
                //if ((pxfid.panel() == 1) && (pxfid.module() == 4)) std::cout << m_rawid << ", ";
                //std::cout << m_rawid << std::setprecision(9) <<  " " << m_x << " " << m_y << " " << m_z;
                //std::cout << std::setprecision(9) << " " << m_alpha << " " << m_beta << " " << m_gamma << std::endl;  
                //}
                
        }
        
        delete theAlignments;

        std::vector<AlignTransformError> alignErrors = alignmentErrors->m_alignError;
        for (std::vector<AlignTransformError>::const_iterator i = alignErrors.begin(); i != alignErrors.end(); ++i){

                m_rawid = i->rawId();
                CLHEP::HepSymMatrix errMatrix = i->matrix();
                DetId detid(m_rawid);
                m_subdetid = detid.subdetId();
                m_xx = errMatrix[0][0];
                m_xy = errMatrix[0][1];
                m_xz = errMatrix[0][2];
                m_yy = errMatrix[1][1];
                m_yz = errMatrix[1][2];
                m_zz = errMatrix[2][2];
                m_treeErrors->Fill();
        }
        
        //write out 
        m_file->cd();
        m_tree->Write();
        m_treeErrors->Write();
        m_file->Close();
}

Member Data Documentation

Definition at line 70 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 70 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 78 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze(), and TrackerGeometryIntoNtuples().

Definition at line 70 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 76 of file TrackerGeometryIntoNtuples.cc.

Referenced by TrackerGeometryIntoNtuples().

Definition at line 77 of file TrackerGeometryIntoNtuples.cc.

Referenced by TrackerGeometryIntoNtuples().

Definition at line 68 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 71 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 74 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), analyze(), and TrackerGeometryIntoNtuples().

Definition at line 75 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), analyze(), and TrackerGeometryIntoNtuples().

Definition at line 69 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 72 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 72 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 72 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 69 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 72 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 72 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 69 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 72 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

Definition at line 66 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze(), and ~TrackerGeometryIntoNtuples().