Fork me on GitHub

source: svn/trunk/modules/ConstituentFilter.cc@ 1348

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

replace ;; with ;

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 3.7 KB
RevLine 
[1074]1
2/** \class ConstituentFilter
3 *
4 * Drops all input objects that are not constituents of any jet.
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
14#include "modules/ConstituentFilter.h"
15
16#include "classes/DelphesClasses.h"
17#include "classes/DelphesFactory.h"
18#include "classes/DelphesFormula.h"
19
20#include "ExRootAnalysis/ExRootResult.h"
21#include "ExRootAnalysis/ExRootFilter.h"
22#include "ExRootAnalysis/ExRootClassifier.h"
23
24#include "TMath.h"
25#include "TString.h"
26#include "TFormula.h"
27#include "TRandom3.h"
28#include "TObjArray.h"
29#include "TDatabasePDG.h"
30#include "TLorentzVector.h"
31
32#include <algorithm>
33#include <stdexcept>
34#include <iostream>
35#include <sstream>
36
37using namespace std;
38
39//------------------------------------------------------------------------------
40
41ConstituentFilter::ConstituentFilter()
42{
43}
44
45//------------------------------------------------------------------------------
46
47ConstituentFilter::~ConstituentFilter()
48{
49}
50
51//------------------------------------------------------------------------------
52
53void ConstituentFilter::Init()
54{
55 ExRootConfParam param;
56 Long_t i, size;
57 const TObjArray *array;
58 TIterator *iterator;
59
[1075]60 fJetPTMin = GetDouble("JetPTMin", 0.0);
61
62 // import input array(s)
63
[1074]64 param = GetParam("JetInputArray");
65 size = param.GetSize();
66 for(i = 0; i < size; ++i)
67 {
68 array = ImportArray(param[i].GetString());
69 iterator = array->MakeIterator();
70
71 fInputList.push_back(iterator);
72 }
73
74 param = GetParam("ConstituentInputArray");
75 size = param.GetSize();
76 for(i = 0; i < size/2; ++i)
77 {
78 array = ImportArray(param[i*2].GetString());
79 iterator = array->MakeIterator();
80
[1314]81 fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
[1074]82 }
83}
84
85//------------------------------------------------------------------------------
86
87void ConstituentFilter::Finish()
88{
89 map< TIterator *, TObjArray * >::iterator itInputMap;
90 vector< TIterator * >::iterator itInputList;
91 TIterator *iterator;
92
93 for(itInputList = fInputList.begin(); itInputList != fInputList.end(); ++itInputList)
94 {
95 iterator = *itInputList;
96 if(iterator) delete iterator;
97 }
98
99 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
100 {
101 iterator = itInputMap->first;
102 if(iterator) delete iterator;
103 }
104}
105
106//------------------------------------------------------------------------------
107
108void ConstituentFilter::Process()
109{
[1075]110 Candidate *jet, *constituent;
[1074]111 map< TIterator *, TObjArray * >::iterator itInputMap;
112 vector< TIterator * >::iterator itInputList;
113 TIterator *iterator;
114 TObjArray *array;
115
116 // loop over all jet input arrays
117 for(itInputList = fInputList.begin(); itInputList != fInputList.end(); ++itInputList)
118 {
119 iterator = *itInputList;
120
121 // loop over all jets
122 iterator->Reset();
[1075]123 while((jet = static_cast<Candidate*>(iterator->Next())))
[1074]124 {
[1075]125 TIter itConstituents(jet->GetCandidates());
[1074]126
[1075]127 if(jet->Momentum.Pt() <= fJetPTMin) continue;
128
[1074]129 // loop over all constituents
130 while((constituent = static_cast<Candidate*>(itConstituents.Next())))
131 {
132 // set the IsConstituent flag
133 constituent->IsConstituent = 1;
134 }
135 }
136 }
137
138 // loop over all constituent input arrays
139 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
140 {
141 iterator = itInputMap->first;
142 array = itInputMap->second;
143
[1075]144 // loop over all constituents
[1074]145 iterator->Reset();
[1075]146 while((constituent = static_cast<Candidate*>(iterator->Next())))
[1074]147 {
[1075]148 // check the IsConstituent flag
149 if(constituent->IsConstituent)
[1074]150 {
[1075]151 array->Add(constituent);
[1074]152 }
153 }
154 }
155}
156
157//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.