GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TXXXProc.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "TXXXProc.h"
15
16#include "TH1.h"
17#include "TH2.h"
18#include "TTimeStamp.h"
19#include "TMath.h"
20
21#include "TGo4Log.h"
22#include "TGo4MbsEvent.h"
23#include "TGo4WinCond.h"
24#include "TGo4PolyCond.h"
25#include "TGo4Picture.h"
26
27#include "TXXXParam.h"
28
29//***********************************************************
31{
32}
33
34//***********************************************************
36{
37 TGo4Log::Info("TXXXProc: Delete instance");
38}
39
40//***********************************************************
41// this one is used in standard factory
42TXXXProc::TXXXProc(const char *name) : TGo4EventProcessor(name)
43{
44 TGo4Log::Info("TXXXProc: Create instance");
45
46 fParam = (TXXXParam*) MakeParameter("Par1", "TXXXParam");
47
48 for (int i = 0; i < 8; i++) {
49 TString hname = TString::Format("Crate1/Cr1Ch%02d", i + 1);
50 TString htitle = TString::Format("Crate 1 channel %2d", i+1);
51 fCr1Ch[i] = MakeTH1('I', hname.Data(), htitle.Data(), 5000, 1., 5001.);
52 hname = TString::Format("Crate2/Cr2Ch%02d",i+1);
53 htitle = TString::Format("Crate 2 channel %2d",i+1);
54 fCr2Ch[i] = MakeTH1('I', hname.Data(), htitle.Data(), 5000, 1., 5001.);
55 }
56
57 fCr1Ch1x2 = MakeTH2('I', "Cr1Ch1x2","Crate 1 channel 1x2", 200, 1., 5001., 200, 1., 5001.);
58 fHis1 = MakeTH1('I', "His1","Condition histogram", 5000, 1., 5001.);
59 fHis2 = MakeTH1('I', "His2","Condition histogram", 5000, 1., 5001.);
60 fHis1gate = MakeTH1('I', "His1g","Gated histogram", 5000, 1., 5001.);
61 fHis2gate = MakeTH1('I', "His2g","Gated histogram", 5000, 1., 5001.);
62 fHis3 = MakeTH1('I', "His3","Singular histogram", 20000, 0.999, 1.001);
63 fHis3Counter = 0;
64
65 fconHis1 = MakeWinCond("cHis1", 100,2000, "His1");
66 fconHis2 = MakeWinCond("cHis2", 100,2000, "His2");
67
68 Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
69 fPolyCon = MakePolyCond("polycon", 3, cutpnts);
70
71 fcondSet = GetPicture("condSet");
72 if (!fcondSet) {
73 // in the upper two pads, the condition limits can be set,
74 // in the lower two pads, the resulting histograms are shown
75 fcondSet = new TGo4Picture("condSet","Set conditions");
76 fcondSet->SetDivision(2,2);
77 fcondSet->Pic(0,0)->AddObject(fHis1);
78 fcondSet->Pic(0,1)->AddObject(fHis2);
79 fcondSet->Pic(0,0)->AddCondition(fconHis1);
80 fcondSet->Pic(0,1)->AddCondition(fconHis2);
81 fcondSet->Pic(1,0)->AddObject(fHis1gate);
82 fcondSet->Pic(1,1)->AddObject(fHis2gate);
83
84 fcondSet->Pic(1,0)->SetFillAtt(4, 1001); // solid
85 fcondSet->Pic(1,0)->SetLineAtt(4,1,1);
86 fcondSet->Pic(1,1)->SetFillAtt(9, 1001); // solid
87 fcondSet->Pic(1,1)->SetLineAtt(9,1,1);
88 AddPicture(fcondSet);
89 }
90
91/*
92 // this is example of creating canvas, which can be observed in the gui" << std::endl;
93 TCanvas *mycan = new TCanvas("TestCanvas","Does this work?", 3);
94 std::cout << "Did Creating canvas " << std::endl;
95 mycan->Divide(2,2);
96 mycan->cd(1);
97 fHis1->Draw();
98 mycan->cd(2);
99 fHis2->Draw();
100 AddCanvas(mycan);
101
102*/
103}
104
105//-----------------------------------------------------------
106// event function
108{ // called by framework. We dont fill any output event here at all
109
110 if (!GetInputEvent() || (GetInputEvent()->IsA() != TGo4MbsEvent::Class())) {
111 std::cout << "TXXXProc: no input MBS event found!" << std::endl;
112 return kFALSE;
113 }
114
115 auto evnt = static_cast<TGo4MbsEvent *>(GetInputEvent());
116
117 if(evnt->GetTrigger() > 11) {
118 std::cout << "**** TXXXProc: Skip trigger event" << std::endl;
119 return kFALSE;
120 }
121 // first we fill the arrays fCrate1,2 with data from MBS source
122 // we have up to two subevents, crate 1 and 2
123 // Note that one has to loop over all subevents and select them by
124 // crate number: psubevt->GetSubcrate(),
125 // procid: psubevt->GetProcid(),
126 // and/or control: psubevt->GetControl()
127 // here we use only crate number
128
129 Float_t Crate1[8];
130 Float_t Crate2[8];
131 for(Int_t i = 0; i<8; i++) {
132 Crate1[i] = 0.;
133 Crate2[i] = 0.;
134 }
135
136 // uncomment this lines to update histogram on the gui periodically without activating monitoring
137 // static int cnt = 0;
138 // if ((cnt++ % 100000) == 0) SendObjectToGUI(fHis1);
139
140 evnt->ResetIterator();
141 while(auto psubevt = evnt->NextSubEvent()) { // loop over subevents
142 Int_t * pdata = psubevt->GetDataField();
143 Int_t lwords = psubevt->GetIntLen();
144 if(lwords > 8) lwords = 8; // take only first 8 lwords
145
146 if(psubevt->GetSubcrate() == 1)
147 for(Int_t i = 0; i<lwords; i++)
148 Crate1[i] = (Float_t)*pdata++;
149
150 if(psubevt->GetSubcrate() == 2)
151 for(Int_t i = 0; i<lwords; i++)
152 Crate2[i] = (Float_t)*pdata++;
153 }
154
155 // now we fill histograms from the arrays
156 if (fParam->fillRaw)
157 for(Int_t i = 0; i<8; i++) {
158 fCr1Ch[i]->Fill(Crate1[i]);
159 fCr2Ch[i]->Fill(Crate2[i]);
160 }
161 Float_t value1 = Crate1[0];
162 Float_t value2 = Crate1[1];
163 fHis1->Fill(value1); // fill histograms without gate
164 fHis2->Fill(value2);
165 if(fconHis1->Test(value1))fHis1gate->Fill(value1); //fill histograms with gate
166 if(fconHis2->Test(value2))fHis2gate->Fill(value2);
167 if(fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
168 if (fHis3Counter == 0) {
169 TTimeStamp tm;
170 tm.Set();
171 fHis3->Reset();
172 fHis3->Fill(1 + 0.0005*TMath::Cos(tm.AsDouble()/100));
173 }
174 fHis3Counter = (fHis3Counter+1) % 10000;
175 return kTRUE;
176}
The abstract base class for the data elements of which the unpacked events (or detector structure dat...
Abstract event processor.
TGo4EventElement * GetInputEvent()
Access to external raw event which is set as association member.
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
Definition TGo4Log.cxx:294
Picture cconfiguration in Go4.
Definition TGo4Picture.h:40
TH1 * fCr1Ch[8]
Definition TXXXProc.h:32
Long_t fHis3Counter
Definition TXXXProc.h:38
TH1 * fHis2
Definition TXXXProc.h:37
TGo4WinCond * fconHis1
Definition TXXXProc.h:39
TH1 * fHis3
Definition TXXXProc.h:45
Bool_t BuildEvent(TGo4EventElement *target) override
Fill the destination event dest.
Definition TXXXProc.cxx:163
virtual ~TXXXProc()
Definition TXXXProc.cxx:39
TH1 * fHis2gate
Definition TXXXProc.h:38
TGo4PolyCond * fPolyCon
Definition TXXXProc.h:41
TH2 * fCr1Ch1x2
Definition TXXXProc.h:34
TH1 * fCr2Ch[8]
Definition TXXXProc.h:33
TH1 * fHis1gate
Definition TXXXProc.h:36
TH1 * fHis1
Definition TXXXProc.h:35
TGo4WinCond * fconHis2
Definition TXXXProc.h:40
TXXXParam * fParam
Definition TXXXProc.h:42