Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:08

0001 #include "RecoVertex/ConfigurableVertexReco/test/VertexHisto.h"
0002 #include "Workspace/DataHarvesting/interface/Writer.h"
0003 #include "Workspace/DataHarvesting/interface/SystemWriter.h"
0004 #include "Workspace/DataHarvesting/interface/Tuple.h"
0005 
0006 using namespace std;
0007 using namespace reco;
0008 using namespace edm;
0009 using namespace dataharvester;
0010 
0011 void VertexHisto::stamp()
0012 {
0013   if ( hasStamped ) return;
0014   SystemWriter ( filename_ ).save ();
0015   hasStamped=true;
0016 }
0017 
0018 VertexHisto::VertexHisto ( const string & filename, const string & trackname ) : filename_ ( filename ),
0019   /* tracks_ ( TrackHisto ( trackname ) ), */ hasStamped(false)
0020 {
0021   stamp();
0022 }
0023 
0024 void VertexHisto::saveTracks ( const TransientVertex & trec, 
0025     const reco::RecoToSimCollection & p,
0026     const string & name ) const
0027 {
0028   /*
0029   vector < TransientTrack > ttrks = trec.originalTracks();
0030   for ( vector< TransientTrack >::const_iterator i=ttrks.begin(); 
0031         i!=ttrks.end() ; ++i )
0032   {
0033     // reco::Track t = i->track();
0034     // reco::TrackRef k; // ( t );
0035     TrackRef k = i->trackBaseRef().castTo<TrackRef>();
0036     vector<pair<TrackingParticleRef, double> > coll = p[k];
0037     if ( coll.size() )
0038     {
0039       tracks_.analyse ( *(coll[0].first), (*i), "VtxTk" );
0040     } else {
0041       tracks_.analyse ( (*i), "UnassociatedTk" );
0042     }
0043   }
0044 
0045   if ( trec.hasRefittedTracks () )
0046   {
0047     vector < TransientTrack > ttrks = trec.refittedTracks();
0048     for ( vector< TransientTrack >::const_iterator i=ttrks.begin(); 
0049           i!=ttrks.end() ; ++i )
0050     {
0051       // reco::Track t = i->track();
0052       // reco::TrackRef k; // ( t );
0053       TrackRef k = trec.originalTrack ( *i ).trackBaseRef().castTo<TrackRef>();
0054       vector<pair<TrackingParticleRef, double> > coll = p[k];
0055       if ( coll.size() )
0056       {
0057         tracks_.analyse ( *(coll[0].first), (*i), "RefittedVtxTk" );
0058       } else {
0059         tracks_.analyse ( (*i), "UnassociatedRefittedTk" );
0060       }
0061     }
0062   }*/
0063 }
0064 
0065 void VertexHisto::analyse ( const TrackingVertex & sim, const TransientVertex & rec,
0066                             const string & name ) const
0067 {
0068   Tuple t ( name );
0069   float simx=sim.position().x();
0070   float simy=sim.position().y();
0071   float simz=sim.position().z();
0072   float recx=rec.position().x();
0073   float recy=rec.position().y();
0074   float recz=rec.position().z();
0075   float dx=recx-simx;
0076   float dy=recy-simy;
0077   float dz=recz-simz;
0078   t["simx"]=simx;
0079   t["simy"]=simy;
0080   t["simz"]=simz;
0081   t["recx"]=recx;
0082   t["recy"]=recy;
0083   t["recz"]=recz;
0084   t["x"]=dx;
0085   t["y"]=dy;
0086   t["z"]=dz;
0087   t["dx"]=dx;
0088   t["dy"]=dy;
0089   t["dz"]=dz;
0090   float pullx = dx / sqrt ( rec.positionError().cxx() );
0091   float pully = dy / sqrt ( rec.positionError().cyy() );
0092   float pullz = dz / sqrt ( rec.positionError().czz() );
0093   t["stx"]=pullx;
0094   t["sty"]=pully;
0095   t["stz"]=pullz;
0096   t["time"]=0.;
0097 
0098   Writer::file ( filename_ ) << t;
0099 }
0100 
0101 VertexHisto::~VertexHisto()
0102 {
0103   Writer::close();
0104 }