CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
LHEAnalyzer Class Reference
Inheritance diagram for LHEAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 LHEAnalyzer (const edm::ParameterSet &params)
 
virtual ~LHEAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &es) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Member Functions

void fillDJRSched (unsigned int min, unsigned int max)
 

Private Attributes

unsigned int binsDelta
 
unsigned int binsPt
 
double defaultDeltaCut
 
double defaultPtCut
 
boost::ptr_vector< JetClusteringdeltaClustering
 
std::vector< unsigned int > djrSched
 
std::vector< TH1 * > histoDelta
 
std::vector< TH1 * > histoPt
 
JetInput jetInput
 
double maxDelta
 
unsigned int maxDJR
 
double maxEta
 
double maxPt
 
double minDelta
 
unsigned int minDJR
 
double minPt
 
std::auto_ptr< JetClusteringptClustering
 
double ptFraction
 
edm::InputTag sourceLabel
 
bool useEt
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 38 of file LHEAnalyzer.cc.

Constructor & Destructor Documentation

LHEAnalyzer::LHEAnalyzer ( const edm::ParameterSet params)
explicit

Definition at line 77 of file LHEAnalyzer.cc.

References edm::ParameterSet::addParameter(), binsDelta, binsPt, defaultDeltaCut, defaultPtCut, deltaClustering, fillDJRSched(), edm::ParameterSet::getParameter(), h, histoDelta, histoPt, i, TFileService::make(), maxDelta, maxDJR, maxPt, minDelta, minDJR, minPt, ptClustering, ptFraction, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, tmp, and useEt.

77  :
78  sourceLabel(params.getParameter<edm::InputTag>("src")),
79  jetInput(params.getParameter<edm::ParameterSet>("jetInput")),
80  defaultDeltaCut(params.getParameter<double>("defaultDeltaCut")),
81  defaultPtCut(params.getParameter<double>("defaultPtCut")),
82  maxEta(params.getParameter<double>("maxEta")),
83  useEt(params.getParameter<bool>("useEt")),
84  ptFraction(params.getUntrackedParameter<double>("ptFraction", 0.75)),
85  binsDelta(params.getParameter<unsigned int>("binsDelta")),
86  minDelta(params.getParameter<double>("minDelta")),
87  maxDelta(params.getParameter<double>("maxDelta")),
88  binsPt(params.getParameter<unsigned int>("binsPt")),
89  minPt(params.getParameter<double>("minPt")),
90  maxPt(params.getParameter<double>("maxPt")),
91  minDJR(params.getParameter<unsigned int>("minDJR")),
92  maxDJR(params.getParameter<unsigned int>("maxDJR"))
93 {
94  edm::ParameterSet jetClusPSet =
95  params.getParameter<edm::ParameterSet>("jetClustering");
96 
97  for(unsigned int i = 0; i <= binsDelta; i++) {
98  double deltaCut =
100  jetClusPSet.addParameter("coneRadius", deltaCut);
102  tmp.addParameter("algorithm", jetClusPSet);
103  deltaClustering.push_back(
105  }
106 
107  jetClusPSet.addParameter("coneRadius", defaultDeltaCut);
109  tmp.addParameter("algorithm", jetClusPSet);
110  ptClustering.reset(new JetClustering(tmp, minPt * ptFraction));
111 
112  fillDJRSched(minDJR <= 0 ? 1 : minDJR, maxDJR - 1);
113 
115  for(unsigned int i = minDJR; i < maxDJR; i++) {
116  std::ostringstream ss, ss2;
117  ss << (i + 1) << "#rightarrow" << i << " jets";
118  ss2 << i;
119  TH1 *h = fs->make<TH1D>(("delta" + ss2.str()).c_str(),
120  ("DJR " + ss.str()).c_str(),
122  h->SetXTitle("p_{T} [GeV/c^2]");
123  h->SetYTitle("#delta#sigma [mb]");
124 
125  if (i == 0) {
126  h->Delete();
127  h = 0;
128  }
129  histoDelta.push_back(h);
130 
131  std::string what = useEt ? "E" : "p";
132  h = fs->make<TH1D>(("pt" + ss2.str()).c_str(),
133  ("DJR " + ss.str()).c_str(), binsPt,
134  std::log10(minPt), std::log10(maxPt));
135  h->SetXTitle(("log_{10}(" + what +
136  "_{T} [GeV/c^{2}])").c_str());
137  h->SetYTitle("#delta#sigma [mb]");
138 
139  histoPt.push_back(h);
140  }
141 }
unsigned int minDJR
Definition: LHEAnalyzer.cc:66
std::auto_ptr< JetClustering > ptClustering
Definition: LHEAnalyzer.cc:70
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< TH1 * > histoDelta
Definition: LHEAnalyzer.cc:73
double maxPt
Definition: LHEAnalyzer.cc:65
double maxEta
Definition: LHEAnalyzer.cc:56
JetInput jetInput
Definition: LHEAnalyzer.cc:52
double defaultDeltaCut
Definition: LHEAnalyzer.cc:54
double minDelta
Definition: LHEAnalyzer.cc:61
double maxDelta
Definition: LHEAnalyzer.cc:62
double minPt
Definition: LHEAnalyzer.cc:64
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
double defaultPtCut
Definition: LHEAnalyzer.cc:55
unsigned int binsDelta
Definition: LHEAnalyzer.cc:60
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:142
void fillDJRSched(unsigned int min, unsigned int max)
Definition: LHEAnalyzer.cc:147
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
unsigned int maxDJR
Definition: LHEAnalyzer.cc:67
unsigned int binsPt
Definition: LHEAnalyzer.cc:63
edm::InputTag sourceLabel
Definition: LHEAnalyzer.cc:51
std::vector< TH1 * > histoPt
Definition: LHEAnalyzer.cc:74
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double ptFraction
Definition: LHEAnalyzer.cc:58
boost::ptr_vector< JetClustering > deltaClustering
Definition: LHEAnalyzer.cc:69
LHEAnalyzer::~LHEAnalyzer ( )
virtual

Definition at line 143 of file LHEAnalyzer.cc.

144 {
145 }

Member Function Documentation

void LHEAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overrideprotectedvirtual

Implements edm::EDAnalyzer.

Definition at line 159 of file LHEAnalyzer.cc.

References binsDelta, defaultPtCut, deltaClustering, djrSched, first, MCTruth::genEvent, h, histoDelta, histoPt, i, getDQMSummary::iter, j, jetInput, fwrapper::jets, maxDJR, minDJR, RecoTauCleanerPlugins::pt, query::result, edm::second(), python.multivaluedict::sort(), sourceLabel, pileupCalc::upper, and useEt.

160 {
161  using boost::bind;
162  typedef JetClustering::Jet Jet;
163 
165  event.getByLabel(sourceLabel, hepmc);
166 
167  std::auto_ptr<HepMC::GenEvent> clonedEvent;
168  const HepMC::GenEvent *genEvent = hepmc->GetEvent();
169  if (!genEvent->signal_process_vertex()) {
170  clonedEvent.reset(new HepMC::GenEvent(*genEvent));
171  const HepMC::GenVertex *signalVertex =
172  LHEEvent::findSignalVertex(clonedEvent.get());
173  clonedEvent->set_signal_process_vertex(
174  const_cast<HepMC::GenVertex*>(signalVertex));
175  genEvent = clonedEvent.get();
176  }
177 
178  JetInput::ParticleVector particles = jetInput(genEvent);
179 
180  std::vector<Jet> ptJets = (*ptClustering)(particles);
181  std::sort(ptJets.begin(), ptJets.end(),
182  bind(std::greater<double>(),
183  bind(useEt ? &Jet::et : &Jet::pt, _1),
184  bind(useEt ? &Jet::et : &Jet::pt, _2)));
185 
186  typedef std::pair<int, int> Pair;
187  std::vector<Pair> deltaJets(maxDJR - minDJR + 1,
188  Pair(-1, binsDelta + 1));
189 
190  for(std::vector<unsigned int>::const_iterator djr = djrSched.begin();
191  djr != djrSched.end(); ++djr) {
192 //std::cout << "DJR schedule " << (*djr + 1) << " -> " << *djr << std::endl;
193  int result = -1;
194  for(;;) {
195 //for(int i = minDJR; i <= maxDJR; i++)
196 //std::cout << "+++ " << i << ": (" << deltaJets[i - minDJR].first << ", " << deltaJets[i - minDJR].second << ")" << std::endl;
197  int upper = binsDelta + 1;
198  for(int i = *djr; i >= (int)minDJR; i--) {
199  if (deltaJets[i - minDJR].second <=
200  (int)binsDelta) {
201  upper = deltaJets[i - minDJR].second;
202  break;
203  }
204  }
205  int lower = -1;
206  for(int i = *djr + 1; i <= (int)maxDJR; i++) {
207  if (deltaJets[i - minDJR].first >= 0) {
208  lower = deltaJets[i - minDJR].first;
209  break;
210  }
211  }
212 //std::cout << "\t" << lower << " < " << upper << std::endl;
213 
214  result = (lower + upper + 2) / 2 - 1;
215  if (result == lower)
216  break;
217  else if (result < lower) {
218  result = -1;
219  break;
220  }
221 
222  std::vector<Jet> jets =
223  deltaClustering[result](particles);
224  unsigned int nJets = 0;
225  for(std::vector<Jet>::const_iterator iter =
226  jets.begin(); iter != jets.end(); ++iter)
227  if ((useEt ? iter->et() : iter->pt())
228  > defaultPtCut)
229  nJets++;
230 
231 //std::cout << "\t---(" << *djr << ")--> bin " << result << ": " << nJets << " jets" << std::endl;
232 
233  if (nJets < minDJR)
234  nJets = minDJR;
235  else if (nJets > maxDJR)
236  nJets = maxDJR;
237 
238  for(int j = nJets; j >= (int)minDJR; j--) {
239  if (deltaJets[j - minDJR].first < 0 ||
240  result > deltaJets[j - minDJR].first)
241  deltaJets[j - minDJR].first = result;
242  }
243  for(int j = nJets; j <= (int)maxDJR; j++) {
244  if (deltaJets[j - minDJR].second <
245  (int)binsDelta ||
246  result < deltaJets[j - minDJR].second)
247  deltaJets[j - minDJR].second = result;
248  }
249  }
250 
251 //std::cout << "final " << *djr << ": " << result << std::endl;
252  TH1 *h = histoDelta[*djr - minDJR];
253  h->Fill(h->GetBinCenter(result + 1));
254 
255  h = histoPt[*djr - minDJR];
256  if (*djr >= ptJets.size())
257  h->Fill(-999.0);
258  else if (useEt)
259  h->Fill(std::log10(ptJets[*djr].et()));
260  else
261  h->Fill(std::log10(ptJets[*djr].pt()));
262  }
263 
264  if (minDJR <= 0) {
265  TH1 *h = histoPt[0];
266  if (minDJR >= ptJets.size())
267  h->Fill(-999.0);
268  else if (useEt)
269  h->Fill(std::log10(ptJets[minDJR].et()));
270  else
271  h->Fill(std::log10(ptJets[minDJR].pt()));
272  }
273 }
unsigned int minDJR
Definition: LHEAnalyzer.cc:66
int i
Definition: DBlmapReader.cc:9
std::vector< TH1 * > histoDelta
Definition: LHEAnalyzer.cc:73
JetInput jetInput
Definition: LHEAnalyzer.cc:52
double defaultPtCut
Definition: LHEAnalyzer.cc:55
U second(std::pair< T, U > const &p)
unsigned int binsDelta
Definition: LHEAnalyzer.cc:60
std::vector< unsigned int > djrSched
Definition: LHEAnalyzer.cc:71
vector< PseudoJet > jets
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
tuple genEvent
Definition: MCTruth.py:33
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
unsigned int maxDJR
Definition: LHEAnalyzer.cc:67
bool first
Definition: L1TdeRCT.cc:75
edm::InputTag sourceLabel
Definition: LHEAnalyzer.cc:51
std::vector< TH1 * > histoPt
Definition: LHEAnalyzer.cc:74
std::vector< const HepMC::GenParticle * > ParticleVector
Definition: JetInput.h:17
boost::ptr_vector< JetClustering > deltaClustering
Definition: LHEAnalyzer.cc:69
void LHEAnalyzer::fillDJRSched ( unsigned int  min,
unsigned int  max 
)
private

Definition at line 147 of file LHEAnalyzer.cc.

References djrSched, and bookConverter::max.

Referenced by LHEAnalyzer().

148 {
149  unsigned int middle = (min + max) / 2;
150 
151  djrSched.push_back(middle);
152 
153  if (min < middle)
154  fillDJRSched(min, middle - 1);
155  if (middle < max)
156  fillDJRSched(middle + 1, max);
157 }
std::vector< unsigned int > djrSched
Definition: LHEAnalyzer.cc:71
void fillDJRSched(unsigned int min, unsigned int max)
Definition: LHEAnalyzer.cc:147
T min(T a, T b)
Definition: MathUtil.h:58

Member Data Documentation

unsigned int LHEAnalyzer::binsDelta
private

Definition at line 60 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

unsigned int LHEAnalyzer::binsPt
private

Definition at line 63 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

double LHEAnalyzer::defaultDeltaCut
private

Definition at line 54 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

double LHEAnalyzer::defaultPtCut
private

Definition at line 55 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

boost::ptr_vector<JetClustering> LHEAnalyzer::deltaClustering
private

Definition at line 69 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

std::vector<unsigned int> LHEAnalyzer::djrSched
private

Definition at line 71 of file LHEAnalyzer.cc.

Referenced by analyze(), and fillDJRSched().

std::vector<TH1*> LHEAnalyzer::histoDelta
private

Definition at line 73 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

std::vector<TH1*> LHEAnalyzer::histoPt
private

Definition at line 74 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

JetInput LHEAnalyzer::jetInput
private

Definition at line 52 of file LHEAnalyzer.cc.

Referenced by analyze().

double LHEAnalyzer::maxDelta
private

Definition at line 62 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

unsigned int LHEAnalyzer::maxDJR
private

Definition at line 67 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

double LHEAnalyzer::maxEta
private

Definition at line 56 of file LHEAnalyzer.cc.

double LHEAnalyzer::maxPt
private

Definition at line 65 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

double LHEAnalyzer::minDelta
private

Definition at line 61 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

unsigned int LHEAnalyzer::minDJR
private

Definition at line 66 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().

double LHEAnalyzer::minPt
private

Definition at line 64 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

std::auto_ptr<JetClustering> LHEAnalyzer::ptClustering
private

Definition at line 70 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

double LHEAnalyzer::ptFraction
private

Definition at line 58 of file LHEAnalyzer.cc.

Referenced by LHEAnalyzer().

edm::InputTag LHEAnalyzer::sourceLabel
private

Definition at line 51 of file LHEAnalyzer.cc.

Referenced by analyze().

bool LHEAnalyzer::useEt
private

Definition at line 57 of file LHEAnalyzer.cc.

Referenced by analyze(), and LHEAnalyzer().