cd PgmCM2/ cd BetaMiniUser/ vi LisEvt.cc
1 //--------------------------------------------------------------------------
2 // Programming with babar CM2
3 // LisEvt.cc
4 //
5 // Description:
6 // Class LisEvt
7 //
8 // This is an analysis module class used to
9 // create an Excel csv file with events data
10 // using CM2.
11 //
12 //------------------------------------------------------------------------
13 #include "BaBar/BaBar.hh"
14 //-----------------------
15 // This Class's Header --
16 //-----------------------
17 #include "BetaMiniUser/LisEvt.hh"
18
19 //-------------
20 // C Headers --
21 //-------------
22 #include <assert.h>
23
24 //---------------
25 // C++ Headers --
26 //---------------
27 #include <iostream.h>
28 #include <math.h>
29
30 //-------------------------------
31 // Collaborating Class Headers --
32 //-------------------------------
33 #include "CLHEP/Alist/ConstAList.h"
34 #include "AbsEvent/AbsEvent.hh"
35 #include "AbsEvent/getTmpAList.hh"
36 #include "AbsEnv/AbsEnv.hh"
37 #include "GenEnv/GenEnv.hh"
38
39 #include "ProxyDict/IfdStrKey.hh"
40 #include "ProxyDict/IfdKey.hh"
41
42 #include "Beta/BtaCandidate.hh"
43 #include "BetaMicroAdapter/BtaCalQual.hh"
44 #include "HepTuple/TupleManager.h"
45 #include "HepTuple/Histogram.h"
46 //-----------------------------------------------------------------------
47 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
48 //-----------------------------------------------------------------------
49
50 static const char rcsid[] = "$Id: WorkBook1.cc,v 1.1 1998/07/08 23:26:29 young Exp $";
51 static int conevt;
52
53 //----------------
54 // Constructors --
55 //----------------
56
57 // in general, a module constructor should not do much. The begin(job) or
58 // begin(run) members are better places to put initialization
59 LisEvt::LisEvt( const char* const theName,
60 const char* const theDescription )
61 : AppModule( theName, theDescription )
62 , _btaChargedList("trackCandidates", this, "ChargedTracks")
63 {
64 }
65
66 //--------------
67 // Destructor --
68 //--------------
69
70 // The destructor should be limited to undoing the work of the constructor
71 LisEvt::~LisEvt( )
72 {
73 }
74
75
76 //--------------
77 // Operations --
78 //--------------
79
80 // The begin(AppJob*) member function is run before any events are
81 // processed. In this example code, it opens the output histogram file
82 // and then books a histogram.
83 AppResult
84 LisEvt::beginJob( AbsEvent* anEvent )
85 {
86 cout<< name() << ": Begin job" << endl;
87 conevt=0;
88 HepTupleManager* manager = gblEnv->getGen()->ntupleManager();
89 assert(manager != 0);
90
91 // book the momentum distribution histogram
92
93 return AppResult::OK;
94 }
95
96 // end(AppJob*) function is called after all events have been processed.
97 AppResult
98 LisEvt::endJob( AbsEvent* anEvent )
99 {
100 cout << name() << ": End job" << endl;
101 return AppResult::OK;
102 }
103
104
105 // event function is called once per event
106 AppResult LisEvt::event( AbsEvent* anEvent )
107 {
108 int contrk;
109
110 conevt++;
111 if (_verbose.value()) {
112 cout << name() << ": Event" << endl;
113 }
114
115 // get list of input track candidates
116 HepAList<BtaCandidate>* trkList;
117 getTmpAList (anEvent, trkList, _btaChargedList.value() );
118
119 // Loop over track candidates to plot momentum
120 HepAListIterator<BtaCandidate> iterTrk(*trkList);
121 BtaCandidate* trk;
122 contrk=0;
123 while ( 0 != ( trk = iterTrk()) ) {
124 const BtaCalQual* CalQual = trk->getMicroAdapter()->getCalQual();
125 cout << conevt << ", " << contrk << ", " <<
126 trk->p4().x() << ", " << trk->p4().y() << ", " << trk->p4().z() <<
127 ", " << sqrt(trk->p4().x()*trk->p4().x()+trk->p4().y()*trk->p4().y()+
128 trk->p4().z()*trk->p4().z()) << ", " << trk->energy() << ", " <<
129 trk->charge() << ", ";
130 if(CalQual!=0) {
131 cout << CalQual->ecalEnergy();
132 }
133 cout << endl;
134 contrk++;
135 }
136
137 // done
138 return AppResult::OK;
139 }
vi LisEvt.hh
1 //--------------------------------------------------------------------------
2 // Programming in Babar CM2
3 // LisEvt.hh
4 //
5 // Description:
6 // Class LisEvt
7 // This is an analysis module class used as the
8 // create an Excel csv file with events data
9 // using CM2.
10 //
11 //------------------------------------------------------------------------
12
13 #ifndef LisEvt_HH
14 #define LisEvt_HH
15
16
17 //----------------------
18 // Base Class Headers --
19 //----------------------
20 #include "Framework/APPModule.hh"
21 #include "AbsParm/AbsParmIfdStrKey.hh"
22
23 //------------------------------------
24 // Collaborating Class Declarations --
25 //------------------------------------
26
27 //---------------------
28 //-- Class Interface --
29 //---------------------
30
31 class LisEvt : public AppModule {
32
33 //--------------------
34 // Instance Members --
35 //--------------------
36
37 public:
38
39 // Constructors
40 LisEvt( const char* const theName, const char* const theDescription );
41
42 // Destructor
43 virtual ~LisEvt( );
44
45 // Operations
46
47 virtual AppResult beginJob ( AbsEvent* anEvent );
48 virtual AppResult event ( AbsEvent* anEvent );
49 virtual AppResult endJob ( AbsEvent* anEvent );
50
51 protected:
52
53
54
55 private:
56
57 AbsParmIfdStrKey _btaChargedList;
58
59 };
60
61 #endif
vi LisEvt.tcl
1 #------------------------------------------------------------------------------
2 # MomEnH.tcl
3 #------------------------------------------------------------------------------
4 # always source the error logger early in your main tcl script
5 sourceFoundFile ErrLogger/ErrLog.tcl
6 sourceFoundFile FrameScripts/FwkCfgVar.tcl
7 sourceFoundFile FrameScripts/talkto.tcl
8 # Disable the use of envvars
9 set ProdTclOnly true
10
11 # set the error logging level to 'warning'. If you encounter a configuration
12 # error you can get more information using 'trace'
13 ErrLoggingLevel warning
14
15 #
16 # Turn off some specialty items
17 #
18 module disable NTrk
19 module disable MomEnH
20 module disable PEntp
21 module disable colPEntp
22 module disable EnPBip
23
24 ## allowed values of BetaMiniReadPersistence are (currently) "Kan", "Bdb"
25 ##
26 set BetaMiniReadPersistence Kan
27
28 ## allowed (non-expert) values of levelOfDetail are "micro", "cache", "extend"
29 ## or "refit"
30 ##
31 FwkCfgVar levelOfDetail "cache"
32
33 ## allowed values of ConfigPatch are "Run1", "Run2" or "MC". This MUST be set
34 ## consistent ## with your input data type or you will get INCONSISTENT OR
35 ## INCORRECT RESULTS
36 ##
37 FwkCfgVar ConfigPatch "Run3"
38
39 ##
40 ## You can enter input collections two ways: either append them to a list, or
41 ## explicitly enter them in the input module. Do one or the other, BUT NOT
42 ## BOTH.
43 ## If inputList is set before executing btaMini.tcl, that will automatically
44 ## add the collections to the appropriate input module, otherwise make sure you
45 ## talk to the right one.
46 ##
47 ## lappend inputList collection1 collection2 ...
48 ##
49 ## OR THE FOLLOWING (choose the correct one based on persistence)
50 ##
51 ## talkto BdbEventInput {
52 ## talkto KanEventInput {
53 ## input add collection1
54 ## input add collection2
55 ## ...
56 ## }
57
58
59 ##
60 ## Set the number of events to run. If this isn't set, all events in the
61 ## input collections will be processed.
62 ##
63 FwkCfgVar NEvent
64
65 ## choose the flavor of ntuple to write (hbook or root) and the file name
66 ##
67 FwkCfgVar BetaMiniTuple "root"
68 FwkCfgVar histFileName "enphist.roo"
69
70 ## create Everything path and add core sequences to it. btaMiniPhysics is the
71 ## same as btaMini, just appending a few standard list generating modules. For
72 ## reading data with stored composites, you may have a conflict running
73 ## btaMiniPhyscs.tcl
74 ##
75 ## You can also run (most of) the PhysProdSequence, complete with its 3 gamma
76 ## conversion finders, etc. Consider disabling the portion of this sequence
77 ## that you do not need to save yourself some time. The BetaLumiSequence
78 ## and TagProd sequences are left off, as they otherwise cause problems.
79 ##
80 sourceFoundFile BetaMiniUser/btaMini.tcl
81 #sourceFoundFile BetaMiniUser/btaMiniPhysics.tcl
82 #sourceFoundFile BetaMiniUser/btaMiniPhysProdSequence.tcl
83 ## Add Analysis module
84 ##
85 path append Everything LisEvt
86
87 ##
88 ## If your job has a tag-level filter, here is how you should run it
89 ## so as to avoid wasting time reading the mini when the tag filter fails
90 ## Here's a simple example that restricts to just multi-hadron events
91 ## on Kan input
92
93 module clone TagFilterByName TagBGFMultiHadron
94 module talk TagBGFMultiHadron
95 andList set BGFMultiHadron
96 assertIfMissing set true
97 exit
98
99 module talk EvtCounter
100 printFreq set 100000
101 exit
102
103 #sequence append BetaMiniReadSequence -a KanEventUpdateTag TagBGFMultiHadron
104
105 path list
106 if [info exists NEvent] {
107 ev begin -nev $NEvent
108 } else {
109 ev begin
110 }
111
112 ErrMsg trace "completed OK"
113 exit
The next step consists of writing the main application module and compiling and linking all of the modules.
cd ../workdir/ vi LisEvtJob.tcl
set ConfigPatch Run2 set levelOfDetail cache set BetaMiniTuple hbook set histFileName biparhist.hbk set NEvent 10 source Tau1NDataset.tcl sourceFoundFile BetaMiniUser/LisEvt.tcl
. ./fullboot.sh BetaMiniApp LisEvtJob.tcl
cd ../../SDSoft/workdir/ ls /nfs/work/store -l
drwxr-xr-x 3 root root 4096 Sep 27 23:57 PRskims drwxr-xr-x 4 root root 4096 Sep 28 01:44 SPskims
ls /home/jamwer/SDSoft/workdir/simula.*.root
/home/jamwer/SDSoft/workdir/simula.01.root /home/jamwer/SDSoft/workdir/simula.02E.root
scp /home/jamwer/SDSoft/workdir/simula.*.root root@cap.hep.man.ac.uk:/work/store/SPskims
simula.01.root 100% |*****************************| 7395 KB 00:00 simula.02E.root 100% |*****************************| 7508 KB 00:00
cd ../BetaMiniUser vi SimulaListEvt.tcl
1 #------------------------------------------------------------------------------
2 # MomEnH.tcl
3 #------------------------------------------------------------------------------
4 # always source the error logger early in your main tcl script
5 sourceFoundFile ErrLogger/ErrLog.tcl
6 sourceFoundFile FrameScripts/FwkCfgVar.tcl
7 sourceFoundFile FrameScripts/talkto.tcl
8 # Disable the use of envvars
9 set ProdTclOnly true
10
11 # set the error logging level to 'warning'. If you encounter a configuration
12 # error you can get more information using 'trace'
13 ErrLoggingLevel warning
14
15 #
16 # Turn off some specialty items
17 #
18 module disable NTrk
19 module disable MomEnH
20 module disable PEntp
21 module disable colPEntp
22 module disable EnPBip
23 module disable LisEvt
24 module disable recoevt
25 module disable verMCTruth
26
27 ## allowed values of BetaMiniReadPersistence are (currently) "Kan", "Bdb"
28 ##
29 set BetaMiniReadPersistence Kan
30
31 ## allowed (non-expert) values of levelOfDetail are "micro", "cache", "extend"
32 ## or "refit"
33 ##
34 FwkCfgVar levelOfDetail "cache"
35
36 ## allowed values of ConfigPatch are "Run1", "Run2" or "MC". This MUST be set
37 ## consistent ## with your input data type or you will get INCONSISTENT OR
38 ## INCORRECT RESULTS
39 ##
40 FwkCfgVar ConfigPatch "MC"
41
42 ##
43 ## You can enter input collections two ways: either append them to a list, or
44 ## explicitly enter them in the input module. Do one or the other, BUT NOT
45 ## BOTH.
46 ## If inputList is set before executing btaMini.tcl, that will automatically
47 ## add the collections to the appropriate input module, otherwise make sure you
48 ## talk to the right one.
49 ##
50 ## lappend inputList collection1 collection2 ...
51 ##
52 ## OR THE FOLLOWING (choose the correct one based on persistence)
53 ##
54 ## talkto BdbEventInput {
55 ## talkto KanEventInput {
56 ## input add collection1
57 ## input add collection2
58 ## ...
59 ## }
60
61
62 ##
63 ## Set the number of events to run. If this isn't set, all events in the
64 ## input collections will be processed.
65 ##
66 FwkCfgVar NEvent
67
68 ## choose the flavor of ntuple to write (hbook or root) and the file name
69 ##
70 FwkCfgVar BetaMiniTuple "root"
71 FwkCfgVar histFileName "enphist.roo"
72
73 ## create Everything path and add core sequences to it. btaMiniPhysics is the
74 ## same as btaMini, just appending a few standard list generating modules. For
75 ## reading data with stored composites, you may have a conflict running
76 ## btaMiniPhyscs.tcl
77 ##
78 ## You can also run (most of) the PhysProdSequence, complete with its 3 gamma
79 ## conversion finders, etc. Consider disabling the portion of this sequence
80 ## that you do not need to save yourself some time. The BetaLumiSequence
81 ## and TagProd sequences are left off, as they otherwise cause problems.
82 ##
83 sourceFoundFile BetaMiniUser/btaMini.tcl
84 #sourceFoundFile BetaMiniUser/btaMiniPhysics.tcl
85 #sourceFoundFile BetaMiniUser/btaMiniPhysProdSequence.tcl
86 ## Add Analysis module
87 ##
88 path append Everything recodata
89
90 ##
91 ## If your job has a tag-level filter, here is how you should run it
92 ## so as to avoid wasting time reading the mini when the tag filter fails
93 ## Here's a simple example that restricts to just multi-hadron events
94 ## on Kan input
95
96 module clone TagFilterByName TagBGFMultiHadron
97 module talk TagBGFMultiHadron
98 andList set BGFMultiHadron
99 assertIfMissing set true
100 exit
101
102 module talk EvtCounter
103 printFreq set 100000
104 exit
105
106 #sequence append BetaMiniReadSequence -a KanEventUpdateTag TagBGFMultiHadron
107
108 path list
109 if [info exists NEvent] {
110 ev begin -nev $NEvent
111 } else {
112 ev begin
113 }
114
115 ErrMsg trace "completed OK"
116 exit
117
cd ../../PgmCM2/workdir/ vi SimulaData.tcl## This file points to the MC dataset generated by SDSoft/workdir lappend inputList /store/SPskims/simula
vi SimulaJob.tcl
set ConfigPatch MC set levelOfDetail cache set BetaMiniTuple hbook set histFileName comphist.hbk set NEvent 10 source SimulaData.tcl sourceFoundFile BetaMiniUser/SimulaLisEvt.tcl
|
|
|
Feedback to: jamwer@hep.man.ac.uk |