ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/src/CutFlow.cc
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/src/CutFlow.cc (file contents):
Revision 1.3 by ahart, Fri Sep 7 19:52:46 2012 UTC vs.
Revision 1.7 by ahart, Wed Feb 6 00:24:27 2013 UTC

# Line 5 | Line 5 | CutFlow::CutFlow (const edm::Service<TFi
5    sw_.Start ();
6    string cutFlowName = "cutFlow",
7           selectionName = "selection",
8 <         rejectionName = "rejection";
8 >         minusOneName = "minusOne";
9  
10    prefix_ = prefix;
11    if (prefix_ != "")
12      {
13        cutFlowName = prefix_ + "CutFlow";
14        selectionName = prefix_ + "Selection";
15 <      rejectionName = prefix_ + "Rejection";
15 >      minusOneName = prefix_ + "MinusOne";
16      }
17  
18    TH1::SetDefaultSumw2 ();
19    cutFlow_ = fs->make<TH1D> (cutFlowName.c_str (), "", 1, 0.0, 1.0);
20    selection_ = fs->make<TH1D> (selectionName.c_str (), "", 1, 0.0, 1.0);
21 <  rejection_ = fs->make<TH1D> (rejectionName.c_str (), "", 1, 0.0, 1.0);
21 >  minusOne_ = fs->make<TH1D> (minusOneName.c_str (), "", 1, 0.0, 1.0);
22  
23    cutFlow_->GetXaxis ()->SetBinLabel (1, "Total");
24    selection_->GetXaxis ()->SetBinLabel (1, "Total");
25 <  rejection_->GetXaxis ()->SetBinLabel (1, "Total");
25 >  minusOne_->GetXaxis ()->SetBinLabel (1, "Total");
26   }
27  
28   CutFlow::~CutFlow ()
# Line 42 | Line 42 | CutFlow::operator[] (const string &cutNa
42  
43        cutFlow_->SetBins (cutNames_.size () + 1, 0.0, cutNames_.size () + 1.0);
44        selection_->SetBins (cutNames_.size () + 1, 0.0, cutNames_.size () + 1.0);
45 <      rejection_->SetBins (cutNames_.size () + 1, 0.0, cutNames_.size () + 1.0);
45 >      minusOne_->SetBins (cutNames_.size () + 1, 0.0, cutNames_.size () + 1.0);
46  
47        cutFlow_->GetXaxis ()->SetBinLabel (cutNames_.size () + 1, cutName.c_str ());
48        selection_->GetXaxis ()->SetBinLabel (cutNames_.size () + 1, cutName.c_str ());
49 <      rejection_->GetXaxis ()->SetBinLabel (cutNames_.size () + 1, cutName.c_str ());
49 >      minusOne_->GetXaxis ()->SetBinLabel (cutNames_.size () + 1, cutName.c_str ());
50      }
51  
52    return cuts_[cutName];
# Line 64 | Line 64 | CutFlow::pass () const
64   }
65  
66   void
67 < CutFlow::fillCutFlow ()
67 > CutFlow::fillCutFlow (double w)
68   {
69    bool fillCumulative = true, fillComplement = true;
70    double complement = -1.0;
71  
72 <  cutFlow_->Fill (0.5);
73 <  selection_->Fill (0.5);
72 >  cutFlow_->Fill (0.5, w);
73 >  selection_->Fill (0.5, w);
74 >  minusOne_->Fill (0.5, w);
75    for (vector<string>::const_iterator cut = cutNames_.begin (); cut != cutNames_.end (); cut++)
76      {
77        if (cuts_[*cut])
78          {
79            double binCenter = selection_->GetBinCenter (cut - cutNames_.begin () + 2);
80  
81 <          selection_->Fill (binCenter);
81 >          selection_->Fill (binCenter, w);
82            if (fillCumulative)
83 <            cutFlow_->Fill (binCenter);
83 >            cutFlow_->Fill (binCenter, w);
84          }
85        else
86          {
87            fillCumulative = false;
88            if (complement < 0.0)
89 <            complement = rejection_->GetBinCenter (cut - cutNames_.begin () + 2);
89 >            complement = minusOne_->GetBinCenter (cut - cutNames_.begin () + 2);
90            else
91              fillComplement = false;
92          }
93      }
94    if (fillCumulative)
95      {
95      rejection_->Fill (0.5);
96        for (vector<string>::const_iterator cut = cutNames_.begin (); cut != cutNames_.end (); cut++)
97          {
98 <          double binCenter = rejection_->GetBinCenter (cut - cutNames_.begin () + 2);
98 >          double binCenter = minusOne_->GetBinCenter (cut - cutNames_.begin () + 2);
99  
100 <          rejection_->Fill (binCenter);
100 >          minusOne_->Fill (binCenter, w);
101          }
102      }
103    if (!fillCumulative && fillComplement)
104 <    rejection_->Fill (complement);
104 >    minusOne_->Fill (complement, w);
105   }
106  
107   void
# Line 170 | Line 170 | CutFlow::outputCutFlow ()
170      }
171  
172    clog << setw (80) << setfill ('-') << '-' << setfill (' ') << endl;
173 <  clog << setw (16) << left << "Cut Name" << right << setw (16) << "Cut Flow" << setw (16) << "Efficiency" << setw (16) << "Selection" << setw (16) << "Rejection" << endl;
173 >  clog << setw (15) << left << "Cut Name" << right << setw (16) << "Events" << setw (16) << "Cumulative Eff." << setw (16) << "Individual Eff." << setw (16) << "Minus One" << endl;
174    clog << setw (80) << setfill ('-') << '-' << setfill (' ') << endl;
175    totalEvents = cutFlow_->GetBinContent (1);
176 <  clog << setw (25) << left << "Total:" << right << setw (25) << totalEvents << setw (25) << "100%" << endl;
176 >  clog << setw (15) << left << "Total:" << right << setw (16) << totalEvents << setw (16) << "100%" << setw (16) << "100%" << setw (16) << "0%" << endl;
177    for (vector<string>::const_iterator cut = cutNames_.begin (); cut != cutNames_.end (); cut++)
178      {
179        double cutFlow = cutFlow_->GetBinContent (cut - cutNames_.begin () + 2),
180               selection = selection_->GetBinContent (cut - cutNames_.begin () + 2),
181 <             rejection = rejection_->GetBinContent (cut - cutNames_.begin () + 2);
181 >             minusOne = minusOne_->GetBinContent (cut - cutNames_.begin () + 2);
182  
183 <      clog << setw (16) << left << (*cut + ":") << right << setw (16) << cutFlow << setw (16) << 100.0 * (cutFlow / (double) totalEvents) << "%"
184 <                                                                                 << setw (16) << 100.0 * (selection / (double) totalEvents) << "%"
185 <                                                                                 << setw (16) << 100.0 * (rejection / (double) totalEvents) << "%" << endl;
183 >      clog << setw (15) << left << (*cut + ":") << right << setw (16) << cutFlow << setw (15) << 100.0 * (cutFlow / (double) totalEvents) << "%"
184 >                                                                                 << setw (15) << 100.0 * (selection / (double) totalEvents) << "%"
185 >                                                                                 << setw (15) << 100.0 * (minusOne / (double) totalEvents) << "%" << endl;
186      }
187    clog << setw (80) << setfill ('-') << '-' << setfill (' ') << endl;
188  clog << endl;
188   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines