]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TMEVSIM/TMevSim.cxx
Trigger descriptor for MUON standalone (Ch.Finck)
[u/mrichter/AliRoot.git] / TMEVSIM / TMevSim.cxx
index 5903e097afb2f089f442143cf8af2d82c195a8b7..9c9d807f5fa9ead79bebafe9044926902618f900 100644 (file)
@@ -13,9 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-*/
+/* $Id$ */
 
 ////////////////////////////////////////////////////////////////////////////
 // 
@@ -393,15 +391,11 @@ $Log$
 ///////////////////////////////////////////////////////////////////////////////
 
 
+#include <Riostream.h>
 
-
-#include <fstream>
-#include <iomanip.h>
 #include "TMevSim.h"
-
-#include "MevSimCommon.h"
+#include"TMevSimPartTypeParams.h"
 #include "TParticle.h"
-#include "TFile.h"
 
 #ifndef WIN32
 # define multgen multgen_
@@ -449,6 +443,7 @@ TMevSim::TMevSim(Int_t nEvents, Int_t modelType, Int_t reacPlaneCntrl,
    fNScanPts = 100;
    firand = irand;
    fParticleTypeParameters = new TClonesArray("TMevSimPartTypeParams",10);
+   fNPDGCodes = 0;
    DefineParticles();
 }
 //______________________________________________________________________________
@@ -464,13 +459,14 @@ TMevSim::~TMevSim()
   }
 }
 //______________________________________________________________________________
-TMevSim::TMevSim(TMevSim& mevsim) {
+TMevSim::TMevSim(TMevSim& mevsim) : TGenerator(mevsim) {
 // The copy constructor
    
    *this = mevsim;
 }
 //______________________________________________________________________________
-TMevSim& TMevSim::operator=(TMevSim& mevsim) {
+
+TMevSim& TMevSim::operator=(const TMevSim& mevsim) {
 // An assignment operator: initializes all the event-wide variables of MevSim with
 // the ones from a copied object. It also copies the parameters specific to
 // each particle species.
@@ -555,9 +551,10 @@ void        TMevSim::Initialize() {
 
      for (Int_t cnt1 = 0; cnt1 < NFLOWTERMS; cnt1++) {
        *file << "  ";
-       for (Int_t cnt2 = 0; cnt2 < 4; cnt2++) *file << params->GetVnMeanComponent(cnt1, cnt2) << "  ";
+       Int_t cnt2;
+       for (cnt2 = 0; cnt2 < 4; cnt2++) *file << params->GetVnMeanComponent(cnt1, cnt2) << "  ";
        *file << "  \n  ";
-       for (Int_t cnt2 = 0; cnt2 < 4; cnt2++) *file << params->GetVnStDevComponent(cnt1, cnt2) << "  ";
+       for (cnt2 = 0; cnt2 < 4; cnt2++) *file << params->GetVnStDevComponent(cnt1, cnt2) << "  ";
        *file << "  \n";
      }
    }
@@ -565,16 +562,16 @@ void        TMevSim::Initialize() {
 
 }
 //______________________________________________________________________________
-void        TMevSim::GenerateEvent() {
+void TMevSim::GenerateEvent() {
 // Generates one MevSim event. TMevSim::Initialize() must be called prior
 // to calling this function.
    
-   cout << "Calling FORTRAN multgen()" << endl;
+   Info("GenerateEvent","Calling FORTRAN multgen()");
    multgen();
 }
 
 //______________________________________________________________________________
-Int_t TMevSim::ImportParticles(TClonesArray *particles, Option_t *option)
+Int_t TMevSim::ImportParticles(TClonesArray *particles, Option_t */*option*/)
 {
 // Read in particles created by MevSim into the TClonesArray(). The Initialize()
 // and GenrateEvent() functions must be called prior to calling this funtion.
@@ -582,8 +579,8 @@ Int_t TMevSim::ImportParticles(TClonesArray *particles, Option_t *option)
 // information is Geant PID, 3 momentum components and the energy of the particle.
    
    if (particles == 0) return 0;
-   TClonesArray &Particles = *particles;
-   Particles.Clear();
+   TClonesArray &aParticles = *particles;
+   aParticles.Clear();
    
    Int_t totpart = 0;
    for (Int_t nrpidtype=0; nrpidtype < (fParticleTypeParameters->GetLast() + 1); nrpidtype++) {
@@ -598,7 +595,7 @@ Int_t TMevSim::ImportParticles(TClonesArray *particles, Option_t *option)
         Float_t pz = TRACK.pout[poffset];
         poffset += NPID;
         Float_t mass = TRACK.pout[poffset];
-        new(Particles[totpart+nrpart]) TParticle(
+        new(aParticles[totpart+nrpart]) TParticle(
                                          PDGFromId(pidcode),  // Get the PDG ID from GEANT ID
                                          0,
                                          0,
@@ -620,6 +617,49 @@ Int_t TMevSim::ImportParticles(TClonesArray *particles, Option_t *option)
    return totpart;
 }
 //______________________________________________________________________________
+TObjArray * TMevSim::ImportParticles(Option_t */*option*/)
+{
+// Read in particles created by MevSim into the TClonesArray(). The Initialize()
+// and GenrateEvent() functions must be called prior to calling this funtion.
+// The particles are read from the COMMON POUT. Right now the only provided 
+// information is Geant PID, 3 momentum components and the energy of the particle.
+   
+   fParticles->Clear();
+   
+   for (Int_t nrpidtype=0; nrpidtype < (fParticleTypeParameters->GetLast() + 1); nrpidtype++) {
+      Int_t nrpart = 0;
+      Int_t pidcode = ((TMevSimPartTypeParams *) (*fParticleTypeParameters)[nrpidtype])->GetGPid();
+      while ((TRACK.pout[(4*nrpart+3)*NPID+nrpidtype] > 0.0) || (TRACK.pout[(4*nrpart)*NPID+nrpidtype] != 0.0)) {
+        int poffset = 4*nrpart*NPID+nrpidtype;
+        Float_t px = TRACK.pout[poffset];
+        poffset += NPID;
+        Float_t py = TRACK.pout[poffset];
+        poffset += NPID;
+        Float_t pz = TRACK.pout[poffset];
+        poffset += NPID;
+        Float_t mass = TRACK.pout[poffset];
+        TParticle * p = new TParticle(
+                                         PDGFromId(pidcode),  // Get the PDG ID from GEANT ID
+                                         0,
+                                         0,
+                                         0,
+                                         0,
+                                         0,
+                                         px,
+                                         py,
+                                         pz,
+                                         sqrt(mass*mass+px*px+py*py+pz*pz),                               
+                                         0,
+                                         0,
+                                         0,
+                                         0);
+        fParticles->Add(p);
+        nrpart++;
+      }
+   }
+   return fParticles;
+}
+//______________________________________________________________________________
 void        TMevSim::SetNEvents(Int_t nEvents ) { 
 // Sets the number of events to be generated by MevSim.
 // Caution: Setting nEvents > 1 will have no effect, since only the last generated 
@@ -810,7 +850,7 @@ void        TMevSim::SetPartTypeParams(Int_t index, TMevSimPartTypeParams *param
    *((TMevSimPartTypeParams *) ((*fParticleTypeParameters)[index])) = *params;
 }
 //______________________________________________________________________________
-void        TMevSim::GetPartTypeParamsByIndex(Int_t index, TMevSimPartTypeParams *params) 
+void TMevSim::GetPartTypeParamsByIndex(Int_t index, TMevSimPartTypeParams *params) const
 {
 // Return the particle parameters stored in the list at the postion index.   
 // Returns NULL if index is out of bounds.
@@ -821,7 +861,7 @@ void        TMevSim::GetPartTypeParamsByIndex(Int_t index, TMevSimPartTypeParams
      params = NULL;
 }
 //______________________________________________________________________________
-void        TMevSim::GetPartTypeParamsByGPid(Int_t gpid, TMevSimPartTypeParams *params) 
+void TMevSim::GetPartTypeParamsByGPid(Int_t gpid, TMevSimPartTypeParams *params) const
 {
 // Return the particle parameters for the particle with Geant PID gpid.
 // Returns NULL if the parameters for such particle do not exist in the list.