#include "PEmbeddedParticles.h"
#include "PChannel.h"
PEmbeddedParticles::PEmbeddedParticles() {
local_pos = 0;
for (Int_t i=0; i<MAX_EMBEDDEDPARTICLES; i++) {
local_pMin [i] = 0;
local_pMax [i] = 0;
local_openingAngle[i] = 0;
local_theta [i] = 0;
local_phi [i] = 0;
local_mMax [i] = 0;
local_mMin [i] = 0;
local_thetaMin [i] = 0;
local_thetaMax [i] = 0;
local_phiMin [i] = 0;
local_phiMax [i] = 0;
local_version [i] = 0;
downscaling [i] = 0;
last_downscaling [i] = 0;
local [i] = NULL;
}
vertex_x = makeStaticData()->GetBatchValue("_event_vertex_x");
vertex_y = makeStaticData()->GetBatchValue("_event_vertex_y");
vertex_z = makeStaticData()->GetBatchValue("_event_vertex_z");
}
Bool_t PEmbeddedParticles::SetSampling(Double_t pMin, Double_t pMax,
Double_t openingAngle, Double_t theta,
Double_t phi,
Double_t mMin, Double_t mMax) {
if (local_pos == 0) {
Warning("SetSampling", "no particle defined");
return kFALSE;
}
local_pMin [local_pos - 1] = pMin;
local_pMax [local_pos - 1] = pMax;
local_mMin [local_pos - 1] = mMin;
local_mMax [local_pos - 1] = mMax;
local_openingAngle[local_pos - 1] = -cos(openingAngle);
local_theta [local_pos - 1] = theta;
local_phi [local_pos - 1] = phi;
local_version [local_pos - 1] = 0;
return kTRUE;
};
Bool_t PEmbeddedParticles::SetSamplingSector(Double_t pMin , Double_t pMax,
Double_t thetaMin , Double_t thetaMax,
Double_t phiMin , Double_t phiMax,
Double_t phiStartVal, Int_t numParticle,
Double_t deltaPhi , Int_t numSectors)
{
if(local_pos == 0) {
Warning("SetSamplingSector","no particle defined");
return kFALSE;
}
startPhi = phiStartVal;
nParticle = numParticle;
Int_t addedParticle = 0;
if(nParticle > MAX_EMBEDDEDPARTICLES/numSectors){
nParticle = MAX_EMBEDDEDPARTICLES/numSectors;
Warning("SetSamplingSector()",
"Number of particles /sector > MAX_EMBEDDEDPARTICLES/%i, will be trucated to numParticle = %i .",
numSectors,MAX_EMBEDDEDPARTICLES/numSectors);
}
for(Int_t s = 0; s < numSectors; s ++)
{
for(Int_t n = 0; n < nParticle; n ++){
if(addedParticle > 0){
AddParticle((PParticle*)local[local_pos - 1]->Clone(),
downscaling[local_pos - 1]);
}
Double_t phi_shift = (s * deltaPhi + startPhi) * TMath::DegToRad();
local_pMin [local_pos - 1] = pMin;
local_pMax [local_pos - 1] = pMax;
local_thetaMin[local_pos - 1] = thetaMin * TMath::DegToRad();
local_thetaMax[local_pos - 1] = thetaMax * TMath::DegToRad();
local_phiMin [local_pos - 1] = phi_shift + phiMin * TMath::DegToRad();
local_phiMax [local_pos - 1] = phi_shift + phiMax * TMath::DegToRad();
local_version [local_pos - 1] = 1;
if(local[local_pos - 1]->M() > 0){
local_mMax [local_pos - 1] = -1;
}
addedParticle ++;
}
}
return kTRUE;
}
Bool_t PEmbeddedParticles::AddParticle(PParticle * particle, int downsc) {
if (local_pos == MAX_EMBEDDEDPARTICLES ) {
cout << "MAX_EMBEDDEDPARTICLES reached" << endl;
return kFALSE;
}
downscaling [local_pos] = downsc;
last_downscaling[local_pos] = 1;
local [local_pos ++] = particle;
return kTRUE;
}
Bool_t PEmbeddedParticles::Modify(PParticle **mstack, int *, int *num, int stacksize) {
int cur = *num;
Double_t p,cos_theta,sin_theta,theta,phi,m;
for (int i=0; i<local_pos; i++) {
if (last_downscaling[i] == downscaling[i])
{
last_downscaling[i] = 1;
*(mstack[cur]) = *(local[i]);
mstack[cur]->SetVertex(*vertex_x,
*vertex_y,
*vertex_z,0.);
mstack[cur]->SetSourceId(EMBEDDED_SOURCE_ID);
mstack[cur]->SetProperTime();
if (local_pMax[i] > 0) {
if (local_version[i] == 0) {
p = local_pMin[i] + (PUtils::sampleFlat() * (local_pMax[i] - local_pMin[i]));
theta = acos(1. - ((local_openingAngle[i] + 1) * PUtils::sampleFlat()));
phi = 2. * TMath::Pi() * PUtils::sampleFlat();
sin_theta = sin(theta);
mstack[cur]->SetPx(p * cos(phi) * sin_theta);
mstack[cur]->SetPy(p * sin(phi) * sin_theta);
mstack[cur]->SetPz(p * cos(theta));
mstack[cur]->RotateY(local_theta[i]);
mstack[cur]->RotateZ(local_phi [i]);
if (local_mMax[i] < 0.) {
mstack[cur]->SetM(local[i]->M());
} else {
m = local_mMin[i] + (PUtils::sampleFlat() * (local_mMax[i] - local_mMin[i])) ;
mstack[cur]->SetM(m);
}
}
else if (local_version[i] == 1) {
cos_theta = cos(local_thetaMin[i]) + (PUtils::sampleFlat() * (cos(local_thetaMax[i]) - cos(local_thetaMin[i])));
p = local_pMin [i] + (PUtils::sampleFlat() * (local_pMax [i] - local_pMin [i]));
phi = local_phiMin[i] + (PUtils::sampleFlat() * (local_phiMax[i] - local_phiMin[i]));
theta = acos(cos_theta);
sin_theta = sin(theta);
mstack[cur]->SetPx(p * cos(phi) * sin_theta);
mstack[cur]->SetPy(p * sin(phi) * sin_theta);
mstack[cur]->SetPz(p * cos_theta);
if (local_mMax[i] < 0.) {
mstack[cur]->SetM(local[i]->M());
} else {
mstack[cur]->SetM(makeStaticData()->GetParticleMass(mstack[cur]->ID()));
}
}
}
cur ++;
if (cur == stacksize) {
return kFALSE;
}
} else last_downscaling[i] ++;
}
*num = cur;
return kTRUE;
}
ClassImp(PEmbeddedParticles)
PEmbeddedParticles.cc:100 PEmbeddedParticles.cc:101 PEmbeddedParticles.cc:102 PEmbeddedParticles.cc:103 PEmbeddedParticles.cc:104 PEmbeddedParticles.cc:105 PEmbeddedParticles.cc:106 PEmbeddedParticles.cc:107 PEmbeddedParticles.cc:108 PEmbeddedParticles.cc:109 PEmbeddedParticles.cc:110 PEmbeddedParticles.cc:111 PEmbeddedParticles.cc:112 PEmbeddedParticles.cc:113 PEmbeddedParticles.cc:114 PEmbeddedParticles.cc:115 PEmbeddedParticles.cc:116 PEmbeddedParticles.cc:117 PEmbeddedParticles.cc:118 PEmbeddedParticles.cc:119 PEmbeddedParticles.cc:120 PEmbeddedParticles.cc:121 PEmbeddedParticles.cc:122 PEmbeddedParticles.cc:123 PEmbeddedParticles.cc:124 PEmbeddedParticles.cc:125 PEmbeddedParticles.cc:126 PEmbeddedParticles.cc:127 PEmbeddedParticles.cc:128 PEmbeddedParticles.cc:129 PEmbeddedParticles.cc:130 PEmbeddedParticles.cc:131 PEmbeddedParticles.cc:132 PEmbeddedParticles.cc:133 PEmbeddedParticles.cc:134 PEmbeddedParticles.cc:135 PEmbeddedParticles.cc:136 PEmbeddedParticles.cc:137 PEmbeddedParticles.cc:138 PEmbeddedParticles.cc:139 PEmbeddedParticles.cc:140 PEmbeddedParticles.cc:141 PEmbeddedParticles.cc:142 PEmbeddedParticles.cc:143 PEmbeddedParticles.cc:144 PEmbeddedParticles.cc:145 PEmbeddedParticles.cc:146 PEmbeddedParticles.cc:147 PEmbeddedParticles.cc:148 PEmbeddedParticles.cc:149 PEmbeddedParticles.cc:150 PEmbeddedParticles.cc:151 PEmbeddedParticles.cc:152 PEmbeddedParticles.cc:153 PEmbeddedParticles.cc:154 PEmbeddedParticles.cc:155 PEmbeddedParticles.cc:156 PEmbeddedParticles.cc:157 PEmbeddedParticles.cc:158 PEmbeddedParticles.cc:159 PEmbeddedParticles.cc:160 PEmbeddedParticles.cc:161 PEmbeddedParticles.cc:162 PEmbeddedParticles.cc:163 PEmbeddedParticles.cc:164 PEmbeddedParticles.cc:165 PEmbeddedParticles.cc:166 PEmbeddedParticles.cc:167 PEmbeddedParticles.cc:168 PEmbeddedParticles.cc:169 PEmbeddedParticles.cc:170 PEmbeddedParticles.cc:171 PEmbeddedParticles.cc:172 PEmbeddedParticles.cc:173 PEmbeddedParticles.cc:174 PEmbeddedParticles.cc:175 PEmbeddedParticles.cc:176 PEmbeddedParticles.cc:177 PEmbeddedParticles.cc:178 PEmbeddedParticles.cc:179 PEmbeddedParticles.cc:180 PEmbeddedParticles.cc:181 PEmbeddedParticles.cc:182 PEmbeddedParticles.cc:183 PEmbeddedParticles.cc:184 PEmbeddedParticles.cc:185 PEmbeddedParticles.cc:186 PEmbeddedParticles.cc:187 PEmbeddedParticles.cc:188 PEmbeddedParticles.cc:189 PEmbeddedParticles.cc:190 PEmbeddedParticles.cc:191 PEmbeddedParticles.cc:192 PEmbeddedParticles.cc:193 PEmbeddedParticles.cc:194 PEmbeddedParticles.cc:195 PEmbeddedParticles.cc:196 PEmbeddedParticles.cc:197 PEmbeddedParticles.cc:198 PEmbeddedParticles.cc:199 PEmbeddedParticles.cc:200 PEmbeddedParticles.cc:201 PEmbeddedParticles.cc:202 PEmbeddedParticles.cc:203 PEmbeddedParticles.cc:204 PEmbeddedParticles.cc:205 PEmbeddedParticles.cc:206 PEmbeddedParticles.cc:207 PEmbeddedParticles.cc:208 PEmbeddedParticles.cc:209 PEmbeddedParticles.cc:210 PEmbeddedParticles.cc:211 PEmbeddedParticles.cc:212 PEmbeddedParticles.cc:213 PEmbeddedParticles.cc:214 PEmbeddedParticles.cc:215 PEmbeddedParticles.cc:216 PEmbeddedParticles.cc:217 PEmbeddedParticles.cc:218 PEmbeddedParticles.cc:219 PEmbeddedParticles.cc:220 PEmbeddedParticles.cc:221 PEmbeddedParticles.cc:222 PEmbeddedParticles.cc:223 PEmbeddedParticles.cc:224 PEmbeddedParticles.cc:225 PEmbeddedParticles.cc:226 PEmbeddedParticles.cc:227 PEmbeddedParticles.cc:228 PEmbeddedParticles.cc:229 PEmbeddedParticles.cc:230 PEmbeddedParticles.cc:231 PEmbeddedParticles.cc:232 PEmbeddedParticles.cc:233 PEmbeddedParticles.cc:234 PEmbeddedParticles.cc:235 PEmbeddedParticles.cc:236 PEmbeddedParticles.cc:237 PEmbeddedParticles.cc:238 PEmbeddedParticles.cc:239 PEmbeddedParticles.cc:240 PEmbeddedParticles.cc:241 PEmbeddedParticles.cc:242 PEmbeddedParticles.cc:243 PEmbeddedParticles.cc:244