#include "LOpticsOpt.h"
#include "THaGlobals.h"
#include "THaEvData.h"
#include "THaDetMap.h"
#include "THaTrack.h"
#include "THaScintillator.h"
#include "THaSpectrometer.h"
#include "TClonesArray.h"
#include "TList.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TH2.h"
#include "TH1.h"
#include "TF1.h"
#include "TLatex.h"
#include "TVector3.h"
#include "TLine.h"
#include "TArrow.h"
#include "VarDef.h"
#include "TROOT.h"
#include "THaString.h"
#include <map>
#include <cstdio>
#include <cstdlib>
#ifdef WITH_DEBUG
#include <iostream>
#endif
using namespace std;
using THaString::Split;
const Double_t HRSAngle = 15.993/180.*TMath::Pi();
const Double_t MissPointZ = -1.63e-3;
const Double_t MissPointY = 0.98e-3;
const Double_t SieveOffX = -(4.49)*1e-3;
const Double_t SieveOffY = +(-0.34)*1e-3;
const Double_t ZPos = 1157*1e-3;
const Double_t SieveSpaceX = 1.025 * 25.400e-3;
const Double_t SieveSpaceY = .513 * 25.400e-3;
const UInt_t NSieve = 7;
static const UInt_t NFiols = 6;
const Double_t targetfoils[]={0.0019-0.2,0.0019-0.2+0.2/3.,0.0019-0.2+0.2/3.*2.,0.0019,0.0019+0.2/3.,0.0019+0.2/3.*2.,+0.0019+0.2};
const UInt_t NKine = 5;
#define DIPOLE_MAG2MOM(Mag) (2.702*Mag-1.6e-03*Mag*Mag*Mag)
const Double_t HRSCentralMom[NKine]=
{
DIPOLE_MAG2MOM((0.471328+0.471327)/2),DIPOLE_MAG2MOM(0.462306)
,DIPOLE_MAG2MOM((0.453231+0.453236)/2),DIPOLE_MAG2MOM(0.444172)
,DIPOLE_MAG2MOM((0.435115+0.435118)/2)
};
const Double_t GroundNuclearMass = 12*.931494028-.511e-3*6;
const Double_t ExcitationEnergy[NKine]=
{0.,0.00443891,0.00443891,0.00443891,0.00443891};
const UInt_t NExcitationStates = 8;
const Double_t ExcitationEnergyList[NExcitationStates]
={0,0.00443891,0.00765420,0.009641,0.010844,0.011160,0.011828,0.012710};
const Double_t AllLossExceptFoil = 1e-3*(
.075
+0.374
+0.0168+0.0228
+0.109
+.1
+.1
);
const Double_t LossEachFoil = 1e-3*(0.08775);
const Double_t RadiationLossByFoil[]={
AllLossExceptFoil+LossEachFoil*1,
AllLossExceptFoil+LossEachFoil*2,
AllLossExceptFoil+LossEachFoil*3,
AllLossExceptFoil+LossEachFoil*4,
AllLossExceptFoil+LossEachFoil*5,
AllLossExceptFoil+LossEachFoil*6,
AllLossExceptFoil+LossEachFoil*7
};
const Double_t ExtTarCor_ThetaCorr = 0.61;
const Double_t ExtTarCor_DeltaCorr = 5.18;
Double_t LOpticsOpt::SumSquareDp(Bool_t IncludeExtraData)
{
Double_t d_dp = 0;
Double_t rms_dp = 0;
static UInt_t NCall = 0;
NCall++;
UInt_t NCalibData=0;
if (IncludeExtraData)
{
Warning("SumSquareDp","Data Beyond selected excitation state is included in this calculation");
}
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
Double_t dp, dp_kin;
EventData &eventdata = fRawData[idx];
if (eventdata.Data[kExtraDataFlag]>0 && !IncludeExtraData) continue;
NCalibData++;
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fDMatrixElems);
dp = CalcTargetVar(fDMatrixElems, powers);
dp_kin = dp - eventdata.Data[kDpKinOffsets];
const UInt_t KineID = (UInt_t)(eventdata.Data[kKineID]);
assert(KineID<NKine);
const Double_t ArbitaryDpKinShift = fArbitaryDpKinShift[KineID];
d_dp += dp_kin - eventdata.Data[kRealDpKinMatrix]+ArbitaryDpKinShift;
rms_dp += (dp_kin - eventdata.Data[kRealDpKinMatrix]+ArbitaryDpKinShift)
*(dp_kin - eventdata.Data[kRealDpKinMatrix]+ArbitaryDpKinShift);
DEBUG_MASSINFO("SumSquareDp","d_dp = %f = \t%f - \t%f",
dp_kin - eventdata.Data[kRealDpKinMatrix], dp_kin , eventdata.Data[kRealDpKinMatrix] );
eventdata.Data[kCalcDpKinMatrix] = dp_kin;
eventdata.Data[kCalcDpKin] = dp_kin+eventdata.Data[kRealTgX]/ExtTarCor_DeltaCorr;
}
if (!IncludeExtraData)
assert(fNCalibData==NCalibData);
DEBUG_INFO("SumSquareDp","#%d : d_dp = %f,rms_dp=%f",NCall,
d_dp/NCalibData,TMath::Sqrt(rms_dp/NCalibData));
return rms_dp;
}
Double_t LOpticsOpt::SumSquareDTh(void)
{
Double_t dth = 0;
Double_t rmsth = 0;
static UInt_t NCall = 0;
NCall++;
Double_t theta;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fTMatrixElems);
theta = CalcTargetVar(fTMatrixElems, powers);
dth += theta - eventdata.Data[kRealThMatrix];
rmsth += (theta - eventdata.Data[kRealThMatrix])*(theta - eventdata.Data[kRealThMatrix]);
DEBUG_MASSINFO("SumSquareDTh","D_Th = %f = \t%f - \t%f",
theta - eventdata.Data[kRealThMatrix], theta , eventdata.Data[kRealThMatrix] );
DEBUG_MASSINFO("SumSquareDTh","%d : %f, %f, %f, %f, %f"
,kRealTh
, eventdata.Data[kRealTh-2]
, eventdata.Data[kRealTh-1]
, eventdata.Data[kRealTh]
, eventdata.Data[kRealTh+1]
, eventdata.Data[kRealTh+2]
);
eventdata.Data[kCalcTh] = theta;
}
DEBUG_INFO("SumSquareDTh","#%d : dth = %f,rmsth=%f",NCall,
dth/fNRawData,TMath::Sqrt(rmsth/fNRawData));
return rmsth;
}
Double_t LOpticsOpt::SumSquareDPhi(void)
{
Double_t dphi=0;
Double_t rmsphi=0;
static UInt_t NCall = 0;
NCall++;
Double_t phi;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fPMatrixElems);
phi = CalcTargetVar(fPMatrixElems, powers);
dphi += phi - eventdata.Data[kRealPhi];
rmsphi += (phi - eventdata.Data[kRealPhi])*(phi - eventdata.Data[kRealPhi]);
eventdata.Data[kCalcPh] = phi;
}
DEBUG_INFO("SumSquareDPhi","#%d : dphi = %f, rmsphi=%f",NCall,
dphi/fNRawData,TMath::Sqrt(rmsphi/fNRawData));
return rmsphi;
}
Double_t LOpticsOpt::SumSquareDTgY(void)
{
Double_t dtg_y=0;
Double_t dtg_y_rms=0;
static UInt_t NCall = 0;
NCall++;
Double_t tg_y;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fYMatrixElems);
tg_y = CalcTargetVar(fYMatrixElems, powers)
;
const UInt_t FoilID = (UInt_t)eventdata.Data[kCutID];
const Double_t ArbitaryVertexShift =
fArbitaryVertexShift[FoilID] * (-TMath::Sin(HRSAngle));
dtg_y += tg_y - eventdata.Data[kRealTgY]+ArbitaryVertexShift;
dtg_y_rms += (tg_y - eventdata.Data[kRealTgY]+ArbitaryVertexShift)
*(tg_y - eventdata.Data[kRealTgY]+ArbitaryVertexShift);
eventdata.Data[kCalcTgY] = tg_y;
}
DEBUG_INFO("SumSquareDTgY","#%d : dtg_y = %f, dtg_y_rms=%f",NCall,
dtg_y/fNRawData,TMath::Sqrt(dtg_y_rms/fNRawData));
return dtg_y_rms;
}
Double_t LOpticsOpt::SumSquareDTgYAverFoils(void)
{
Double_t dtg_y=0;
Double_t dtg_y_rms=0;
static UInt_t NCall = 0;
NCall++;
Double_t tg_y;
Double_t dtg_y_foil[NFiols] ={0};
Double_t rmstg_y_foil[NFiols] ={0};
UInt_t ndata_foil[NFiols] ={0};
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fYMatrixElems);
tg_y = CalcTargetVar(fYMatrixElems, powers);
dtg_y += tg_y - eventdata.Data[kRealTgY];
dtg_y_rms += (tg_y - eventdata.Data[kRealTgY])*(tg_y - eventdata.Data[kRealTgY]);
eventdata.Data[kCalcTgY] = tg_y;
const UInt_t FoilID = (UInt_t)eventdata.Data[kCutID];
const Double_t ArbitaryVertexShift =
fArbitaryVertexShift[FoilID] * (-TMath::Sin(HRSAngle));
ndata_foil[FoilID]++;
dtg_y_foil[FoilID] += eventdata.Data[kCalcTgY] - eventdata.Data[kRealTgY]+ArbitaryVertexShift;
rmstg_y_foil[FoilID] +=
(eventdata.Data[kCalcTgY] - eventdata.Data[kRealTgY]+ArbitaryVertexShift)*
(eventdata.Data[kCalcTgY] - eventdata.Data[kRealTgY]+ArbitaryVertexShift);
}
Double_t dtg_y_foilaver=0;
Double_t dtg_y_rms_foilaver=0;
for(UInt_t FoilID = 0; FoilID<NFiols; FoilID++)
{
assert(ndata_foil[FoilID]);
const UInt_t N = ndata_foil[FoilID];
dtg_y_foilaver += dtg_y_foil[FoilID]/N;
dtg_y_rms_foilaver += rmstg_y_foil[FoilID]/N;;
}
dtg_y_foilaver = dtg_y_foilaver/NFiols*fNRawData;
dtg_y_rms_foilaver = dtg_y_rms_foilaver/NFiols*fNRawData;
DEBUG_INFO("SumSquareDTgY","#%d Foil Ave: dtg_y = %f, dtg_y_rms=%f",NCall,
dtg_y_foilaver/fNRawData,TMath::Sqrt(dtg_y_rms_foilaver/fNRawData));
DEBUG_INFO("SumSquareDTgY","#%d : dtg_y = %f, dtg_y_rms=%f",NCall,
dtg_y/fNRawData,TMath::Sqrt(dtg_y_rms/fNRawData));
return dtg_y_rms_foilaver;
}
void LOpticsOpt::PrepareSieve(void)
{
Double_t dth = 0, dphi=0;
Double_t exttargcorr_th=0, rms_exttargcorr_th=0;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
UInt_t res = (UInt_t)eventdata.Data[kCutID];
const UInt_t FoilID = res/(NSieve*NSieve);
res = res%(NSieve*NSieve);
const UInt_t Col = res/(NSieve);
const UInt_t Row = res%(NSieve);
assert(FoilID<NFiols);
const TVector3 SieveHoleTCS(
SieveOffX + (-1.*Row+3.)*SieveSpaceX,
SieveOffY + (-1.*Col+3.)*SieveSpaceY,
ZPos
);
const TVector3 BeamSpotHCS(
eventdata.Data[kBeamX],
eventdata.Data[kBeamY],
targetfoils[FoilID]
);
const TVector3 BeamSpotTCS=fTCSInHCS.Inverse()*(BeamSpotHCS-fPointingOffset);
const TVector3 MomDirectionTCS = SieveHoleTCS - BeamSpotTCS;
eventdata.Data[kRealTh] = MomDirectionTCS.X()/MomDirectionTCS.Z();
eventdata.Data[kRealPhi] = MomDirectionTCS.Y()/MomDirectionTCS.Z();
const Double_t x_tg = BeamSpotTCS.X()-BeamSpotTCS.Z()*eventdata.Data[kRealTh];
eventdata.Data[kRealTgX] = x_tg;
eventdata.Data[kRealThMatrix]=eventdata.Data[kRealTh] - x_tg*ExtTarCor_ThetaCorr;
exttargcorr_th += x_tg*ExtTarCor_ThetaCorr;
rms_exttargcorr_th += x_tg*ExtTarCor_ThetaCorr*x_tg*ExtTarCor_ThetaCorr;
DEBUG_MASSINFO("PrepareSieve","%d,%d,%d: D_Th = %f,\t D_Phi = %f",FoilID,Col,Row,
eventdata.Data[kRealThMatrix]-eventdata.Data[kL_tr_tg_th],
eventdata.Data[kRealPhi]-eventdata.Data[kL_tr_tg_ph]
);
DEBUG_MASSINFO("PrepareSieve","%f,\t%f",
eventdata.Data[kRealThMatrix],eventdata.Data[kL_tr_tg_th]
);
dth+=eventdata.Data[kRealThMatrix]-eventdata.Data[kL_tr_tg_th];
dphi+=eventdata.Data[kRealPhi]-eventdata.Data[kL_tr_tg_ph];
}
DEBUG_INFO("PrepareSieve","Average : D_Th = %f,\t D_Phi = %f",dth/fNRawData,dphi/fNRawData);
DEBUG_INFO("PrepareSieve","Average Extended Target Corretion: th = %f,\t rms_th = %f"
,exttargcorr_th/fNRawData,TMath::Sqrt(rms_exttargcorr_th/fNRawData));
SumSquareDTh();
SumSquareDPhi();
}
void LOpticsOpt::PrepareVertex(void)
{
fCurrentMatrixElems = & fYMatrixElems;
Double_t dtg_y = 0,dtg_y_rms = 0;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
UInt_t res = (UInt_t)eventdata.Data[kCutID];
const UInt_t FoilID = res;
assert(FoilID<NFiols);
TVector3 BeamSpotHCS(
eventdata.Data[kBeamX],
eventdata.Data[kBeamY],
targetfoils[FoilID]
);
TVector3 BeamSpotTCS=fTCSInHCS.Inverse()*(BeamSpotHCS-fPointingOffset);
Double_t Real_Tg_Y = BeamSpotTCS.Y()
+ eventdata.Data[kL_tr_tg_ph] * (0-BeamSpotTCS.Z());
eventdata.Data[kRealTgY] = Real_Tg_Y;
eventdata.Data[kRealReactZ] = targetfoils[FoilID];
dtg_y += (eventdata.Data[kL_tr_tg_y] - Real_Tg_Y);
dtg_y_rms += (eventdata.Data[kL_tr_tg_y] - Real_Tg_Y)
*(eventdata.Data[kL_tr_tg_y] - Real_Tg_Y);
TVector3 Tg_YSpotTCS(0
,eventdata.Data[kRealTgY]
,0
);
TVector3 MomDirectionTCS(0
,eventdata.Data[kL_tr_tg_ph]
,1
);
TVector3 Tg_YSpotHCS=fTCSInHCS*Tg_YSpotTCS+fPointingOffset;
TVector3 MomDirectionHCS=fTCSInHCS*MomDirectionTCS;
assert(Tg_YSpotHCS.Y()==MissPointY);
assert(MomDirectionHCS.Y()==0);
Double_t reactz = Tg_YSpotHCS.Z()
- (Tg_YSpotHCS.X()-eventdata.Data[kBeamX])
/MomDirectionHCS.X()*MomDirectionHCS.Z();
DEBUG_MASSINFO("PrepareVertex","reactz =%f, eventdata.Data[kRealReactZ]=%f",
reactz,eventdata.Data[kRealReactZ]);
DEBUG_MASSINFO("PrepareVertex","Real_Tg_Y =%f, eventdata.Data[kRealReactZ]=%f, targetfoils[FoilID]=%f",
Real_Tg_Y,eventdata.Data[kL_tr_tg_ph],targetfoils[FoilID]);
assert(TMath::Abs(reactz - eventdata.Data[kRealReactZ])<1e-4);
}
DEBUG_INFO("PrepareVertex","Average : dtg_y = %f, dtg_y_rms=%f"
,dtg_y/fNRawData,dtg_y_rms/fNRawData);
SumSquareDTgY();
}
void LOpticsOpt::PrepareDp(void)
{
printf("HRSCentralMom[%d] (GeV) = {",NKine);
for(UInt_t KineID = 0; KineID<NKine; KineID++)
printf("%f ",HRSCentralMom[KineID]*1000);
printf("}\n");
printf("RadiationLossByFoil[%d] (MeV) = {",NFiols);
for(UInt_t FoilID = 0; FoilID<NFiols; FoilID++)
printf("%f ",RadiationLossByFoil[FoilID]*1000);
printf("}\n");
fCurrentMatrixElems = & fDMatrixElems;
Double_t dth = 0, dphi=0, scatang=0;
Double_t dpkinoff = 0, dpkinoff_rms=0;
fNCalibData = 0;
Double_t exttargcorr_dp=0, rms_exttargcorr_dp=0;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
DEBUG_MASSINFO("PrepareDp","=========== Event %d ===========",idx);
EventData &eventdata = fRawData[idx];
UInt_t res = (UInt_t)eventdata.Data[kCutID];
const UInt_t ExtraDataFlag = res/(NSieve*NSieve*NFiols*NKine);
res = res%(NSieve*NSieve*NFiols*NKine);
const UInt_t KineID = res/(NSieve*NSieve*NFiols);
res = res%(NSieve*NSieve*NFiols);
const UInt_t FoilID = res/(NSieve*NSieve);
res = res%(NSieve*NSieve);
const UInt_t Col = res/(NSieve);
const UInt_t Row = res%(NSieve);
assert(ExtraDataFlag<2);
assert(KineID<NKine);
assert(FoilID<NFiols);
DEBUG_MASSINFO("PrepareDp","%d => KineID=%d,\tFoilID=%d,\tCol=%d,\tRow=%d",
(UInt_t)eventdata.Data[kCutID],KineID,FoilID,Col,Row);
eventdata.Data[kExtraDataFlag] = ExtraDataFlag;
if (!ExtraDataFlag) fNCalibData++;
eventdata.Data[kKineID] = KineID;
eventdata.Data[kCentralp] = HRSCentralMom[KineID];
const Double_t EPICS_P = eventdata.Data[kL_tr_p]/(1.+eventdata.Data[kL_tr_tg_dp]);
DEBUG_MASSINFO("PrepareDp","Central_P/GeV: EPICS=%f, NMR=%f",
EPICS_P,eventdata.Data[kCentralp]);
assert(TMath::Abs(EPICS_P - eventdata.Data[kCentralp])<1e-3);
TVector3 SieveHoleTCS(
SieveOffX + (-1.*Row+3.)*SieveSpaceX,
SieveOffY + (-1.*Col+3.)*SieveSpaceY,
ZPos
);
TVector3 BeamSpotHCS(
eventdata.Data[kBeamX],
eventdata.Data[kBeamY],
targetfoils[FoilID]
);
TVector3 BeamSpotTCS=fTCSInHCS.Inverse()*(BeamSpotHCS-fPointingOffset);
TVector3 MomDirectionTCS = SieveHoleTCS - BeamSpotTCS;
eventdata.Data[kRealTh] = MomDirectionTCS.X()/MomDirectionTCS.Z();
eventdata.Data[kRealPhi] = MomDirectionTCS.Y()/MomDirectionTCS.Z();
const Double_t x_tg = BeamSpotTCS.X()-BeamSpotTCS.Z()*eventdata.Data[kRealTh];
eventdata.Data[kRealTgX] = x_tg;
DEBUG_MASSINFO("PrepareDp","%d,%d,%d: D_Th = %f,\t D_Phi = %f",FoilID,Col,Row,
eventdata.Data[kRealThMatrix]-eventdata.Data[kL_tr_tg_th],
eventdata.Data[kRealPhi]-eventdata.Data[kL_tr_tg_ph]);
DEBUG_MASSINFO("PrepareDp","RealTh=%f,\tL_tr_tg_th=%f",
eventdata.Data[kRealThMatrix],eventdata.Data[kL_tr_tg_th]);
DEBUG_MASSINFO("PrepareDp","RealPh=%f,\tkL_tr_tg_ph=%f",
eventdata.Data[kRealPhi],eventdata.Data[kL_tr_tg_ph]);
DEBUG_MASSINFO("PrepareDp","SieveHoleY=%f,\tMom.Y=%f,\tMom.Z=%f",
SieveHoleTCS.y(),MomDirectionTCS.Y(),MomDirectionTCS.Z());
dth+=eventdata.Data[kRealThMatrix]-eventdata.Data[kL_tr_tg_th];
dphi+=eventdata.Data[kRealPhi]-eventdata.Data[kL_tr_tg_ph];
TVector3 MomDirectionHCS = fTCSInHCS*MomDirectionTCS;
TVector3 BeamDirection(0,0,1);
const Double_t ScatteringAngle = BeamDirection.Angle(MomDirectionHCS);
eventdata.Data[kScatterAngle] = ScatteringAngle;
scatang+=ScatteringAngle;
const Double_t DM = ExcitationEnergy[KineID];
const Double_t Ma = GroundNuclearMass;
const Double_t P0 = eventdata.Data[kurb_e];
const Double_t DpKinOffsets =
(ScatMom(DM, Ma, P0, ScatteringAngle)
-ScatMom(DM, Ma, P0, HRSAngle))/eventdata.Data[kCentralp];
eventdata.Data[kDpKinOffsets] = DpKinOffsets;
dpkinoff += DpKinOffsets;
dpkinoff_rms += DpKinOffsets*DpKinOffsets;
eventdata.Data[kRadiLossDp]
= RadiationLossByFoil[FoilID] / eventdata.Data[kCentralp];
eventdata.Data[kRealDpKin] =
ScatMom(DM, Ma, P0, HRSAngle)/eventdata.Data[kCentralp]- 1 -eventdata.Data[kRadiLossDp] ;
eventdata.Data[kRealDpKinMatrix]=eventdata.Data[kRealDpKin] - x_tg/ExtTarCor_DeltaCorr;
exttargcorr_dp+=x_tg/ExtTarCor_DeltaCorr;
rms_exttargcorr_dp+=(x_tg/ExtTarCor_DeltaCorr)*(x_tg/ExtTarCor_DeltaCorr);
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
assert(kRealDpKinExcitations+ExcitID<kRealTh);
eventdata.Data[kRealDpKinExcitations+ExcitID] =
ScatMom(ExcitationEnergyList[ExcitID], Ma, P0, HRSAngle)/
eventdata.Data[kCentralp]-1;
}
DEBUG_MASSINFO("PrepareDp","ScatterAngle=%f,\tDpKinOffsets=%f",
ScatteringAngle/TMath::Pi()*180,DpKinOffsets);
if (idx>0)
{
const EventData &lasteventdata = fRawData[idx-1];
if (eventdata.Data[kRunNum] == lasteventdata.Data[kRunNum])
{
assert(eventdata.Data[kKineID] == lasteventdata.Data[kKineID]);
assert(TMath::Abs(eventdata.Data[kCentralp]-lasteventdata.Data[kCentralp])<1e-5);
assert(TMath::Abs(eventdata.Data[kRealDpKin]-lasteventdata.Data[kRealDpKin])<4e-3);
}
else
{
DEBUG_INFO("PrepareDp","Run %4.0f : Kinematics #%1.0f, Central p = %fGeV, Excit. State Selected=%f MeV, Dp Kin=%f%%"
,eventdata.Data[kRunNum]
,eventdata.Data[kKineID]
,eventdata.Data[kCentralp]
,1000*ExcitationEnergy[KineID]
,100*eventdata.Data[kRealDpKin]);
}
}
else
{
DEBUG_INFO("PrepareDp","Run %4.0f : Kinematics #%1.0f, Central p = %fGeV, Excit. State Selected=%f MeV, Dp Kin=%f%%"
,eventdata.Data[kRunNum]
,eventdata.Data[kKineID]
,eventdata.Data[kCentralp]
,1000*ExcitationEnergy[KineID]
,100*eventdata.Data[kRealDpKin]);
}
}
DEBUG_INFO("PrepareDp","%d out of %d data is for calibration"
,fNCalibData,fNRawData);
DEBUG_INFO("PrepareDp","Average : D_Th = %f,\t D_Phi = %f",dth/fNRawData,dphi/fNRawData);
DEBUG_INFO("PrepareDp","Average : ScatteringAngle = %f",scatang/fNRawData/TMath::Pi()*180);
DEBUG_INFO("PrepareDp","Average DpKinOffsets = %f, RMS DpKinOffsets = %f"
,dpkinoff/fNRawData,TMath::Sqrt(dpkinoff_rms/fNRawData));
DEBUG_INFO("PrepareDp","Average Extended Target Corretion: dp = %f,\t rms_dp = %f"
,exttargcorr_dp/fNRawData,TMath::Sqrt(rms_exttargcorr_dp/fNRawData));
SumSquareDTh();
SumSquareDPhi();
SumSquareDp();
}
TCanvas * LOpticsOpt::CheckSieve()
{
DEBUG_INFO("CheckSieve","Entry Point");
TH2D * HSievePlane[NFiols] = {0};
for(UInt_t idx = 0; idx<NFiols; idx++)
{
HSievePlane[idx] = new TH2D(Form("Sieve_Foil%d",idx),
Form("Sieve Plane (tg_X vs tg_Y) for Foil #%d",idx),
1000,-.05,.05,1000,-.1,.1
);
assert(HSievePlane[idx]);
}
Double_t dX = 0, dY=0;
enum {kEventID, kRealSieveX, kRealSieveY, kCalcSieveX, kCalcSieveY};
Double_t SieveEventID[NFiols][NSieve][NSieve][5]={{{{0}}}};
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
const EventData &eventdata = fRawData[idx];
UInt_t res = (UInt_t)eventdata.Data[kCutID];
const UInt_t FoilID = res/(NSieve*NSieve);
res = res%(NSieve*NSieve);
const UInt_t Col = res/(NSieve);
const UInt_t Row = res%(NSieve);
assert(FoilID<NFiols);
TVector3 SieveHoleTCS(
SieveOffX + (-1.*Row+3.)*SieveSpaceX,
SieveOffY + (-1.*Col+3.)*SieveSpaceY,
ZPos
);
TVector3 BeamSpotHCS(
eventdata.Data[kBeamX],
eventdata.Data[kBeamY],
targetfoils[FoilID]
);
TVector3 BeamSpotTCS=fTCSInHCS.Inverse()*(BeamSpotHCS-fPointingOffset);
TVector3 MomDirectionTCS = SieveHoleTCS - BeamSpotTCS;
Double_t ProjectionX = BeamSpotTCS.X()
+ (eventdata.Data[kCalcTh]+eventdata.Data[kRealTgX]*ExtTarCor_ThetaCorr) * (SieveHoleTCS.Z() - BeamSpotTCS.Z());
Double_t ProjectionY = BeamSpotTCS.Y()
+ eventdata.Data[kCalcPh] * (SieveHoleTCS.Z() - BeamSpotTCS.Z());
HSievePlane[FoilID]->Fill(ProjectionY,ProjectionX);
dX+= ProjectionX - SieveHoleTCS.X();
dY+= ProjectionY - SieveHoleTCS.Y();
SieveEventID[FoilID][Col][Row][kEventID] = idx;
SieveEventID[FoilID][Col][Row][kRealSieveX] = SieveHoleTCS.X();
SieveEventID[FoilID][Col][Row][kRealSieveY] = SieveHoleTCS.Y();
SieveEventID[FoilID][Col][Row][kCalcSieveX] = ProjectionX;
SieveEventID[FoilID][Col][Row][kCalcSieveY] = ProjectionY;
}
DEBUG_INFO("CheckSieve","Average : D_X = %f,\t D_Y = %f",dX/fNRawData,dY/fNRawData);
TCanvas * c1 = new TCanvas("SieveCheck","SieveCheck",1900,1100);
c1->Divide(3,2);
for(UInt_t idx = 0; idx<NFiols; idx++)
{
UInt_t FoilID = idx;
c1->cd(idx+1);
assert(HSievePlane[idx]);
HSievePlane[idx]->Draw("COLZ");
Double_t MaxPlot = .05;
for(UInt_t Row = 0; Row < NSieve; Row++)
{
Double_t SievePos = SieveOffX + (-1.*Row+3.)*SieveSpaceX;
TLine *l = new TLine(-MaxPlot,SievePos,+MaxPlot,SievePos);
l->SetLineColor(6);
l->Draw();
}
MaxPlot = .1;
for(UInt_t Col = 0; Col < NSieve; Col++)
{
Double_t SievePos = SieveOffY + (-1.*Col+3.)*SieveSpaceY;
TLine *l = new TLine(SievePos,-MaxPlot,SievePos,MaxPlot);
l->SetLineColor(6);
l->Draw();
}
for(UInt_t Col = 0; Col < NSieve; Col++){
for(UInt_t Row = 0; Row < NSieve; Row++){
if (SieveEventID[FoilID][Col][Row][kEventID]>0)
{
assert(SieveEventID[FoilID][Col][Row][kEventID] < fNRawData);
TArrow * ar2 = new TArrow(SieveEventID[FoilID][Col][Row][kCalcSieveY]
,SieveEventID[FoilID][Col][Row][kCalcSieveX]
,SieveEventID[FoilID][Col][Row][kRealSieveY]
,SieveEventID[FoilID][Col][Row][kRealSieveX]
,0.008,"|>");
ar2->SetAngle(40);
ar2->SetLineColor(6);
ar2->SetFillColor(3);
ar2->Draw();
}
}
}
}
return c1;
}
TCanvas * LOpticsOpt::CheckVertex()
{
DEBUG_INFO("CheckVertex","Entry Point");
const Double_t VertexRange=.25;
TH2D * hYVSReactZ = new TH2D("hYVSReactZ","Rot. Y VS ReactZ",1000,-VertexRange,VertexRange, 1000,-.1,.1);
TH2D * hPhVSReactZ = new TH2D("hPhVSReactZ","Rot. Ph VS ReactZ",1000,-VertexRange,VertexRange, 1000,-.05,.05);
TH1D * hReactZ = new TH1D("hReactZ","LHRS ReactZ",400,-VertexRange,VertexRange);
Double_t dtg_vz = 0, dtg_vz_rms = 0, reactz=0;
Double_t dtg_vz_foil[NFiols] ={0};
Double_t dtg_y_foil[NFiols] ={0};
Double_t rmstg_vz_foil[NFiols] ={0};
Double_t rmstg_y_foil[NFiols] ={0};
UInt_t ndata_foil[NFiols] ={0};
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
EventData &eventdata = fRawData[idx];
TVector3 Tg_YSpotTCS(0
,eventdata.Data[kCalcTgY]
,0
);
TVector3 MomDirectionTCS(0
,eventdata.Data[kL_tr_tg_ph]
,1
);
TVector3 Tg_YSpotHCS=fTCSInHCS*Tg_YSpotTCS+fPointingOffset;
TVector3 MomDirectionHCS=fTCSInHCS*MomDirectionTCS;
assert(Tg_YSpotHCS.Y()==MissPointY);
assert(MomDirectionHCS.Y()==0);
reactz = Tg_YSpotHCS.Z()
- (Tg_YSpotHCS.X()-eventdata.Data[kBeamX])
/MomDirectionHCS.X()*MomDirectionHCS.Z();
eventdata.Data[kCalcReactZ] = reactz;
dtg_vz += reactz - eventdata.Data[kRealReactZ];
dtg_vz_rms += (reactz - eventdata.Data[kRealReactZ])*(reactz - eventdata.Data[kRealReactZ]);
hYVSReactZ->Fill(reactz,eventdata.Data[kY]);
hPhVSReactZ->Fill(reactz,eventdata.Data[kPhi]);
hReactZ->Fill(reactz);
const UInt_t FoilID = (UInt_t)eventdata.Data[kCutID];
ndata_foil[FoilID]++;
dtg_vz_foil[FoilID] += eventdata.Data[kCalcReactZ] - eventdata.Data[kRealReactZ];
rmstg_vz_foil[FoilID] += (eventdata.Data[kCalcReactZ] - eventdata.Data[kRealReactZ])*(eventdata.Data[kCalcReactZ] - eventdata.Data[kRealReactZ]);
dtg_y_foil[FoilID] += eventdata.Data[kCalcTgY] - eventdata.Data[kRealTgY];
rmstg_y_foil[FoilID] += (eventdata.Data[kCalcTgY] - eventdata.Data[kRealTgY])*(eventdata.Data[kCalcTgY] - eventdata.Data[kRealTgY]);
}
DEBUG_INFO("CheckVertex","dtg_vz = %f,\t dtg_vz_rms = %f",dtg_vz/fNRawData,dtg_vz_rms/fNRawData);
TCanvas * c1 = new TCanvas("CheckVertex","SieveCheck",1800,900);
c1->Divide(1,3);
UInt_t idx=1;
c1->cd(idx++);
hYVSReactZ->Draw("COLZ");
c1->cd(idx++);
hPhVSReactZ->Draw("COLZ");
c1->cd(idx++);
hReactZ->Draw();
for(idx = 1; idx<=3; idx++)
{
c1->cd(idx);
for(UInt_t FoilID = 0; FoilID<NFiols; FoilID++)
{
const Double_t MaxPlot = 2000;
TLine *l = new TLine(targetfoils[FoilID],-MaxPlot,targetfoils[FoilID],+MaxPlot);
l->SetLineColor(6);
l->Draw();
}
}
cout<<"Statistic on each foils:\n";
cout<<"Foil ID\td_vz\trms_vz\td_tgy\trms_tgy\n";
for(UInt_t FoilID = 0; FoilID<NFiols; FoilID++)
{
assert(ndata_foil[FoilID]);
const UInt_t N = ndata_foil[FoilID];
printf("%d\t%f\t%f\t%f\t%f\n",FoilID
,dtg_vz_foil[FoilID]/N
,rmstg_vz_foil[FoilID]/N
,dtg_y_foil[FoilID]/N
,rmstg_y_foil[FoilID]/N);
}
return c1;
}
TCanvas * LOpticsOpt::CheckDp()
{
DEBUG_INFO("CheckDp","Entry Point");
SumSquareDp(kTRUE);
const Double_t DpRange=.05;
const UInt_t NDpRange=800;
TH1D * hDpKinCalib[NKine];
TH1D * hDpKinAll[NKine];
Double_t RealDpKin[NKine];
Double_t AverCalcDpKin[NKine]={0};
UInt_t NEvntDpKin[NKine]={0};
Double_t RealDpKinAllExcit[NExcitationStates][NKine];
Double_t NewArbitaryDpKinShift[NKine];
for(UInt_t KineID=0; KineID<NKine; KineID++)
{
hDpKinCalib[KineID]
= new TH1D(Form("hDpKinCalib%d",KineID)
,Form("Dp_Kin for Delta Scan Kine. #%d (Selected Exct. State)",KineID)
,NDpRange,-DpRange,DpRange);
hDpKinAll[KineID]
= new TH1D(Form("hDpKinAll%d",KineID)
,Form("Dp_Kin for Delta Scan Kine. #%d (All Data)",KineID)
,NDpRange,-DpRange,DpRange);
assert(hDpKinCalib[KineID]);
assert(hDpKinAll[KineID]);
}
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
const EventData &eventdata = fRawData[idx];
const UInt_t ExtraDataFlag = (UInt_t)(eventdata.Data[kExtraDataFlag]);
assert(ExtraDataFlag==0 || ExtraDataFlag==1);
const UInt_t KineID = (UInt_t)(eventdata.Data[kKineID]);
assert(KineID<NKine);
if (!ExtraDataFlag)
{
hDpKinCalib[KineID]->Fill(eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp]);
AverCalcDpKin[KineID]+=
eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp];
NEvntDpKin[KineID]++;
}
hDpKinAll[KineID]->Fill(eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp]);
RealDpKin[KineID] = eventdata.Data[kRealDpKin]+eventdata.Data[kRadiLossDp];
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
assert(kRealDpKinExcitations+ExcitID<kRealTh);
RealDpKinAllExcit[ExcitID][KineID]
=eventdata.Data[kRealDpKinExcitations+ExcitID];
}
}
TCanvas * c1 = new TCanvas("CheckDp","Check Dp Kin Reconstruction",1800,900);
c1->Divide(3,2);
UInt_t idx=1;
for(UInt_t KineID=0; KineID<NKine; KineID++)
{
c1->cd(idx++);
gPad -> SetLogy();
AverCalcDpKin[KineID]/=NEvntDpKin[KineID];
DEBUG_MASSINFO("CheckDp","AverCalcDpKin[%d] = %f"
,KineID,AverCalcDpKin[KineID]);
hDpKinCalib[KineID]->SetLineColor(4);
hDpKinCalib[KineID]->SetFillColor(4);
hDpKinCalib[KineID]->SetFillStyle(3008);
hDpKinAll[KineID]->SetLineColor(1);
const Double_t dpRange=0.01;
hDpKinCalib[KineID]->
SetAxisRange(RealDpKin[KineID]-dpRange,RealDpKin[KineID]+dpRange);
hDpKinAll[KineID]->
SetAxisRange(RealDpKin[KineID]-dpRange,RealDpKin[KineID]+dpRange);
hDpKinCalib[KineID]
->SetXTitle("radiation corrected dp_kin (angular independant dp)");
hDpKinAll[KineID]
->SetXTitle("radiation corrected dp_kin (angular independant dp)");
hDpKinAll[KineID]->Draw();
hDpKinCalib[KineID]->Draw("SAME");
const Double_t MaxPlot = 20000;
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
const Double_t x = RealDpKinAllExcit[ExcitID][KineID];
TLine *l = new TLine(x,0,x,+MaxPlot);
l->SetLineColor(3);
l->SetLineWidth(2);
l->Draw();
}
TLine *l = new TLine(RealDpKin[KineID],0,RealDpKin[KineID],+MaxPlot);
l->SetLineColor(6);
l->SetLineWidth(2);
l->Draw();
const Double_t DefResolution = 5e-4;
const Double_t FitRangeMultiply = 2;
TString FitFunc = Form("DpPeak%d",KineID);
TF1 *f = new TF1(FitFunc,"gaus+[3]+[4]*x"
,AverCalcDpKin[KineID]-DefResolution*FitRangeMultiply
,AverCalcDpKin[KineID]+DefResolution*FitRangeMultiply);
f->SetParameter(1,AverCalcDpKin[KineID]);
f->SetParameter(2,DefResolution);
hDpKinAll[KineID] -> Fit(FitFunc,"RN0");
f->SetLineColor(2);
f->Draw("SAME");
TLatex *t = new TLatex(f->GetParameter(1)+DefResolution
,f->GetParameter(0)+f->GetParameter(3)+f->GetParameter(4)*f->GetParameter(1)
,Form("\\Delta \\pm \\sigma = %2.1f \\pm %2.1f \\times 10^{-4}"
,10000*(f->GetParameter(1)-RealDpKin[KineID])
,10000*f->GetParameter(2)));
t->SetTextSize(0.05);
t->SetTextAlign(12);
t->SetTextColor(2);
t->Draw();
NewArbitaryDpKinShift[KineID] =
f->GetParameter(1)-RealDpKin[KineID]+fArbitaryDpKinShift[KineID];
}
Info("CheckDp","New set of arbitary dp shifts:");
for(UInt_t KineID=0; KineID<NKine; KineID++)
printf("opt->fArbitaryDpKinShift[%d] = %e;\n"
,KineID,NewArbitaryDpKinShift[KineID]);
return c1;
}
TCanvas * LOpticsOpt::CheckDpVSAngle()
{
DEBUG_INFO("CheckDpVSAngle","Entry Point");
SumSquareDp(kTRUE);
const Double_t DpRange=.05;
const UInt_t NDpRange=800*5;
const Double_t AngleRange=2;
const UInt_t NAngleRange=100*5;
TH2D * hDpKinCalib[NKine];
TH2D * hDpKinAll[NKine];
Double_t RealDpKin[NKine];
Double_t RealDpKinAllExcit[NExcitationStates][NKine];
for(UInt_t KineID=0; KineID<NKine; KineID++)
{
hDpKinCalib[KineID]
= new TH2D(Form("hDpKinCalibVSAngle%d",KineID)
,Form("Dp_Kin for Delta Scan Kine. #%d (Selected Exct. State)",KineID)
,NDpRange,-DpRange,DpRange
,NAngleRange,HRSAngle/TMath::Pi()*180-AngleRange,HRSAngle/TMath::Pi()*180+AngleRange);
hDpKinAll[KineID]
= new TH2D(Form("hDpKinAllVSAngle%d",KineID)
,Form("Dp_Kin for Delta Scan Kine. #%d (All Data)",KineID)
,NDpRange,-DpRange,DpRange
,NAngleRange,HRSAngle/TMath::Pi()*180-AngleRange,HRSAngle/TMath::Pi()*180+AngleRange);
assert(hDpKinCalib[KineID]);
assert(hDpKinAll[KineID]);
}
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
const EventData &eventdata = fRawData[idx];
const UInt_t ExtraDataFlag = (UInt_t)(eventdata.Data[kExtraDataFlag]);
assert(ExtraDataFlag==0 || ExtraDataFlag==1);
const UInt_t KineID = (UInt_t)(eventdata.Data[kKineID]);
assert(KineID<NKine);
if (!ExtraDataFlag)
{
hDpKinCalib[KineID]
->Fill(eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp]
,+eventdata.Data[kScatterAngle]/TMath::Pi()*180);
}
hDpKinAll[KineID]
->Fill(eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp]
,+eventdata.Data[kScatterAngle]/TMath::Pi()*180);
RealDpKin[KineID] = eventdata.Data[kRealDpKin]+eventdata.Data[kRadiLossDp];
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
assert(kRealDpKinExcitations+ExcitID<kRealTh);
RealDpKinAllExcit[ExcitID][KineID]
=eventdata.Data[kRealDpKinExcitations+ExcitID];
}
}
TCanvas * c1 = new TCanvas("CheckDpVSAngle","Check Dp Kin Reconstruction VS Scattering Angle",1800,900);
c1->Divide(3,2);
UInt_t idx=1;
for(UInt_t KineID=0; KineID<NKine; KineID++)
{
c1->cd(idx++);
const Double_t dpRange=0.01;
hDpKinCalib[KineID]->
SetAxisRange(RealDpKin[KineID]-dpRange,RealDpKin[KineID]+dpRange);
hDpKinAll[KineID]->
SetAxisRange(RealDpKin[KineID]-dpRange,RealDpKin[KineID]+dpRange);
hDpKinCalib[KineID]
->SetXTitle("radiation corrected dp_kin (angular independant dp)");
hDpKinCalib[KineID]
->SetYTitle("Scattering Angle (Degree)");
hDpKinAll[KineID]
->SetXTitle("radiation corrected dp_kin (angular independant dp)");
hDpKinAll[KineID]
->SetYTitle("Scattering Angle (Degree)");
hDpKinAll[KineID]->Draw("COLZ");
const Double_t MinPlot = HRSAngle/TMath::Pi()*180-AngleRange;
const Double_t MaxPlot = HRSAngle/TMath::Pi()*180+AngleRange;
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
const Double_t x = RealDpKinAllExcit[ExcitID][KineID];
TLine *l = new TLine(x,MinPlot,x,+MaxPlot);
l->SetLineColor(3);
l->SetLineWidth(2);
l->Draw();
}
TLine *l = new TLine(RealDpKin[KineID],MinPlot,RealDpKin[KineID],+MaxPlot);
l->SetLineColor(6);
l->SetLineWidth(2);
l->Draw();
}
return c1;
}
TCanvas * LOpticsOpt::CheckDpVSCutID()
{
DEBUG_INFO("CheckDpVSCutID","Entry Point");
SumSquareDp(kTRUE);
const Double_t DpRange=.05;
const UInt_t NDpRange=800*5;
const UInt_t NCutID = NSieve*NSieve*NFiols;
const Double_t CutIDRangeLow = -.5;
const Double_t CutIDRangeHigh= -.5+NCutID;
TH2D * hDpKinCalib[NKine];
TH2D * hDpKinAll[NKine];
Double_t RealDpKin[NKine];
Double_t RealDpKinAllExcit[NExcitationStates][NKine];
for(UInt_t KineID=0; KineID<NKine; KineID++)
{
hDpKinCalib[KineID]
= new TH2D(Form("hDpKinCalibVSCutID%d",KineID)
,Form("Dp_Kin for Delta Scan Kine. #%d (Selected Exct. State)",KineID)
,NDpRange,-DpRange,DpRange
,NCutID,CutIDRangeLow,CutIDRangeHigh);
hDpKinAll[KineID]
= new TH2D(Form("hDpKinAllVSCutID%d",KineID)
,Form("Dp_Kin for Delta Scan Kine. #%d (All Data)",KineID)
,NDpRange,-DpRange,DpRange
,NCutID,CutIDRangeLow,CutIDRangeHigh);
assert(hDpKinCalib[KineID]);
assert(hDpKinAll[KineID]);
}
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
const EventData &eventdata = fRawData[idx];
const UInt_t ExtraDataFlag = (UInt_t)(eventdata.Data[kExtraDataFlag]);
assert(ExtraDataFlag==0 || ExtraDataFlag==1);
const UInt_t KineID = (UInt_t)(eventdata.Data[kKineID]);
assert(KineID<NKine);
if (!ExtraDataFlag)
{
hDpKinCalib[KineID]
->Fill(eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp]
,((UInt_t)eventdata.Data[kCutID])%NCutID);
}
hDpKinAll[KineID]
->Fill(eventdata.Data[kCalcDpKin]+eventdata.Data[kRadiLossDp]
,((UInt_t)eventdata.Data[kCutID])%NCutID);
RealDpKin[KineID] = eventdata.Data[kRealDpKin]+eventdata.Data[kRadiLossDp];
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
assert(kRealDpKinExcitations+ExcitID<kRealTh);
RealDpKinAllExcit[ExcitID][KineID]
=eventdata.Data[kRealDpKinExcitations+ExcitID];
}
}
TCanvas * c1 = new TCanvas("CheckDpVSCutID","Check Dp Kin Reconstruction VS Scattering Angle",1800,900);
c1->Divide(3,2);
UInt_t idx=1;
for(UInt_t KineID=0; KineID<NKine; KineID++)
{
c1->cd(idx++);
const Double_t dpRange=0.01;
hDpKinCalib[KineID]->
SetAxisRange(RealDpKin[KineID]-dpRange,RealDpKin[KineID]+dpRange);
hDpKinAll[KineID]->
SetAxisRange(RealDpKin[KineID]-dpRange,RealDpKin[KineID]+dpRange);
hDpKinCalib[KineID]
->SetXTitle("radiation corrected dp_kin (angular independant dp)");
hDpKinCalib[KineID]
->SetYTitle("combination of foil and sieve hole ID");
hDpKinAll[KineID]
->SetXTitle("radiation corrected dp_kin (angular independant dp)");
hDpKinAll[KineID]
->SetYTitle("combination of foil and sieve hole ID");
hDpKinAll[KineID]->Draw("COLZ");
const Double_t MinPlot = CutIDRangeLow;
const Double_t MaxPlot = CutIDRangeHigh;
for (UInt_t ExcitID = 0; ExcitID<NExcitationStates; ExcitID++)
{
const Double_t x = RealDpKinAllExcit[ExcitID][KineID];
TLine *l = new TLine(x,MinPlot,x,+MaxPlot);
l->SetLineColor(3);
l->SetLineWidth(2);
l->Draw();
}
for(UInt_t FoilID = 0; FoilID<NFiols; FoilID++)
{
const Double_t y = FoilID*NSieve*NSieve-.5;
TLine *l = new TLine(RealDpKin[KineID]-dpRange,y,RealDpKin[KineID]+dpRange,y);
l->SetLineColor(5);
l->SetLineWidth(1);
l->Draw();
}
TLine *l = new TLine(RealDpKin[KineID],MinPlot,RealDpKin[KineID],+MaxPlot);
l->SetLineColor(6);
l->SetLineWidth(2);
l->Draw();
}
return c1;
}
Double_t LOpticsOpt::VerifyMatrix_Sieve(void)
{
Double_t dth = 0, dphi=0;
Double_t rmsth = 0, rmsphi=0;
Double_t theta, phi;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
const EventData eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fDMatrixElems);
CalcMatrix(x_fp, fTMatrixElems);
CalcMatrix(x_fp, fYMatrixElems);
CalcMatrix(x_fp, fYTAMatrixElems);
CalcMatrix(x_fp, fPMatrixElems);
CalcMatrix(x_fp, fPTAMatrixElems);
theta = CalcTargetVar(fTMatrixElems, powers);
phi = CalcTargetVar(fPMatrixElems, powers)+CalcTargetVar(fPTAMatrixElems,powers);
dth += theta - eventdata.Data[kL_tr_tg_th];
rmsth += (theta - eventdata.Data[kL_tr_tg_th])*(theta - eventdata.Data[kL_tr_tg_th]);
dphi += phi - eventdata.Data[kL_tr_tg_ph];
rmsphi += (phi - eventdata.Data[kL_tr_tg_ph])*(phi - eventdata.Data[kL_tr_tg_ph]);
}
DEBUG_INFO("VerifyMatrix_Sieve","dth = %f,rmsth=%f",
dth/fNRawData,TMath::Sqrt(rmsth/fNRawData));
DEBUG_INFO("VerifyMatrix_Sieve","dphi = %f, rmsphi=%f",
dphi/fNRawData,TMath::Sqrt(rmsphi/fNRawData));
return TMath::Sqrt(rmsth/fNRawData+rmsphi/fNRawData);
}
Double_t LOpticsOpt::VerifyMatrix_Vertex(void)
{
Double_t dtg_y=0;
Double_t dtg_y_rms=0;
Double_t y/*, pathl*/;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
const EventData eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fYMatrixElems);
y = CalcTargetVar(fYMatrixElems, powers);
dtg_y += y - eventdata.Data[kL_tr_tg_y];
dtg_y_rms += (y - eventdata.Data[kL_tr_tg_y])*(y - eventdata.Data[kL_tr_tg_y]);
DEBUG_MASSINFO("VerifyMatrix_Vertex","y = %f; eventdata.Data[kL_tr_tg_y] = %f",
y , eventdata.Data[kL_tr_tg_y]);
}
DEBUG_INFO("VerifyMatrix_Vertex","dtg_y = %f,dtg_y_rms=%f",
dtg_y/fNRawData,TMath::Sqrt(dtg_y_rms/fNRawData));
return TMath::Sqrt(dtg_y_rms/fNRawData);
}
Double_t LOpticsOpt::VerifyMatrix_Dp(void)
{
Double_t d_dp = 0;
Double_t rms_dp = 0;
static UInt_t NCall = 0;
NCall++;
for (UInt_t idx = 0; idx<fNRawData; idx++)
{
Double_t dp, dp_kin;
EventData &eventdata = fRawData[idx];
Double_t x_fp = eventdata.Data[kX];
const Double_t (*powers)[5] = eventdata.powers;
CalcMatrix(x_fp, fDMatrixElems);
dp = CalcTargetVar(fDMatrixElems, powers);
dp_kin = dp - eventdata.Data[kDpKinOffsets];
d_dp += dp - eventdata.Data[kL_tr_tg_dp];
rms_dp += (dp - eventdata.Data[kL_tr_tg_dp])*(dp - eventdata.Data[kL_tr_tg_dp]);
DEBUG_MASSINFO("SumSquareDp","d_dp = %f = \t%f - \t%f",
dp_kin - eventdata.Data[kRealDpKin], dp_kin , eventdata.Data[kRealDpKin] );
}
DEBUG_INFO("VerifyMatrix_Dp","(dp_Calc - dp in root tree) = d_dp = %f, rms_d_dp=%f",
d_dp/fNRawData,TMath::Sqrt(rms_dp/fNRawData));
return TMath::Sqrt(rms_dp/fNRawData);
}
LOpticsOpt::LOpticsOpt( const char* name, const char* description,
THaApparatus* apparatus ) :
THaTrackingDetector(name,description,apparatus)
{
fPrefix="L.vdc.";
fCurrentMatrixElems = NULL;
TVector3 TCSX(0,-1,0);
TVector3 TCSZ(TMath::Sin(HRSAngle),0,TMath::Cos(HRSAngle));
TVector3 TCSY = TCSZ.Cross(TCSX);
fTCSInHCS.RotateAxes(TCSX,TCSY,TCSZ);
fPointingOffset.SetXYZ(
-MissPointZ*TMath::Sin(HRSAngle)*TMath::Cos(HRSAngle)
,(Double_t)MissPointY
,MissPointZ*TMath::Sin(HRSAngle)*TMath::Sin(HRSAngle)
);
DEBUG_INFO("LOpticsOpt","HRS @ %f Degree, PointingOffset = (%f,%f,%f)",
HRSAngle/TMath::Pi()*180,
fPointingOffset.X(),fPointingOffset.Y(),fPointingOffset.Z());
fNRawData=0;
for(UInt_t i=0; i<100; i++)
fArbitaryDpKinShift[i] = fArbitaryVertexShift[i] = 0;
}
Int_t LOpticsOpt::LoadDataBase( TString DataBaseName )
{
FILE* file = fopen( DataBaseName,"r" );
if( !file ) {
Error("LoadDataBase","%s can not be opened", DataBaseName.Data());
return kFileError;
}
else DEBUG_INFO("LoadDataBase","Parsing Database %s", DataBaseName.Data());
static const char* const here = "LoadDataBase";
const int LEN = 200;
char buff[LEN];
TString tag(fPrefix);
Ssiz_t pos = tag.Index(".");
if( pos != kNPOS )
tag = tag(0,pos+1);
else
tag.Append(".");
tag.Prepend("[");
tag.Append("global]");
TString line, tag2(tag);
tag.ToLower();
bool found = false;
while (!found && fgets (buff, LEN, file) != NULL) {
char* buf = ::Compress(buff);
line = buf;
delete [] buf;
if( line.EndsWith("\n") ) line.Chop();
line.ToLower();
if ( tag == line )
found = true;
}
if( !found ) {
Error(Here(here), "Database entry %s not found!", tag2.Data() );
fclose(file);
return kInitError;
}
fgets(buff, LEN, file);
fgets(buff, LEN, file);
fTMatrixElems.clear();
fDMatrixElems.clear();
fPMatrixElems.clear();
fPTAMatrixElems.clear();
fYMatrixElems.clear();
fYTAMatrixElems.clear();
fLMatrixElems.clear();
fFPMatrixElems.clear();
fFPMatrixElems.resize(3);
typedef vector<string>::size_type vsiz_t;
map<string,vsiz_t> power;
power["t"] = 3;
power["y"] = 3;
power["p"] = 3;
power["D"] = 3;
power["T"] = 3;
power["Y"] = 3;
power["YTA"] = 4;
power["P"] = 3;
power["PTA"] = 4;
power["L"] = 4;
power["XF"] = 5;
power["TF"] = 5;
power["PF"] = 5;
power["YF"] = 5;
map<string,vector<THaMatrixElement>*> matrix_map;
matrix_map["t"] = &fFPMatrixElems;
matrix_map["y"] = &fFPMatrixElems;
matrix_map["p"] = &fFPMatrixElems;
matrix_map["D"] = &fDMatrixElems;
matrix_map["T"] = &fTMatrixElems;
matrix_map["Y"] = &fYMatrixElems;
matrix_map["YTA"] = &fYTAMatrixElems;
matrix_map["P"] = &fPMatrixElems;
matrix_map["PTA"] = &fPTAMatrixElems;
matrix_map["L"] = &fLMatrixElems;
map <string,int> fp_map;
fp_map["t"] = 0;
fp_map["y"] = 1;
fp_map["p"] = 2;
while( fgets(buff, LEN, file) ) {
string line(buff);
if( line.size() > 0 && line[line.size()-1] == '\n' ) {
buff[line.size()-1] = 0;
line.erase(line.size()-1,1);
}
vector<string> line_spl = Split(line);
if(line_spl.empty())
continue;
const char* w = line_spl[0].c_str();
vsiz_t npow = power[w];
if( npow == 0 )
break;
#if DEBUG_LEVEL>=4
cout<<"Matrix Line = ";
for (pos=1; (UInt_t)pos<(UInt_t)line_spl.size(); pos++) {
cout<< pos <<"("<<line_spl[pos].c_str()<<"), ";
}
cout<<endl;
#endif
THaMatrixElement ME;
ME.pw.resize(npow);
ME.iszero = true; ME.order = 0;
vsiz_t pos;
for (pos=1; pos<=npow && pos<line_spl.size(); pos++) {
ME.pw[pos-1] = atoi(line_spl[pos].c_str());
}
vsiz_t p_cnt;
for ( p_cnt=0; pos<line_spl.size() && p_cnt<kPORDER && pos<=npow+kPORDER;
pos++,p_cnt++ )
{
ME.poly[p_cnt] = atof(line_spl[pos].c_str());
if (ME.poly[p_cnt] != 0.0) {
ME.iszero = false;
ME.order = p_cnt+1;
}
}
if (p_cnt < 1) {
Error(Here(here), "Could not read in Matrix Element %s%d%d%d!",
w, ME.pw[0], ME.pw[1], ME.pw[2]);
Error(Here(here), "Line looks like: %s",line.c_str());
fclose(file);
return kInitError;
}
ME.OptOrder = atoi(line_spl[line_spl.size()-1].c_str());
if( ME.iszero )
continue;
vector<THaMatrixElement> *mat = matrix_map[w];
if (mat) {
if( mat == &fFPMatrixElems ) {
if( ME.pw[0] == 0 && ME.pw[1] == 0 && ME.pw[2] == 0 ) {
THaMatrixElement& m = (*mat)[fp_map[w]];
if( m.order > 0 ) {
Warning(Here(here), "Duplicate definition of focal plane "
"matrix element: %s. Using first definition.", buff);
} else
m = ME;
} else
Warning(Here(here), "Bad coefficients of focal plane matrix "
"element %s", buff);
}
else {
bool match = false;
for( vector<THaMatrixElement>::iterator it = mat->begin();
it != mat->end() && !(match = it->match(ME)); it++ ) {}
if( match ) {
Warning(Here(here), "Duplicate definition of "
"matrix element: %s. Using first definition.", buff);
} else
mat->push_back(ME);
}
}
else if ( fDebug > 0 )
Warning(Here(here), "Not storing matrix for: %s !", w);
}
CalcMatrix(1.,fLMatrixElems);
fIsInit = true;
fclose(file);
return kOK;
}
LOpticsOpt::~LOpticsOpt()
{
}
void LOpticsOpt::CalcTargetCoords(THaTrack *track, const ECoordTypes mode)
{
Double_t x_fp, y_fp, th_fp, ph_fp;
Double_t powers[kNUM_PRECOMP_POW][5];
Double_t x, y, theta, phi, dp, p, pathl;
if(mode == kTransport) {
x_fp = track->GetX();
y_fp = track->GetY();
th_fp = track->GetTheta();
ph_fp = track->GetPhi();
} else {
x_fp = track->GetRX();
y_fp = track->GetRY();
th_fp = track->GetRTheta();
ph_fp = track->GetRPhi();
}
for(int i=0; i<kNUM_PRECOMP_POW; i++) {
powers[i][0] = pow(x_fp, i);
powers[i][1] = pow(th_fp, i);
powers[i][2] = pow(y_fp, i);
powers[i][3] = pow(ph_fp, i);
powers[i][4] = pow(TMath::Abs(th_fp),i);
}
CalcMatrix(x_fp, fDMatrixElems);
CalcMatrix(x_fp, fTMatrixElems);
CalcMatrix(x_fp, fYMatrixElems);
CalcMatrix(x_fp, fYTAMatrixElems);
CalcMatrix(x_fp, fPMatrixElems);
CalcMatrix(x_fp, fPTAMatrixElems);
theta = CalcTargetVar(fTMatrixElems, powers);
phi = CalcTargetVar(fPMatrixElems, powers)+CalcTargetVar(fPTAMatrixElems,powers);
y = CalcTargetVar(fYMatrixElems, powers)+CalcTargetVar(fYTAMatrixElems,powers);
THaSpectrometer *app = static_cast<THaSpectrometer*>(GetApparatus());
dp = CalcTargetVar(fDMatrixElems, powers);
p = app->GetPcentral() * (1.0+dp);
pathl = CalcTarget2FPLen(fLMatrixElems, powers);
x = 0.0;
track->SetTarget(x, y, theta, phi);
track->SetDp(dp);
track->SetMomentum(p);
track->SetPathLen(pathl);
app->TransportToLab( p, theta, phi, track->GetPvect() );
}
void LOpticsOpt::CalcMatrix( const Double_t x, vector<THaMatrixElement>& matrix )
{
for( vector<THaMatrixElement>::iterator it=matrix.begin();
it!=matrix.end(); it++ ) {
it->v = 0.0;
if(it->order > 0) {
for(int i=it->order-1; i>=1; i--)
it->v = x * (it->v + it->poly[i]);
it->v += it->poly[0];
}
}
}
Double_t LOpticsOpt::CalcTargetVar(const vector<THaMatrixElement>& matrix,
const Double_t powers[][5])
{
Double_t retval=0.0;
Double_t v=0;
for( vector<THaMatrixElement>::const_iterator it=matrix.begin();
it!=matrix.end(); it++ )
if(it->v != 0.0) {
v = it->v;
unsigned int np = it->pw.size();
for (unsigned int i=0; i<np; i++)
v *= powers[it->pw[i]][i+1];
retval += v;
}
return retval;
}
Double_t LOpticsOpt::CalcTarget2FPLen(const vector<THaMatrixElement>& matrix,
const Double_t powers[][5])
{
Double_t retval=0.0;
for( vector<THaMatrixElement>::const_iterator it=matrix.begin();
it!=matrix.end(); it++ )
if(it->v != 0.0)
retval += it->v * powers[it->pw[0]][0]
* powers[it->pw[1]][1]
* powers[it->pw[2]][2]
* powers[it->pw[3]][3];
return retval;
}
UInt_t LOpticsOpt::LoadRawData(TString DataFileName,UInt_t NLoad)
{
DEBUG_INFO("LoadRawData","Loading %s",DataFileName.Data());
FILE* file = fopen( DataFileName,"r" );
if( !file ) return kFileError;
UInt_t NRead = 0;
const int LEN = 2000;
char buff[LEN];
Double_t NDataRead = 0;
while( fgets(buff, LEN, file) ) {
assert(NRead<MaxNRawData);
if (NRead>=NLoad) continue;
Double_t * eventdata = fRawData[NRead].Data;
string line(buff);
if( line.size() > 0 && line[line.size()-1] == '\n' ) {
buff[line.size()-1] = 0;
line.erase(line.size()-1,1);
}
vector<string> line_spl = Split(line);
assert(line_spl.size()<=MaxNEventData);
for(UInt_t idx = 0; idx<line_spl.size(); idx++)
eventdata[idx] = atof(line_spl[idx].c_str());
NDataRead+=line_spl.size();
Double_t (*powers)[5] = fRawData[NRead].powers;
Double_t x_fp = eventdata[kX];
Double_t th_fp = eventdata[kTh];
Double_t y_fp = eventdata[kY];
Double_t ph_fp = eventdata[kPhi];
for(int i=0; i<kNUM_PRECOMP_POW; i++) {
powers[i][0] = pow(x_fp, i);
powers[i][1] = pow(th_fp, i);
powers[i][2] = pow(y_fp, i);
powers[i][3] = pow(ph_fp, i);
powers[i][4] = pow(TMath::Abs(th_fp),i);
}
NRead++;
}
fclose(file);
fNRawData = NRead;
fNCalibData = NRead;
DEBUG_INFO("LoadRawData","%d events x %f record/event read from %s",
fNRawData,NDataRead/fNRawData,DataFileName.Data());
return NRead;
}
UInt_t LOpticsOpt::Matrix2Array(Double_t Array[], const std::vector<THaMatrixElement> &Matrix, Bool_t FreeParaFlag[])
{
typedef vector<THaMatrixElement>::size_type vsiz_t;
UInt_t idx =0;
for (vsiz_t i=0; i<Matrix.size(); i++) {
const THaMatrixElement& m = Matrix[i];
UInt_t j;
for (j=0; (int)j<m.order; j++) {
if (FreeParaFlag) FreeParaFlag[idx] = j<m.OptOrder?kTRUE:kFALSE;
Array[idx++]=m.poly[j];
}
for (; j<kPORDER; j++) {
if (FreeParaFlag) FreeParaFlag[idx] = j<m.OptOrder?kTRUE:kFALSE;
Array[idx++]=0;
}
}
DEBUG_INFO("Matrix2Array","Fill Size = %d",idx);
return idx;
}
UInt_t LOpticsOpt::Array2Matrix(const Double_t Array[], std::vector<THaMatrixElement> &Matrix)
{
typedef vector<THaMatrixElement>::size_type vsiz_t;
UInt_t idx =0;
for (vsiz_t i=0; i<Matrix.size(); i++) {
THaMatrixElement& m = Matrix[i];
int j;
m.order = kPORDER;
for (j=0; j<m.order; j++) {
m.poly[j]=Array[idx++];
}
m.SkimPoly();
}
DEBUG_INFO("Array2Matrix","Load Size = %d",idx);
return idx;
}
void LOpticsOpt::Print(const Option_t* opt) const
{
THaTrackingDetector::Print(opt);
typedef vector<THaMatrixElement>::size_type vsiz_t;
printf("LOpticsOpt::Print: Transport Matrix: D-terms\n");
for (vsiz_t i=0; i<fDMatrixElems.size(); i++) {
const THaMatrixElement& m = fDMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
printf(" %2d",m.pw[j]);
}
for (int j=0; j<m.order; j++) {
printf("\t%g",m.poly[j]);
}
printf(" : Opt -> %d",m.OptOrder);
if ((UInt_t)m.order!=m.OptOrder) printf(" != Matrix Order !!");
printf("\n");
}
printf("LOpticsOpt::Print: Transport Matrix: T-terms\n");
for (vsiz_t i=0; i<fTMatrixElems.size(); i++) {
const THaMatrixElement& m = fTMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
printf(" %2d",m.pw[j]);
}
for (int j=0; j<m.order; j++) {
printf("\t%g",m.poly[j]);
}
printf(" : Opt -> %d",m.OptOrder);
if ((UInt_t)m.order!=m.OptOrder) printf(" != Matrix Order !!");
printf("\n");
}
printf("LOpticsOpt::Print: Transport Matrix: Y-terms\n");
for (vsiz_t i=0; i<fYMatrixElems.size(); i++) {
const THaMatrixElement& m = fYMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
printf(" %2d",m.pw[j]);
}
for (int j=0; j<m.order; j++) {
printf("\t%g",m.poly[j]);
}
printf(" : Opt -> %d",m.OptOrder);
if ((UInt_t)m.order!=m.OptOrder) printf(" != Matrix Order !!");
printf("\n");
}
printf("LOpticsOpt::Print: Transport Matrix: P-terms\n");
for (vsiz_t i=0; i<fPMatrixElems.size(); i++) {
const THaMatrixElement& m = fPMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
printf(" %2d",m.pw[j]);
}
for (int j=0; j<m.order; j++) {
printf("\t%g",m.poly[j]);
}
printf(" : Opt -> %d",m.OptOrder);
if ((UInt_t)m.order!=m.OptOrder) printf(" != Matrix Order !!");
printf("\n");
}
printf("fArbitaryVertexShift[%d] = {",NFiols);
for(UInt_t FoilID = 0; FoilID<NFiols; FoilID++)
printf("%f ",fArbitaryVertexShift[FoilID]);
printf("}\n");
printf("fArbitaryDpKinShift[%d] = {",NKine);
for(UInt_t KineID=0; KineID<NKine; KineID++)
printf("%f ",fArbitaryDpKinShift[KineID]);
printf("}\n");
return;
}
Int_t LOpticsOpt::SaveDataBase(TString DataBaseName)
{
DEBUG_INFO("SaveDataBase","Saving to %s",DataBaseName.Data());
typedef vector<THaMatrixElement>::size_type vsiz_t;
FILE* file = fopen( DataBaseName,"w" );
if( !file ) {
Info("SaveDataBase","Error Openin %s",DataBaseName.Data());
return kFileError;
}
fprintf(file,"[ L.global ]");fprintf(file,"\n");
fprintf(file,"0.3327 1 0.0 270.2 0.0 -1.6e-03 VDC Angle, Plane Spacing, Gamma Coefficents");fprintf(file,"\n");
fprintf(file,"matrix elements");fprintf(file,"\n");
fprintf(file,"t 0 0 0 -1.001135e+00 -3.313373e-01 -4.290819e-02 4.470852e-03 0.000000e+00 0.000000e+00 0.000000e+00 0");fprintf(file,"\n");
fprintf(file,"y 0 0 0 -8.060915e-03 1.071977e-03 9.019102e-04 -3.239615e-04 0.000000e+00 0.000000e+00 0.000000e+00 0");fprintf(file,"\n");
fprintf(file,"p 0 0 0 -2.861912e-03 -2.469069e-03 8.427172e-03 2.274635e-03 0.000000e+00 0.000000e+00 0.000000e+00 0");fprintf(file,"\n");
DEBUG_INFO("SaveDataBase","Transport Matrix: D-terms");
for (vsiz_t i=0; i<fDMatrixElems.size(); i++) {
fprintf(file,"D ");
const THaMatrixElement& m = fDMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
fprintf(file,"%d ",m.pw[j]);
}
int j;
for (j=0; j<m.order; j++) {
fprintf(file," %13.6e",m.poly[j]);
}
for (; j<kPORDER; j++) {
fprintf(file," %13.6e",0.0);
}
fprintf(file," %d",m.OptOrder);
fprintf(file,"\n");
}
DEBUG_INFO("SaveDataBase","Transport Matrix: T-terms");
for (vsiz_t i=0; i<fTMatrixElems.size(); i++) {
fprintf(file,"T ");
const THaMatrixElement& m = fTMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
fprintf(file,"%d ",m.pw[j]);
}
int j;
for (j=0; j<m.order; j++) {
fprintf(file," %13.6e",m.poly[j]);
}
for (; j<kPORDER; j++) {
fprintf(file," %13.6e",0.0);
}
fprintf(file," %d",m.OptOrder);
fprintf(file,"\n");
}
DEBUG_INFO("SaveDataBase","Transport Matrix: P-terms");
for (vsiz_t i=0; i<fPMatrixElems.size(); i++) {
fprintf(file,"P ");
const THaMatrixElement& m = fPMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
fprintf(file,"%d ",m.pw[j]);
}
int j;
for (j=0; j<m.order; j++) {
fprintf(file," %13.6e",m.poly[j]);
}
for (; j<kPORDER; j++) {
fprintf(file," %13.6e",0.0);
}
fprintf(file," %d",m.OptOrder);
fprintf(file,"\n");
}
DEBUG_INFO("SaveDataBase","Transport Matrix: Y-terms");
for (vsiz_t i=0; i<fYMatrixElems.size(); i++) {
fprintf(file,"Y ");
const THaMatrixElement& m = fYMatrixElems[i];
for (vsiz_t j=0; j<m.pw.size(); j++) {
fprintf(file,"%d ",m.pw[j]);
}
int j;
for (j=0; j<m.order; j++) {
fprintf(file," %13.6e",m.poly[j]);
}
for (; j<kPORDER; j++) {
fprintf(file," %13.6e",0.0);
}
fprintf(file," %d",m.OptOrder);
fprintf(file,"\n");
}
fprintf(file,"L 0 0 0 0 25.713");fprintf(file,"\n");
fprintf(file,"L 1 0 0 0 0.1650 ");fprintf(file,"\n");
fprintf(file,"L 2 0 0 0 -0.05");fprintf(file,"\n");
fprintf(file,"L 0 1 0 0 -11.6554");fprintf(file,"\n");
fprintf(file,"L 0 2 0 0 -9.4951");fprintf(file,"\n");
fprintf(file,"L 0 0 1 0 0.0");fprintf(file,"\n");
fprintf(file,"L 0 0 2 0 0.0");fprintf(file,"\n");
fprintf(file,"L 0 0 0 1 0.0");fprintf(file,"\n");
fprintf(file,"L 0 0 0 2 0.0");fprintf(file,"\n");
fprintf(file,"XF 1 0 0 0 0 -2.181E+00");fprintf(file,"\n");
fprintf(file,"XF 0 1 0 0 0 -1.980E-01");fprintf(file,"\n");
fprintf(file,"XF 0 0 0 0 1 1.191E+01");fprintf(file,"\n");
fprintf(file,"TF 1 0 0 0 0 -1.000E-01");fprintf(file,"\n");
fprintf(file,"TF 0 1 0 0 0 -4.690E-01");fprintf(file,"\n");
fprintf(file,"TF 0 0 0 0 1 1.967E+00");fprintf(file,"\n");
fprintf(file,"PF 0 0 1 0 0 3.630E-01");fprintf(file,"\n");
fprintf(file,"PF 0 0 0 1 0 -0.902E+00");fprintf(file,"\n");
fprintf(file,"YF 0 0 1 0 0 -5.950E-01");fprintf(file,"\n");
fprintf(file,"YF 0 0 0 1 0 -1.274E+00");fprintf(file,"\n");
fclose(file);
return kOK;
}
bool THaMatrixElement::match(const THaMatrixElement& rhs) const
{
if( pw.size() != rhs.pw.size() )
return false;
for( vector<int>::size_type i=0; i<pw.size(); i++ ) {
if( pw[i] != rhs.pw[i] )
return false;
}
return true;
}
void THaMatrixElement::SkimPoly()
{
if (iszero) return;
while(!poly[order-1] && order >0)
{
poly.pop_back();
order = order-1;
}
if (order==0) iszero = kTRUE;
}
THaAnalysisObject::EStatus LOpticsOpt::Init( const TDatime& )
{
return fStatus = kOK;
}
Int_t LOpticsOpt::ConstructTracks( TClonesArray* , Int_t )
{
return 0;
}
void LOpticsOpt::Clear( Option_t* )
{
}
Int_t LOpticsOpt::Decode( const THaEvData& )
{
return 0;
}
Int_t LOpticsOpt::CoarseTrack( TClonesArray& )
{
return 0;
}
Int_t LOpticsOpt::FineTrack( TClonesArray& )
{
return 0;
}
Int_t LOpticsOpt::FindVertices( TClonesArray& tracks )
{
Int_t n_exist = tracks.GetLast()+1;
for( Int_t t = 0; t < n_exist; t++ ) {
THaTrack* theTrack = static_cast<THaTrack*>( tracks.At(t) );
CalcTargetCoords(theTrack, kRotatingTransport);
}
return 0;
}
ClassImp(LOpticsOpt);
Last change: Sat Aug 29 01:15:07 2009
Last generated: 2009-08-29 01:15
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.