]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EPOS/TEpos.cxx
Adding helper functions to define 2012 pp data PS and online trigger selection
[u/mrichter/AliRoot.git] / EPOS / TEpos.cxx
index f1bdacabeb7aa7a06c09f54e358a8594df5c37b7..b894541c2f4d01e9fc2e0d98bec6e735f27c3404 100644 (file)
@@ -1,18 +1,18 @@
-/*
- *###################################################################
- *#        EPOS 1.67     K. WERNER, T. PIEROG, S. PORTEBOEUF.       #
- *#                      Contact: werner@subatech.in2p3.fr          #
- *###################################################################
- *
- * TEpos.cxx
- * 
- * Wraper class for interfacing EPOS model, derived from ROOT's TGenerator.
- * It generates temporary input file for the model, providing user with
- * ability to add his/hers own lines to the input.
- * Output is read directly from common blocks.
- *
- *      Author: Piotr Ostrowski, postrow@if.pw.edu.pl
- */
+//
+//###################################################################
+//#        EPOS 1.67     K. WERNER, T. PIEROG, S. PORTEBOEUF.       #
+//#                      Contact: werner@subatech.in2p3.fr          #
+//###################################################################
+//
+// TEpos.cxx
+// 
+// Wraper class for interfacing EPOS model, derived from ROOT's TGenerator.
+// It generates temporary input file for the model, providing user with
+// ability to add his/hers own lines to the input.
+// Output is read directly from common blocks.
+//
+//      Author: Piotr Ostrowski, postrow@if.pw.edu.pl
+//
 
 
 #include <TClonesArray.h>
 #include <TParticle.h>
 #include <TROOT.h>
 #include <TRandom.h>
+#include <TMath.h>
 #include <iostream>
 #include <fstream>
 #include <string>
 #include <vector>
 #include "eposproc.h"
 #include "EPOScommon.h"
+#include "AliGenEposIsajetToPdgConverter.h"
 #include "TEpos.h"
 
 using namespace std;
@@ -41,17 +43,69 @@ TEpos::TEpos()  : TGenerator("EPOS", "Epos event generator"),
                fBminim(0.0),
                fBmaxim(10000.0),
                fPhimin(0.0),
-               fPhimax(2*3.1415927),
+               fPhimax(TMath::TwoPi()),
                fEcms(-1),
                fSplitting(kFALSE),
                fNoDecays(),
-               fExtraInputLines()
+               fExtraInputLines(),
+               fIdConverter()
 {
+       fIdConverter=new AliGenEposIsajetToPdgConverter();
 }
 
-TEpos::~TEpos() {}
+TEpos::TEpos(const TEpos&)  : TGenerator("EPOS", "Epos event generator"),
+               fLaproj(0),
+               fMaproj(0),
+               fLatarg(0),
+               fMatarg(0),
+               fBminim(0.0),
+               fBmaxim(10000.0),
+               fPhimin(0.0),
+               fPhimax(TMath::TwoPi()),
+               fEcms(-1),
+               fSplitting(kFALSE),
+               fNoDecays(),
+               fExtraInputLines(),
+               fIdConverter()
+{
+       fIdConverter = new AliGenEposIsajetToPdgConverter();
+}
+
+TEpos::~TEpos() {
+       delete fIdConverter;
+}
+
+TEpos& TEpos::operator=(const TEpos& epos) {
+  //operator=
+  if (this != &epos) {
+    if (fIdConverter) {
+       delete fIdConverter;
+       fIdConverter = new AliGenEposIsajetToPdgConverter(*epos.fIdConverter);
+    } else{
+       fIdConverter = 0;
+    }
+    fLaproj = epos.fLaproj;
+    fMaproj = epos.fMaproj;
+    fLatarg = epos.fLatarg;
+    fMatarg = epos.fMatarg;
+    fBminim = epos.fBminim;
+    fBmaxim = epos.fBmaxim;
+    fPhimin = epos.fPhimin;
+    fPhimax = epos.fPhimax;
+    fEcms   = epos.fEcms;
+    fSplitting = epos.fSplitting;
+    for(UInt_t i = 0; i < epos.fNoDecays.size(); ++i) {
+      fNoDecays.push_back(epos.fNoDecays[i]);
+    }
+    for(UInt_t i = 0; i < epos.fExtraInputLines.size(); ++i) {
+      fExtraInputLines.push_back(epos.fExtraInputLines[i]);
+    }
+  }
+  return *this;
+}
 
 void TEpos::Initialize() {
+  // Generates input file and prepares EPOS to read from it.
        Int_t nopeno = 0;
        GenerateInputFile();
        aaset(0);
@@ -74,16 +128,17 @@ void TEpos::Initialize() {
                IniModel(appli.model);
        ebin.nrebin = 1;
        ainit();
+       aseed(2);
 }
 
 void TEpos::GenerateEvent() {
-       cseed.seedj = gRandom->Rndm() * 1e10;
-       aseed(2);
+//     cseed.seedj = gRandom->Rndm() * 1e10;
        Int_t n = 1;
        evgen(n);
 }
 
 Int_t TEpos::ImportParticles(TClonesArray *particles, Option_t *) {
+  //Fills provided ClonesArray with generated particles
        particles->Clear();
        if (!cevt.nevt) return 0;
        Int_t numpart = cptl.nptl;
@@ -97,12 +152,8 @@ Int_t TEpos::ImportParticles(TClonesArray *particles, Option_t *) {
                        if (mother->GetFirstDaughter()==-1)
                                mother->SetFirstDaughter(iPart);
                }
-               TDatabasePDG *pdgDb = TDatabasePDG::Instance();
                Int_t status = cptl.istptl[iPart] + 1;
-               Int_t pdg = pdgDb->ConvertIsajetToPdg(cptl.idptl[iPart]);
-               if (pdg == 0) {
-                       printf("TEpos: Warning, unknown particle, index: %d, ISAJET: %d\n",iPart,cptl.idptl[iPart]);
-               }
+               Int_t pdg = fIdConverter->ConvertIsajetToPdg(cptl.idptl[iPart]);
                new((*particles)[iPart]) TParticle(pdg, status,
                                 tFather, -1, -1, -1,
                                 cptl.pptl[iPart][0], cptl.pptl[iPart][1],cptl.pptl[iPart][2],cptl.pptl[iPart][3],
@@ -114,6 +165,7 @@ Int_t TEpos::ImportParticles(TClonesArray *particles, Option_t *) {
 }
 
 TObjArray*  TEpos::ImportParticles(Option_t *) {
+  //Creates new particle array
        fParticles->Clear();
        if (!cevt.nevt) return NULL;
        Int_t numpart = cptl.nptl;
@@ -127,12 +179,8 @@ TObjArray*  TEpos::ImportParticles(Option_t *) {
                        if (mother->GetFirstDaughter()==-1)
                                mother->SetFirstDaughter(iPart);
                }
-               TDatabasePDG *pdgDb = TDatabasePDG::Instance();
                Int_t status = cptl.istptl[iPart] + 1;
-               Int_t pdg = pdgDb->ConvertIsajetToPdg(cptl.idptl[iPart]);
-               if (pdg == 0) {
-                       printf("TEpos: Warning, unknown particle, index: %d, ISAJET: %d\n",iPart,cptl.idptl[iPart]);
-               }
+               Int_t pdg = fIdConverter->ConvertIsajetToPdg(cptl.idptl[iPart]);
                TParticle* p = new TParticle(pdg, status,
                                 tFather, -1, -1, -1,
                                 cptl.pptl[iPart][0], cptl.pptl[iPart][1],cptl.pptl[iPart][2],cptl.pptl[iPart][3],
@@ -153,22 +201,23 @@ void TEpos::AddExtraInputLine(const char *line) {
 }
 
 void TEpos::GenerateInputFile() {
+  // Generate input file in EPOS format
        ofstream file(GetInputFileName(), ios_base::out | ios_base::trunc);
        char epo[256];
        char *epoEnv = getenv("EPO");
        if (epoEnv) {
-               strcpy(epo, epoEnv);
+               strncpy(epo, epoEnv, 255);
        } else {
-               strcpy(epo, getenv("ALICE_ROOT"));
+               strncpy(epo, getenv("ALICE_ROOT"), 255);
        }
-       strcat(epo, "/EPOS/epos167");
+       strncat(epo, "/EPOS/epos167", 255);
 
        file << "fname pathnx " << epo << "/" << endl;
        file << "fname histo none" << endl;
        file << "fname copy none" << endl;
        file << "fname log none" << endl;
        file << "fname check none" << endl;
-       file << "fname data /tmp/epos.out" << endl;
+//     file << "fname data /tmp/epos.out" << endl;
        file << "fname initl " << epo << "/epos.initl" << endl;
        file << "fname inidi " << epo << "/epos.inidi" << endl;
        file << "fname inidr " << epo << "/epos.inidr" << endl;
@@ -219,34 +268,34 @@ void TEpos::GenerateInputFile() {
                file << fExtraInputLines[i] << endl;
        }
 
-    file << "output epos" << endl;
-    file << "record event nevt nptl b endrecord" << endl;
-    file << "record particle i id fa mo c1 c2 st endrecord" << endl;
+//    file << "output epos" << endl;
+//    file << "record event nevt nptl b endrecord" << endl;
+//    file << "record particle i id fa mo c1 c2 st endrecord" << endl;
 
        file << "input " << epo << "/epos.param" << endl;
        file << "runprogram" << endl;
        file.close();
 }
 
-Float_t TEpos::GetBimevt() { return cevt.bimevt; }
-Float_t TEpos::GetPhievt() { return cevt.phievt; }
-Int_t TEpos::GetKolevt() { return cevt.kolevt; }
-Int_t TEpos::GetKoievt() { return cevt.koievt; }
-Float_t TEpos::GetPmxevt() { return cevt.pmxevt; }
-Float_t TEpos::GetEgyevt() { return cevt.egyevt; }
-Int_t TEpos::GetNpjevt() { return cevt.npjevt; }
-Int_t TEpos::GetNtgevt() { return cevt.ntgevt; }
-Int_t TEpos::GetNpnevt() { return cevt.npnevt; }
-Int_t TEpos::GetNppevt() { return cevt.nppevt; }
-Int_t TEpos::GetNtnevt() { return cevt.ntnevt; }
-Int_t TEpos::GetNtpevt() { return cevt.ntpevt; }
-Int_t TEpos::GetJpnevt() { return cevt.jpnevt; }
-Int_t TEpos::GetJppevt() { return cevt.jppevt; }
-Int_t TEpos::GetJtnevt() { return cevt.jtnevt; }
-Int_t TEpos::GetJtpevt() { return cevt.jtpevt; }
-Float_t TEpos::GetXbjevt() { return cevt.xbjevt; }
-Float_t TEpos::GetQsqevt() { return cevt.qsqevt; }
-Int_t TEpos::GetNglevt() { return cevt.nglevt; }
-Float_t TEpos::GetZppevt() { return cevt.zppevt; }
-Float_t TEpos::GetZptevt() { return cevt.zptevt; }
+Float_t TEpos::GetBimevt() const { return cevt.bimevt; }
+Float_t TEpos::GetPhievt() const { return cevt.phievt; }
+Int_t TEpos::GetKolevt() const { return cevt.kolevt; }
+Int_t TEpos::GetKoievt() const { return cevt.koievt; }
+Float_t TEpos::GetPmxevt() const { return cevt.pmxevt; }
+Float_t TEpos::GetEgyevt() const { return cevt.egyevt; }
+Int_t TEpos::GetNpjevt() const { return cevt.npjevt; }
+Int_t TEpos::GetNtgevt() const { return cevt.ntgevt; }
+Int_t TEpos::GetNpnevt() const { return cevt.npnevt; }
+Int_t TEpos::GetNppevt() const { return cevt.nppevt; }
+Int_t TEpos::GetNtnevt() const { return cevt.ntnevt; }
+Int_t TEpos::GetNtpevt() const { return cevt.ntpevt; }
+Int_t TEpos::GetJpnevt() const { return cevt.jpnevt; }
+Int_t TEpos::GetJppevt() const { return cevt.jppevt; }
+Int_t TEpos::GetJtnevt() const { return cevt.jtnevt; }
+Int_t TEpos::GetJtpevt() const { return cevt.jtpevt; }
+Float_t TEpos::GetXbjevt() const { return cevt.xbjevt; }
+Float_t TEpos::GetQsqevt() const { return cevt.qsqevt; }
+Int_t TEpos::GetNglevt() const { return cevt.nglevt; }
+Float_t TEpos::GetZppevt() const { return cevt.zppevt; }
+Float_t TEpos::GetZptevt() const { return cevt.zptevt; }