/[PAMELA software]/PamCut/Collections/EffCollection/EffCollection.cpp
ViewVC logotype

Contents of /PamCut/Collections/EffCollection/EffCollection.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Fri Aug 14 10:32:22 2009 UTC (15 years, 4 months ago) by pam-fi
Branch: MAIN
Changes since 1.3: +1 -1 lines
Bug fix.

1 /*
2 * EffCollection.cpp
3 *
4 * Created on: 10/ago/2009
5 * Author: Nicola Mori
6 */
7
8 /*! @file EffCollection.cpp The EffCollection class implementation file. */
9
10 #include "EffCollection.h"
11
12 EffCollection::EffCollection(const char *collectionName, TString outFileBase) :
13 VerboseCollection(collectionName), _selCollection("selCollection"), _detCollection("detCollection"), _outFileBase(
14 outFileBase), _det(0), _sel(0) {
15
16 }
17
18 void EffCollection::AddDetectorCut(PamCut &cut) {
19 _detCollection.AddCut(cut);
20 }
21
22 void EffCollection::AddSelectionCut(PamCut &cut) {
23 _selCollection.AddCut(cut);
24 }
25
26 void EffCollection::AddDetectorAction(CollectionAction &action) {
27 _detCollection.AddAction(action);
28 }
29
30 void EffCollection::AddSelectionAction(CollectionAction &action) {
31 _selCollection.AddAction(action);
32 }
33
34 int EffCollection::ApplyCut(PamLevel2 *event) {
35
36 _nEv++;
37 if (_selCollection.ApplyCut(event) == CUTOK) {
38 _sel++;
39 if (_detCollection.ApplyCut(event) == CUTOK) {
40 _det++;
41 _nGood++;
42 return CUTOK;
43 }
44 }
45
46 return 0;
47 }
48
49 void EffCollection::Finalize() {
50 // Let's add all the cuts to the vector of the collection before calling VerboseCollection::Finalize
51 for (unsigned int i = 0; i < _selCollection.GetSize(); i++)
52 _cuts.push_back(_selCollection.GetCut(i));
53 for (unsigned int i = 0; i < _detCollection.GetSize(); i++)
54 _cuts.push_back(_detCollection.GetCut(i));
55 // Now all the cuts are in place, and VerboseCollection can print its report
56 VerboseCollection::Finalize();
57
58 // Add some info about efficiency
59 float eff;
60 if (_sel != 0.)
61 eff = (float)_det / (float)_sel;
62 else
63 eff = 0.;
64 cout << " ****** Efficiency informations ******\n";
65 cout << " Detector cuts:\n";
66 for (unsigned int i = 0; i < _detCollection.GetSize(); i++)
67 cout << " - " << _detCollection.GetCut(i)->GetName() << "\n";
68 cout << " Total detector efficiency: " << eff << endl;
69
70 // Write the output file
71 if (_outFileBase != "") {
72 ofstream outTextFile((_outFileBase + "-eff.txt").Data(), ios_base::out);
73 outTextFile << _det << " " << _sel << " " << eff << endl;
74 outTextFile.close();
75 }
76
77 }

  ViewVC Help
Powered by ViewVC 1.1.23