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