Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaEvt125Handler.cxx
Go to the documentation of this file.
1
2//
3// THaEvt125Handler
4// author Robert Michaels (rom@jlab.org), Jan 2017
5//
6// Example of an Event Type Handler for event type 125,
7// the hall C prestart event.
8//
9// It was tested on some hms data. However, note that I don't know what
10// these data mean yet and I presume the data structure is under development;
11// someone will need to modify this class (and the comments).
12//
13// To use as a plugin with your own modifications, you can do this in
14// your analysis script
15//
16// gHaEvtHandlers->Add (new THaEvt125Handler("hallcpre","for evtype 125"));
17//
18// Global variables are defined in Init. You can see them in Podd, as
19// analyzer [2] gHaVars->Print()
20//
21// OBJ: THaVar HCvar1 Hall C event type 125 variable 1
22// OBJ: THaVar HCvar2 Hall C event type 125 variable 2
23// OBJ: THaVar HCvar3 Hall C event type 125 variable 3
24// OBJ: THaVar HCvar4 Hall C event type 125 variable 4
25//
26// The data can be added to the ROOT Tree "T" using the output
27// definition file. Then you can see them, for example as follows
28//
29// T->Scan("HCvar1:HCvar2:HCvar3:HCvar4")
30//
32
33#include "THaEvt125Handler.h"
34#include "THaEvData.h"
35#include "THaVarList.h"
36#include <cstring>
37#include <cstdio>
38#include <iostream>
39
40using namespace std;
41
42THaEvt125Handler::THaEvt125Handler(const char *name, const char* description)
43 : THaEvtTypeHandler(name,description), NVars(0), dvars(nullptr)
44{
45}
46
47Float_t THaEvt125Handler::GetData(const std::string& tag)
48{
49 // A public method which other classes may use
50 if (theDataMap.find(tag) == theDataMap.end())
51 return 0;
52 return theDataMap[tag];
53}
54
55
57{
58
59 const UInt_t startidx = 3;
60
61 if ( !IsMyEvent(evdata->GetEvType()) ) return -1;
62
63 if (fDebug) cout << "------------------\n Event type 125 \n\n" << endl;
64
65 for (UInt_t i = 0; i < evdata->GetEvLength(); i++) {
66
67 if (fDebug) cout << "data[" << dec << i
68 << "] = 0x" << hex << evdata->GetRawData(i)
69 << " = decimal " << dec << evdata->GetRawData(i) << endl;
70
71// This is a fake example of how to decode. Modify it as you wish,
72// and then change these comments.
73// The data in "dvars" appears as global variables.
74
75 if (i >= startidx) {
76 UInt_t index = i-startidx;
77 if (index < NVars) dvars[index] = evdata->GetRawData(i);
78 }
79
80 }
81
82 return 1;
83}
84
85
87{
88
89 cout << "Howdy ! We are initializing THaEvt125Handler !! name = "<<fName<<endl;
90
91 AddEvtType(125); // what events to look for
92
93// dvars is a member of this class.
94// The index of the dvars array track the array of global variables created.
95// This is just a fake example with 4 variables.
96// Please change these comments when you modify this class.
97
98 NVars = 4;
99 dvars = new Double_t[NVars];
100 memset(dvars, 0, NVars*sizeof(Double_t));
101 if (gHaVars) {
102 cout << "EvtHandler:: Have gHaVars. Good thing. "<<gHaVars<<endl;
103 } else {
104 cout << "EvtHandler:: No gHaVars ?! Well, that is a problem !!"<<endl;
105 return kInitError;
106 }
107 const Int_t* count = nullptr;
108 const int LEN = 80;
109 char cname[LEN];
110 char cdescription[LEN];
111 for (UInt_t i = 0; i < NVars; i++) {
112 snprintf(cname, LEN, "HCvar%d", i+1);
113 snprintf(cdescription, LEN, "Hall C event type 125 variable %d", i+1);
114 gHaVars->DefineByType(cname, cdescription, &dvars[i], kDouble, count);
115 }
116
117
118 fStatus = kOK;
119 return kOK;
120}
121
int Int_t
unsigned int UInt_t
float Float_t
double Double_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
char name[80]
R__EXTERN class THaVarList * gHaVars
Definition THaGlobals.h:11
#define snprintf
UInt_t GetEvType() const
Definition THaEvData.h:53
UInt_t GetRawData(UInt_t crate, UInt_t slot, UInt_t hit) const
Definition THaEvData.h:288
UInt_t GetEvLength() const
Definition THaEvData.h:54
virtual Int_t Analyze(THaEvData *evdata)
THaEvt125Handler(const char *name, const char *description)
Float_t GetData(const std::string &tag)
std::map< std::string, Float_t > theDataMap
virtual void AddEvtType(UInt_t evtype)
virtual Bool_t IsMyEvent(UInt_t type) const
virtual THaVar * DefineByType(const char *name, const char *desc, const void *loc, VarType type, const Int_t *count, const char *errloc="DefineByType")
TString fName
STL namespace.
ClassImp(TPyArg)