ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/VertexAnalyzer.cc
(Generate patch)

Comparing UserCode/Morgan/src/VertexAnalyzer.cc (file contents):
Revision 1.3 by lethuill, Fri Apr 10 12:06:37 2009 UTC vs.
Revision 1.5 by lethuill, Thu Apr 16 16:50:21 2009 UTC

# Line 9 | Line 9 | VertexAnalyzer::VertexAnalyzer(const edm
9          primaryVertexProducer_ = producersNames.getParameter<edm::InputTag>("primaryVertexProducer");
10   }
11  
12 +
13   VertexAnalyzer::VertexAnalyzer(const edm::ParameterSet& producersNames, int verbosity):verbosity_(verbosity)
14   {
15          primaryVertexProducer_ = producersNames.getParameter<edm::InputTag>("primaryVertexProducer");
16   }
17  
18 +
19   VertexAnalyzer::~VertexAnalyzer()
20   {
21   }
22  
23 < void VertexAnalyzer::Process(const edm::Event& iEvent, TRootEvent* rootEvent, TClonesArray* rootVertices)
23 >
24 > void VertexAnalyzer::Process(const edm::Event& iEvent, TClonesArray* rootVertices)
25   {
26  
27          edm::Handle< reco::VertexCollection > recoVertices;
28          iEvent.getByLabel(primaryVertexProducer_, recoVertices);
29          if(verbosity_>1) std::cout  << "   Number of primary vertices = " << recoVertices->size() << "   Label: " << primaryVertexProducer_.label() << "   Instance: " << primaryVertexProducer_.instance() << std::endl;
30 +
31 +
32 +        int iRootVertex = 0;
33          for (unsigned int j=0; j<recoVertices->size(); j++)
34          {
35                  const reco::Vertex* vertex = & ((*recoVertices)[j]);
# Line 46 | Line 52 | void VertexAnalyzer::Process(const edm::
52  
53                  Int_t ntracks = 0;
54                  Float_t higherPt = 0.;
55 <                Float_t scalarEt = 0.;
55 >                Float_t scalarSumPt = 0.;
56  
57                  for( std::vector< reco::TrackBaseRef >::const_iterator it = vertex->tracks_begin(); it != vertex->tracks_end(); it++)
58                  {
59 <                        //const reco::TrackBaseRef  tkRef = (*it);
60 <                        //const reco::Track * tk = (const reco::Track *)(&(*it));
55 <                        //cout << "tk->pt()=" << tk->pt() << endl;
56 <                        // Put your track selection here...
57 <                        // if ( track->pt() < 1.0 ) continue;
58 <                        //scalarEt = scalarEt + (*it).pt();
59 <                        //if( track->pt()>higherPt ) higherPt=track->pt();
59 >                        scalarSumPt += (**it).pt();
60 >                        if( (**it).pt()>higherPt ) higherPt=(**it).pt();
61                          ntracks++;
62                  }
63 +
64 +                // No refitted tracks embeded in reco::Vertex....
65 +                //cout  << "vertex->refittedTracks().size()=" << vertex->refittedTracks().size() << endl;
66                  
67                  localVertex.setNtracks( ntracks );
68                  localVertex.setHigherTrackPt( higherPt );
69 <                localVertex.setScalarEt( scalarEt );
69 >                localVertex.setScalarSumPt( scalarSumPt );
70  
71 <                new( (*rootVertices)[j] ) TRootVertex(localVertex);
72 <                if(verbosity_>2) cout << "   ["<< setw(3) << j << "] " << localVertex << endl;
71 >                new( (*rootVertices)[iRootVertex] ) TRootVertex(localVertex);
72 >                if(verbosity_>2) cout << "   ["<< setw(3) << iRootVertex << "] " << localVertex << endl;
73 >                iRootVertex++;
74          }
75 +
76 + }
77 +
78 +
79 + void VertexAnalyzer::SelectPrimary(TRootEvent* rootEvent, TClonesArray* rootVertices)
80 + {
81 +
82 +        int ibestVertex = -1;
83 +        float highestScalarSumPt = -1.;
84 +        TRootVertex* localVertex = 0;
85          
86 <        // FIXME - Set index of selected primary vertex in TRootEvent
87 <        //rootEvent->setRootPrimaryVertexIndex( );
88 <        //rootEvent->setRecoPrimaryVertexIndex( );
86 >        for (int ivtx=0; ivtx<rootVertices->GetEntriesFast(); ivtx++)
87 >        {
88 >                localVertex = (TRootVertex*) rootVertices->At(ivtx);
89 >                // Put you primary vertex selection here...
90 >                if ( localVertex->scalarSumPt()>highestScalarSumPt )
91 >                {
92 >                        highestScalarSumPt = localVertex->scalarSumPt();
93 >                        ibestVertex = ivtx;
94 >                }
95 >        }
96  
97 +        if ( ibestVertex >= 0)
98 +        {
99 +                localVertex = (TRootVertex*) rootVertices->At(ibestVertex);
100 +                rootEvent->setPrimaryVertexIndex( ibestVertex );
101 +                rootEvent->setPrimaryVertex( localVertex );
102 +        }
103 +        
104 +        if(verbosity_>1) std::cout  << "   Selected primary vertex: TRootVertex[" << ibestVertex << "]" << std::endl;
105   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines