[Rivet-svn] r2670 - trunk/src/Analyses

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Sun Aug 22 14:26:25 BST 2010


Author: buckley
Date: Sun Aug 22 14:26:25 2010
New Revision: 2670

Log:
Converting to Rivet std coding style (spacing around operators for readability) while adding new histos... no functionality change in this commit, since I wanted to keep the cosmetics separate. Sorry for the whitespace changes.

Modified:
   trunk/src/Analyses/MC_JetAnalysis.cc

Modified: trunk/src/Analyses/MC_JetAnalysis.cc
==============================================================================
--- trunk/src/Analyses/MC_JetAnalysis.cc	Fri Aug 20 15:48:51 2010	(r2669)
+++ trunk/src/Analyses/MC_JetAnalysis.cc	Sun Aug 22 14:26:25 2010	(r2670)
@@ -23,50 +23,50 @@
   // Book histograms
   void MC_JetAnalysis::init() {
 
-    for (size_t i=0; i<m_njet; ++i) {
+    for (size_t i=0; i < m_njet; ++i) {
       stringstream dname;
-      dname<<"log10_d_"<<i<<i+1;
+      dname << "log10_d_" << i << i+1;
 
       _h_log10_d[i] = bookHistogram1D(dname.str(), 50, 0.2, log10(0.5*sqrtS()));
 
       stringstream Rname;
-      Rname<<"log10_R_"<<i;
+      Rname << "log10_R_" << i;
       _h_log10_R[i] = bookDataPointSet(Rname.str(), 50, 0.2, log10(0.5*sqrtS()));
 
       stringstream pTname;
-      pTname<<"jet_pT_"<<i+1;
+      pTname << "jet_pT_" << i+1;
       double pTmax = 1.0/(double(i)+2.0)*sqrtS()/GeV/2.0;
       int nbins_pT = 100/(i+1);
       _h_pT_jet[i] = bookHistogram1D(pTname.str(), logBinEdges(nbins_pT, 10.0, pTmax));
 
       stringstream massname;
-      massname<<"jet_mass_"<<i+1;
+      massname << "jet_mass_" << i+1;
       double mmax = 100.0;
       int nbins_m = 100/(i+1);
       _h_mass_jet[i] = bookHistogram1D(massname.str(), logBinEdges(nbins_m, 1.0, mmax));
 
       stringstream etaname;
-      etaname<<"jet_eta_"<<i+1;
+      etaname << "jet_eta_" << i+1;
       _h_eta_jet[i] = bookHistogram1D(etaname.str(), i>1 ? 25 : 50, -5.0, 5.0);
 
       stringstream rapname;
-      rapname<<"jet_y_"<<i+1;
+      rapname << "jet_y_" << i+1;
       _h_rap_jet[i] = bookHistogram1D(rapname.str(), i>1 ? 25 : 50, -5.0, 5.0);
 
       for (size_t j=i+1; j<m_njet; ++j) {
         std::pair<size_t, size_t> ij(std::make_pair(i, j));
 
         stringstream detaname;
-        detaname<<"jets_deta_"<<i+1<<j+1;
+        detaname << "jets_deta_" << i+1 << j+1;
         _h_deta_jets.insert(make_pair(ij, bookHistogram1D(detaname.str(), 25, -5.0, 5.0)));
 
         stringstream dRname;
-        dRname<<"jets_dR_"<<i+1<<j+1;
+        dRname << "jets_dR_" << i+1 << j+1;
         _h_dR_jets.insert(make_pair(ij, bookHistogram1D(dRname.str(), 25, 0.0, 5.0)));
       }
     }
     stringstream Rname;
-    Rname<<"log10_R_"<<m_njet;
+    Rname << "log10_R_" << m_njet;
     _h_log10_R[m_njet] = bookDataPointSet(Rname.str(), 50, 0.2, log10(0.5*sqrtS()));
 
     _h_jet_multi_exclusive = bookHistogram1D("jet_multi_exclusive", m_njet+3, -0.5, m_njet+3-0.5);
@@ -84,31 +84,31 @@
 
     // Jet resolutions and integrated jet rates
     const fastjet::ClusterSequence* seq = jetpro.clusterSeq();
-    if (seq!=NULL) {
+    if (seq != NULL) {
       double previous_dij = 10.0;
-      for (size_t i=0; i<m_njet; ++i) {
+      for (size_t i = 0; i < m_njet; ++i) {
         // Jet resolution i -> j
-        double d_ij=log10(sqrt(seq->exclusive_dmerge_max(i)));
+        double d_ij = log10(sqrt(seq->exclusive_dmerge_max(i)));
 
         // Fill differential jet resolution
         _h_log10_d[i]->fill(d_ij, weight);
 
         // Fill integrated jet resolution
-        for (int ibin=0; ibin<_h_log10_R[i]->size(); ++ibin) {
-          IDataPoint* dp=_h_log10_R[i]->point(ibin);
-          double dcut=dp->coordinate(0)->value();
-          if (d_ij<dcut && previous_dij>dcut) {
-            dp->coordinate(1)->setValue(dp->coordinate(1)->value()+weight);
+        for (int ibin = 0; ibin < _h_log10_R[i]->size(); ++ibin) {
+          IDataPoint* dp = _h_log10_R[i]->point(ibin);
+          double dcut = dp->coordinate(0)->value();
+          if (d_ij < dcut && previous_dij > dcut) {
+            dp->coordinate(1)->setValue(dp->coordinate(1)->value() + weight);
           }
         }
         previous_dij = d_ij;
       }
       // One remaining integrated jet resolution
-      for (int ibin=0; ibin<_h_log10_R[m_njet]->size(); ++ibin) {
-        IDataPoint* dp=_h_log10_R[m_njet]->point(ibin);
-        double dcut=dp->coordinate(0)->value();
-        if (previous_dij>dcut) {
-          dp->coordinate(1)->setValue(dp->coordinate(1)->value()+weight);
+      for (int ibin = 0; ibin<_h_log10_R[m_njet]->size(); ++ibin) {
+        IDataPoint* dp = _h_log10_R[m_njet]->point(ibin);
+        double dcut = dp->coordinate(0)->value();
+        if (previous_dij > dcut) {
+          dp->coordinate(1)->setValue(dp->coordinate(1)->value() + weight);
         }
       }
     }
@@ -116,7 +116,7 @@
     const Jets& jets = jetpro.jetsByPt(m_jetptcut);
 
     // The remaining direct jet observables
-    for (size_t i=0; i<m_njet; ++i) {
+    for (size_t i = 0; i < m_njet; ++i) {
       if (jets.size()<i+1) continue;
       _h_pT_jet[i]->fill(jets[i].momentum().pT()/GeV, weight);
       // Check for numerical precision issues with jet masses
@@ -131,10 +131,9 @@
       _h_mass_jet[i]->fill(sqrt(m2_i)/GeV, weight);
       _h_eta_jet[i]->fill(jets[i].momentum().eta(), weight);
       _h_rap_jet[i]->fill(jets[i].momentum().rapidity(), weight);
-      // cout << "Jet mass [" << i+1 << "] = " << jets[i].momentum().mass()/GeV << " GeV" << endl;
 
-      for (size_t j=i+1; j<m_njet; ++j) {
-        if (jets.size()<j+1) continue;
+      for (size_t j = i+1; j < m_njet; ++j) {
+        if (jets.size() < j+1) continue;
         std::pair<size_t, size_t> ij(std::make_pair(i, j));
         double deta = jets[i].momentum().eta()-jets[j].momentum().eta();
         double dR = deltaR(jets[i].momentum(), jets[j].momentum());
@@ -144,8 +143,8 @@
     }
     _h_jet_multi_exclusive->fill(jets.size(), weight);
 
-    for (size_t i=0; i<m_njet+2; ++i) {
-      if (jets.size()>=i) {
+    for (size_t i = 0; i < m_njet+2; ++i) {
+      if (jets.size() >= i) {
         _h_jet_multi_inclusive->fill(i, weight);
       }
     }
@@ -154,10 +153,10 @@
 
   // Finalize
   void MC_JetAnalysis::finalize() {
-    for (size_t i=0; i<m_njet; ++i) {
+    for (size_t i = 0; i < m_njet; ++i) {
       scale(_h_log10_d[i], crossSection()/sumOfWeights());
-      for (int ibin=0; ibin<_h_log10_R[i]->size(); ++ibin) {
-        IDataPoint* dp=_h_log10_R[i]->point(ibin);
+      for (int ibin = 0; ibin<_h_log10_R[i]->size(); ++ibin) {
+        IDataPoint* dp = _h_log10_R[i]->point(ibin);
         dp->coordinate(1)->setValue(dp->coordinate(1)->value()*crossSection()/sumOfWeights());
       }
 
@@ -167,30 +166,30 @@
       scale(_h_rap_jet[i], crossSection()/sumOfWeights());
 
     }
-    for (int ibin=0; ibin<_h_log10_R[m_njet]->size(); ++ibin) {
-      IDataPoint* dp=_h_log10_R[m_njet]->point(ibin);
+    for (int ibin = 0; ibin<_h_log10_R[m_njet]->size(); ++ibin) {
+      IDataPoint* dp =_h_log10_R[m_njet]->point(ibin);
       dp->coordinate(1)->setValue(dp->coordinate(1)->value()*crossSection()/sumOfWeights());
     }
 
     // Scale the d{eta,R} histograms
     map<pair<size_t, size_t>, AIDA::IHistogram1D*>::iterator it;
-    for (it=_h_deta_jets.begin(); it!=_h_deta_jets.begin(); ++it) {
+    for (it = _h_deta_jets.begin(); it != _h_deta_jets.begin(); ++it) {
       scale(it->second, crossSection()/sumOfWeights());
     }
-    for (it=_h_dR_jets.begin(); it!=_h_dR_jets.begin(); ++it) {
+    for (it = _h_dR_jets.begin(); it != _h_dR_jets.begin(); ++it) {
       scale(it->second, crossSection()/sumOfWeights());
     }
 
     // Fill inclusive jet multi ratio
-    int Nbins=_h_jet_multi_inclusive->axis().bins();
+    int Nbins = _h_jet_multi_inclusive->axis().bins();
     std::vector<double> ratio(Nbins-1, 0.0);
     std::vector<double> err(Nbins-1, 0.0);
-    for (int i=0; i<Nbins-1; ++i) {
-      if (_h_jet_multi_inclusive->binHeight(i)>0.0 && _h_jet_multi_inclusive->binHeight(i+1)>0.0) {
-        ratio[i]=_h_jet_multi_inclusive->binHeight(i+1)/_h_jet_multi_inclusive->binHeight(i);
-        double relerr_i=_h_jet_multi_inclusive->binError(i)/_h_jet_multi_inclusive->binHeight(i);
-        double relerr_j=_h_jet_multi_inclusive->binError(i+1)/_h_jet_multi_inclusive->binHeight(i+1);
-        err[i]=ratio[i]*(relerr_i+relerr_j);
+    for (int i = 0; i < Nbins-1; ++i) {
+      if (_h_jet_multi_inclusive->binHeight(i) > 0.0 && _h_jet_multi_inclusive->binHeight(i+1) > 0.0) {
+        ratio[i] = _h_jet_multi_inclusive->binHeight(i+1)/_h_jet_multi_inclusive->binHeight(i);
+        double relerr_i = _h_jet_multi_inclusive->binError(i)/_h_jet_multi_inclusive->binHeight(i);
+        double relerr_j = _h_jet_multi_inclusive->binError(i+1)/_h_jet_multi_inclusive->binHeight(i+1);
+        err[i] = ratio[i] * (relerr_i + relerr_j);
       }
     }
     _h_jet_multi_ratio->setCoordinate(1, ratio, err);


More information about the Rivet-svn mailing list