StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarFilterMaker.cxx
1 #include "StarFilterMaker.h"
2 ClassImp(StarFilterMaker);
3 
4 #include "g2t/St_g2t_particle_Module.h"
5 #include "tables/St_g2t_event_Table.h"
6 #include "tables/St_g2t_gepart_Table.h"
7 #include "tables/St_g2t_vertex_Table.h"
8 #include "tables/St_g2t_event_Table.h"
9 
10 #include "StarCallf77.h"
11 #include <iostream>
12 #include "St_geant_Maker/St_geant_Maker.h"
13 #include "TGiant3.h"
14 #include <map>
15 #include "TString.h"
16 #include "TSystem.h"
17 
18 #include "StBFChain.h"
19 #include "TFile.h"
20 #include "TTree.h"
21 #include "TClass.h"
22 
23 
24 #include "StarGenerator/EVENT/StarGenEvent.h"
25 #include "StarGenerator/EVENT/StarGenParticle.h"
26 #include "StarGenerator/BASE/StarPrimaryMaker.h"
27 #include "StarGenerator/UTIL/StarRandom.h"
28 
29 #include "TMCProcess.h"
30 
31 using namespace std;
32 
33 // --------------------------------------------------------------------------------------------------------------
34 StarFilterMaker::StarFilterMaker( const Char_t *name ) :
35  StMaker(name),
36  NumberofEvents(0),
37  AcceptedEvents(0),
38  RejectedEvents(0),
39  RejectedSinceLast(0),
40  mEvent(0),
41  bFlag(false)
42 {
43 }
44 // --------------------------------------------------------------------------------------------------------------
45 Int_t StarFilterMaker::Init()
46 {
47 
48  return kStOK;
49 
50 }
51 // --------------------------------------------------------------------------------------------------------------
52 void StarFilterMaker::Clear( const Option_t *opts )
53 {
54 
55  StMaker::Clear(opts);
56 }
57 // --------------------------------------------------------------------------------------------------------------
59 {
60  // No need to save the tree because the event generator will take care of that, but we should dump statistics here
61  // Dump stats to file and screen
62 
63  LOG_INFO << Form("Number of events seen: %i", NumberofEvents ) << endm;
64  LOG_INFO << Form("Number of events accepted: %i", AcceptedEvents ) << endm;
65  LOG_INFO << Form("Number of rejected events: %i", RejectedEvents ) << endm;
66  LOG_INFO << Form("Rejection power: %8.3g", double(RejectedEvents)/double(NumberofEvents) ) << endm;
67  LOG_INFO << Form("Acceptance: %8.3g", double(1.0)-double(RejectedEvents)/double(NumberofEvents) ) << endm;
68 
69  return StMaker::Finish();
70 }
71 // --------------------------------------------------------------------------------------------------------------
73 {
74 
75  // Increment total number of events seen
76  NumberofEvents++;
77 
78  // Obtain the result from the filter
79  UInt_t result = (UInt_t)Filter( mEvent );
80 
81  // Set the result on the event
82  mEvent -> SetFilterResult( result );
83 
84  // If the event was rejected, increment the rejected event counters
85  if( result & StarGenEvent::kReject )
86  {
87  RejectedEvents++;
88  RejectedSinceLast++;
89  }
90  // Otherwise, inrement accepted events and reset the rejected since last counter
91  else if ( result & StarGenEvent::kAccept )
92  {
93  AcceptedEvents++;
94  RejectedSinceLast = 0;
95  }
96  else
97  { // huh?
98  assert(0);
99  }
100 
101  return kStOk;
102 
103 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StMaker.cxx:634
virtual Int_t Filter(StarGenEvent *event=0)=0
Main filter class. Goes anywhere in the chain, filters StarGenEvent objects.
Definition: Stypes.h:40
virtual Int_t Finish()
Definition: StMaker.cxx:776
Definition: Stypes.h:41