GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TYYYUnpackProc.cxx
Go to the documentation of this file.
1 // $Id: TYYYUnpackProc.cxx 3322 2021-10-11 14:09:58Z 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 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 "TYYYUnpackProc.h"
15 
16 #include "TClass.h"
17 #include "TCanvas.h"
18 #include "TMath.h"
19 #include "TH1.h"
20 #include "TH2.h"
21 
22 #include "TGo4Log.h"
23 #include "TGo4WinCond.h"
24 #include "TGo4PolyCond.h"
25 
26 #include "TYYYUnpackEvent.h"
27 #include "TYYYRawEvent.h"
28 #include "TYYYParameter.h"
29 
30 //***********************************************************
33  fX(0),fY(0),fZ(0),fVX(0),fVY(0),fVZ(0),fNumScatt(0),
34  fXY(0),fVXVY(0), fXYCond(0), fVXVYCond(0), fEmitX(0), fEmitY(0), fEmitDist(0),
35  fWinConR(0), fWinConV(0), fPolyConEmit(0),
36  fParam1(0)
37 {
38 }
39 //***********************************************************
40 TYYYUnpackProc::TYYYUnpackProc(const char* name) :
41  TGo4EventProcessor(name),
42  fX(0),fY(0),fZ(0),fVX(0),fVY(0),fVZ(0),fNumScatt(0),
43  fXY(0),fVXVY(0), fXYCond(0), fVXVYCond(0), fEmitX(0), fEmitY(0), fEmitDist(0),
44  fWinConR(0), fWinConV(0), fPolyConEmit(0),
45  fParam1(0)
46 {
47  TGo4Log::Info("TYYYUnpackProc: Create %s", name);
48 
50 
51  fParam1 = (TYYYParameter *) GetParameter("YYYPar1");
52  fParam1->PrintParameter(0,0);
53 
54  fX = MakeTH1('D', "Position/Xfinal", "Scatt sim x (nm)",1000,-1e7,1e+7);
55  fY = MakeTH1('D', "Position/Yfinal", "Scatt sim y (nm)",1000,-1e7,1e+7);
56  fZ = MakeTH1('D', "Position/Zfinal", "Scatt sim z (nm)",1000, 1., 1e+8);
57 
58  fVX = MakeTH1('D', "Velocity/Vxfinal", "Scatt sim vx (nm/ps)",10000, -5e+3,5e+3);
59  fVY = MakeTH1('D', "Velocity/Vyfinal", "Scatt sim vy (nm/ps)",10000, -5e+3,5e+3);
60  fVZ = MakeTH1('D', "Velocity/Vzfinal", "Scatt sim vz (nm/ps)",10000, 1.,3e+4);
61  fThetaX=MakeTH1('D', "Angle/thetax", "Scatt sim x' (mrad)",10000, -5e+2,5e+2);
62  fThetaY=MakeTH1('D', "Angle/thetay", "Scatt sim y' (mrad)",10000, -5e+2,5e+2);
63  fThetaR=MakeTH1('D', "Angle/thetaR", "Scatt sim r' (mrad)",10000, 0,2e+3);
64  fNumScatt = MakeTH1('D', "Nscatt", "Multiple scattering collisions",50000, 0, 50000.);
65 
66  fXY = MakeTH2('D', "Position/X-Y","x versus y final",100,-1e7,1e+7,100,-1e+7,1e+7);
67  fVXVY = MakeTH2('D', "Velocity/Vx-Vy","vx versus vy final",1000,-5e+3,5e+3,1000,-5e+3,5e+3);
68  fXYCond = MakeTH2('D', "Position/X-Y-cond","x versus y final",1000,-1e+7,1e+7,1000,-1e+7,1e+7);
69  fVXVYCond = MakeTH2('D', "Velocity/Vx-Vy-cond","vx versus vy final",100,-1e+3,1e+3,100,-1e+3,1e+3);
70 
71  fEmitX = MakeTH2('D', "X-X'","transverse emittance x",1000,-1e+7,1e+7,1000,-0.1,0.1);
72  fEmitY = MakeTH2('D', "Y-Y'","transverse emittance y",1000,-1e+7,1e+7,1000,-0.1,0.1);
73  fEmitDist = MakeTH1('D', "Emit4d","transverse emittance distribution",4000,0,2e+5);
74 
75  fWinConR = MakeWinCond("RCondition", 50., 70.);
76  fWinConV = MakeWinCond("VCondition", 50, 70, 90, 120);
77  if (IsObjMade()) {
78  fWinConV->Disable(true);
79  fWinConV->Invert(kTRUE);
80  }
81 
82  Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
83  fPolyConEmit = MakePolyCond("EmittCondition", 3, cutpnts);
84 
85  fWinConR->PrintCondition(true);
87 
88  if (GetCanvas("TestCanvas2")==0) {
89  TCanvas* mycan = new TCanvas("TestCanvas2","Does this work2?");
90  mycan->Divide(2,2);
91  mycan->cd(1);
92  fX->Draw();
93  mycan->cd(2);
94  fY->Draw();
95 
96  AddCanvas(mycan);
97  }
98 }
99 //***********************************************************
101 {
102  fWinConR->PrintCondition(true);
104 }
105 //***********************************************************
106 
108 {
109  return cl->InheritsFrom(TYYYUnpackEvent::Class());
110 }
111 
112 
113 //-----------------------------------------------------------
114 
116 {
117  TYYYRawEvent *inp = dynamic_cast<TYYYRawEvent*> (GetInputEvent());
118 
119  TYYYUnpackEvent* poutevt = (TYYYUnpackEvent*) (dest);
120 
121  if ((inp==0) || (poutevt==0)) {
122  TGo4Log::Error("YYYUnpackProc: events are not specified!");
123  return kFALSE;
124  }
125 
126  // fill poutevt here:
127  for(Int_t i=0; i<3;++i)
128  {
129  poutevt->fdR[i] = inp->fdData[i]; // units: nm
130  poutevt->fdV[i] = inp->fdData[i+3]; // units: nm/ps
131  }
132  poutevt->fdR[0]-=5e+6; // correction for beam axis offset
133  poutevt->fdR[1]-=5e+6; // beam was shifted by 5 mm
134  poutevt->fiNumScatt= (Int_t) inp->fdData[6];
135  // calculate derived values;
136  if(poutevt->fdV[2]) poutevt->fdGam[0]=poutevt->fdV[0]/poutevt->fdV[2]; // gammax=vx/vz (rad)
137  if(poutevt->fdV[2]) poutevt->fdGam[1]=poutevt->fdV[1]/poutevt->fdV[2]; // gammay=vy/vz (rad)
138  Double_t scalefact=1e-3; // transform nm*rad to mm*mrad
139  poutevt->fdEmittX=poutevt->fdR[0]*poutevt->fdGam[0]*TMath::Pi()*scalefact;
140  poutevt->fdEmittY=poutevt->fdR[1]*poutevt->fdGam[1]*TMath::Pi()*scalefact;
141  poutevt->fdEmitt4d=poutevt->fdEmittX*poutevt->fdEmittY;
142  // fill histograms:
143  fX->Fill(poutevt->fdR[0]);
144  fY->Fill(poutevt->fdR[1]);
145  fZ->Fill(poutevt->fdR[2]);
146  fVX->Fill(poutevt->fdV[0]);
147  fVY->Fill(poutevt->fdV[1]);
148  fVZ->Fill(poutevt->fdV[2]);
149  if(poutevt->fdV[2])
150  {
151  fThetaX->Fill(poutevt->fdV[0]/poutevt->fdV[2] * 1000); // angle in millirad
152  fThetaY->Fill(poutevt->fdV[1]/poutevt->fdV[2] * 1000); // angle in millirad
153  fThetaR->Fill(TMath::Sqrt(poutevt->fdV[1]*poutevt->fdV[1] + poutevt->fdV[0]*poutevt->fdV[0])/poutevt->fdV[2] * 1000); // angle in millirad
154  }
155  fNumScatt->Fill(poutevt->fiNumScatt);
156  fXY->Fill(poutevt->fdR[0],poutevt->fdR[1]);
157  fVXVY->Fill(poutevt->fdV[0],poutevt->fdV[1]);
158  if(fWinConR->Test(poutevt->fdR[0],poutevt->fdR[1]))
159  fXYCond->Fill(poutevt->fdR[0],poutevt->fdR[1]);
160  if(fWinConV->Test(poutevt->fdV[0],poutevt->fdV[1]))
161  fVXVYCond->Fill(poutevt->fdV[0],poutevt->fdV[1]);
162  fEmitX->Fill(poutevt->fdR[0],poutevt->fdGam[0]);
163  fEmitY->Fill(poutevt->fdR[1],poutevt->fdGam[1]);
164  fEmitDist->Fill(poutevt->fdEmitt4d);
165 
166  return kTRUE;
167 }
Double_t fdGam[2]
virtual void PrintCondition(Bool_t points=kTRUE)
TGo4PolyCond * fPolyConEmit
virtual void PrintCondition(Bool_t full=kTRUE)
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 Int_t PrintParameter(Text_t *n, Int_t)
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=0)
virtual Bool_t BuildEvent(TGo4EventElement *dest)
TGo4PolyCond * MakePolyCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=0)
Double_t fdV[3]
TGo4WinCond * fWinConV
TYYYParameter * fParam1
TCanvas * GetCanvas(const char *name)
Bool_t AddCanvas(TCanvas *can, const char *subfolder=0)
TGo4WinCond * fWinConR
Double_t * fdData
Definition: TYYYRawEvent.h:49
virtual void Disable(Bool_t result)
TGo4Parameter * GetParameter(const char *name, const char *par_class=0)
TGo4EventElement * GetInputEvent()
virtual Bool_t Test(Double_t v1)
Definition: TGo4WinCond.cxx:86
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)
virtual Bool_t CheckEventClass(TClass *cl)
Double_t fdR[3]
static void Error(const char *text,...)
Definition: TGo4Log.cxx:323
static void Info(const char *text,...)
Definition: TGo4Log.cxx:297
virtual void Invert(Bool_t on)
virtual ~TYYYUnpackProc()