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 1996 2017-03-10 14:30:17Z 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 "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
42 TXXXProc::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  fCr1Ch[i] = MakeTH1('I', Form("Crate1/Cr1Ch%02d",i+1), Form("Crate 1 channel %2d",i+1), 5000, 1., 5001.);
50  fCr2Ch[i] = MakeTH1('I', Form("Crate2/Cr2Ch%02d",i+1), Form("Crate 2 channel %2d",i+1), 5000, 1., 5001.);
51  }
52 
53  fCr1Ch1x2 = MakeTH2('I', "Cr1Ch1x2","Crate 1 channel 1x2", 200, 1., 5001., 200, 1., 5001.);
54  fHis1 = MakeTH1('I', "His1","Condition histogram", 5000, 1., 5001.);
55  fHis2 = MakeTH1('I', "His2","Condition histogram", 5000, 1., 5001.);
56  fHis1gate = MakeTH1('I', "His1g","Gated histogram", 5000, 1., 5001.);
57  fHis2gate = MakeTH1('I', "His2g","Gated histogram", 5000, 1., 5001.);
58  fHis3 = MakeTH1('I', "His3","Singular histogram", 20000, 0.999, 1.001);
59  fHis3Counter = 0;
60 
61  fconHis1 = MakeWinCond("cHis1", 100,2000, "His1");
62  fconHis2 = MakeWinCond("cHis2", 100,2000, "His2");
63 
64  Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
65  fPolyCon = MakePolyCond("polycon", 3, cutpnts);
66 
67  fcondSet = GetPicture("condSet");
68  if (fcondSet==0) {
69  // in the upper two pads, the condition limits can be set,
70  // in the lower two pads, the resulting histograms are shown
71  fcondSet = new TGo4Picture("condSet","Set conditions");
72  fcondSet->SetDivision(2,2);
73  fcondSet->Pic(0,0)->AddObject(fHis1);
74  fcondSet->Pic(0,1)->AddObject(fHis2);
79 
80  fcondSet->Pic(1,0)->SetFillAtt(4, 1001); // solid
81  fcondSet->Pic(1,0)->SetLineAtt(4,1,1);
82  fcondSet->Pic(1,1)->SetFillAtt(9, 1001); // solid
83  fcondSet->Pic(1,1)->SetLineAtt(9,1,1);
85  }
86 
87 /*
88  // this is example of creating canvas, which can be observed in the gui" << std::endl;
89  TCanvas* mycan = new TCanvas("TestCanvas","Does this work?", 3);
90  std::cout << "Did Creating canvas " << std::endl;
91  mycan->Divide(2,2);
92  mycan->cd(1);
93  fHis1->Draw();
94  mycan->cd(2);
95  fHis2->Draw();
96  AddCanvas(mycan);
97 
98 */
99 }
100 
101 //-----------------------------------------------------------
102 // event function
104 { // called by framework. We dont fill any output event here at all
105 
106  if ((GetInputEvent()==0) || (GetInputEvent()->IsA() != TGo4MbsEvent::Class())) {
107  std::cout << "TXXXProc: no input MBS event found!" << std::endl;
108  return kFALSE;
109  }
110 
112 
113  if(evnt->GetTrigger() > 11) {
114  std::cout << "**** TXXXProc: Skip trigger event" << std::endl;
115  return kFALSE;
116  }
117  // first we fill the arrays fCrate1,2 with data from MBS source
118  // we have up to two subevents, crate 1 and 2
119  // Note that one has to loop over all subevents and select them by
120  // crate number: psubevt->GetSubcrate(),
121  // procid: psubevt->GetProcid(),
122  // and/or control: psubevt->GetControl()
123  // here we use only crate number
124 
125  Float_t Crate1[8];
126  Float_t Crate2[8];
127  for(Int_t i = 0; i<8; i++) {
128  Crate1[i] = 0.;
129  Crate2[i] = 0.;
130  }
131 
132 
133  // uncomment this lines to update histogram on the gui periodically without activating monitoring
134  //static int cnt =0;
135  // if ((cnt++ % 100000) == 0) SendObjectToGUI(fHis1);
136 
137  evnt->ResetIterator();
138  TGo4MbsSubEvent *psubevt(0);
139  while((psubevt = evnt->NextSubEvent()) != 0) { // loop over subevents
140  Int_t * pdata = psubevt->GetDataField();
141  Int_t lwords = psubevt->GetIntLen();
142  if(lwords > 8) lwords = 8; // take only first 8 lwords
143 
144  if(psubevt->GetSubcrate() == 1)
145  for(Int_t i = 0; i<lwords; i++)
146  Crate1[i] = (Float_t)*pdata++;
147 
148  if(psubevt->GetSubcrate() == 2)
149  for(Int_t i = 0; i<lwords; i++)
150  Crate2[i] = (Float_t)*pdata++;
151  }
152 
153  // now we fill histograms from the arrays
154  if (fParam->fillRaw)
155  for(Int_t i = 0; i<8; i++) {
156  fCr1Ch[i]->Fill(Crate1[i]);
157  fCr2Ch[i]->Fill(Crate2[i]);
158  }
159  Float_t value1 = Crate1[0];
160  Float_t value2 = Crate1[1];
161  fHis1->Fill(value1); // fill histograms without gate
162  fHis2->Fill(value2);
163  if(fconHis1->Test(value1))fHis1gate->Fill(value1); //fill histograms with gate
164  if(fconHis2->Test(value2))fHis2gate->Fill(value2);
165  if(fPolyCon->Test(value1,value2)) fCr1Ch1x2->Fill(value1,value2);
166  if (fHis3Counter==0) {
167  TTimeStamp tm;
168  tm.Set();
169  fHis3->Reset();
170  fHis3->Fill(1 + 0.0005*TMath::Cos(tm.AsDouble()/100));
171  }
172  fHis3Counter = (fHis3Counter+1) % 10000;
173  return kTRUE;
174 }
TXXXParam * fParam
Definition: TXXXProc.h:42
TGo4Parameter * MakeParameter(const char *fullname, const char *classname, const char *newcmd=0)
TXXXProc()
Definition: TXXXProc.cxx:32
Bool_t BuildEvent(TGo4EventElement *target)
Definition: TXXXProc.cxx:142
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)
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
TGo4PolyCond * MakePolyCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=0)
TH1 * fHis1
Definition: TXXXProc.h:33
TH1 * fHis3
Definition: TXXXProc.h:37
TGo4Picture * Pic(Int_t posy, Int_t posx)
TGo4MbsSubEvent * NextSubEvent(Bool_t all=kFALSE)
Bool_t fillRaw
Definition: TXXXParam.h:23
void SetDivision(Int_t ndivy, Int_t ndivx)
TH1 * fHis2gate
Definition: TXXXProc.h:36
void AddObject(TObject *obj, Option_t *DrawOption=0)
TGo4WinCond * fconHis2
Definition: TXXXProc.h:38
virtual ~TXXXProc()
Definition: TXXXProc.cxx:37
Long_t fHis3Counter
Definition: TXXXProc.h:38
void AddCondition(TNamed *cond=0)
void SetLineAtt(Color_t color, Style_t style, Width_t width, Int_t index=UndefIndex)
TH1 * fCr2Ch[8]
Definition: TXXXProc.h:31
TGo4PolyCond * fPolyCon
Definition: TXXXProc.h:39
TGo4EventElement * GetInputEvent()
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)
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)
Short_t GetTrigger() const
Definition: TGo4MbsEvent.h:146
TH2 * fCr1Ch1x2
Definition: TXXXProc.h:32
void ResetIterator()
Definition: TGo4MbsEvent.h:98
TGo4WinCond * fconHis1
Definition: TXXXProc.h:37
TH1 * fHis1gate
Definition: TXXXProc.h:34
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283