ROOT logo
//_HADES_CLASS_DESCRIPTION 
////////////////////////////////////////////////////////////////////////////
//*-- AUTHOR : G. Kornakov
//
// HParticlePathLengthCorr
//
// Reconstructor to recalulate the path length for the event vertex.
// Beta and Mass of the particle are recalutated. HParticlePathLengthCorr
// can be run by  HParticleT0Reco automatically if enabled.
//
//  setBeamTime() has to be set for the correct data set (default "apr12")
//
//--------------------------------------------------------------------------
// USAGE:
//
//  HParticlePathLengthCorr pathCorr;
//  pathCorr.setBeamTime("apr12");
//
//  // 2 possible ways :
//  a. As Reconstructor add it to standard task list
//  b. With HLoop :
//
//     before eventLoop :  pathCorr.init();
//     inside eventloop :  pathCorr.execute();
//
//
////////////////////////////////////////////////////////////////////////////
#include "hparticlepathlengthcorr.h"
#include "hparticlecand.h"
#include "heventheader.h"
#include "hades.h"
#include "hevent.h"
#include "hgeomvector.h"
#include "hcategory.h"
#include "TMath.h"

ClassImp(HParticlePathLengthCorr)


HParticlePathLengthCorr::HParticlePathLengthCorr(const Text_t* name,const Text_t* title)
    : HReconstructor(name,title)
{
    setBeamTime("apr12");
    candCat = NULL;
}

HParticlePathLengthCorr::~HParticlePathLengthCorr()
{

}

Bool_t HParticlePathLengthCorr::init()
{
    candCat = gHades->getCurrentEvent()->getCategory(catParticleCand); //
    if(!candCat){
	Error("init()","Could not retrieve catParticleCand category!");
	return kFALSE;
    }
    return kTRUE;
}

Bool_t HParticlePathLengthCorr::setBeamTime(TString beamtime)
{
    start = 0.0;
    beamtime.ToLower();
    if(beamtime == "apr12") {
	zVm = -2.9462e+01;
	xVm = 1.03215e-01;
	yVm = 6.80308e-01;
	Double_t tempA[6] = {-0.00244573,0.00203701, 0.00486586,0.00375363, 0.00273255, -0.00214376};
	Double_t tempB[6] = {0.983468,0.983118,0.978343,0.968608,0.971367,0.977932};
	Double_t tempD[6] = {54.1157,55.1195,59.732,66.2281,65.0598,63.026};
	Double_t tempan[6]={0.*TMath::DegToRad(),60.*TMath::DegToRad(),120.*TMath::DegToRad(),180.*TMath::DegToRad(),240.*TMath::DegToRad(),300*TMath::DegToRad()};
	beamVelocity = 0.9015114 ;
	for(Int_t sector=0;sector<6;sector++) {
	    A[sector]  = tempA[sector];
	    B[sector]  = tempB[sector];
	    D[sector]  = tempD[sector];
	    an[sector] = tempan[sector];
	    hPlane[sector].setPlanePar(A[sector]*TMath::Cos(an[sector])-B[sector]*TMath::Sin(an[sector]),A[sector]*TMath::Sin(an[sector])+B[sector]*TMath::Cos(an[sector]),1.0,D[sector]);

	}
	return kTRUE;
    }
    Info("setBeamTime()","Beam time %s is unknown!",beamtime.Data());
    return kFALSE;
}

Int_t HParticlePathLengthCorr::execute()
{
    Float_t newMass2;
    HParticleCand* pCand=0;
    pVertex = (gHades->getCurrentEvent()->getHeader()->getVertexReco()).getPos();
    if(pVertex.X()==-1000. && pVertex.Y()==-1000. && pVertex.Z()==-1000. ) return 0;

    start = (zVm-pVertex.getZ()) /beamVelocity/299.792458;

    if(candCat) {
	for(Int_t i=0;i<candCat->getEntries();i++) {
	    pCand = dynamic_cast<HParticleCand*>(candCat->getObject(i));
	    if(!pCand) continue;
	    if(pCand->getBeta()!=-1 && pCand->isFlagAND(4,
							Particle::kIsAcceptedHitInnerMDC,
							Particle::kIsAcceptedHitOuterMDC,
							Particle::kIsAcceptedHitMETA,
							Particle::kIsAcceptedRK) ) {
		sector      = pCand->getSector();
		Float_t mom = pCand->getMomentum();
		Float_t newPath = pCand->getDistanceToMetaHit();
		Float_t newBeta = pCand->getBeta();
		Float_t tof     = newPath/newBeta/299.792458; //in (ns)
		Float_t xP, yP, zP;
		hPlane[sector].calcSegIntersec(pCand->getZ(), pCand->getR(), pCand->getTheta()*TMath::DegToRad(), pCand->getPhi()*TMath::DegToRad(), xP, yP, zP );
		Float_t rktl = sqrt((xP-xVm)*(xP-xVm)+(yP-yVm)*(yP-yVm)+(zP-zVm)*(zP-zVm) );
		// And the real was:
		Float_t rktl_real = sqrt(  (xP-pVertex.getX())*(xP-pVertex.getX())
					 + (yP-pVertex.getY())*(yP-pVertex.getY())
					 + (zP-pVertex.getZ())*(zP-pVertex.getZ())   );
		// And the new PL is....:
		newPath -=  rktl ;
		newPath +=  rktl_real;
		//Tof correction (ToF of the incident Ion to the center of the target.
		tof += (zVm-pVertex.getZ()) /beamVelocity/299.792458;
		newBeta  =  newPath/tof/299.792458;
		newMass2 =  mom*mom*(1.-newBeta*newBeta)/newBeta/newBeta;
		pCand->setMass2(newMass2);
		pCand->setBeta(newBeta);
		pCand->setDistanceToMetaHit(newPath);
	    }
	}
    }
    return 0;
}



 hparticlepathlengthcorr.cc:1
 hparticlepathlengthcorr.cc:2
 hparticlepathlengthcorr.cc:3
 hparticlepathlengthcorr.cc:4
 hparticlepathlengthcorr.cc:5
 hparticlepathlengthcorr.cc:6
 hparticlepathlengthcorr.cc:7
 hparticlepathlengthcorr.cc:8
 hparticlepathlengthcorr.cc:9
 hparticlepathlengthcorr.cc:10
 hparticlepathlengthcorr.cc:11
 hparticlepathlengthcorr.cc:12
 hparticlepathlengthcorr.cc:13
 hparticlepathlengthcorr.cc:14
 hparticlepathlengthcorr.cc:15
 hparticlepathlengthcorr.cc:16
 hparticlepathlengthcorr.cc:17
 hparticlepathlengthcorr.cc:18
 hparticlepathlengthcorr.cc:19
 hparticlepathlengthcorr.cc:20
 hparticlepathlengthcorr.cc:21
 hparticlepathlengthcorr.cc:22
 hparticlepathlengthcorr.cc:23
 hparticlepathlengthcorr.cc:24
 hparticlepathlengthcorr.cc:25
 hparticlepathlengthcorr.cc:26
 hparticlepathlengthcorr.cc:27
 hparticlepathlengthcorr.cc:28
 hparticlepathlengthcorr.cc:29
 hparticlepathlengthcorr.cc:30
 hparticlepathlengthcorr.cc:31
 hparticlepathlengthcorr.cc:32
 hparticlepathlengthcorr.cc:33
 hparticlepathlengthcorr.cc:34
 hparticlepathlengthcorr.cc:35
 hparticlepathlengthcorr.cc:36
 hparticlepathlengthcorr.cc:37
 hparticlepathlengthcorr.cc:38
 hparticlepathlengthcorr.cc:39
 hparticlepathlengthcorr.cc:40
 hparticlepathlengthcorr.cc:41
 hparticlepathlengthcorr.cc:42
 hparticlepathlengthcorr.cc:43
 hparticlepathlengthcorr.cc:44
 hparticlepathlengthcorr.cc:45
 hparticlepathlengthcorr.cc:46
 hparticlepathlengthcorr.cc:47
 hparticlepathlengthcorr.cc:48
 hparticlepathlengthcorr.cc:49
 hparticlepathlengthcorr.cc:50
 hparticlepathlengthcorr.cc:51
 hparticlepathlengthcorr.cc:52
 hparticlepathlengthcorr.cc:53
 hparticlepathlengthcorr.cc:54
 hparticlepathlengthcorr.cc:55
 hparticlepathlengthcorr.cc:56
 hparticlepathlengthcorr.cc:57
 hparticlepathlengthcorr.cc:58
 hparticlepathlengthcorr.cc:59
 hparticlepathlengthcorr.cc:60
 hparticlepathlengthcorr.cc:61
 hparticlepathlengthcorr.cc:62
 hparticlepathlengthcorr.cc:63
 hparticlepathlengthcorr.cc:64
 hparticlepathlengthcorr.cc:65
 hparticlepathlengthcorr.cc:66
 hparticlepathlengthcorr.cc:67
 hparticlepathlengthcorr.cc:68
 hparticlepathlengthcorr.cc:69
 hparticlepathlengthcorr.cc:70
 hparticlepathlengthcorr.cc:71
 hparticlepathlengthcorr.cc:72
 hparticlepathlengthcorr.cc:73
 hparticlepathlengthcorr.cc:74
 hparticlepathlengthcorr.cc:75
 hparticlepathlengthcorr.cc:76
 hparticlepathlengthcorr.cc:77
 hparticlepathlengthcorr.cc:78
 hparticlepathlengthcorr.cc:79
 hparticlepathlengthcorr.cc:80
 hparticlepathlengthcorr.cc:81
 hparticlepathlengthcorr.cc:82
 hparticlepathlengthcorr.cc:83
 hparticlepathlengthcorr.cc:84
 hparticlepathlengthcorr.cc:85
 hparticlepathlengthcorr.cc:86
 hparticlepathlengthcorr.cc:87
 hparticlepathlengthcorr.cc:88
 hparticlepathlengthcorr.cc:89
 hparticlepathlengthcorr.cc:90
 hparticlepathlengthcorr.cc:91
 hparticlepathlengthcorr.cc:92
 hparticlepathlengthcorr.cc:93
 hparticlepathlengthcorr.cc:94
 hparticlepathlengthcorr.cc:95
 hparticlepathlengthcorr.cc:96
 hparticlepathlengthcorr.cc:97
 hparticlepathlengthcorr.cc:98
 hparticlepathlengthcorr.cc:99
 hparticlepathlengthcorr.cc:100
 hparticlepathlengthcorr.cc:101
 hparticlepathlengthcorr.cc:102
 hparticlepathlengthcorr.cc:103
 hparticlepathlengthcorr.cc:104
 hparticlepathlengthcorr.cc:105
 hparticlepathlengthcorr.cc:106
 hparticlepathlengthcorr.cc:107
 hparticlepathlengthcorr.cc:108
 hparticlepathlengthcorr.cc:109
 hparticlepathlengthcorr.cc:110
 hparticlepathlengthcorr.cc:111
 hparticlepathlengthcorr.cc:112
 hparticlepathlengthcorr.cc:113
 hparticlepathlengthcorr.cc:114
 hparticlepathlengthcorr.cc:115
 hparticlepathlengthcorr.cc:116
 hparticlepathlengthcorr.cc:117
 hparticlepathlengthcorr.cc:118
 hparticlepathlengthcorr.cc:119
 hparticlepathlengthcorr.cc:120
 hparticlepathlengthcorr.cc:121
 hparticlepathlengthcorr.cc:122
 hparticlepathlengthcorr.cc:123
 hparticlepathlengthcorr.cc:124
 hparticlepathlengthcorr.cc:125
 hparticlepathlengthcorr.cc:126
 hparticlepathlengthcorr.cc:127
 hparticlepathlengthcorr.cc:128
 hparticlepathlengthcorr.cc:129
 hparticlepathlengthcorr.cc:130
 hparticlepathlengthcorr.cc:131
 hparticlepathlengthcorr.cc:132
 hparticlepathlengthcorr.cc:133
 hparticlepathlengthcorr.cc:134
 hparticlepathlengthcorr.cc:135
 hparticlepathlengthcorr.cc:136