GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TYYYUnpackProc.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 "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//***********************************************************
35
36//***********************************************************
39{
40 TGo4Log::Info("TYYYUnpackProc: Create %s", name);
41
43
44 fParam1 = (TYYYParameter *) GetParameter("YYYPar1");
45 fParam1->Print();
46
47 fX = MakeTH1('D', "Position/Xfinal", "Scatt sim x (nm)",1000,-1e7,1e+7);
48 fY = MakeTH1('D', "Position/Yfinal", "Scatt sim y (nm)",1000,-1e7,1e+7);
49 fZ = MakeTH1('D', "Position/Zfinal", "Scatt sim z (nm)",1000, 1., 1e+8);
50
51 fVX = MakeTH1('D', "Velocity/Vxfinal", "Scatt sim vx (nm/ps)",10000, -5e+3,5e+3);
52 fVY = MakeTH1('D', "Velocity/Vyfinal", "Scatt sim vy (nm/ps)",10000, -5e+3,5e+3);
53 fVZ = MakeTH1('D', "Velocity/Vzfinal", "Scatt sim vz (nm/ps)",10000, 1.,3e+4);
54 fThetaX=MakeTH1('D', "Angle/thetax", "Scatt sim x' (mrad)",10000, -5e+2,5e+2);
55 fThetaY=MakeTH1('D', "Angle/thetay", "Scatt sim y' (mrad)",10000, -5e+2,5e+2);
56 fThetaR=MakeTH1('D', "Angle/thetaR", "Scatt sim r' (mrad)",10000, 0,2e+3);
57 fNumScatt = MakeTH1('D', "Nscatt", "Multiple scattering collisions",50000, 0, 50000.);
58
59 fXY = MakeTH2('D', "Position/X-Y","x versus y final",100,-1e7,1e+7,100,-1e+7,1e+7);
60 fVXVY = MakeTH2('D', "Velocity/Vx-Vy","vx versus vy final",1000,-5e+3,5e+3,1000,-5e+3,5e+3);
61 fXYCond = MakeTH2('D', "Position/X-Y-cond","x versus y final",1000,-1e+7,1e+7,1000,-1e+7,1e+7);
62 fVXVYCond = MakeTH2('D', "Velocity/Vx-Vy-cond","vx versus vy final",100,-1e+3,1e+3,100,-1e+3,1e+3);
63
64 fEmitX = MakeTH2('D', "X-X'","transverse emittance x",1000,-1e+7,1e+7,1000,-0.1,0.1);
65 fEmitY = MakeTH2('D', "Y-Y'","transverse emittance y",1000,-1e+7,1e+7,1000,-0.1,0.1);
66 fEmitDist = MakeTH1('D', "Emit4d","transverse emittance distribution",4000,0,2e+5);
67
68 fWinConR = MakeWinCond("RCondition", 50., 70.);
69 fWinConV = MakeWinCond("VCondition", 50, 70, 90, 120);
70 if (IsObjMade()) {
71 fWinConV->Disable(true);
72 fWinConV->Invert(kTRUE);
73 }
74
75 Double_t cutpnts[3][2] = { {400, 800}, {700, 900}, {600, 1100} };
76 fPolyConEmit = MakePolyCond("EmittCondition", 3, cutpnts);
77
78 fWinConR->PrintCondition(true);
79 fPolyConEmit->PrintCondition(true);
80
81 if (!GetCanvas("TestCanvas2")) {
82 TCanvas *mycan = new TCanvas("TestCanvas2","Does this work2?");
83 mycan->Divide(2,2);
84 mycan->cd(1);
85 fX->Draw();
86 mycan->cd(2);
87 fY->Draw();
88
89 AddCanvas(mycan);
90 }
91}
92
93//***********************************************************
95{
96 fWinConR->PrintCondition(true);
97 fPolyConEmit->PrintCondition(true);
98}
99
100//***********************************************************
102{
103 return cl->InheritsFrom(TYYYUnpackEvent::Class());
104}
105
106//-----------------------------------------------------------
108{
109 auto inp = dynamic_cast<TYYYRawEvent*> (GetInputEvent());
110
111 auto poutevt = static_cast<TYYYUnpackEvent *>(dest);
112
113 if (!inp || !poutevt) {
114 TGo4Log::Error("YYYUnpackProc: events are not specified!");
115 return kFALSE;
116 }
117
118 // fill poutevt here:
119 for (Int_t i = 0; i < 3; ++i) {
120 poutevt->fdR[i] = inp->fdData[i]; // units: nm
121 poutevt->fdV[i] = inp->fdData[i+3]; // units: nm/ps
122 }
123 poutevt->fdR[0]-=5e+6; // correction for beam axis offset
124 poutevt->fdR[1]-=5e+6; // beam was shifted by 5 mm
125 poutevt->fiNumScatt = (Int_t) inp->fdData[6];
126 // calculate derived values;
127 if(poutevt->fdV[2]) poutevt->fdGam[0]=poutevt->fdV[0]/poutevt->fdV[2]; // gammax=vx/vz (rad)
128 if(poutevt->fdV[2]) poutevt->fdGam[1]=poutevt->fdV[1]/poutevt->fdV[2]; // gammay=vy/vz (rad)
129 Double_t scalefact=1e-3; // transform nm*rad to mm*mrad
130 poutevt->fdEmittX=poutevt->fdR[0]*poutevt->fdGam[0]*TMath::Pi()*scalefact;
131 poutevt->fdEmittY=poutevt->fdR[1]*poutevt->fdGam[1]*TMath::Pi()*scalefact;
132 poutevt->fdEmitt4d=poutevt->fdEmittX*poutevt->fdEmittY;
133 // fill histograms:
134 fX->Fill(poutevt->fdR[0]);
135 fY->Fill(poutevt->fdR[1]);
136 fZ->Fill(poutevt->fdR[2]);
137 fVX->Fill(poutevt->fdV[0]);
138 fVY->Fill(poutevt->fdV[1]);
139 fVZ->Fill(poutevt->fdV[2]);
140 if(poutevt->fdV[2])
141 {
142 fThetaX->Fill(poutevt->fdV[0]/poutevt->fdV[2] * 1000); // angle in millirad
143 fThetaY->Fill(poutevt->fdV[1]/poutevt->fdV[2] * 1000); // angle in millirad
144 fThetaR->Fill(TMath::Sqrt(poutevt->fdV[1]*poutevt->fdV[1] + poutevt->fdV[0]*poutevt->fdV[0])/poutevt->fdV[2] * 1000); // angle in millirad
145 }
146 fNumScatt->Fill(poutevt->fiNumScatt);
147 fXY->Fill(poutevt->fdR[0],poutevt->fdR[1]);
148 fVXVY->Fill(poutevt->fdV[0],poutevt->fdV[1]);
149 if(fWinConR->Test(poutevt->fdR[0],poutevt->fdR[1]))
150 fXYCond->Fill(poutevt->fdR[0],poutevt->fdR[1]);
151 if(fWinConV->Test(poutevt->fdV[0],poutevt->fdV[1]))
152 fVXVYCond->Fill(poutevt->fdV[0],poutevt->fdV[1]);
153 fEmitX->Fill(poutevt->fdR[0],poutevt->fdGam[0]);
154 fEmitY->Fill(poutevt->fdR[1],poutevt->fdGam[1]);
155 fEmitDist->Fill(poutevt->fdEmitt4d);
156
157 return kTRUE;
158}
Bool_t AddCanvas(TCanvas *can, const char *subfolder=nullptr)
Register TCanvas to go4 framework.
TH1 * MakeTH1(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *xtitle=nullptr, const char *ytitle=nullptr)
Create one dimensional histogram of specified type.
TGo4Parameter * GetParameter(const char *name, const char *par_class=nullptr)
Get parameter from go4 framework.
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=nullptr, const char *ytitle=nullptr, const char *ztitle=nullptr)
Create two dimensional histogram of specified type.
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=nullptr)
Create 1D window condition.
TCanvas * GetCanvas(const char *name)
Get TCanvas from go4 framework.
TGo4EventProcessor(const char *name)
Bool_t IsObjMade() const
Returns kTRUE if object in last Make... call was created, kFALSE when object was retrieved from autos...
TGo4EventElement * GetInputEvent()
Access to external raw event which is set as association member.
TGo4PolyCond * MakePolyCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=nullptr)
Create polygon condition.
friend class TGo4EventElement
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
Example for user defined raw event class.
Bool_t BuildEvent(TGo4EventElement *dest) override
Fill the destination event dest.
TGo4WinCond * fWinConV
virtual ~TYYYUnpackProc()
TGo4PolyCond * fPolyConEmit
Bool_t CheckEventClass(TClass *cl) override
This method checks if event class is suited for the source.
TGo4WinCond * fWinConR
TYYYParameter * fParam1