CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HerwigMaxPtPartonFilter.cc
Go to the documentation of this file.
1 /*
2 Author: Brian L. Dorney
3 Date: July 29th 2010
4 Version: 2.2
5 First Release In: CMSSW_3_8_X
6 
7 Modified From: PythiaFilter.cc
8 
9 Special Thanks to Filip Moortgat
10 
11 PURPOSE: This Filter is designed to run on Herwig Monte Carlo Event Files
12 (Pythia status codes are assumed to NOT BE EMULATED!!!!)
13 
14 For a description of Herwig Status Codes, See:
15 http://webber.home.cern.ch/webber/hw65_manual.html#htoc96
16 (Section 8.3.1)
17 
18 This Filter Finds all final state quarks (pdg_id=1,2,3,4 or 5, status=158 or 159) with Pt>1 GeV/c
19 that occur before the first cluster (pdg_id=91) appears in the event cascade. This is done per event.
20 
21 Then a histogram (which is RESET EACH EVENT) 2D histogram is formed, the Final State quarks
22 are then plotted in eta-phi space. These histogram entries are weighted by the quark Pt.
23 
24 This forms a 2D eta-phi "jet" topology for each event, and acts as a very rudimentary jet algorithm
25 
26 The maximum bin entry (i.e. "jet") in this histogram is the highest Pt "Jet" in the event.
27 
28 This is then used for filtering.
29 
30 The size of each bin in this 2D histogram corresponds roughly to a cone radius of 0.5
31 
32 i.e. This Filter Checks:
33 minptcut <= Highest Pt "Jet" < maxptcut
34 
35 If this is true, the event is accepted.
36 */
37 
40 
41 #include <math.h>
42 
43 using namespace edm;
44 using namespace std;
45 
47  label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
48  minptcut(iConfig.getUntrackedParameter("MinPt", 0.)),
49  maxptcut(iConfig.getUntrackedParameter("MaxPt", 10000.)),
50  processID(iConfig.getUntrackedParameter("ProcessID", 0)){
51  //now do what ever initialization is needed
52 
53 
54  hFSPartons_JS_PtWgting = new TH2D("hFSPartons_JS_PtWgting","#phi-#eta Space of FS Partons (p_{T} wgt'ing)",20,-5.205,5.205,32,-M_PI,M_PI);
55 
56 }
57 
58 
60 
61  // do anything here that needs to be done at desctruction time
62  // (e.g. close files, deallocate resources etc.)
63 
65 
66 }
67 
68 
69 //
70 // member functions
71 //
72 
73 // ------------ method called to produce the data ------------
75 
76  //Histogram, reset each event
77  hFSPartons_JS_PtWgting->Reset();
78 
79  bool accepted = false; //The Accept/Reject Variable
80  bool isFSQuark = false; //Keeps track of whether a particle is a Final State Quark
81  double maxPartonPt=0.0; //Self Explanatory
82 
83  //int ChosenPartonId=0, ChosenPartonSt=0;
84 
85  int pos1stCluster=0; //keeps track of the position of the first herwig cluster in the event
86 
87  //This is when Hadronization within the event occurs.
88  long counter = 0; //keeps track of the particle index in the event
89 
91  iEvent.getByLabel(label_, evt);
92 
93  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
94 
95 
96  if(processID == 0 || processID == myGenEvent->signal_process_id()) { //processId if statement
97 
98  //Find the Position of the 1st Herwig Cluster
99  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();p != myGenEvent->particles_end(); ++p ) {
100  if(abs((*p)->pdg_id())==91){
101  break;
102  }
103  pos1stCluster++; //Starts at Zero, like the Collection
104  }
105 
106  //Loop through the all particles in the event
107  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();p != myGenEvent->particles_end(); ++p ) {
108  //"Garbage" Cut, 1 GeV/c Pt Cut on All Particles Considered
109  if((*p)->momentum().perp()>1.0){
110  //Final State Quark criterion
111  if(abs((*p)->pdg_id())==1 || abs((*p)->pdg_id())==2 || abs((*p)->pdg_id())==3 || abs((*p)->pdg_id())==4 || abs((*p)->pdg_id())==5){
112  if( counter<pos1stCluster && ((*p)->status()==158 || (*p)->status()==159) ){
113  isFSQuark=true;
114  }
115  }//end if FS Quark criterion
116  }//End "Garbage" Cut
117 
118  if(isFSQuark){
119  hFSPartons_JS_PtWgting->Fill( (*p)->momentum().eta(), (*p)->momentum().phi(), (*p)->momentum().perp()); //weighted by Particle Pt
120  }
121 
122  counter++;
123  isFSQuark=false;
124  } //end all particles loop
125 
126  maxPartonPt=hFSPartons_JS_PtWgting->GetMaximum();
127 
128  //The Actual Filtering Process
129  if(maxPartonPt>=minptcut && maxPartonPt<maxptcut){
130  accepted=true; //Accept the Event
131 
132  }//End Filtering
133  }//end processId if statement
134 
135  else{ accepted = true; }
136 
137  if (accepted){return true; }
138  else {return false;}
139 }
#define abs(x)
Definition: mlp_lapack.h:159
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define M_PI
Definition: BFit3D.cc:3
HerwigMaxPtPartonFilter(const edm::ParameterSet &)
virtual bool filter(edm::Event &, const edm::EventSetup &)