]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New class.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Jan 2010 08:57:23 +0000 (08:57 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Jan 2010 08:57:23 +0000 (08:57 +0000)
Author LOPEZ Xavier <lopez@clermont.in2p3.fr>

EVGEN/AliGenTHnSparse.cxx [new file with mode: 0644]
EVGEN/AliGenTHnSparse.h [new file with mode: 0644]
EVGEN/EVGENLinkDef.h
EVGEN/libEVGEN.pkg

diff --git a/EVGEN/AliGenTHnSparse.cxx b/EVGEN/AliGenTHnSparse.cxx
new file mode 100644 (file)
index 0000000..c80cdf3
--- /dev/null
@@ -0,0 +1,150 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------------------------
+// Particle generator according to 4 correlated variables : here
+// z, ptot, r, theta. The input is a THnSparse object included in
+// the root file (path and name to be set via the SetTHnSparse method).
+// This class is similar to AliGenFunction.
+//-----------------------------------------------------------------------
+// Author : X. Lopez - LPC Clermont (fr)
+//-----------------------------------------------------------------------
+/*
+  Example for generation :
+       AliGenTHnSparse *gener = new AliGenTHnSparse();
+       gener->SetNumberParticles(10);
+       gener->SetPart(13);
+       gener->SetThnSparse("file_name","thn_name");
+       gener->Init();
+*/
+
+#include <TRandom.h>
+#include <TFile.h>
+#include "THnSparse.h"
+
+#include "AliGenTHnSparse.h"
+
+ClassImp(AliGenTHnSparse)
+
+//_______________________________________________________________________
+AliGenTHnSparse::AliGenTHnSparse():
+  AliGenerator(),
+  fHn(0),
+  fFile(0),
+  fIpart(0)
+{
+    // Default constructor
+    SetNumberParticles(1);
+}
+
+//_______________________________________________________________________
+AliGenTHnSparse::AliGenTHnSparse(const AliGenTHnSparse& func):
+  AliGenerator(),
+  fHn(func.fHn),
+  fFile(func.fFile),
+  fIpart(func.fIpart)
+{
+    // Copy constructor
+    SetNumberParticles(1);
+}
+
+//_______________________________________________________________________
+AliGenTHnSparse & AliGenTHnSparse::operator=(const AliGenTHnSparse& func)
+{
+    // Assigment operator
+    if(&func == this) return *this;
+    fHn  = func.fHn;
+    fFile  = func.fFile;
+    fIpart  = func.fIpart;
+    return *this;
+}
+
+//_______________________________________________________________________
+AliGenTHnSparse::~AliGenTHnSparse()
+{
+    // Destructor
+    delete fFile;
+}
+
+//_______________________________________________________________________
+void AliGenTHnSparse::Generate()
+{
+  
+    // Generate Npart of id Ipart
+    
+    Double_t rand[4]; //  z, ptot, r, theta
+    Float_t pos[3], phi, ptot, theta, pt, z, r;
+    Float_t mom[3];
+    Int_t pdg = fIpart;
+  
+    for (Int_t ipart = 0; ipart < fNpart; ipart++) {
+
+       fHn->GetRandom(rand);
+       z=rand[0];
+       ptot=rand[1];
+       r=rand[2];
+       theta=rand[3];
+
+// Phi: same for position and momemtum
+       phi=(-180+gRandom->Rndm()*360)*TMath::Pi()/180;
+
+// position at production
+       
+       pos[0] = r*TMath::Cos(phi);
+       pos[1] = r*TMath::Sin(phi);
+       pos[2] = z;
+       
+// momentum at production
+
+       pt     = ptot*TMath::Sin(theta);
+       mom[0] = pt*TMath::Cos(phi); 
+       mom[1] = pt*TMath::Sin(phi); 
+       mom[2] = ptot*TMath::Cos(theta);
+
+// propagation
+
+       Float_t polarization[3]= {0,0,0};
+       Int_t nt;
+       PushTrack(fTrackIt,-1,pdg,mom, pos, polarization,0,kPPrimary,nt);
+  }
+
+    return;
+}
+
+//_______________________________________________________________________
+void AliGenTHnSparse::Init()
+{
+    
+    // Initialisation, check consistency of selected file
+    printf("************ AliGenTHnSparse ****************\n");
+    printf("*********************************************\n");
+    if (!fHn){
+       AliFatal("THnSparse file not specified");
+    }
+
+    return;
+}
+
+//_______________________________________________________________________
+void AliGenTHnSparse::SetThnSparse(char *file_name, char *thn_name)
+{
+
+    // Open the file and get object
+    TFile *fFile = new TFile(file_name);
+    fHn = (THnSparseF*)(fFile->Get(thn_name));
+
+}
diff --git a/EVGEN/AliGenTHnSparse.h b/EVGEN/AliGenTHnSparse.h
new file mode 100644 (file)
index 0000000..e7e7c08
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef ALIGENTHNSPARSE_H
+#define ALIGENTHNSPARSE_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+// Particle generator according to 4 correlated variables : here
+// z, ptot, r, theta. The input is a THnSparse object included in
+// the root file (path and name to be set via the SetTHnSparse method).
+// This class is similar to AliGenFunction.
+
+#include "AliLog.h"
+#include "AliGenerator.h"
+#include "THnSparse.h"
+
+class AliGenTHnSparse : public AliGenerator
+{
+public:
+
+  AliGenTHnSparse();
+  AliGenTHnSparse(const AliGenTHnSparse& func);
+  AliGenTHnSparse &operator=(const AliGenTHnSparse& func);
+  virtual ~AliGenTHnSparse();
+  virtual void Generate();
+  virtual void Init();
+  virtual void SetPart(Int_t part) {fIpart=part;}
+  virtual void SetThnSparse(char *file_name, char *thn_name);
+  
+private:
+
+  THnSparse *fHn; // Pointer to THnSparse object
+  TFile *fFile;   // Pointer to input file
+  Int_t fIpart;   // Particle type
+
+  ClassDef(AliGenTHnSparse,1)
+};
+
+#endif
index 96c6d0c05290396aaaa9d00175661e1fa69bf9df..fcef766d98e59822d5f8d51464fadea2a99f66a0 100644 (file)
@@ -60,4 +60,5 @@
 #pragma link C++ class  AliGenPromptPhotons+;
 #pragma link C++ class  AliGenPileup+;
 #pragma link C++ class  AliGenFunction+;
+#pragma link C++ class  AliGenTHnSparse+;
 #endif
index 3737588bdc91f56bdabd834ac6fbdfcc4ae32550..b859d44ba7d8126241eacdc59d9c492eeeeba4df 100644 (file)
@@ -20,7 +20,8 @@ SRCS          = AliGenHIJINGpara.cxx AliGenBox.cxx AliGenFixed.cxx \
                AliGenMUONCocktail.cxx AliGenMUONCocktailpp.cxx AliGenHBTosl.cxx \
                AliGenReaderEMD.cxx AliDecayerPolarized.cxx AliGenCorrHF.cxx AliGenCosmicsParam.cxx \
                AliGenKrypton.cxx AliGenThermalPhotons.cxx AliGenPromptPhotons.cxx\
-               AliGenPileup.cxx AliGenFunction.cxx
+               AliGenPileup.cxx AliGenFunction.cxx AliGenTHnSparse.cxx
+
 
 # Headerfiles for this particular package (Path respect to own directory)
 HDRS= $(SRCS:.cxx=.h)