|
| 1 | + |
| 2 | +#include "Pythia8/Pythia.h" |
| 3 | +#include "Pythia8/HeavyIons.h" |
| 4 | +#include "FairGenerator.h" |
| 5 | +#include "FairPrimaryGenerator.h" |
| 6 | +#include "Generators/GeneratorPythia8.h" |
| 7 | +#include "TRandom3.h" |
| 8 | +#include "TParticlePDG.h" |
| 9 | +#include "TDatabasePDG.h" |
| 10 | + |
| 11 | +#include <map> |
| 12 | +#include <unordered_set> |
| 13 | + |
| 14 | +class GeneratorPythia8SyntheFlow : public o2::eventgen::GeneratorPythia8 |
| 15 | +{ |
| 16 | +public: |
| 17 | + /// Constructor |
| 18 | + GeneratorPythia8SyntheFlow() { |
| 19 | + lutGen = new o2::eventgen::FlowMapper(); |
| 20 | + |
| 21 | + // -------- CONFIGURE SYNTHETIC FLOW ------------ |
| 22 | + // specify a v2 vs pT here |
| 23 | + TFile *filehep = new TFile("/Users/daviddc/Downloads/HEPData-ins1116150-v1-Table_1.root", "READ"); |
| 24 | + TH1D *hv = (TH1D*) filehep->Get("Table 1/Hist1D_y6"); |
| 25 | + |
| 26 | + TFile *fileEcc = new TFile("/Users/daviddc/Downloads/eccentricityvsb.root", "READ"); |
| 27 | + TH1D *hEccentricities = (TH1D*) fileEcc->Get("hEccentricities"); |
| 28 | + |
| 29 | + cout<<"Generating LUT for flow test"<<endl; |
| 30 | + lutGen->CreateLUT(hv, hEccentricities); |
| 31 | + cout<<"Finished creating LUT!"<<endl; |
| 32 | + // -------- END CONFIGURE SYNTHETIC FLOW ------------ |
| 33 | + } |
| 34 | + |
| 35 | + /// Destructor |
| 36 | + ~GeneratorPythia8SyntheFlow() = default; |
| 37 | + |
| 38 | + //__________________________________________________________________ |
| 39 | + Bool_t generateEvent() override { |
| 40 | + |
| 41 | + // Generate PYTHIA event |
| 42 | + Bool_t lPythiaOK = kFALSE; |
| 43 | + while (!lPythiaOK){ |
| 44 | + lPythiaOK = mPythia.next(); |
| 45 | + } |
| 46 | + |
| 47 | + //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 48 | + // loop over the entire event record and rotate all particles |
| 49 | + // synthetic flow exercise |
| 50 | + // first: get event plane |
| 51 | + float eventPlaneAngle = mPythia.info.hiInfo->phi(); |
| 52 | + float impactParameter = mPythia.info.hiInfo->b(); |
| 53 | + |
| 54 | + for ( Long_t j=0; j < mPythia.event.size(); j++ ) { |
| 55 | + float pyphi = mPythia.event[j].phi(); |
| 56 | + float pypT = mPythia.event[j].pT(); |
| 57 | + |
| 58 | + // calculate delta with EP |
| 59 | + float deltaPhiEP = pyphi - eventPlaneAngle; |
| 60 | + float shift = 0.0; |
| 61 | + while(deltaPhiEP<0.0){ |
| 62 | + deltaPhiEP += 2*TMath::Pi(); |
| 63 | + shift += 2*TMath::Pi(); |
| 64 | + } |
| 65 | + while(deltaPhiEP>2*TMath::Pi()){ |
| 66 | + deltaPhiEP -= 2*TMath::Pi(); |
| 67 | + shift -= 2*TMath::Pi(); |
| 68 | + } |
| 69 | + float newDeltaPhiEP = lutGen->MapPhi(deltaPhiEP, impactParameter, pypT); |
| 70 | + float pyphiNew = newDeltaPhiEP - shift + eventPlaneAngle; |
| 71 | + |
| 72 | + if(pyphiNew>TMath::Pi()) |
| 73 | + pyphiNew -= 2.0*TMath::Pi(); |
| 74 | + if(pyphiNew<-TMath::Pi()) |
| 75 | + pyphiNew += 2.0*TMath::Pi(); |
| 76 | + mPythia.event[j].rot(0.0, pyphiNew-pyphi); |
| 77 | + } |
| 78 | + //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 79 | + |
| 80 | + return true; |
| 81 | + } |
| 82 | + |
| 83 | +private: |
| 84 | + o2::eventgen::FlowMapper *lutGen; // for mapping phi angles |
| 85 | +}; |
| 86 | + |
| 87 | + FairGenerator *generator_syntheFlow() |
| 88 | + { |
| 89 | + return new GeneratorPythia8SyntheFlow(); |
| 90 | + } |
0 commit comments