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 "TCutG.h"
19
20#include "TGo4Log.h"
21#include "TGo4WinCond.h"
22#include "TGo4PolyCond.h"
23#include "TGo4CondArray.h"
24#include "TGo4Picture.h"
25#include "TGo4MbsEvent.h"
26
27#include "TXXXEvent.h"
28#include "TXXXControl.h"
29
30//***********************************************************
32{
33 TGo4Log::Info("TXXXProc: Create instance");
34}
35
36//***********************************************************
38{
39 TGo4Log::Info("TXXXProc: Delete instance");
40}
41
42//***********************************************************
43// this one is used in standard factory
44TXXXProc::TXXXProc(const char *name) : TGo4EventProcessor(name)
45{
46 TGo4Log::Info("TXXXProc: Create instance %s", name);
47
49
50 // Parameters are created in analysis, therefore just take it out
51 fControl = (TXXXControl *) GetParameter("Control");
52
53 // This example analysis allows for en-disabling the histogram filling.
54 // Macro histofill.C sets histogram fill status in parameter "Control".
55 // This macro histofill.C, not the auto save file, will set status.
56 ExecuteScript("histofill.C");
57 fControl->Print();
58
59 TGo4Log::Info("TXXXProc: Produce histograms");
60 // Creation of histograms (or take them from autosave)
61 for (int i = 0; i < 8; i++) {
62 TString hname = TString::Format("Crate1/Cr1Ch%02d", i + 1);
63 TString htitle = TString::Format("Crate 1 channel %2d", i+1);
64 fCr1Ch[i] = MakeTH1('I', hname.Data(), htitle.Data(), 5000, 1., 5001.);
65 hname = TString::Format("Crate2/Cr2Ch%02d",i+1);
66 htitle = TString::Format("Crate 2 channel %2d",i+1);
67 fCr2Ch[i] = MakeTH1('I', hname.Data(), htitle.Data(), 5000, 1., 5001.);
68 }
69
70 fCr1Ch1x2 = MakeTH2('I', "Cr1Ch1x2","Crate 1 channel 1x2", 200, 1., 5001., 200, 1., 5001.);
71 fHis1 = MakeTH1('I', "His1","Condition histogram", 5000, 1., 5001.);
72 fHis2 = MakeTH1('I', "His2","Condition histogram", 5000, 1., 5001.);
73 fHis1gate = MakeTH1('I', "His1g","Gated histogram", 5000, 1., 5001.);
74 fHis2gate = MakeTH1('I', "His2g","Gated histogram", 5000, 1., 5001.);
75
76 TGo4Log::Info("TXXXProc: Produce conditions");
77 fconHis1 = MakeWinCond("cHis1", 100, 2000, "His1");
78 fconHis2 = MakeWinCond("cHis2", 100, 2000, "His2");
79
80 Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
81 fPolyCon = MakePolyCond("polycon", 3, cutpnts);
82
83 fConArr = (TGo4CondArray*)GetAnalysisCondition("polyconar");
84 if(!fConArr) {
85 // This is example how to create condition array
86 TGo4Log::Info("TXXXProc: Create condition array");
87 Double_t xvalues[4] = { 1000, 2000, 1500, 1000 };
88 Double_t yvalues[4] = { 1000, 1000, 3000, 1000 };
89 TCutG *mycut = new TCutG("cut2", 4, xvalues, yvalues);
90 fConArr = new TGo4CondArray("polyconar",4,"TGo4PolyCond");
91 fConArr->SetValues(mycut);
92 fConArr->Disable(true); // means: condition check always returns true
93 delete mycut; // mycat has been copied into the conditions
94 AddAnalysisCondition(fConArr);
95 } else {
96 TGo4Log::Info("TXXXProc: Restore condition array from autosave");
97 fConArr->ResetCounts();
98 }
99 // connect histograms to conditions. will be drawn when condition is edited.
100 ((*fConArr)[0])->Enable();
101 ((*fConArr)[1])->Enable(); // 2 and 3 remain disabled
102
103 TGo4Log::Info("TXXXProc: Produce pictures");
104 fcondSet = GetPicture("condSet");
105 if (!fcondSet) {
106 // in the upper two pads, the condition limits can be set,
107 // in the lower two pads, the resulting histograms are shown
108 fcondSet = new TGo4Picture("condSet","Set conditions");
109 fcondSet->SetDivision(2,2);
110 fcondSet->Pic(0,0)->AddObject(fHis1);
111 fcondSet->Pic(0,1)->AddObject(fHis2);
112 fcondSet->Pic(0,0)->AddCondition(fconHis1);
113 fcondSet->Pic(0,1)->AddCondition(fconHis2);
114 fcondSet->Pic(1,0)->AddObject(fHis1gate);
115 fcondSet->Pic(1,1)->AddObject(fHis2gate);
116 fcondSet->Pic(1,0)->SetFillAtt(4, 1001); // solid
117 fcondSet->Pic(1,0)->SetLineAtt(4,1,1);
118 fcondSet->Pic(1,1)->SetFillAtt(9, 1001); // solid
119 fcondSet->Pic(1,1)->SetLineAtt(9,1,1);
120 AddPicture(fcondSet);
121 }
122
123 fPicture = GetPicture("Picture");
124 if (!fPicture) {
125 fPicture = new TGo4Picture("Picture","Picture example");
126 fPicture->SetLinesDivision(3, 2,3,1);
127 fPicture->LPic(0,0)->AddObject(fCr1Ch[0]);
128 fPicture->LPic(0,0)->SetFillAtt(5, 3001); // pattern
129 fPicture->LPic(0,0)->SetLineAtt(5,1,1);
130 fPicture->LPic(0,1)->AddObject(fCr1Ch[1]);
131 fPicture->LPic(0,1)->SetFillAtt(4, 3001); // pattern
132 fPicture->LPic(0,1)->SetLineAtt(4,1,1);
133 fPicture->LPic(1,0)->AddObject(fCr1Ch[2]);
134 fPicture->LPic(1,0)->SetFillAtt(6, 1001); // solid
135 fPicture->LPic(1,0)->SetLineAtt(6,1,1);
136 fPicture->LPic(1,1)->AddObject(fCr1Ch[3]);
137 fPicture->LPic(1,1)->SetFillAtt(7, 1001); // solid
138 fPicture->LPic(1,1)->SetLineAtt(7,1,1);
139 fPicture->LPic(1,2)->AddObject(fCr1Ch[4]);
140 fPicture->LPic(3,0)->AddObject(fCr1Ch1x2);
141 fPicture->LPic(3,0)->SetDrawOption("CONT");
142 AddPicture(fPicture);
143 }
144}
145//-----------------------------------------------------------
146// event function
148{
149 // called by framework from TXXXEvent to fill it
150
151 auto XXXEvent = static_cast<TXXXEvent *>(target);
152 auto source = static_cast<TGo4MbsEvent *>(GetInputEvent());
153
154 if(!source) {
155 TGo4Log::Error("TXXXProc: no input event!");
156 return kFALSE;
157 }
158 if(source->GetTrigger() > 11) {
159 TGo4Log::Info("TXXXProc: Skip trigger event");
160 XXXEvent->SetValid(kFALSE); // not store
161 return kFALSE;
162 }
163 // first we fill the TXXXEvent with data from MBS source
164 // we have up to two subevents, crate 1 and 2
165 // Note that one has to loop over all subevents and select them by
166 // crate number: psubevt->GetSubcrate(),
167 // procid: psubevt->GetProcid(),
168 // and/or control: psubevt->GetControl()
169 // here we use only crate number
170
171 source->ResetIterator();
172 while(auto psubevt = source->NextSubEvent()) { // loop over subevents
173 Int_t *pdata = psubevt->GetDataField();
174 Int_t lwords = psubevt->GetIntLen();
175 if(lwords > 8) lwords=8; // take only first 8 lwords
176
177 if(psubevt->GetSubcrate() == 1) {
178 for(Int_t i = 0; i<lwords; i++) {
179 // Int_t index = *pdata&0xfff; // in case low word is index
180 //Float_t value = (*pdata>>16)&0xfff; // and high word is data
181 Float_t value = (Float_t)*pdata++; // otherwise longword data
182 Int_t index = i; // and index in order
183 XXXEvent->fCrate1[index] = value; // copy to output event
184 }
185 }
186 if(psubevt->GetSubcrate() == 2)
187 for(Int_t i = 0; i<lwords; i++)
188 XXXEvent->fCrate2[i] = (Float_t)*pdata++;
189 }
190
191 // now we fill histograms from XXXEvent
192 if(fControl->fill) {
193 for(Int_t i = 0; i<8; i++) {
194 fCr1Ch[i]->Fill(XXXEvent->fCrate1[i]);
195 fCr2Ch[i]->Fill(XXXEvent->fCrate2[i]);
196 }
197 Float_t value1 = XXXEvent->fCrate1[0];
198 Float_t value2 = XXXEvent->fCrate1[1];
199 fHis1->Fill(value1); //fill histograms without gate
200 fHis2->Fill(value2);
201 if (fconHis1->Test(value1)) fHis1gate->Fill(value1); //fill histograms with gate
202 if (fconHis2->Test(value2)) fHis2gate->Fill(value2);
203 // fill Cr1Ch1x2 for three polygons:
204 if (fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
205 if(((*fConArr)[0])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
206 if(((*fConArr)[1])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
207 }
208 XXXEvent->SetValid(kTRUE); // to store
209 return kTRUE;
210}
Array of conditions.
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
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
Definition TGo4Log.cxx:320
Picture cconfiguration in Go4.
Definition TGo4Picture.h:40
TGo4CondArray * fConArr
Definition TXXXProc.h:42
TH1 * fCr1Ch[8]
Definition TXXXProc.h:32
TXXXControl * fControl
Definition TXXXProc.h:43
TH1 * fHis2
Definition TXXXProc.h:37
TGo4WinCond * fconHis1
Definition TXXXProc.h:39
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