00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TYYYUnpackProc.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TMath.h"
00021 #include "TH1.h"
00022 #include "TH2.h"
00023 #include "TCutG.h"
00024
00025 #include "TGo4WinCond.h"
00026 #include "TGo4PolyCond.h"
00027
00028 #include "TYYYUnpackEvent.h"
00029 #include "TYYYRawEvent.h"
00030 #include "TYYYParameter.h"
00031
00032
00033 TYYYUnpackProc::TYYYUnpackProc()
00034 : TGo4EventProcessor("YYYProc"),
00035 fX(0),fY(0),fZ(0),fVX(0),fVY(0),fVZ(0),fNumScatt(0),
00036 fXY(0),fVXVY(0), fXYCond(0),fVXVYCond(0),fEmitX(0),fEmitY(0),
00037 fInput(0),fParam1(0)
00038 {
00039 }
00040
00041
00042 TYYYUnpackProc::TYYYUnpackProc(const char* name)
00043 : TGo4EventProcessor(name)
00044 {
00045 cout << "**** TYYYUnpackProc: Create" << endl;
00046
00048
00049 fParam1 = (TYYYParameter *) GetParameter("YYYPar1");
00050 fParam1->PrintParameter(0,0);
00051
00052
00053 if(GetHistogram("Position/Xfinal")==0)
00054 {
00055 fX = new TH1D ("Xfinal", "Scatt sim x (nm)",1000,-1e7,1e+7);
00056 fY = new TH1D ("Yfinal", "Scatt sim y (nm)",1000,-1e7,1e+7);
00057 fZ = new TH1D ("Zfinal", "Scatt sim z (nm)",1000,1,1e+8);
00058 fVX = new TH1D ("Vxfinal", "Scatt sim vx (nm/ps)",1000,-5e+3,5e+3);
00059 fVY = new TH1D ("Vyfinal", "Scatt sim vy (nm/ps)",1000,-5e+3,5e+3);
00060 fVZ = new TH1D ("Vzfinal", "Scatt sim vz (nm/ps)",1000,1,3e+4);
00061 fNumScatt = new TH1D ("Nscatt", "Multiple scattering collisions",50000,15000,25000);
00062 fXY = new TH2D("X-Y","x versus y final",100,-1e7,1e+7,100,-1e+7,1e+7);
00063 fVXVY = new TH2D("Vx-Vy","vx versus vy final",100,-5e+3,5e+3,100,-5e+3,5e+3);
00064 fXYCond = new TH2D("X-Y-cond","x versus y final",100,-1e+7,1e+7,100,-1e+7,1e+7);
00065 fVXVYCond = new TH2D("Vx-Vy-cond","vx versus vy final",100,-1e+3,1e+3,100,-1e+3,1e+3);
00066 fEmitX = new TH2D("X-X'","transverse emittance x",100,-1e+7,1e+7,100,-0.1,0.1);
00067 fEmitY = new TH2D("Y-Y'","transverse emittance y",100,-1e+7,1e+7,100,-0.1,0.1);
00068 fEmitDist = new TH1D("Emit4d","transverse emittance distribution",4000,0,2e+5);
00069
00070
00071
00072
00073 AddHistogram(fX,"Position");
00074 AddHistogram(fY,"Position");
00075 AddHistogram(fZ,"Position");
00076 AddHistogram(fXY,"Position");
00077 AddHistogram(fXYCond,"Position");
00078 AddHistogram(fVX,"Velocity");
00079 AddHistogram(fVY,"Velocity");
00080 AddHistogram(fVZ,"Velocity");
00081 AddHistogram(fVXVY,"Velocity");
00082 AddHistogram(fVXVYCond,"Velocity");
00083 AddHistogram(fNumScatt);
00084 AddHistogram(fEmitX);
00085 AddHistogram(fEmitY);
00086 AddHistogram(fEmitDist);
00087 }
00088 else
00089 {
00090 fX = (TH1D*)GetHistogram("Position/Xfinal");
00091 fY = (TH1D*)GetHistogram("Position/Yfinal");
00092 fZ = (TH1D*)GetHistogram("Position/Zfinal");
00093 fVX = (TH1D*)GetHistogram("Velocity/Vxfinal");
00094 fVY = (TH1D*)GetHistogram("Velocity/Vyfinal");
00095 fVZ = (TH1D*)GetHistogram("Velocity/Vzfinal");
00096 fNumScatt = (TH1D*)GetHistogram("Nscatt");;
00097 fXY = (TH2D*)GetHistogram("Position/X-Y");
00098 fVXVY = (TH2D*)GetHistogram("Velocity/Vx-Vy");
00099 fXYCond = (TH2D*)GetHistogram("Position/X-Y-cond");
00100 fVXVYCond = (TH2D*)GetHistogram("Velocity/Vx-Vy-cond");
00101 fEmitX = (TH2D*)GetHistogram("X-X'");
00102 fEmitY = (TH2D*)GetHistogram("Y-Y'");
00103 fEmitDist = (TH1D*)GetHistogram("Emit4d");
00104
00105 cout << "Unpack: Restored histograms from autosave" << endl;
00106 }
00107
00108 if(GetAnalysisCondition("RCondition")==0)
00109 {
00110 fWinConR= new TGo4WinCond("RCondition");
00111 fWinConR->SetValues(50,70);
00112 fWinConR->Disable(true);
00113
00114 fWinConV= new TGo4WinCond("VCondition");
00115 fWinConV->SetValues(50,70,90,120);
00116 fWinConV->Disable(true);
00117 fWinConV->Invert(kTRUE);
00118 Double_t xvalues[4]={400,700,600,400};
00119 Double_t yvalues[4]={800,900,1100,800};
00120 TCutG* mycut= new TCutG("initialcut",4,xvalues,yvalues);
00121 fPolyConEmit= new TGo4PolyCond("EmittCondition");
00122 fPolyConEmit->SetValues(mycut);
00123 fPolyConEmit->Disable(true);
00124 delete mycut;
00125
00126
00127 AddAnalysisCondition(fWinConR);
00128 AddAnalysisCondition(fWinConV);
00129 AddAnalysisCondition(fPolyConEmit);
00130 }
00131 else
00132 {
00133 fWinConR = (TGo4WinCond*) GetAnalysisCondition("RCondition");
00134 fWinConV = (TGo4WinCond*) GetAnalysisCondition("VCondition");
00135 fPolyConEmit = (TGo4PolyCond*) GetAnalysisCondition("EmittCondition");
00136 fWinConR->ResetCounts();
00137 fWinConV->ResetCounts();
00138 fPolyConEmit->ResetCounts();
00139 cout << "Unpack: Restored conditions from autosave" << endl;
00140 }
00141 fWinConR->Enable();
00142 fWinConR->PrintCondition(true);
00143 fPolyConEmit->Enable();
00144 fPolyConEmit->PrintCondition(true);
00145 }
00146
00147 TYYYUnpackProc::~TYYYUnpackProc()
00148 {
00149 fWinConR->PrintCondition(true);
00150 fPolyConEmit->PrintCondition(true);
00151 }
00152
00153
00154
00155 void TYYYUnpackProc::YYYUnpack(TYYYUnpackEvent* poutevt)
00156 {
00157 fInput = dynamic_cast<TYYYRawEvent*> (GetInputEvent());
00158 if(fInput)
00159 {
00160
00161 for(Int_t i=0; i<3;++i)
00162 {
00163 poutevt->fdR[i]=fInput->fdData[i];
00164 poutevt->fdV[i]=fInput->fdData[i+3];
00165 }
00166 poutevt->fdR[0]-=5e+6;
00167 poutevt->fdR[1]-=5e+6;
00168 poutevt->fiNumScatt= (Int_t) fInput->fdData[6];
00169
00170 if(poutevt->fdV[2]) poutevt->fdGam[0]=poutevt->fdV[0]/poutevt->fdV[2];
00171 if(poutevt->fdV[2]) poutevt->fdGam[1]=poutevt->fdV[1]/poutevt->fdV[2];
00172 Double_t scalefact=1e-3;
00173 poutevt->fdEmittX=poutevt->fdR[0]*poutevt->fdGam[0]*TMath::Pi()*scalefact;
00174 poutevt->fdEmittY=poutevt->fdR[1]*poutevt->fdGam[1]*TMath::Pi()*scalefact;
00175 poutevt->fdEmitt4d=poutevt->fdEmittX*poutevt->fdEmittY;
00176
00177 fX->Fill(poutevt->fdR[0]);
00178 fY->Fill(poutevt->fdR[1]);
00179 fZ->Fill(poutevt->fdR[2]);;
00180 fVX->Fill(poutevt->fdV[0]);
00181 fVY->Fill(poutevt->fdV[1]);
00182 fVZ->Fill(poutevt->fdV[2]);
00183 fNumScatt->Fill(poutevt->fiNumScatt);
00184 fXY->Fill(poutevt->fdR[0],poutevt->fdR[1]);
00185 fVXVY->Fill(poutevt->fdV[0],poutevt->fdV[1]);
00186 if(fWinConR->Test(poutevt->fdR[0],poutevt->fdR[1]))
00187 fXYCond->Fill(poutevt->fdR[0],poutevt->fdR[1]);
00188 if(fWinConV->Test(poutevt->fdV[0],poutevt->fdV[1]))
00189 fVXVYCond->Fill(poutevt->fdV[0],poutevt->fdV[1]);
00190 fEmitX->Fill(poutevt->fdR[0],poutevt->fdGam[0]);
00191 fEmitY->Fill(poutevt->fdR[1],poutevt->fdGam[1]);
00192 fEmitDist->Fill(poutevt->fdEmitt4d);
00193 }
00194 else cout << "YYYUnpackProc: no input event !"<< endl;
00195 }
00196
00197