|
| 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 | +#include "CCDB/BasicCCDBManager.h" |
| 11 | +#include "TH1F.h" |
| 12 | +#include "TH1D.h" |
| 13 | + |
| 14 | +#include <map> |
| 15 | +#include <unordered_set> |
| 16 | + |
| 17 | +class GeneratorPythia8SyntheFlow : public o2::eventgen::GeneratorPythia8 |
| 18 | +{ |
| 19 | +public: |
| 20 | + /// Constructor |
| 21 | + GeneratorPythia8SyntheFlow() { |
| 22 | + lutGen = new o2::eventgen::FlowMapper(); |
| 23 | + |
| 24 | + // -------- CONFIGURE SYNTHETIC FLOW ------------ |
| 25 | + // establish connection to ccdb |
| 26 | + o2::ccdb::CcdbApi ccdb_api; |
| 27 | + ccdb_api.init("https://alice-ccdb.cern.ch"); |
| 28 | + |
| 29 | + // config was placed at midpoint of run 564356, retrieve that |
| 30 | + std::map<string, string> metadataRCT, headers; |
| 31 | + headers = ccdb_api.retrieveHeaders("RCT/Info/RunInformation/564356", metadataRCT, -1); |
| 32 | + int64_t tsSOR = atol(headers["SOR"].c_str()); |
| 33 | + int64_t tsEOR = atol(headers["EOR"].c_str()); |
| 34 | + int64_t midRun = 0.5*tsSOR+0.5*tsEOR; |
| 35 | + |
| 36 | + map<string, string> metadata; // can be empty |
| 37 | + auto list = ccdb_api.retrieveFromTFileAny<TList>("Users/d/ddobrigk/syntheflow", metadata, midRun); |
| 38 | + |
| 39 | + TH1D *hv2vspT = (TH1D*) list->FindObject("hFlowVsPt_ins1116150_v1_Table_1"); |
| 40 | + TH1D *heccvsb = (TH1D*) list->FindObject("hEccentricityVsB"); |
| 41 | + |
| 42 | + cout<<"Generating LUT for flow test"<<endl; |
| 43 | + lutGen->CreateLUT(hv2vspT, heccvsb); |
| 44 | + cout<<"Finished creating LUT!"<<endl; |
| 45 | + // -------- END CONFIGURE SYNTHETIC FLOW ------------ |
| 46 | + } |
| 47 | + |
| 48 | + /// Destructor |
| 49 | + ~GeneratorPythia8SyntheFlow() = default; |
| 50 | + |
| 51 | + //__________________________________________________________________ |
| 52 | + Bool_t generateEvent() override { |
| 53 | + |
| 54 | + // Generate PYTHIA event |
| 55 | + Bool_t lPythiaOK = kFALSE; |
| 56 | + while (!lPythiaOK){ |
| 57 | + lPythiaOK = mPythia.next(); |
| 58 | + } |
| 59 | + |
| 60 | + //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 61 | + // loop over the entire event record and rotate all particles |
| 62 | + // synthetic flow exercise |
| 63 | + // first: get event plane |
| 64 | + float eventPlaneAngle = mPythia.info.hiInfo->phi(); |
| 65 | + float impactParameter = mPythia.info.hiInfo->b(); |
| 66 | + |
| 67 | + for ( Long_t j=0; j < mPythia.event.size(); j++ ) { |
| 68 | + float pyphi = mPythia.event[j].phi(); |
| 69 | + float pypT = mPythia.event[j].pT(); |
| 70 | + |
| 71 | + // calculate delta with EP |
| 72 | + float deltaPhiEP = pyphi - eventPlaneAngle; |
| 73 | + float shift = 0.0; |
| 74 | + while(deltaPhiEP<0.0){ |
| 75 | + deltaPhiEP += 2*TMath::Pi(); |
| 76 | + shift += 2*TMath::Pi(); |
| 77 | + } |
| 78 | + while(deltaPhiEP>2*TMath::Pi()){ |
| 79 | + deltaPhiEP -= 2*TMath::Pi(); |
| 80 | + shift -= 2*TMath::Pi(); |
| 81 | + } |
| 82 | + float newDeltaPhiEP = lutGen->MapPhi(deltaPhiEP, impactParameter, pypT); |
| 83 | + float pyphiNew = newDeltaPhiEP - shift + eventPlaneAngle; |
| 84 | + |
| 85 | + if(pyphiNew>TMath::Pi()) |
| 86 | + pyphiNew -= 2.0*TMath::Pi(); |
| 87 | + if(pyphiNew<-TMath::Pi()) |
| 88 | + pyphiNew += 2.0*TMath::Pi(); |
| 89 | + mPythia.event[j].rot(0.0, pyphiNew-pyphi); |
| 90 | + } |
| 91 | + //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 92 | + |
| 93 | + return true; |
| 94 | + } |
| 95 | + |
| 96 | +private: |
| 97 | + o2::eventgen::FlowMapper *lutGen; // for mapping phi angles |
| 98 | +}; |
| 99 | + |
| 100 | + FairGenerator *generator_syntheFlow() |
| 101 | + { |
| 102 | + auto generator = new GeneratorPythia8SyntheFlow(); |
| 103 | + gRandom->SetSeed(0); |
| 104 | + generator->readString("Random:setSeed = on"); |
| 105 | + generator->readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); |
| 106 | + return generator; |
| 107 | + } |
0 commit comments