CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CMS_2011_S8884919.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 #include "Rivet/Analysis.hh"
3 #include "Rivet/RivetAIDA.hh"
4 #include "Rivet/Projections/ChargedFinalState.hh"
5 #include "Rivet/Projections/HadronicFinalState.hh"
6 #include "Rivet/Tools/ParticleIdUtils.hh"
7 #include "Rivet/Projections/Beam.hh"
8 using namespace std;
9 
10 namespace Rivet {
11 
12 
13  class CMS_2011_S8884919 : public Analysis {
14  public:
15 
16  CMS_2011_S8884919() : Analysis("CMS_2011_S8884919") {
17  setBeams(PROTON, PROTON);
18  setNeedsCrossSection(false);
19  }
20 
21  //Container for the moments
22  /* struct IMoments {
23  int n;
24  double mean;
25  vector<double> cq;
26 
27  //default constructor
28  IMoments():n(6),mean(0),cq(vector<double>(n,0)){}
29  };
30 
31  IMoments _moments_eta05;
32  IMoments _moments_eta24; */
33 
34 
35 //AK =====================================================DECLARATIONS
36  private:
37 
38 
39  vector<AIDA::IHistogram1D*> _h_dNch_dn;
40 
41  //vector<double> _v_dNch_dn_binning1_eta05;
42  //vector<double> _v_dNch_dn_binning1_eta24;
43 
44  AIDA::IHistogram1D* _h_dNch_dn_pt500_eta24;
45 
46  //AIDA::IHistogram1D* _h_cq_eta05;
47  //AIDA::IHistogram1D* _h_cq_eta24;
48 
49  AIDA::IProfile1D* _h_dmpt_dNch_eta24;
50 
51  AIDA::IHistogram1D* _h_KNO_eta05;
52  AIDA::IHistogram1D* _h_KNO_eta24;
53 
55  vector<double> _etabins;
56  vector<int> _nch_in_Evt;
57  vector<int> _nch_in_Evt_pt500;
58  double _sumpt;
59  int nch_max;
60 
61  //mandatory functions
62  void init();
63  void analyze(const Event&);
64  void finalize();
65 
66 
67  /*void moments_add(IMoments& , double , double = 1);
68  void makeMoments(AIDA::IHistogram1D* , IMoments&);
69  void makeMoments(vector<double>& , IMoments&);
70 
71  void makeKNO(AIDA::IHistogram1D* nch , AIDA::IHistogram1D* kno){
72 
73  }*/
74 
75 
76  };
77 
78 
79 
80 //----------------------------------------------------------------------------------------------
81 
82 
83  /*void CMS_2011_S8884919::moments_add(IMoments& moments , double value , double weight){
84  moments.mean += value*weight;
85 
86  for(int m = 0 ; m < moments.n ; ++m)
87  (moments.cq[m]) += pow(value,m) * weight;
88  }
89 
90 
91  void CMS_2011_S8884919::makeMoments(AIDA::IHistogram1D* h , IMoments& moments){
92  int sumHeight = 0;
93 
94  for(int i=0 ; i < h->axis().bins() ; ++i){
95  moments_add(moments , (h->axis().binLowerEdge(i) + h->axis().binUpperEdge(i)) / 2. , h->binHeight(i));
96  sumHeight += h->binHeight(i);
97  }
98 
99 
100  //finishing moments
101  if(sumHeight != 0){
102  moments.mean /= sumHeight;
103  for(int m = 0 ; m < moments.n ; ++m)
104  if( moments.mean != 0) moments.cq[m] = (moments.cq[m] / sumHeight) / pow(moments.mean , m) ;
105  }
106  }
107 
108  void CMS_2011_S8884919::makeMoments(vector<double>& v , IMoments& moments){
109  int sumHeight = 0;
110 
111  for(unsigned i=0 ; i < v.size() ; ++i){
112  moments_add(moments , i , v[i]);
113  sumHeight += v[i];
114  }
115 
116 
117  //finishing moments
118  if(sumHeight != 0){
119  moments.mean /= sumHeight;
120  for(int m = 0 ; m < moments.n ; ++m)
121  if( moments.mean != 0) moments.cq[m] = (moments.cq[m] / sumHeight) / pow(moments.mean , m) ;
122  }
123  }
124  */
125 
126 
127 
128 
129 //AK =====================================================INIT
131  ChargedFinalState cfs(-2.4, 2.4, 0.0*GeV);
132  addProjection(cfs, "CFS");
133  addProjection(Beam(), "Beam");
134 
135  nch_max = 400;
136  _Nevt_after_cuts = 0;
137 
138  //eta bins
139  _etabins.push_back(0.5) ; _etabins.push_back(1.0) ; _etabins.push_back(1.5) ; _etabins.push_back(2.0) ; _etabins.push_back(2.4) ;
140  _h_dNch_dn.reserve( _etabins.size() );
141  ostringstream t("");
142 
143  if(fuzzyEquals(sqrtS(), 900, 1E-3)){
144 
145  for (unsigned ietabin=0; ietabin < _etabins.size(); ietabin++){
146  t.str("") ; t << "$|\\eta| <$ " << _etabins[ietabin] << " , $\\sqrt(s)$ = 0.9 TeV" ;
147  _h_dNch_dn.push_back( bookHistogram1D( 2 + ietabin, 1, 1 , t.str() , "n" , "$P_{n}$") );
148  }
149 
150  _h_dNch_dn_pt500_eta24 = bookHistogram1D( 20 , 1, 1 , "$p_{T} >$ 500 GeV/c , $|\\eta| <$ 2.4 , $\\sqrt(s)$ = 0.9 TeV" , "n" , "$P_{n}$");
151 
152  //_h_cq_eta05 = bookHistogram1D( 17 , 1, 1 , "$|\\eta| <$ 0.5 , $\\sqrt(s)$ = 0.9 TeV" , "q" , "$C_{q}$");
153  //_h_cq_eta24 = bookHistogram1D( 17 , 1, 2 , "$|\\eta| <$ 2.4 , $\\sqrt(s)$ = 0.9 TeV" , "q" , "$C_{q}$");
154 
155  _h_dmpt_dNch_eta24 = bookProfile1D( 23 , 1, 1 , "$|\\eta| <$ 2.4 , $\\sqrt(s)$ = 0.9 TeV" , "n" , "$< p_{T}> [ GeV/c ]$");
156 
157  }
158 
159  if(fuzzyEquals(sqrtS(), 2360, 1E-3)){
160  for (unsigned ietabin=0; ietabin < _etabins.size(); ietabin++){
161  t.str("") ; t << "$|\\eta| <$ " << _etabins[ietabin] << " , $\\sqrt(s)$ = 2.36 TeV" ;
162  _h_dNch_dn.push_back( bookHistogram1D( 7 + ietabin, 1, 1 , t.str() , "n" , "$P_{n}$") );
163  }
164 
165  _h_dNch_dn_pt500_eta24 = bookHistogram1D( 21 , 1, 1 , "$p_{T} >$ 500 GeV/c , $|\\eta| <$ 2.4 , $\\sqrt(s)$ = 2.36 TeV" , "n" , "$P_{n}$");
166 
167  //_h_cq_eta05 = bookHistogram1D( 18 , 1, 1 , "$|\\eta| <$ 0.5 , $\\sqrt(s)$ = 2.36 TeV" , "q" , "$C_{q}$");
168  //_h_cq_eta24 = bookHistogram1D( 18 , 1, 2 , "$|\\eta| <$ 2.4 , $\\sqrt(s)$ = 2.36 TeV" , "q" , "$C_{q}$");
169 
170  _h_dmpt_dNch_eta24 = bookProfile1D( 24 , 1, 1 , "$|\\eta| <$ 2.4 , $\\sqrt(s)$ = 2.36 TeV" , "n" , "$< p_{T}> [ GeV/c ]$");
171  }
172 
173  if(fuzzyEquals(sqrtS(), 7000, 1E-3)){
174  for (unsigned ietabin=0; ietabin < _etabins.size(); ietabin++){
175  t.str("") ; t << "$|\\eta| <$ " << _etabins[ietabin] << " , $\\sqrt(s)$ = 7 TeV" ;
176  _h_dNch_dn.push_back( bookHistogram1D( 12 + ietabin, 1, 1 , t.str() , "n" , "$P_{n}$") );
177  }
178 
179  _h_dNch_dn_pt500_eta24 = bookHistogram1D( 22 , 1, 1 , "$p_{T} >$ 500 GeV/c , $|\\eta| <$ 2.4 , $\\sqrt(s)$ = 7 TeV" , "n" , "$P_{n}$");
180 
181  //_h_cq_eta05 = bookHistogram1D( 19 , 1, 1 , "$|\\eta| <$ 0.5 , $\\sqrt(s)$ = 7 TeV" , "q" , "$C_{q}$");
182  //_h_cq_eta24 = bookHistogram1D( 19 , 1, 2 , "$|\\eta| <$ 2.4 , $\\sqrt(s)$ = 7 TeV" , "q" , "$C_{q}$");
183 
184  _h_dmpt_dNch_eta24 = bookProfile1D( 25 , 1, 1 , "$|\\eta| <$2.4 , $\\sqrt(s)$ = 7 TeV" , "n" , "$< p_{T}> [ GeV/c ]$");
185 
186  }
187 
188  //_v_dNch_dn_binning1_eta05.assign(nch_max+1,0);
189  //_v_dNch_dn_binning1_eta24.assign(nch_max+1,0);
190 
191  }
192 
193 //AK =====================================================ANALYZE
194  void CMS_2011_S8884919::analyze(const Event& event) {
195  const double weight = event.weight();
196 
197  //charge particles
198  const ChargedFinalState& charged = applyProjection<ChargedFinalState>(event, "CFS");
199 
200  //This cut is not needed
201  /*if (charged.particles().size()<1) {
202  vetoEvent;
203  }*/
204 
205 
206  _Nevt_after_cuts += weight;
207 
208  //resetting the multiplicity for the event to 0;
209  _nch_in_Evt.assign(_etabins.size() , 0);
210  _nch_in_Evt_pt500.assign(_etabins.size() , 0);
211  _sumpt = 0;
212 
213  //std::cout << charged.size() << std::endl;
214 
215  //Loop over particles in event
216  foreach (const Particle& p, charged.particles()) {
217 
218  //selecting only charged hadrons
219  if(! PID::isHadron(p.pdgId())) continue;
220 
221  double pT = p.momentum().pT();
222  double eta = p.momentum().eta();
223 
224  _sumpt+=pT;
225 
226  //cout << "eta : " << eta << " pT : " << pT << endl;
227 
228  for (int ietabin=_etabins.size()-1; ietabin >= 0 ; --ietabin){
229  //cout << " etabin : " << _etabins[ietabin] << " res : " << (fabs(eta) <= _etabins[ietabin]) << endl;
230  if (fabs(eta) <= _etabins[ietabin]){
231  ++(_nch_in_Evt[ietabin]);
232 
233  if(pT>0.5)
234  ++(_nch_in_Evt_pt500[ietabin]);
235  }
236  //break loop to go faster
237  else
238  break;
239 
240  }
241 
242  }
243 
244  //filling mutliplicity dependent histogramms
245  for (unsigned ietabin=0; ietabin < _etabins.size(); ietabin++){
246  _h_dNch_dn[ietabin]->fill(_nch_in_Evt[ietabin] , weight);
247  }
248 
249  //Do only if eta bins are the needed ones
250  if(_etabins[4] == 2.4 && _etabins[0] == 0.5){
251  if(_nch_in_Evt[4] != 0) _h_dmpt_dNch_eta24->fill(_nch_in_Evt[4] , _sumpt / _nch_in_Evt[4] , weight);
252 
253  _h_dNch_dn_pt500_eta24->fill(_nch_in_Evt_pt500[4] , weight);
254 
255  /*if( _nch_in_Evt[4] < nch_max ){
256  (_v_dNch_dn_binning1_eta05[_nch_in_Evt[0]])+=weight;
257  (_v_dNch_dn_binning1_eta24[_nch_in_Evt[0]])+=weight;
258  }*/
259 
260  }
261  else
262  getLog() << Log::WARNING << "You changed the number of eta bins, but forgot to propagate it everywhere !! " << endl;
263 
264  }
265 
266 //AK =====================================================FINALIZE
267  void CMS_2011_S8884919::finalize() {
268  getLog() << Log::INFO << "Number of events after event selection: " << _Nevt_after_cuts << endl;
269 
270  /*makeMoments(_v_dNch_dn_binning1_eta05 , _moments_eta05);
271  makeMoments(_v_dNch_dn_binning1_eta24 , _moments_eta24);
272 
273  for(int m = 0 ; m < _moments_eta05.n ; ++m){
274  _h_cq_eta05->fill(m , _moments_eta05.cq[m]);
275  _h_cq_eta24->fill(m , _moments_eta24.cq[m]);
276  }*/
277 
278  for (unsigned ietabin=0; ietabin < _etabins.size(); ietabin++){
279  normalize(_h_dNch_dn[ietabin]);
280  }
281  normalize(_h_dNch_dn_pt500_eta24);
282  }
283 
284 
285  // This global object acts as a hook for the plugin system
286  AnalysisBuilder<CMS_2011_S8884919> plugin_CMS_2011_S8884919;
287 
288 }
289 
AIDA::IHistogram1D * _h_KNO_eta24
AIDA::IHistogram1D * _h_dNch_dn_pt500_eta24
int init
Definition: HydjetWrapper.h:63
static const int WARNING
T eta() const
vector< AIDA::IHistogram1D * > _h_dNch_dn
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
AIDA::IProfile1D * _h_dmpt_dNch_eta24
AnalysisBuilder< CMS_2011_S8884919 > plugin_CMS_2011_S8884919
AIDA::IHistogram1D * _h_KNO_eta05