1 |
#include "../interface/ElectronAssociator.h"
|
2 |
|
3 |
ElectronAssociator::ElectronAssociator():verbosity_(0)
|
4 |
{
|
5 |
}
|
6 |
|
7 |
ElectronAssociator::~ElectronAssociator()
|
8 |
{
|
9 |
}
|
10 |
|
11 |
void ElectronAssociator::associateSuperCluster(TClonesArray* electrons, TClonesArray* superClusters)
|
12 |
{
|
13 |
|
14 |
TRootElectron* localElectron;
|
15 |
TRootSuperCluster* localSuperCluster;
|
16 |
if(verbosity_>1) cout << endl << "Associating SuperClusters with Electrons... " << endl;
|
17 |
|
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 iele=0; iele<electrons->GetEntriesFast(); iele++)
|
30 |
{
|
31 |
localElectron = (TRootElectron*)electrons->At(iele);
|
32 |
energy5x5= localElectron->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 |
localElectron->setSCIndex( localSuperCluster->type(), (*it).second );
|
38 |
localElectron->setSCRef( localSuperCluster->type(), localSuperCluster );
|
39 |
localSuperCluster->setElectronIndex( iele );
|
40 |
localSuperCluster->setElectron( localElectron );
|
41 |
}
|
42 |
}
|
43 |
|
44 |
scMap.clear();
|
45 |
}
|
46 |
|
47 |
|
48 |
void ElectronAssociator::printElectrons(TClonesArray* electrons, TClonesArray* superClusters, Int_t type)
|
49 |
{
|
50 |
TRootElectron* localElectron;
|
51 |
map<Int_t,Int_t> idxMap;
|
52 |
map<Int_t,Int_t>::iterator iter;
|
53 |
|
54 |
cout << endl;
|
55 |
for (int iele=0; iele<electrons->GetEntriesFast(); iele++)
|
56 |
{
|
57 |
localElectron = (TRootElectron*)electrons->At(iele);
|
58 |
|
59 |
cout << " [" << iele << "] " << *localElectron << endl;
|
60 |
|
61 |
idxMap=localElectron->scIndexMap();
|
62 |
for( iter = idxMap.begin(); iter != idxMap.end(); iter++ )
|
63 |
{
|
64 |
if ( (type==0) || (iter->first==type) )
|
65 |
{
|
66 |
cout << " [" << iter->second << "] " << *( (TRootSuperCluster*) superClusters->At(iter->second) ) << endl;
|
67 |
}
|
68 |
}
|
69 |
}
|
70 |
}
|
71 |
|
72 |
|
73 |
void ElectronAssociator::fullPrintElectrons(TClonesArray* electrons, TClonesArray* superClusters, TClonesArray* basicClusters, Int_t type)
|
74 |
{
|
75 |
TRootElectron* localElectron;
|
76 |
TRootSuperCluster* localSC;
|
77 |
map<Int_t,Int_t> idxMap;
|
78 |
map<Int_t,Int_t>::iterator iter;
|
79 |
Int_t subIdx;
|
80 |
|
81 |
for (int iele=0; iele<electrons->GetEntriesFast(); iele++)
|
82 |
{
|
83 |
localElectron = (TRootElectron*)electrons->At(iele);
|
84 |
|
85 |
cout << endl << " [" << iele << "] "; localElectron->Print(); cout << endl;
|
86 |
|
87 |
idxMap=localElectron->scIndexMap();
|
88 |
for( iter = idxMap.begin(); iter != idxMap.end(); iter++ )
|
89 |
{
|
90 |
if ( (type==0) || (iter->first==type) )
|
91 |
{
|
92 |
localSC = (TRootSuperCluster*) superClusters->At(iter->second);
|
93 |
cout << " [" << iter->second << "] " << *localSC << endl;
|
94 |
|
95 |
for (unsigned int isub=0; isub<localSC->subBasicClusterIndexVector().size(); isub++)
|
96 |
{
|
97 |
subIdx=localSC->subBasicClusterIndexVector().at(isub);
|
98 |
cout << " [" << subIdx << "] " << *( (TRootCluster*) basicClusters->At(subIdx) ) << endl;
|
99 |
}
|
100 |
}
|
101 |
}
|
102 |
}
|
103 |
}
|