first TB geometry implementation
authorpavlinov <pavlinov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 4 Dec 2010 11:07:24 +0000 (11:07 +0000)
committerpavlinov <pavlinov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 4 Dec 2010 11:07:24 +0000 (11:07 +0000)
EMCAL/AliEMCALWsuCosmicRaySetUp.cxx
EMCAL/AliEMCALWsuCosmicRaySetUp.h

index 0093884..791948d 100644 (file)
@@ -1,5 +1,5 @@
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
  * Author: The ALICE Off-line Project.                                    *
  * Contributors are mentioned in the code where appropriate.              *
@@ -28,7 +28,7 @@
 <br clear=left>
 <font size=+2 color=red>
 <p>The responsible person for this module is
-<a href="mailto:pavlinov@physics.wayne.edu">Aleksei Pavlino, WSU</a>.
+<a href="mailto:pavlinov@physics.wayne.edu">Alexei Pavlino, WSU</a>.
 </font>
 <pre>
 */
 ///////////////////////////////////////////////////////////////////////////////
 
 #include <TVirtualMC.h>
+#include <TROOT.h>
+#include <TDatabasePDG.h>
+#include <TBrowser.h>
+#include <TLorentzVector.h>
+#include <TParticle.h>
+#include <TList.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TAxis.h>
 
 #include "AliEMCALWsuCosmicRaySetUp.h"
 //#include "AliMagF.h"
+#include "AliStack.h"
 #include "AliRun.h"
+#include "AliMC.h"
+
+#include "AliEMCALHistoUtilities.h"
+
+using namespace std;
+
+typedef AliEMCALHistoUtilities hist;
+
+TDatabasePDG *pdg = 0; 
+
+Int_t gid=0;
 
 ClassImp(AliEMCALWsuCosmicRaySetUp)
+
+//  TList *fLHists=0, *ll=0; 
+
 //_____________________________________________________________________________
-AliEMCALWsuCosmicRaySetUp::AliEMCALWsuCosmicRaySetUp()
+  AliEMCALWsuCosmicRaySetUp::AliEMCALWsuCosmicRaySetUp(): AliModule()
+                                                     //,fMasterVolume()
+                                                   ,fLHists(0),fMasterVolume()
 {
   //
   // Default constructor
@@ -56,6 +81,8 @@ AliEMCALWsuCosmicRaySetUp::AliEMCALWsuCosmicRaySetUp()
 //_____________________________________________________________________________
 AliEMCALWsuCosmicRaySetUp::AliEMCALWsuCosmicRaySetUp(const char *name, const char *title)
        : AliModule(name,title)
+                                                   //,fMasterVolume()
+                                                   ,fLHists(0),fMasterVolume()
 {
   //
   // Standard constructor of the  Wsu Cosmic Ray SetUp external volume
@@ -76,10 +103,11 @@ void AliEMCALWsuCosmicRaySetUp::CreateGeometry()
     <img src="picts/AliEMCALWsuCosmicRaySetUpTree.gif">
   */
   //End_Html
+  pdg = TDatabasePDG::Instance();
 
   // Master Volume
-  fMasterVolume[0] = fMasterVolume[1] = 25.0;
-  fMasterVolume[2] = 300.;
+  fMasterVolume[0] = fMasterVolume[1] = 35.0;
+  fMasterVolume[2] = 450.;
 
   Int_t *idtmed = fIdtmed->GetArray()+1;
   int idAir = idtmed[0];
@@ -89,16 +117,35 @@ void AliEMCALWsuCosmicRaySetUp::CreateGeometry()
   //
   Float_t sc[3]; // tube
   sc[0] = 0.0;
-  sc[1] = 5.0;
-  sc[2] = 0.5;
-  Float_t zsc[3]={10.,110., 310.};
+  sc[1] = 10.0;
+  sc[2] = 1.0; // thicness of Sc is 2 cm
+  Float_t zsc[3] = {10.,330.6, 810.1}; 
   int idSC = idtmed[1];
   gMC->Gsvolu("SCOU","TUBE",idSC, sc,3); // Master volume
+  printf(" idtmed[0] %i idtmed[1] %i \n", idtmed[0] , idtmed[1]); 
   Int_t idRot=0; // no rotation
   for(Int_t i=0; i<3; i++) {
     Float_t zpos = zsc[i] - fMasterVolume[2];
     gMC->Gspos("SCOU", i+1, "WSUC", 0.0, 0.0, zpos, idRot, "ONLY"); 
   }
+  //
+  // Dead end : Dec 2,2010
+  //
+  Float_t zbox[3]={30., 30.0, 0.1};
+  gMC->Gsvolu("SEND","BOX",idAir, zbox,3); // Master volume
+  gMC->Gspos("SEND", 1, "WSUC", 0.0, 0.0, 448.0, idRot, "ONLY"); 
+  // Hists
+  fLHists = new TList;
+  fLHists->SetName("hists");
+  //
+  //AliMC *ALIMC  = dynamic_cast<AliMC *>(gMC);
+  //AliGenBox* gB = dynamic_cast<AliGenBox *>(ALIMC->Generator());
+  //Double_t p = gB->
+  fLHists->Add(BookKineHists(1.,"primeKineHists"));
+  fLHists->Add(BookKineHists(1.,"endKineHists"));
+  fLHists->Add(BookKineHists(1.,"secondaryKineHists"));
+  //ll = BookKineHists(1.,"kineHists");
+  //gROOT->GetListOfBrowsables()->Add(ll);
 }
  
 //_____________________________________________________________________________
@@ -125,29 +172,136 @@ void AliEMCALWsuCosmicRaySetUp::CreateMaterials()
   AliMedium(1,"Air     $",1,0,isxfld,sxmgmx,10,-1,-0.1,0.1 ,-10);
   AliMedium(2, "Scintillator$", 2, 1,
             isxfld, sxmgmx, 10.0, 0.001, deemax, 0.001, 0.001, 0, 0) ;
-  
+  // cuts
+  DefineCuts(1);
+  DefineCuts(2);
 }
  
-//_____________________________________________________________________________
-void AliEMCALWsuCosmicRaySetUp::DrawWSUC(float cxy) const
+void AliEMCALWsuCosmicRaySetUp::DefineCuts(const Int_t idtmed)
 {
+  // Dec 2,2010 : it works
+  Float_t cutgam=10.e-5; // 100 kev;
+  Float_t cutele=10.e-5; // 100 kev;
+  gMC->Gstpar(idtmed,"CUTGAM", cutgam);
+  gMC->Gstpar(idtmed,"CUTELE", cutele); // 1MEV -> 0.1MEV; 15-aug-05
+  gMC->Gstpar(idtmed,"BCUTE",  cutgam);  // BCUTE and BCUTM start from GUTGUM
+  gMC->Gstpar(idtmed,"BCUTM",  cutgam);  // BCUTE and BCUTM start from GUTGUM
+  // --- Generate explicitly delta rays in Lead ---
+  gMC->Gstpar(idtmed, "LOSS", 3) ;
+  gMC->Gstpar(idtmed, "DRAY", 1) ;
+  gMC->Gstpar(idtmed, "DCUTE", cutele) ;
+  gMC->Gstpar(idtmed, "DCUTM", cutele) ;
+}
+void AliEMCALWsuCosmicRaySetUp::StepManager(void)
+{
+  // Dec 1,2010
+  static Int_t pri=1;
+  static TString curVolName="";
+  static TLorentzVector pos;  // Lorentz vector of the track current position.
+  static TLorentzVector mom;  // Lorentz vector of the track current momentum.
+
+  if(pri>=2) printf("<I> AliEMCALWsuCosmicRaySetUp::StepManager %s \n", gMC->CurrentVolName());
+  Int_t tracknumber =  gAlice->GetMCApp()->GetCurrentTrackNumber();
+  Int_t parent=0;
+  TParticle* part=0;
+  curVolName = gMC->CurrentVolName();
+  if(curVolName.Contains("SEND")) {
+    gMC->TrackMomentum(mom);
+    gMC->TrackPosition(pos);
+    if(pri>=2) printf(" %s tracknumber %i p %f \n", curVolName.Data(), tracknumber, mom.P());
+    if(pri>=2) printf(" x %f y %f z %f \n", pos[0], pos[1], pos[2]);
+    if(gMC->IsTrackEntering()) { // primary only TList *l = GetLhists(1);
+      TList *l = 0;
+      if(tracknumber==0){
+        l = GetLhists(1);
+        part=gAlice->GetMCApp()->Particle(0);
+        gid = pdg->ConvertPdgToGeant3(part->GetPdgCode()); 
+        hist::FillH1(l, 1, double(gid));
+      } else {
+        l = GetLhists(2);
+        part=gAlice->GetMCApp()->Particle(tracknumber);
+        gid = pdg->ConvertPdgToGeant3(part->GetPdgCode()); 
+        hist::FillH1(l, 1, double(gid));
+      }
+      Int_t ic = 2;
+      hist::FillH1(l, ic++, mom.P());
+      hist::FillH1(l, ic++, mom.Eta());
+      hist::FillH1(l, ic++, TVector2::Phi_0_2pi(mom.Phi())*TMath::RadToDeg() );
+      hist::FillH1(l, ic++, mom.Theta()*TMath::RadToDeg());
+    }
+  }
+}
+
+void AliEMCALWsuCosmicRaySetUp::FinishEvent()
+{
+  // Dec 2,2010
+  int ic=0;
+
+  TList *l = GetLhists(0);
+  //  TList *l = ll;
+  AliStack* st =  AliRunLoader::Instance()->Stack();
+  TParticle *p = st->Particle(0);
+  gid = pdg->ConvertPdgToGeant3(p->GetPdgCode());
+
+  ic=1;
+  hist::FillH1(l, ic++, double(gid));
+  hist::FillH1(l, ic++, p->P());
+  hist::FillH1(l, ic++, p->Eta());
+  hist::FillH1(l, ic++, TVector2::Phi_0_2pi(p->Phi())*TMath::RadToDeg() );
+  hist::FillH1(l, ic++, p->Theta()*TMath::RadToDeg());
+}
+
+TList* AliEMCALWsuCosmicRaySetUp::BookKineHists(const Double_t p , const Char_t *opt)
+{
+  // Dec 2,2010
+  gROOT->cd();
+  TH1::AddDirectory(1);
+
+  TH1 *h = 0, *hgid=0;
+  Int_t nphi=180;
+  Int_t phimin=0.0, phimax=360.;
+  Double_t pmax=110.;
+  if(p>0.1) pmax = 1.1*p;
+  h = new TH1F("00_hNPrim"," number of primary particles ", 10, 0.5, 10.5);
+  hgid = new TH1F("01_hGidprim","Geant Id of primary particles", 16, 0.5, 16.5);
+  new TH1F("02_hPmomPrim","p of primary particles", 200, 0.0, pmax);
+  new TH1F("03_hEtaPrim","#eta primary particles", 80, 0.0, 8.0);
+  new TH1F("04_hPhiPrim","#phi primary particles", nphi,phimin,phimax);
+  new TH1F("05_hThetaPrim","#theta primary particles", 90, 0.0, 90.);
   //
-  // Draw a view of the Wsu Cosmic Ray SetUp 
-  //
-  // Set everything unseen
-  gMC->Gsatt("*", "seen", -1);
-  // 
-  // Set WSUC mother visible
-  gMC->Gsatt("WSUC","SEEN",1);
-  //
-  // Set the volumes visible
-  //
-  gMC->Gdopt("hide","off");
+  TAxis *xax=hgid->GetXaxis();
+  xax->SetBinLabel(1,"#gamma");
+  xax->SetBinLabel(2,"e^{+}");
+  xax->SetBinLabel(3,"e^{-}");
+  xax->SetBinLabel(4,"#nu");
+  xax->SetBinLabel(5,"#mu^{+}");
+  xax->SetBinLabel(6,"#mu^{-}");
+  xax->SetBinLabel(7,"#pi^{0}");
+  xax->SetBinLabel(8,"#pi^{+}");
+  xax->SetBinLabel(9,"#pi^{-}");
+  xax->SetBinLabel(10,"K_{L}");
+  xax->SetBinLabel(11,"K^{+}");
+  xax->SetBinLabel(12,"K^{-}");
+  xax->SetBinLabel(13,"n");
+  xax->SetBinLabel(14,"p");
+  xax->SetBinLabel(15,"#bar{p}");
+  xax->SetBinLabel(16,"K_{s}");
+  //  hgid->SetBinLabel(,"");
 
-  gMC->Gdraw("WSUC", 40, 30, 0, 10, 9, cxy, cxy);
-  gMC->Gdhead(1111, "WSU Cosmic Ray Setup ");
+  TList *l = 0;
+  l = hist::MoveHistsToList(opt, 1);
+  if(strlen(opt)) hist::AddToNameAndTitleToList(l, opt, opt);
 
-  gMC->Gdman(18, 4, "MAN");
+  TH1::AddDirectory(0);
+
+  return l;
 }
 
+void AliEMCALWsuCosmicRaySetUp::Browse(TBrowser* b)
+{
+  if(fLHists) b->Add(fLHists);
+  TObject::Browse(b);
+}
+/*
+*/
index 77728dd..dcebd7b 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef ALIBODY_H
 #define ALIBODY_H
-/* Copyright(c) 1998-2005, ALICE Experiment at CERN, All rights reserved. *
+/* Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
 /* $Id$ */
@@ -12,6 +12,8 @@
  
 #include "AliModule.h"
 
+class TList;
+
 class AliEMCALWsuCosmicRaySetUp : public AliModule {
  
 public:
@@ -20,12 +22,23 @@ public:
   virtual     ~AliEMCALWsuCosmicRaySetUp() {}
   virtual void  CreateGeometry();
   virtual void  CreateMaterials();
+  void DefineCuts(const Int_t idtmed=1);
   virtual Int_t IsVersion() const {return 0;}
-  void  DrawWSUC(float cxy=0.025) const; // *MENU*
   // GetMethod
   Float_t* GetMasterVolume() {return fMasterVolume;}
+  TList*   GetLhists() {return fLHists;}
+  TList*   GetLhists(Int_t ind) {return ind<0?fLHists:dynamic_cast<TList *>(fLHists->At(ind));}
+  // Dec 1,2010
+  virtual void StepManager(void) ;
+  virtual void FinishEvent();
+
+  TList*  BookKineHists(const Double_t p=1., const Char_t *opt="kine");
+  //
+  virtual Bool_t  IsFolder() const {return kTRUE;}
+  virtual void Browse(TBrowser* b);
 
   protected:
+  TList *fLHists;           // list of hists
   Float_t fMasterVolume[3]; // size of MASTER volume
 
   ClassDef(AliEMCALWsuCosmicRaySetUp,1)  // Class manager for the Wsu Cosmic Ray SetUp