Fork me on GitHub

source: svn/trunk/modules/UniqueObjectFinder.cc@ 1388

Last change on this file since 1388 was 1314, checked in by Pavel Demin, 11 years ago

replace ;; with ;

  • Property svn:keywords set to Id Revision Date
File size: 3.3 KB
RevLine 
[694]1
[814]2/** \class UniqueObjectFinder
3 *
[933]4 * Finds uniquely identified photons, electrons and jets.
[814]5 *
6 * $Date: 2013-11-04 10:21:27 +0000 (Mon, 04 Nov 2013) $
7 * $Revision: 1314 $
8 *
9 *
10 * \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
[812]14#include "modules/UniqueObjectFinder.h"
[694]15
16#include "classes/DelphesClasses.h"
[703]17#include "classes/DelphesFactory.h"
[766]18#include "classes/DelphesFormula.h"
[694]19
[703]20#include "ExRootAnalysis/ExRootResult.h"
[694]21#include "ExRootAnalysis/ExRootFilter.h"
22#include "ExRootAnalysis/ExRootClassifier.h"
23
24#include "TMath.h"
25#include "TString.h"
26#include "TFormula.h"
[703]27#include "TRandom3.h"
28#include "TObjArray.h"
29#include "TDatabasePDG.h"
[694]30#include "TLorentzVector.h"
31
[703]32#include <algorithm>
33#include <stdexcept>
[694]34#include <iostream>
35#include <sstream>
36
37using namespace std;
38
39//------------------------------------------------------------------------------
40
[812]41UniqueObjectFinder::UniqueObjectFinder()
[694]42{
43}
44
45//------------------------------------------------------------------------------
46
[812]47UniqueObjectFinder::~UniqueObjectFinder()
[694]48{
49}
50
51//------------------------------------------------------------------------------
52
[812]53void UniqueObjectFinder::Init()
[694]54{
[812]55 // import arrays with output from other modules
[694]56
[825]57 ExRootConfParam param = GetParam("InputArray");
[812]58 Long_t i, size;
59 const TObjArray *array;
60 TIterator *iterator;
[694]61
[812]62 size = param.GetSize();
63 for(i = 0; i < size/2; ++i)
64 {
65 array = ImportArray(param[i*2].GetString());
66 iterator = array->MakeIterator();
[694]67
[1314]68 fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
[812]69 }
70}
[694]71
[812]72//------------------------------------------------------------------------------
[694]73
[812]74void UniqueObjectFinder::Finish()
75{
76 map< TIterator *, TObjArray * >::iterator itInputMap;
77 TIterator *iterator;
[694]78
[812]79 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
80 {
81 iterator = itInputMap->first;
82
83 if(iterator) delete iterator;
84 }
[694]85}
86
87//------------------------------------------------------------------------------
88
[812]89void UniqueObjectFinder::Process()
[694]90{
[812]91 Candidate *candidate;
92 map< TIterator *, TObjArray * >::iterator itInputMap;
93 TIterator *iterator;
94 TObjArray *array;
95
96 // loop over all input arrays
97 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
98 {
99 iterator = itInputMap->first;
100 array = itInputMap->second;
101
102 // loop over all candidates
103 iterator->Reset();
104 while((candidate = static_cast<Candidate*>(iterator->Next())))
105 {
106 if(Unique(candidate, itInputMap))
107 {
108 array->Add(candidate);
109 }
110 }
111 }
[694]112}
113
114//------------------------------------------------------------------------------
115
[812]116Bool_t UniqueObjectFinder::Unique(Candidate *candidate, map< TIterator *, TObjArray * >::iterator itInputMap)
[694]117{
[812]118 Candidate *previousCandidate;
119 map< TIterator *, TObjArray * >::iterator previousItInputMap;
120 TObjArray *array;
[694]121
[812]122 // loop over previous arrays
123 for(previousItInputMap = fInputMap.begin(); previousItInputMap != itInputMap; ++previousItInputMap)
[694]124 {
[812]125 array = previousItInputMap->second;
126 TIter iterator(array);
[694]127
[812]128 // loop over all candidates
129 iterator.Reset();
130 while((previousCandidate = static_cast<Candidate*>(iterator.Next())))
[694]131 {
[932]132 if(candidate->Overlaps(previousCandidate))
[812]133 {
134 return kFALSE;
135 }
[694]136 }
137 }
[933]138
[812]139 return kTRUE;
[694]140}
141
142//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.