GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TXXXProc.cxx
Go to the documentation of this file.
1 // $Id: TXXXProc.cxx 930 2013-01-24 16:10:10Z linev $
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 f�r 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 "TROOT.h"
19 #include "TCutG.h"
20 
21 #include "TGo4Log.h"
22 #include "TGo4WinCond.h"
23 #include "TGo4PolyCond.h"
24 #include "TGo4CondArray.h"
25 #include "TGo4Picture.h"
26 #include "TGo4MbsEvent.h"
27 
28 #include "TXXXControl.h"
29 #include "TXXXEvent.h"
30 
31 //***********************************************************
33 {
34  TGo4Log::Info("TXXXProc: Create instance");
35 }
36 //***********************************************************
38 {
39  TGo4Log::Info("TXXXProc: Delete instance");
40 }
41 //***********************************************************
42 // this one is used in standard factory
43 TXXXProc::TXXXProc(const char* name) : TGo4EventProcessor(name)
44 {
45  TGo4Log::Info("TXXXProc: Create instance %s", name);
46 
48 
49  // Parameters are created in analysis, therefore just take it out
50  fControl = (TXXXControl *) GetParameter("Control");
51 
52  // This example analysis allows for en-disabling the histogram filling.
53  // Macro histofill.C sets histogram fill status in parameter "Control".
54  // This macro histofill.C, not the auto save file, will set status.
55  ExecuteScript("histofill.C");
57 
58  TGo4Log::Info("TXXXProc: Produce histograms");
59  // Creation of histograms (or take them from autosave)
60  for(int i=0;i<8;i++) {
61  fCr1Ch[i] = MakeTH1('I', Form("Crate1/Cr1Ch%02d",i+1), Form("Crate 1 channel %2d",i+1), 5000, 1., 5001.);
62  fCr2Ch[i] = MakeTH1('I', Form("Crate2/Cr2Ch%02d",i+1), Form("Crate 2 channel %2d",i+1), 5000, 1., 5001.);
63  }
64 
65  fCr1Ch1x2 = MakeTH2('I', "Cr1Ch1x2","Crate 1 channel 1x2", 200, 1., 5001., 200, 1., 5001.);
66  fHis1 = MakeTH1('I', "His1","Condition histogram", 5000, 1., 5001.);
67  fHis2 = MakeTH1('I', "His2","Condition histogram", 5000, 1., 5001.);
68  fHis1gate = MakeTH1('I', "His1g","Gated histogram", 5000, 1., 5001.);
69  fHis2gate = MakeTH1('I', "His2g","Gated histogram", 5000, 1., 5001.);
70 
71  TGo4Log::Info("TXXXProc: Produce conditions");
72  fconHis1 = MakeWinCond("cHis1", 100, 2000, "His1");
73  fconHis2 = MakeWinCond("cHis2", 100, 2000, "His2");
74 
75  Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
76  fPolyCon = MakePolyCond("polycon", 3, cutpnts);
77 
79  if(fConArr==0) {
80  // This is example how to create condition array
81  TGo4Log::Info("TXXXProc: Create condition array");
82  Double_t xvalues[4] = { 1000, 2000, 1500, 1000 };
83  Double_t yvalues[4] = { 1000, 1000, 3000, 1000 };
84  TCutG* mycut = new TCutG("cut2", 4, xvalues, yvalues);
85  fConArr = new TGo4CondArray("polyconar",4,"TGo4PolyCond");
86  fConArr->SetValues(mycut);
87  fConArr->Disable(true); // means: condition check always returns true
88  delete mycut; // mycat has been copied into the conditions
90  } else {
91  TGo4Log::Info("TXXXProc: Restore condition array from autosave");
93  }
94  // connect histograms to conditions. will be drawn when condition is edited.
95  ((*fConArr)[0])->Enable();
96  ((*fConArr)[1])->Enable(); // 2 and 3 remain disabled
97 
98  TGo4Log::Info("TXXXProc: Produce pictures");
99  fcondSet = GetPicture("condSet");
100  if (fcondSet==0) {
101  // in the upper two pads, the condition limits can be set,
102  // in the lower two pads, the resulting histograms are shown
103  fcondSet = new TGo4Picture("condSet","Set conditions");
104  fcondSet->SetDivision(2,2);
105  fcondSet->Pic(0,0)->AddObject(fHis1);
106  fcondSet->Pic(0,1)->AddObject(fHis2);
111  fcondSet->Pic(1,0)->SetFillAtt(4, 1001); // solid
112  fcondSet->Pic(1,0)->SetLineAtt(4,1,1);
113  fcondSet->Pic(1,1)->SetFillAtt(9, 1001); // solid
114  fcondSet->Pic(1,1)->SetLineAtt(9,1,1);
116  }
117 
118  fPicture = GetPicture("Picture");
119  if (fPicture == 0) {
120  fPicture = new TGo4Picture("Picture","Picture example");
121  fPicture->SetLinesDivision(3, 2,3,1);
122  fPicture->LPic(0,0)->AddObject(fCr1Ch[0]);
123  fPicture->LPic(0,0)->SetFillAtt(5, 3001); // pattern
124  fPicture->LPic(0,0)->SetLineAtt(5,1,1);
125  fPicture->LPic(0,1)->AddObject(fCr1Ch[1]);
126  fPicture->LPic(0,1)->SetFillAtt(4, 3001); // pattern
127  fPicture->LPic(0,1)->SetLineAtt(4,1,1);
128  fPicture->LPic(1,0)->AddObject(fCr1Ch[2]);
129  fPicture->LPic(1,0)->SetFillAtt(6, 1001); // solid
130  fPicture->LPic(1,0)->SetLineAtt(6,1,1);
131  fPicture->LPic(1,1)->AddObject(fCr1Ch[3]);
132  fPicture->LPic(1,1)->SetFillAtt(7, 1001); // solid
133  fPicture->LPic(1,1)->SetLineAtt(7,1,1);
134  fPicture->LPic(1,2)->AddObject(fCr1Ch[4]);
136  fPicture->LPic(3,0)->SetDrawOption("CONT");
138  }
139 }
140 //-----------------------------------------------------------
141 // event function
143 {
144  // called by framework from TXXXEvent to fill it
145 
146  TXXXEvent* XXXEvent = (TXXXEvent*) target;
147 
148  TGo4MbsEvent* source = (TGo4MbsEvent*) GetInputEvent();
149  if(source == 0) {
150  TGo4Log::Error("TXXXProc: no input event!");
151  return kFALSE;
152  }
153  if(source->GetTrigger() > 11) {
154  TGo4Log::Info("TXXXProc: Skip trigger event");
155  XXXEvent->SetValid(kFALSE); // not store
156  return kFALSE;
157  }
158  // first we fill the TXXXEvent with data from MBS source
159  // we have up to two subevents, crate 1 and 2
160  // Note that one has to loop over all subevents and select them by
161  // crate number: psubevt->GetSubcrate(),
162  // procid: psubevt->GetProcid(),
163  // and/or control: psubevt->GetControl()
164  // here we use only crate number
165 
166  source->ResetIterator();
167  TGo4MbsSubEvent* psubevt(0);
168  while((psubevt = source->NextSubEvent()) != 0) { // loop over subevents
169  Int_t *pdata = psubevt->GetDataField();
170  Int_t lwords = psubevt->GetIntLen();
171  if(lwords > 8) lwords=8; // take only first 8 lwords
172 
173  if(psubevt->GetSubcrate() == 1) {
174  for(Int_t i = 0; i<lwords; i++) {
175  // Int_t index = *pdata&0xfff; // in case low word is index
176  //Float_t value = (*pdata>>16)&0xfff; // and high word is data
177  Float_t value = (Float_t)*pdata++; // otherwise longword data
178  Int_t index = i; // and index in order
179  XXXEvent->fCrate1[index] = value; // copy to output event
180  }
181  }
182  if(psubevt->GetSubcrate() == 2)
183  for(Int_t i = 0; i<lwords; i++)
184  XXXEvent->fCrate2[i] = (Float_t)*pdata++;
185  }
186 
187  // now we fill histograms from XXXEvent
188  if(fControl->fill) {
189  for(Int_t i = 0; i<8; i++) {
190  fCr1Ch[i]->Fill(XXXEvent->fCrate1[i]);
191  fCr2Ch[i]->Fill(XXXEvent->fCrate2[i]);
192  }
193  Float_t value1 = XXXEvent->fCrate1[0];
194  Float_t value2 = XXXEvent->fCrate1[1];
195  fHis1->Fill(value1); //fill histograms without gate
196  fHis2->Fill(value2);
197  if (fconHis1->Test(value1)) fHis1gate->Fill(value1); //fill histograms with gate
198  if (fconHis2->Test(value2)) fHis2gate->Fill(value2);
199  // fill Cr1Ch1x2 for three polygons:
200  if (fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
201  if(((*fConArr)[0])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
202  if(((*fConArr)[1])->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
203  }
204  XXXEvent->SetValid(kTRUE); // to store
205  return kTRUE;
206 }
Bool_t fill
Definition: TXXXControl.h:23
TXXXProc()
Definition: TXXXProc.cxx:32
void SetValid(Bool_t on)
Bool_t BuildEvent(TGo4EventElement *target)
Definition: TXXXProc.cxx:142
TGo4Picture * fPicture
Definition: TXXXProc.h:42
TGo4Picture * GetPicture(const char *name)
TH2 * MakeTH2(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char *xtitle=0, const char *ytitle=0, const char *ztitle=0)
virtual Bool_t Test(Double_t x, Double_t y)
TGo4CondArray * fConArr
Definition: TXXXProc.h:40
TH1 * fHis2
Definition: TXXXProc.h:35
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=0)
TGo4Picture * fcondSet
Definition: TXXXProc.h:43
virtual Int_t PrintParameter(Text_t *buffer=0, Int_t buflen=0)
TGo4Condition * GetAnalysisCondition(const char *name, const char *cond_cl=0)
TGo4PolyCond * MakePolyCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=0)
TH1 * fHis1
Definition: TXXXProc.h:33
virtual void SetValues(Double_t low1, Double_t up1)
TGo4Picture * Pic(Int_t posy, Int_t posx)
TGo4MbsSubEvent * NextSubEvent(Bool_t all=kFALSE)
void SetDivision(Int_t ndivy, Int_t ndivx)
TXXXControl * fControl
Definition: TXXXProc.h:41
TH1 * fHis2gate
Definition: TXXXProc.h:36
void AddObject(TObject *obj, Option_t *DrawOption=0)
virtual void Disable(Bool_t result)
TGo4WinCond * fconHis2
Definition: TXXXProc.h:38
Int_t * GetDataField()
virtual ~TXXXProc()
Definition: TXXXProc.cxx:37
Long_t ExecuteScript(const char *script_name)
void AddCondition(TNamed *cond=0)
void SetLineAtt(Color_t color, Style_t style, Width_t width, Int_t index=UndefIndex)
Float_t fCrate2[8]
Definition: TXXXEvent.h:29
TGo4Parameter * GetParameter(const char *name, const char *par_class=0)
void SetLinesDivision(Int_t numlines, const Int_t *numbers)
TH1 * fCr2Ch[8]
Definition: TXXXProc.h:31
TGo4PolyCond * fPolyCon
Definition: TXXXProc.h:39
TGo4EventElement * GetInputEvent()
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=0)
virtual Bool_t Test(Double_t v1)
Definition: TGo4WinCond.cxx:83
TH1 * fCr1Ch[8]
Definition: TXXXProc.h:30
void SetFillAtt(Color_t color, Style_t style, Int_t index=UndefIndex)
Bool_t AddPicture(TGo4Picture *pic, const char *subfolder=0)
Int_t GetIntLen() const
TH1 * MakeTH1(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *xtitle=0, const char *ytitle=0)
Char_t GetSubcrate() const
GO4 ConditionPainter prototype Test
Definition: condition.js:691
Short_t GetTrigger() const
Definition: TGo4MbsEvent.h:146
Float_t fCrate1[8]
Definition: TXXXEvent.h:28
TH2 * fCr1Ch1x2
Definition: TXXXProc.h:32
void ResetIterator()
Definition: TGo4MbsEvent.h:98
TGo4WinCond * fconHis1
Definition: TXXXProc.h:37
virtual void SetDrawOption(Option_t *option="")
Definition: TGo4Picture.h:142
TGo4Picture * LPic(Int_t nline, Int_t ncol)
TH1 * fHis1gate
Definition: TXXXProc.h:34
static void Error(const char *text,...)
Definition: TGo4Log.cxx:309
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283
virtual void ResetCounts()