Line data Source code
1 : //
2 : // MIDAS analyzer example 1: pure C++ analyzer
3 : //
4 : // K.Olchanski
5 : //
6 :
7 : #include <stdio.h>
8 :
9 : #include "manalyzer.h"
10 : #include "midasio.h"
11 :
12 : class ExampleCxx: public TARunObject
13 : {
14 : public:
15 0 : ExampleCxx(TARunInfo* runinfo)
16 0 : : TARunObject(runinfo)
17 : {
18 0 : printf("ExampleCxx::ctor, run %d, file %s\n", runinfo->fRunNo, runinfo->fFileName.c_str());
19 0 : fRunEventCounter = 0;
20 0 : fModuleName = "ExampleCxx";
21 0 : fModuleOrder = 0;
22 0 : }
23 :
24 0 : ~ExampleCxx()
25 0 : {
26 0 : printf("ExampleCxx::dtor!\n");
27 0 : }
28 :
29 0 : void BeginRun(TARunInfo* runinfo)
30 : {
31 0 : printf("ExampleCxx::BeginRun, run %d, file %s\n", runinfo->fRunNo, runinfo->fFileName.c_str());
32 0 : fRunEventCounter = 0;
33 0 : }
34 :
35 0 : void EndRun(TARunInfo* runinfo)
36 : {
37 0 : printf("ExampleCxx::EndRun, run %d\n", runinfo->fRunNo);
38 0 : printf("Counted %d events in run %d\n", fRunEventCounter, runinfo->fRunNo);
39 0 : }
40 :
41 0 : void NextSubrun(TARunInfo* runinfo)
42 : {
43 0 : printf("ExampleCxx::NextSubrun, run %d, file %s\n", runinfo->fRunNo, runinfo->fFileName.c_str());
44 0 : }
45 :
46 0 : void PauseRun(TARunInfo* runinfo)
47 : {
48 0 : printf("ExampleCxx::PauseRun, run %d\n", runinfo->fRunNo);
49 0 : }
50 :
51 0 : void ResumeRun(TARunInfo* runinfo)
52 : {
53 0 : printf("ExampleCxx::ResumeRun, run %d\n", runinfo->fRunNo);
54 0 : }
55 :
56 0 : TAFlowEvent* Analyze(TARunInfo* runinfo, TMEvent* event, TAFlags* flags, TAFlowEvent* flow)
57 : {
58 0 : printf("ExampleCxx::Analyze, run %d, event serno %d, id 0x%04x, data size %d\n", runinfo->fRunNo, event->serial_number, (int)event->event_id, event->data_size);
59 : //event->old_event.SetBankList();
60 : //event->old_event.Print();
61 :
62 0 : fRunEventCounter++;
63 :
64 0 : return flow;
65 : }
66 :
67 0 : void AnalyzeSpecialEvent(TARunInfo* runinfo, TMEvent* event)
68 : {
69 0 : printf("ExampleCxx::AnalyzeSpecialEvent, run %d, event serno %d, id 0x%04x, data size %d\n", runinfo->fRunNo, event->serial_number, (int)event->event_id, event->data_size);
70 0 : }
71 :
72 : int fRunEventCounter = 0;
73 : };
74 :
75 : class ExampleCxxFactory: public TAFactory
76 : {
77 : public:
78 0 : void Usage()
79 : {
80 0 : printf("\tExample TAFactory Usage!\n");
81 0 : printf("\tPrint valid arguements for this modules here!");
82 0 : }
83 :
84 0 : void Init(const std::vector<std::string> &args)
85 : {
86 0 : printf("ExampleCxxFactory::Init!\n");
87 0 : printf("Arguments:\n");
88 0 : for (unsigned i=0; i<args.size(); i++)
89 0 : printf("arg[%d]: [%s]\n", i, args[i].c_str());
90 0 : }
91 :
92 0 : void Finish()
93 : {
94 0 : printf("ExampleCxxFactory::Finish!\n");
95 0 : }
96 :
97 0 : TARunObject* NewRunObject(TARunInfo* runinfo)
98 : {
99 0 : printf("ExampleCxxFactory::NewRunObject, run %d, file %s\n", runinfo->fRunNo, runinfo->fFileName.c_str());
100 0 : return new ExampleCxx(runinfo);
101 : }
102 : };
103 :
104 : static TARegister tar(new ExampleCxxFactory);
105 :
106 : /* emacs
107 : * Local Variables:
108 : * tab-width: 8
109 : * c-basic-offset: 3
110 : * indent-tabs-mode: nil
111 : * End:
112 : */
|