Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4ExampleUserSource/TYYYUnpackProc.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TYYYUnpackProc.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TYYYUnpackEvent.h"
00021 #include "TYYYRawEvent.h"
00022 
00023 //***********************************************************
00024 TYYYUnpackProc::TYYYUnpackProc()
00025   : TGo4EventProcessor("YYYProc"),
00026     fX(0),fY(0),fZ(0),fVX(0),fVY(0),fVZ(0),fNumScatt(0),
00027     fXY(0),fVXVY(0), fXYCond(0),fVXVYCond(0),fEmitX(0),fEmitY(0),
00028     fInput(0),fParam1(0)
00029 {
00030 }
00031 //***********************************************************
00032 // this one is used in TYYYUnpackFact.cxx
00033 TYYYUnpackProc::TYYYUnpackProc(const Text_t * name)
00034   : TGo4EventProcessor(name)
00035 {
00036   cout << "**** TYYYUnpackProc: Create" << endl;
00037 
00039 
00040   fParam1   = (TYYYParameter *)   GetParameter("YYYPar1");
00041   fParam1->PrintParameter(0,0);
00042 
00043   // Creation of histograms:
00044   if(GetHistogram("Position/Xfinal")==0)
00045     {
00046       fX = new TH1D ("Xfinal", "Scatt sim x (nm)",1000,-1e7,1e+7);
00047       fY = new TH1D ("Yfinal", "Scatt sim y (nm)",1000,-1e7,1e+7);
00048       fZ = new TH1D ("Zfinal", "Scatt sim z (nm)",1000,1,1e+8);
00049       fVX = new TH1D ("Vxfinal", "Scatt sim vx (nm/ps)",1000,-5e+3,5e+3);
00050       fVY = new TH1D ("Vyfinal", "Scatt sim vy (nm/ps)",1000,-5e+3,5e+3);
00051       fVZ = new TH1D ("Vzfinal", "Scatt sim vz (nm/ps)",1000,1,3e+4);
00052       fNumScatt = new TH1D ("Nscatt", "Multiple scattering collisions",50000,15000,25000);
00053       fXY = new TH2D("X-Y","x versus y final",100,-1e7,1e+7,100,-1e+7,1e+7);
00054       fVXVY = new TH2D("Vx-Vy","vx versus vy final",100,-5e+3,5e+3,100,-5e+3,5e+3);
00055       fXYCond = new TH2D("X-Y-cond","x versus y final",100,-1e+7,1e+7,100,-1e+7,1e+7);
00056       fVXVYCond = new TH2D("Vx-Vy-cond","vx versus vy final",100,-1e+3,1e+3,100,-1e+3,1e+3);
00057       fEmitX = new TH2D("X-X'","transverse emittance x",100,-1e+7,1e+7,100,-0.1,0.1);
00058       fEmitY = new TH2D("Y-Y'","transverse emittance y",100,-1e+7,1e+7,100,-0.1,0.1);
00059       fEmitDist = new TH1D("Emit4d","transverse emittance distribution",4000,0,2e+5);
00060 
00061 
00062 
00063 
00064       AddHistogram(fX,"Position");
00065       AddHistogram(fY,"Position");
00066       AddHistogram(fZ,"Position");
00067       AddHistogram(fXY,"Position");
00068       AddHistogram(fXYCond,"Position");
00069       AddHistogram(fVX,"Velocity");
00070       AddHistogram(fVY,"Velocity");
00071       AddHistogram(fVZ,"Velocity");
00072       AddHistogram(fVXVY,"Velocity");
00073       AddHistogram(fVXVYCond,"Velocity");
00074       AddHistogram(fNumScatt);
00075       AddHistogram(fEmitX);
00076       AddHistogram(fEmitY);
00077       AddHistogram(fEmitDist);
00078     }
00079   else // got them from autosave file
00080     {
00081       fX = (TH1D*)GetHistogram("Position/Xfinal");
00082       fY = (TH1D*)GetHistogram("Position/Yfinal");
00083       fZ = (TH1D*)GetHistogram("Position/Zfinal");
00084       fVX = (TH1D*)GetHistogram("Velocity/Vxfinal");
00085       fVY = (TH1D*)GetHistogram("Velocity/Vyfinal");
00086       fVZ = (TH1D*)GetHistogram("Velocity/Vzfinal");
00087       fNumScatt = (TH1D*)GetHistogram("Nscatt");;
00088       fXY = (TH2D*)GetHistogram("Position/X-Y");
00089       fVXVY = (TH2D*)GetHistogram("Velocity/Vx-Vy");
00090       fXYCond = (TH2D*)GetHistogram("Position/X-Y-cond");
00091       fVXVYCond = (TH2D*)GetHistogram("Velocity/Vx-Vy-cond");
00092       fEmitX = (TH2D*)GetHistogram("X-X'");
00093       fEmitY = (TH2D*)GetHistogram("Y-Y'");
00094       fEmitDist = (TH1D*)GetHistogram("Emit4d");
00095 
00096       cout << "Unpack: Restored histograms from autosave" << endl;
00097     }
00098   // Creation of conditions:
00099   if(GetAnalysisCondition("RCondition")==0)
00100     {
00101       fWinConR= new TGo4WinCond("RCondition");
00102       fWinConR->SetValues(50,70);
00103       fWinConR->Disable(true); // return always true
00104 
00105       fWinConV= new TGo4WinCond("VCondition");
00106       fWinConV->SetValues(50,70,90,120);
00107       fWinConV->Disable(true);
00108       fWinConV->Invert(kTRUE);
00109       Double_t xvalues[4]={400,700,600,400};
00110       Double_t yvalues[4]={800,900,1100,800};
00111       TCutG* mycut= new TCutG("initialcut",4,xvalues,yvalues);
00112       fPolyConEmit= new TGo4PolyCond("EmittCondition");
00113       fPolyConEmit->SetValues(mycut); // copies mycat into fPolyConEmit
00114       fPolyConEmit->Disable(true);
00115       delete mycut; // mycat has been copied into the conditions
00116 
00117 
00118       AddAnalysisCondition(fWinConR);
00119       AddAnalysisCondition(fWinConV);
00120       AddAnalysisCondition(fPolyConEmit);
00121      }
00122   else // got them from autosave file
00123     {
00124       fWinConR  = (TGo4WinCond*)  GetAnalysisCondition("RCondition");
00125       fWinConV  = (TGo4WinCond*)  GetAnalysisCondition("VCondition");
00126       fPolyConEmit = (TGo4PolyCond*) GetAnalysisCondition("EmittCondition");
00127       fWinConR->ResetCounts();
00128       fWinConV->ResetCounts();
00129       fPolyConEmit->ResetCounts();
00130       cout << "Unpack: Restored conditions from autosave" << endl;
00131     }
00132  fWinConR->Enable();
00133  fWinConR->PrintCondition(true);
00134  fPolyConEmit->Enable();
00135  fPolyConEmit->PrintCondition(true);
00136 }
00137 //***********************************************************
00138 TYYYUnpackProc::~TYYYUnpackProc()
00139 {
00140  fWinConR->PrintCondition(true);
00141  fPolyConEmit->PrintCondition(true);
00142 }
00143 //***********************************************************
00144 
00145 //-----------------------------------------------------------
00146 void TYYYUnpackProc::YYYUnpack(TYYYUnpackEvent* poutevt)
00147 {
00148   fInput    = dynamic_cast<TYYYRawEvent*> (GetInputEvent());
00149   if(fInput)
00150     {
00151          // fill poutevt here:
00152          for(Int_t i=0; i<3;++i)
00153          {
00154             poutevt->fdR[i]=fInput->fdData[i]; // units: nm
00155             poutevt->fdV[i]=fInput->fdData[i+3]; // units: nm/ps
00156          }
00157          poutevt->fdR[0]-=5e+6; // correction for beam axis offset
00158          poutevt->fdR[1]-=5e+6; // beam was shifted by 5 mm
00159          poutevt->fiNumScatt= (Int_t) fInput->fdData[6];
00160          // calculate derived values;
00161          if(poutevt->fdV[2]) poutevt->fdGam[0]=poutevt->fdV[0]/poutevt->fdV[2]; // gammax=vx/vz (rad)
00162          if(poutevt->fdV[2]) poutevt->fdGam[1]=poutevt->fdV[1]/poutevt->fdV[2]; // gammay=vy/vz (rad)
00163          Double_t scalefact=1e-3; // transform nm*rad to mm*mrad
00164          poutevt->fdEmittX=poutevt->fdR[0]*poutevt->fdGam[0]*TMath::Pi()*scalefact;
00165          poutevt->fdEmittY=poutevt->fdR[1]*poutevt->fdGam[1]*TMath::Pi()*scalefact;
00166          poutevt->fdEmitt4d=poutevt->fdEmittX*poutevt->fdEmittY;
00167          // fill histograms:
00168          fX->Fill(poutevt->fdR[0]);
00169          fY->Fill(poutevt->fdR[1]);
00170          fZ->Fill(poutevt->fdR[2]);;
00171          fVX->Fill(poutevt->fdV[0]);
00172          fVY->Fill(poutevt->fdV[1]);
00173          fVZ->Fill(poutevt->fdV[2]);
00174          fNumScatt->Fill(poutevt->fiNumScatt);
00175          fXY->Fill(poutevt->fdR[0],poutevt->fdR[1]);
00176          fVXVY->Fill(poutevt->fdV[0],poutevt->fdV[1]);
00177          if(fWinConR->Test(poutevt->fdR[0],poutevt->fdR[1]))
00178             fXYCond->Fill(poutevt->fdR[0],poutevt->fdR[1]);
00179          if(fWinConV->Test(poutevt->fdV[0],poutevt->fdV[1]))
00180             fVXVYCond->Fill(poutevt->fdV[0],poutevt->fdV[1]);
00181         fEmitX->Fill(poutevt->fdR[0],poutevt->fdGam[0]);
00182         fEmitY->Fill(poutevt->fdR[1],poutevt->fdGam[1]);
00183         fEmitDist->Fill(poutevt->fdEmitt4d);
00184   } // if(fInput)
00185   else    cout << "YYYUnpackProc: no input event !"<< endl;
00186 }
00187 //-----------------------------------------------------------
00188 ClassImp(TYYYUnpackProc)
00189 
00190 
00191 
00192 
00193 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:55 2005 for Go4-v2.10-5 by doxygen1.2.15