ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/PhotonAssociator.cc
Revision: 1.13
Committed: Mon Jun 29 14:52:52 2009 UTC (15 years, 10 months ago) by lethuill
Content type: text/plain
Branch: MAIN
CVS Tags: all_3_3_2_01, all_3_2_5_02, all_3_2_5_01, all_2_2_9_03, all_2_2_9_02, HEAD
Branch point for: CMSSW_2_2_X_br
Changes since 1.12: +5 -5 lines
Log Message:
Complete photons/electrons <-> Superclusters <-> Basic Clusters navigation via TRef or Indices

File Contents

# User Rev Content
1 lethuill 1.10 #include "../interface/PhotonAssociator.h"
2 mlethuil 1.1
3 lethuill 1.13 PhotonAssociator::PhotonAssociator():verbosity_(0)
4 mlethuil 1.1 {
5     }
6 mlethuil 1.5
7 mlethuil 1.1 PhotonAssociator::~PhotonAssociator()
8     {
9     }
10    
11 lethuill 1.12 void PhotonAssociator::associateSuperCluster(TClonesArray* photons, TClonesArray* superClusters)
12 mlethuil 1.1 {
13 lethuill 1.12
14     TRootPhoton* localPhoton;
15     TRootSuperCluster* localSuperCluster;
16 lethuill 1.13 if(verbosity_>1) cout << endl << "Associating SuperClusters with Photons... " << endl;
17 lethuill 1.12
18     Double_t energy5x5;
19     multimap<Double_t,Int_t> scMap;
20     multimap<Double_t,Int_t>::iterator it;
21     pair<multimap<Double_t,Int_t>::iterator,multimap<Double_t,Int_t>::iterator> rangeIt;
22    
23     for (int isc=0; isc<superClusters->GetEntriesFast(); isc++)
24     {
25     energy5x5= ((TRootSuperCluster*) superClusters->At(isc))->e5x5();
26     scMap.insert ( pair<Double_t,Int_t>(energy5x5,isc) );
27     }
28    
29     for (int iphot=0; iphot<photons->GetEntriesFast(); iphot++)
30     {
31     localPhoton = (TRootPhoton*)photons->At(iphot);
32     energy5x5= localPhoton->e5x5();
33     rangeIt=scMap.equal_range(energy5x5);
34     for (it=rangeIt.first; it!=rangeIt.second; ++it)
35     {
36     localSuperCluster = (TRootSuperCluster*) superClusters->At((*it).second);
37     localPhoton->setSCIndex( localSuperCluster->type(), (*it).second );
38     localPhoton->setSCRef( localSuperCluster->type(), localSuperCluster );
39 lethuill 1.13 localSuperCluster->setPhotonIndex( iphot );
40 lethuill 1.12 localSuperCluster->setPhoton( localPhoton );
41     }
42     }
43    
44     scMap.clear();
45 mlethuil 1.1 }
46    
47 lethuill 1.8
48    
49 mlethuil 1.6 //TODO - methode AssociateConversionMC => matching entre TRootPhoton et TRootMCPhoton...
50     // Ajouter IndexMC a TRootPhoton et remplir TRootMCPhoton.recoPhotonIndex_
51 mlethuil 1.2
52    
53    
54 lethuill 1.12 void PhotonAssociator::printPhotons(TClonesArray* photons, TClonesArray* superClusters, Int_t type)
55 mlethuil 1.1 {
56 lethuill 1.12 TRootPhoton* localPhoton;
57     map<Int_t,Int_t> idxMap;
58     map<Int_t,Int_t>::iterator iter;
59    
60     cout << endl;
61     for (int iphot=0; iphot<photons->GetEntriesFast(); iphot++)
62     {
63     localPhoton = (TRootPhoton*)photons->At(iphot);
64    
65     cout << " [" << iphot << "] " << *localPhoton << endl;
66    
67     idxMap=localPhoton->scIndexMap();
68     for( iter = idxMap.begin(); iter != idxMap.end(); iter++ )
69     {
70     if ( (type==0) || (iter->first==type) )
71     {
72     cout << " [" << iter->second << "] " << *( (TRootSuperCluster*) superClusters->At(iter->second) ) << endl;
73     }
74     }
75     }
76 mlethuil 1.1 }
77    
78 mlethuil 1.2
79 lethuill 1.12 void PhotonAssociator::fullPrintPhotons(TClonesArray* photons, TClonesArray* superClusters, TClonesArray* basicClusters, Int_t type)
80 mlethuil 1.1 {
81 lethuill 1.12 TRootPhoton* localPhoton;
82     TRootSuperCluster* localSC;
83     map<Int_t,Int_t> idxMap;
84     map<Int_t,Int_t>::iterator iter;
85     Int_t subIdx;
86    
87     for (int iphot=0; iphot<photons->GetEntriesFast(); iphot++)
88     {
89     localPhoton = (TRootPhoton*)photons->At(iphot);
90    
91     cout << endl << " [" << iphot << "] "; localPhoton->Print(); cout << endl;
92    
93     idxMap=localPhoton->scIndexMap();
94     for( iter = idxMap.begin(); iter != idxMap.end(); iter++ )
95     {
96     if ( (type==0) || (iter->first==type) )
97     {
98     localSC = (TRootSuperCluster*) superClusters->At(iter->second);
99     cout << " [" << iter->second << "] " << *localSC << endl;
100    
101 lethuill 1.13 for (unsigned int isub=0; isub<localSC->subBasicClusterIndexVector().size(); isub++)
102 lethuill 1.12 {
103 lethuill 1.13 subIdx=localSC->subBasicClusterIndexVector().at(isub);
104 lethuill 1.12 cout << " [" << subIdx << "] " << *( (TRootCluster*) basicClusters->At(subIdx) ) << endl;
105     }
106     }
107     }
108     }
109 mlethuil 1.1 }