ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/PhotonAnalyzer.cc
Revision: 1.1
Committed: Mon May 19 16:12:28 2008 UTC (16 years, 11 months ago) by mlethuil
Content type: text/plain
Branch: MAIN
CVS Tags: cmssw_1_6_12
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 mlethuil 1.1 #include "UserCode/Morgan/interface/PhotonAnalyzer.h"
2     #include "DataFormats/EgammaCandidates/interface/PhotonPi0DiscriminatorAssociation.h"
3    
4     using namespace std;
5     using namespace reco;
6     using namespace edm;
7    
8     PhotonAnalyzer::PhotonAnalyzer():verbosity(0)
9     {
10     }
11     PhotonAnalyzer::~PhotonAnalyzer()
12     {
13     }
14    
15     void PhotonAnalyzer::Process(const edm::Event& iEvent, TRootEvent* rootEvent, TClonesArray* rootPhotons, string collectionName)
16     {
17    
18     if(verbosity>1) cout << "PhotonAnalyzer Collection name: " << collectionName << endl;
19     edm::Handle< reco::PhotonCollection > recoPhotons;
20     iEvent.getByLabel(collectionName, recoPhotons);
21     if(verbosity>1) cout << "Number of photons in the event: " << recoPhotons->size() << endl;
22    
23     edm::Handle<reco::PhotonPi0DiscriminatorAssociationMap> pi0map;
24     iEvent.getByLabel("piZeroDiscriminators","PhotonPi0DiscriminatorAssociationMap", pi0map);
25     reco::PhotonPi0DiscriminatorAssociationMap::const_iterator pi0mapIter;
26    
27     unsigned int iPhot = 0;
28     Double_t pi0nn;
29    
30     for (unsigned int j=0; j<recoPhotons->size(); j++)
31     {
32    
33     pi0mapIter = pi0map->find(edm::Ref<reco::PhotonCollection>(recoPhotons,iPhot));
34     pi0nn = ( pi0mapIter == pi0map->end() ? -1 : pi0mapIter->val );
35    
36     TRootPhoton localPhoton( (*recoPhotons)[j].px(), (*recoPhotons)[j].py(), (*recoPhotons)[j].pz(), (*recoPhotons)[j].energy(), (*recoPhotons)[j].vx(), (*recoPhotons)[j].vy(), (*recoPhotons)[j].vz(), 22, (*recoPhotons)[j].charge() );
37     localPhoton.setHasPixelSeed( (*recoPhotons)[j].hasPixelSeed() );
38     localPhoton.setE5x5( (*recoPhotons)[j].e5x5() );
39     localPhoton.setR19( (*recoPhotons)[j].r19() );
40     localPhoton.setR9( (*recoPhotons)[j].r9() );
41     localPhoton.setPi0nn( pi0nn );
42    
43     // FIXME et_had not initialized
44     // localPhoton.setEt_had( ( );
45    
46     localPhoton.setSCPosition( (*recoPhotons)[j].superCluster()->position().X(), (*recoPhotons)[j].superCluster()->position().Y(), (*recoPhotons)[j].superCluster()->position().Z() );
47     localPhoton.setUnconvPosition( (*recoPhotons)[j].unconvertedPosition().X(), (*recoPhotons)[j].unconvertedPosition().Y(), (*recoPhotons)[j].unconvertedPosition().Z() );
48     if(verbosity>2) cout << " without vtx correction: " << localPhoton << endl;
49    
50     // Assume photon is coming from primary vertex
51     if( rootEvent->nPrimaryVertices()>0 )
52     {
53     TVector3 vertex( rootEvent->primaryVertex_x(), rootEvent->primaryVertex_y(), rootEvent->primaryVertex_z() );
54     localPhoton.setVertex(vertex);
55     if(verbosity>2) cout << " with vtx correction : " << localPhoton << endl;
56     }
57     else
58     {
59     if(verbosity>2) cout << " with vtx correction: NO PRIMARY VERTEX FOUND !!!" << endl;
60     }
61    
62     // Stock new TRootPhoton in TCloneArray
63     new( (*rootPhotons)[j] ) TRootPhoton(localPhoton);
64     iPhot++;
65     }
66    
67     }