35#include "GPUParam.inc"
50int32_t genEvents::GetSector(
double GlobalPhi)
52 double phi = GlobalPhi;
61 return (int32_t)(
phi / mSectorDAngle);
64int32_t genEvents::GetDSector(
double LocalPhi) {
return GetSector(LocalPhi + mSectorAngleOffset); }
66double genEvents::GetSectorAngle(int32_t
iSector) {
return mSectorAngleOffset +
iSector * mSectorDAngle; }
70 double phi = atan2(t.GetY(), t.GetX());
72 int32_t dSector = GetDSector(phi);
78 double dAlpha = dSector * mSectorDAngle;
90double genEvents::GetGaus(
double sigma)
94 x = gRandom->Gaus(0., sigma);
95 if (fabs(
x) <= 3.5 * sigma) {
104 for (int32_t
i = 0;
i < 3;
i++) {
105 for (int32_t
j = 0;
j < 2;
j++) {
106 char name[1024], title[1024];
108 snprintf(
name, 1024,
"clError%s%d", (
j == 0 ?
"Y" :
"Z"),
i);
110 snprintf(title, 1024,
"Cluster %s Error for row region %d", (
j == 0 ?
"Y" :
"Z"),
i);
112 mClusterError[
i][
j] =
new TH1F(
name, title, 1000, 0., .7);
113 mClusterError[
i][
j]->GetXaxis()->SetTitle(
"Cluster Error [cm]");
120 TFile* tout =
new TFile(
"generator.root",
"RECREATE");
121 TCanvas*
c =
new TCanvas(
"ClusterErrors",
"Cluste rErrors", 0, 0, 700, 700. * 2. / 3.);
124 for (int32_t
j = 0;
j < 2;
j++) {
125 for (int32_t
i = 0;
i < 3;
i++) {
135 mClusterError[k][
j]->Write();
138 mClusterError[k][
j]->Draw();
143 c->Print(
"plots/clusterErrors.pdf");
153 mRec->ClearIOPointers();
154 static int32_t iEvent = -1;
161 cout <<
"NTracks " << nTracks << endl;
162 std::vector<GPUTPCMCInfo> mcInfo(nTracks);
163 memset(mcInfo.data(), 0, nTracks *
sizeof(mcInfo[0]));
171 prop.SetPolynomialField(&merger.Param().polynomialField);
176 std::vector<GenCluster> vClusters;
177 int32_t clusterId = 0;
181 for (int32_t itr = 0; itr < nTracks; itr++) {
185 mcInfo[itr].pid = -100;
187 mcInfo[itr].prim = 1;
188 mcInfo[itr].primDaughters = 0;
197 double dphi = mTwoPi / nTracks;
198 double phi = mSectorAngleOffset + dphi * itr;
199 double eta = gRandom->Uniform(-1.5, 1.5);
201 double theta = 2 * std::atan(1. /
exp(eta));
202 double lambda = theta - M_PI / 2;
204 double pt = .08 * std::pow(10, gRandom->Uniform(0, 2.2));
207 int32_t
iSector = GetSector(phi);
211 double x0 = cosf(phi);
212 double y0 = sinf(phi);
213 double z0 = tanf(lambda);
214 t.Set(
x0,
y0, z0, pt *
x0, pt *
y0, pt * z0, q);
216 if (RecalculateSector(t,
iSector) != 0) {
217 std::cout <<
"Initial sector wrong!!!" << std::endl;
223 float xRow = GPUTPCGeometry::Row2X(iRow);
226 for (int32_t itry = 0; itry < 1; itry++) {
228 prop.GetBxByBz(GetSectorAngle(
iSector), t.GetX(), t.GetY(), t.GetZ(),
B);
230 err = t.PropagateToXBxByBz(xRow,
B[0],
B[1],
B[2], dLp);
232 std::cout <<
"Can not propagate to x = " << xRow << std::endl;
236 if (fabsf(t.GetZ()) >= GPUTPCGeometry::TPCLength()) {
237 std::cout <<
"Can not propagate to x = " << xRow <<
": Z outside the volume" << std::endl;
243 int32_t isNewSector = RecalculateSector(t,
iSector);
247 std::cout <<
"track " << itr <<
": new sector " <<
iSector <<
" at row " << iRow << std::endl;
260 tg.Rotate(-GetSectorAngle(
iSector));
263 mcInfo[itr].charge = 3 * q;
264 mcInfo[itr].x = tg.GetX();
265 mcInfo[itr].y = tg.GetY();
266 mcInfo[itr].z = tg.GetZ();
267 mcInfo[itr].pX = tg.GetPx();
268 mcInfo[itr].pY = tg.GetPy();
269 mcInfo[itr].pZ = tg.GetPz();
277 const int32_t rowType = iRow < 64 ? 0 : iRow < 128 ? 2 : 1;
279 param.GetClusterErrors2(
iSector, rowType, t.GetZ(), t.GetSinPhi(), t.GetDzDs(), -1.f, 0.f, 0.f, sigmaY, sigmaZ);
280 sigmaY = std::sqrt(sigmaY);
281 sigmaZ = std::sqrt(sigmaZ);
282 mClusterError[rowType][0]->Fill(sigmaY);
283 mClusterError[rowType][1]->Fill(sigmaZ);
291 c.y = t.GetY() + GetGaus(sigmaY);
292 c.z = t.GetZ() + GetGaus(sigmaZ);
294 vClusters.push_back(
c);
298 std::vector<AliHLTTPCClusterMCLabel>
labels;
304 int32_t nNumberOfHits = 0;
305 for (uint32_t
i = 0;
i < vClusters.size();
i++) {
306 if (vClusters[
i].sector ==
iSector) {
311 mRec->mIOPtrs.nClusterData[
iSector] = nNumberOfHits;
316 for (uint32_t
i = 0;
i < vClusters.size();
i++) {
317 GenCluster&
c = vClusters[
i];
327 for (int32_t
j = 0;
j < 3;
j++) {
333 labels.push_back(clusterLabel);
341 mRec->mIOPtrs.nMCLabelsTPC =
labels.size();
342 mRec->mIOPtrs.mcLabelsTPC =
labels.data();
344 mRec->mIOPtrs.nMCInfosTPC = mcInfo.size();
345 mRec->mIOPtrs.mcInfosTPC = mcInfo.data();
347 mRec->mIOPtrs.mcInfosTPCCol = &mcColInfo;
348 mRec->mIOPtrs.nMCInfosTPCCol = 1;
359 mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
362 gen->InitEventGenerator();
368 gen->FinishEventGenerator();
std::vector< std::string > labels
default_random_engine gen(dev())
uint64_t exp(uint64_t base, uint8_t exp) noexcept
#define GPUCA_EVDUMP_FILE
static constexpr int32_t NSECTORS
const GPUParam & GetParam() const
void DumpSettings(const char *dir="")
float const GPUParam float float float float float int32_t int16_t uint8_t float float float charge
static constexpr uint32_t NROWS
void InitEventGenerator()
int32_t GenerateEvent(const GPUParam §orParam, const char *filename)
void FinishEventGenerator()
static void RunEventGenerator(GPUChainTracking *rec, const std::string &dir)
GLuint const GLchar * name
GLuint GLfloat GLfloat y0
GPUSettingsStandalone configStandalone
std::string to_string(gsl::span< T, Size > span)
AliHLTTPCClusterMCWeight fClusterID[3]
std::vector< Cluster > clusters