Adding macros for ACORDE: sim&rec, read raw-data,esd & hits (*.C macros and AliAnalys...
authormrodrigu <mrodrigu@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 3 Jul 2010 06:26:39 +0000 (06:26 +0000)
committermrodrigu <mrodrigu@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 3 Jul 2010 06:26:39 +0000 (06:26 +0000)
12 files changed:
ACORDE/macros/AnalysisMacros/Local/AliAnalysisTaskAcorde.cxx [new file with mode: 0644]
ACORDE/macros/AnalysisMacros/Local/AliAnalysisTaskAcorde.h [new file with mode: 0644]
ACORDE/macros/AnalysisMacros/Local/files.txt [new file with mode: 0644]
ACORDE/macros/AnalysisMacros/Local/runAcordeAna.C [new file with mode: 0755]
ACORDE/macros/TestACORDEHits.C [new file with mode: 0755]
ACORDE/macros/readACORDEESD.C [new file with mode: 0755]
ACORDE/macros/readACORDERawData.C [new file with mode: 0644]
ACORDE/macros/testMC/Config_AliGenACORDE.C [new file with mode: 0644]
ACORDE/macros/testMC/cosmicSim.C [new file with mode: 0644]
ACORDE/macros/testMC/rec.C [new file with mode: 0644]
ACORDE/macros/testMC/recraw/rec.C [new file with mode: 0755]
ACORDE/macros/testMC/run.sh [new file with mode: 0755]

diff --git a/ACORDE/macros/AnalysisMacros/Local/AliAnalysisTaskAcorde.cxx b/ACORDE/macros/AnalysisMacros/Local/AliAnalysisTaskAcorde.cxx
new file mode 100644 (file)
index 0000000..7263527
--- /dev/null
@@ -0,0 +1,434 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// AliAnalysisTaskAcorde class
+//
+// Description:
+//
+//     Reads the information of ACORDE-ESD
+//     Also it is implemented a simple matching between tracks
+//     to look for the extrapolation of them to ACORDE modules
+//
+//     Create some histograms and one tree with the information
+//     of the matching tracks
+//
+//  Author: Mario Rodr√≠guez Cahuantzi
+//             <mario.rocah@gmail.com>
+//             <mrodrigu@mail.cern.ch>
+//
+//  Created: June 30th. 2010 @ FCFM - BUAP, Puebla, MX
+//  Last update: created
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "TChain.h"
+#include "TTree.h"
+#include "TH2F.h"
+#include "TH1F.h"
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+
+#include "AliAnalysisTaskAcorde.h"
+
+#include "TMath.h"
+#include "TArrayI.h"
+#include "TDatabasePDG.h"
+#include "TVectorD.h"
+
+#include "AliESDtrack.h"
+#include "AliTracker.h"
+#include "TFile.h"
+#include "TVectorD.h"
+#include "TStyle.h"
+#include "TCanvas.h"
+#include "TLegend.h"
+ClassImp(AliAnalysisTaskAcorde)
+//________________________________________________________________________
+AliAnalysisTaskAcorde::AliAnalysisTaskAcorde(const char *name) 
+  : AliAnalysisTask(name, ""), 
+       fESD(0),
+       cosmicTree(0),
+       nTracks(0),
+       nMatchTracks(0),
+       minTPCclusters(30),
+       minTrackDist(1000.),
+       minCutDir(0.95),
+       xAco(0),
+       yAco(0),
+       zAco(0),
+       trigger(0),
+       ActiveTriggerDetector(0),
+       nSingleTracks(0),
+       nMatchedTracks(0),
+       histo(0),
+       ntracks(0),
+       acordeHitsAll(0),
+       acordeMultiAll(0),
+       acordeHitsTPC(0),
+       acordeMultiTPC(0),
+       nTracksMatched(0),
+       fTracksToAcorde(0)
+
+{
+       // Constructor of class
+
+       DefineInput(0, TChain::Class());
+       DefineOutput(0,TTree::Class());
+       DefineOutput(1,TList::Class());
+}
+
+//________________________________________________________________________
+AliAnalysisTaskAcorde::~AliAnalysisTaskAcorde()
+{
+       // destructor --> avoid watchdog mails?
+       
+       delete fESD;
+       delete histo;
+       delete cosmicTree;
+}
+//________________________________________________________________________
+void AliAnalysisTaskAcorde::ConnectInputData(Option_t *) 
+{
+       // Connect ESD or AOD here
+       // Called once
+
+       TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
+       if (!tree) 
+       {
+               Printf("ERROR: Could not read chain from input slot 0");
+       }else 
+       {
+
+               AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+               if (!esdH) 
+               {
+                       Printf("ERROR: Could not get ESDInputHandler");
+               }else fESD = esdH->GetEvent();
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskAcorde::CreateOutputObjects()
+{
+
+       // creates one TList with some histograms
+
+       histo = new TList();
+
+       nTracksMatched = new TH1F("nTracksMatched","nTracksMatched from matching algorithm implemented",300,1,300);
+       ntracks = new TH1F("ntracks","nTracks distribution",500,1,500);
+       acordeHitsAll = new TH1F("acordeHitsAll","Hits of ACORDE from ESD",60,-0.5,59.5);
+       acordeHitsTPC = new TH1F("acordeHitsAllTPC","Hits of ACORDE from ESD (if ntracks>0)",61,0,60);
+       acordeMultiAll = new TH1F("acordeMultiAll","Multiplicity of ACORDE modules from ESD",60,-0.5,59.5);
+       acordeMultiTPC = new TH1F("acordeMultiAllTPC","Multiplicity of ACORDE modules from ESD (id ntracks>0)",61,0,60);
+       fTracksToAcorde = new TH2F("fTracksToAcorde","Extrapolated tracks to ACORDE x:z",1200,-600,600,1200,-600,600);
+
+       histo->Add(nTracksMatched);
+       histo->Add(ntracks);
+       histo->Add(acordeHitsAll);
+       histo->Add(acordeHitsTPC);
+       histo->Add(acordeMultiAll);
+       histo->Add(acordeMultiTPC);
+       histo->Add(fTracksToAcorde);
+
+       // Create Tree branches
+       // Called just once
+
+       cosmicTree = new TTree("cosmicTree","cosmicTreeMRC");
+       cosmicTree->Branch("nTracks",&nTracks,"nTracks/I");
+       cosmicTree->Branch("nMatchTracks",&nMatchTracks,"nMatchTracks/I");
+       cosmicTree->Branch("xAco",&xAco,"xAco/F");
+       cosmicTree->Branch("yAco",&yAco,"yAco/F");
+       cosmicTree->Branch("zAco",&zAco,"zAco/F");
+       cosmicTree->Branch("trigger",&trigger,"trigger/I");
+
+}
+
+
+void AliAnalysisTaskAcorde::Exec(Option_t *) 
+{
+       // Main loop
+       // Called for each event
+
+       Int_t counterOfMuons = 0;
+
+
+
+       if (!fESD) 
+       {
+               Printf("ERROR: fESD not available");
+               return;
+       }
+
+
+
+       // Pointer to the information of ACORDE detector
+
+       AliESDACORDE *acordeESD = fESD->GetACORDEData();
+
+       Int_t contMulti = 0;
+       Int_t contMultiTPC = 0;
+
+       for(Int_t imod=0;imod<60;imod++)
+       {
+               if (acordeESD->GetHitChannel(imod)) 
+               {
+                       acordeHitsAll->Fill(imod);
+                       contMulti++;
+               }
+
+       }acordeMultiAll->Fill(contMulti);
+
+       for(Int_t imod=0;imod<60;imod++)
+       {
+               if (acordeESD->GetHitChannel(imod))
+               {
+                       acordeHitsTPC->Fill(imod);
+                       contMultiTPC++;
+               }
+       }acordeMultiTPC->Fill(contMultiTPC);
+
+
+       // Assingment of the type of Trigger to cosmicTree
+
+       ActiveTriggerDetector = fESD->GetFiredTriggerClasses();
+
+       if (ActiveTriggerDetector.Contains("C0SCO")) trigger=0;
+       if (ActiveTriggerDetector.Contains("C0SH2")) trigger=1;
+       if (ActiveTriggerDetector.Contains("C0AMU")) trigger=2;
+       if (ActiveTriggerDetector.Contains("C0LSR")) trigger=3;
+       if (ActiveTriggerDetector.Contains("C0SCO1")) trigger=4;
+       if (ActiveTriggerDetector.Contains("C0OBE")) trigger=5;
+       if (ActiveTriggerDetector.Contains("C0PCO")) trigger=6;
+       if (ActiveTriggerDetector.Contains("C0OB3")) trigger=7;
+       if (ActiveTriggerDetector.Contains("C0OCP")) trigger=8;
+       if (ActiveTriggerDetector.Contains("C0ASL")) trigger=9;
+       
+
+       // Begins the matching analysis between tracks
+
+       nTracks = fESD->GetNumberOfTracks();
+       if (nTracks<=0) return;
+       ntracks->Fill(nTracks);
+
+       fPair = new TArrayI(nTracks);
+       nSingleTracks=0;
+       nMatchedTracks=0;
+       Int_t muons = 0;
+       TFile *curfile = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
+       for (Int_t iTrack=0; iTrack<nTracks; iTrack++)
+       {
+
+               // Special case: nTracks == 1
+               if (nTracks ==1)
+               {
+                       AliESDtrack *singleTrack = fESD->GetTrack(iTrack);
+                       if (!singleTrack || !singleTrack->GetOuterParam() || !singleTrack->GetInnerParam()) continue;
+                       if (singleTrack->GetTPCNcls()<minTPCclusters) continue;
+                       Float_t vertX = singleTrack->Xv();
+                       Float_t vertZ = singleTrack->Zv();
+                       if (TMath::Abs(vertX)>165 || TMath::Abs(vertZ)>245) continue; // far away from the VERTEX
+                       if (singleTrack->E()< 1) continue; // less than 1 GeV 
+                       if (singleTrack->P()< 1) continue; // less than 1 GeV 
+                       nMatchTracks=0;
+                       nSingleTracks = nTracks;
+                       muons = 1;
+
+               } // nTracks ==1
+               else if (nTracks>1) // nTracks > 1
+               {
+
+                       AliESDtrack *track0 = fESD->GetTrack(iTrack);
+                       (*fPair)[iTrack]=-1;
+                       if (!track0 || !track0->GetOuterParam() || !track0->GetInnerParam()) continue;
+
+                       Double_t track0_dir[3];
+                       track0->GetDirection(track0_dir);
+                       Float_t minDist = minTrackDist; 
+
+                       const AliExternalTrackParam * trackIn = track0->GetInnerParam();
+                       const AliExternalTrackParam * trackOut = track0->GetOuterParam();
+
+                       if (!trackIn || !trackOut) continue;
+                       if (nTracks>4 && TMath::Abs(trackIn->GetTgl())<0.0015) continue; // Filter TPC-Laser
+
+                       if (track0->GetTPCNcls()<minTPCclusters) continue;
+
+                       for (Int_t jTrack=iTrack; jTrack<nTracks; ++jTrack)
+                       {
+                               AliESDtrack *track1 = fESD->GetTrack(jTrack);
+                               if (!track1 || !track1->GetOuterParam() || !track1->GetInnerParam()) continue;
+                               Double_t track1_dir[3];
+                               track1->GetDirection(track1_dir);
+                               if (track1->GetTPCNcls()<minTPCclusters) continue;
+                               Float_t direction = track0_dir[0]*track1_dir[0] + track0_dir[1]*track1_dir[1] + track0_dir[2]*track1_dir[2];
+                               if (TMath::Abs(direction)<minCutDir) continue; // direction vector product
+                               Float_t dvertex0[3];
+                               Float_t dvertex1[3];
+
+                               dvertex0[0] = track0->Xv();
+                               dvertex0[1] = track0->Yv();
+                               dvertex0[2] = track0->Zv();
+
+                               dvertex1[0] = track1->Xv();
+                               dvertex1[1] = track1->Yv();
+                               dvertex1[2] = track1->Zv();
+
+                               if (TMath::Abs(dvertex0[0])>165 || TMath::Abs(dvertex0[2])>245 || TMath::Abs(dvertex1[0])>165 || TMath::Abs(dvertex0[2])>245) continue;
+                               // calculate the distance between track0 and track1
+                               
+                               Float_t dy = track0->GetY()+track1->GetY();
+                               Float_t sy2 = track0->GetSigmaY2()+track1->GetSigmaY2();
+                               Float_t dphi = track0->GetAlpha()-track1->GetAlpha()-TMath::Pi();
+                               Float_t sphi2 = track0->GetSigmaSnp2()+track1->GetSigmaSnp2();
+                               Float_t dtheta = track0->GetTgl()+track1->GetTgl();
+                               Float_t stheta2 = track0->GetSigmaTgl2()+track1->GetSigmaTgl2();
+                               Float_t normDist = TMath::Sqrt(dy*dy/sy2+dphi+dphi/sphi2+dtheta*dtheta/stheta2);
+                               if (normDist>minDist) continue;
+
+                               Float_t distTracks = TMath::Sqrt((dvertex0[0]-dvertex1[0])*(dvertex0[0]-dvertex1[0]) + (dvertex0[1]-dvertex1[1])*(dvertex0[1]-dvertex1[1]) + (dvertex0[2]-dvertex1[2])*(dvertex0[2]-dvertex1[2]) );
+                               if (distTracks>2.5) continue;
+
+
+                               minDist = normDist;
+
+                               // after all the cuts we should have only tracks that can be matched
+
+                               (*fPair)[iTrack] = jTrack;
+
+
+                       }       
+               } // nTracks > 1
+       
+
+       } // Loop over all the tracks
+
+
+
+
+       // Matching tracks
+       
+       for (Int_t itrack=0;itrack<nTracks;itrack++)
+       {
+               AliESDtrack *UpTrack = 0;
+               AliESDtrack *DownTrack = 0;
+
+               AliESDtrack *Track0 = fESD->GetTrack(itrack);
+               if (!Track0 || !Track0->GetOuterParam() || !Track0->GetInnerParam() ) continue;
+
+               Double_t mxyz[3];
+               Track0->GetOuterParam()->GetXYZ(mxyz);
+               
+               UpTrack = Track0;
+       
+
+               if ((*fPair)[itrack]>0)
+               {
+                       AliESDtrack *Track1 = fESD->GetTrack((*fPair)[itrack]);
+                       if (!Track1 || !Track1->GetOuterParam() || !Track1->GetInnerParam()) continue;
+                       Float_t dvertex0[3];
+                       Float_t dvertex1[3];
+
+                       dvertex0[0] = Track0->Xv();
+                       dvertex0[1] = Track0->Yv();
+                       dvertex0[2] = Track0->Zv();
+
+                       dvertex1[0] = Track1->Xv();
+                       dvertex1[1] = Track1->Yv();
+                       dvertex1[2] = Track1->Zv();
+
+                       Float_t distTracks = TMath::Sqrt((dvertex0[0]-dvertex1[0])*(dvertex0[0]-dvertex1[0]) + (dvertex0[1]-dvertex1[1])*(dvertex0[1]-dvertex1[1]) + (dvertex0[2]-dvertex1[2])*(dvertex0[2]-dvertex1[2]) );
+                       if (distTracks>2.5) continue;
+
+                       if (Track1->GetOuterParam())
+                       {
+                               Double_t nxyz[3];
+                               Track1->GetOuterParam()->GetXYZ(nxyz);
+                               if (nxyz[1]>mxyz[1])
+                               {
+                                       UpTrack = Track1;
+                               }else DownTrack = Track1;
+                       }
+
+
+
+                       // Here we propagate the Up-Tracks to ACORDE
+
+
+                       const Double_t kRL3 = 510; // radious of L3 magnet
+                       const Double_t kxAcorde = 850.; // radios of "ACORDE" above the magnet
+
+                       Double_t agxyz[3];
+                       
+
+                       AliExternalTrackParam *upper = (AliExternalTrackParam *)(UpTrack->GetOuterParam()->Clone());
+
+                       Bool_t isOk = upper->PropagateTo(kRL3,fESD->GetMagneticField());
+                       upper->GetXYZ(agxyz);
+                       if (agxyz[1]<0) continue;
+
+                       upper->GetXYZ(agxyz);
+                       Double_t galpha = TMath::ATan2(agxyz[1],agxyz[0]);
+                       Double_t alpha = galpha;
+                       galpha*=180/TMath::Pi();
+
+                       if (galpha<45.) alpha = TMath::Pi()/8;
+                       if (galpha>135.) alpha = TMath::Pi()*(7/8);
+                       if (galpha>45 && galpha<135.) alpha = TMath::Pi()/2;
+
+                       if (isOk) upper->Rotate(alpha);
+
+                       if (isOk) isOk = upper->PropagateTo(kxAcorde,0);
+
+                       TVectorD rgxyz(3);
+                       AliExternalTrackParam *param = (AliExternalTrackParam *)upper;
+                       param->GetXYZ(rgxyz.GetMatrixArray());
+                       xAco = rgxyz[0];
+                       yAco = rgxyz[1];
+                       zAco = rgxyz[2];
+                       fTracksToAcorde->Fill(xAco,zAco);
+                       // Count how many tracks have been matched
+                       nMatchedTracks++;
+               } else nSingleTracks++;
+       }
+
+       if ( (nMatchedTracks+nSingleTracks) <= nTracks ) muons=nMatchedTracks+nSingleTracks;
+       nTracksMatched->Fill(muons);
+
+       nMatchTracks = nSingleTracks + nMatchedTracks;
+       
+       // Fills the tree
+
+       cosmicTree->Fill();
+       
+       // Post output data.
+
+       PostData(0,cosmicTree);
+       PostData(1,histo);
+}      
+
+//________________________________________________________________________
+void AliAnalysisTaskAcorde::Terminate(Option_t *) 
+{
+
+//     AliDebug(1,"Do nothig in Terminate");
+
+       //nPart->Draw();
+        TCanvas *c1 = new TCanvas("c1","TPC-resolution for P reconstruction .... MRC");
+
+        c1->Divide(2,2);
+       c1->cd(1);
+       acordeHitsAll->Draw();
+       c1->cd(2)->SetLogy();
+       acordeMultiAll->Draw();
+       c1->cd(3)->SetLogy();
+       //nTracksMatched->Draw();
+       ntracks->Draw();
+       c1->cd(4);
+       fTracksToAcorde->Draw();
+       
+       
+
+
+}
diff --git a/ACORDE/macros/AnalysisMacros/Local/AliAnalysisTaskAcorde.h b/ACORDE/macros/AnalysisMacros/Local/AliAnalysisTaskAcorde.h
new file mode 100644 (file)
index 0000000..de1686b
--- /dev/null
@@ -0,0 +1,84 @@
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// AliAnalysisTaskAcorde class\r
+//\r
+// Description:\r
+//\r
+//     Reads the information of ACORDE-ESD\r
+//     Also it is implemented a simple matching between tracks\r
+//     to look for the extrapolation of them to ACORDE modules\r
+//\r
+//     Create some histograms and one tree with the information\r
+//     of the matching tracks\r
+//\r
+//  Author: Mario Rodr√≠guez Cahuantzi\r
+//             <mario.rocah@gmail.com>\r
+//             <mrodrigu@mail.cern.ch>\r
+//\r
+//  Created: June 30th. 2010 @ FCFM - BUAP, Puebla, MX\r
+//  Last update: created\r
+//\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef AliAnalysisTaskAcorde_cxx\r
+#define AliAnalysisTaskAcorde_cxx\r
+\r
+class TH2F;\r
+class TH1F;\r
+class AliESDEvent;\r
+class TArrayI;\r
+class TList;\r
+#include "AliAnalysisTask.h"\r
+\r
+class AliAnalysisTaskAcorde : public AliAnalysisTask {\r
+ public:\r
+  AliAnalysisTaskAcorde(const char *name = "AliAnalysisTaskAcorde");\r
+  virtual ~AliAnalysisTaskAcorde();            //! Destructor fo task\r
+  \r
+  virtual void   ConnectInputData(Option_t *);         //! Connects input data to class analysis\r
+  virtual void   CreateOutputObjects();        //! Creates output object (cosmicTree)\r
+  virtual void   Exec(Option_t *option);       //! Execution class\r
+  virtual void   Terminate(Option_t *);        //! Terminate class \r
+\r
+ private:\r
+\r
+\r
+  AliESDEvent *fESD;                   //! ESD object\r
+  TArrayI      *fPair;                 //! Pair track connected (up & down)\r
+  TTree *cosmicTree;                   //! TTree with some information of matched tracks\r
+  Int_t nTracks;                       //! # of recontructed tracks\r
+  Int_t nMatchTracks;                  //! # of matched tracks\r
+\r
+\r
+  // Cut definitions\r
+\r
+  const Int_t minTPCclusters;          //! cut in clusters\r
+  const Float_t minTrackDist;          //! cut in distance\r
+  const Float_t minCutDir;             //! minimum cut\r
+\r
+  Float_t xAco;                                //! x-coordinate of extrapolated track to ACORDE\r
+  Float_t yAco;                                //! y-coordinate of extrapolated track to ACORDE\r
+  Float_t zAco;                                //! z-coordinate of extrapolated track to ACORDE\r
+  Int_t trigger;                       //! trigger label\r
+  TString ActiveTriggerDetector;       //! detector string     \r
+\r
+  Int_t nSingleTracks;                 //! no. of single track\r
+  Int_t nMatchedTracks;                        //! no. of matched track\r
+  \r
+\r
+  TList *histo;                                //! list of histograms\r
+  TH1F *acordeHitsAll;                 //! hits of acorde\r
+  TH1F *acordeMultiAll;                        //! multi. of acorde modules\r
+  TH1F *acordeHitsTPC;                 //! hits of acorde (if track)\r
+  TH1F *acordeMultiTPC;                        //! multi. of acorde modules (if track)\r
+  TH1F *nTracksMatched;                        //! matched tracks\r
+  TH1F *ntracks;                       //! no. of tracks\r
+  TH2F *fTracksToAcorde;               //! tracks extrapolated to acorde.\r
+\r
+  AliAnalysisTaskAcorde(const AliAnalysisTaskAcorde&); // not implemented\r
+  AliAnalysisTaskAcorde& operator=(const AliAnalysisTaskAcorde&); // not implemented\r
+  \r
+  ClassDef(AliAnalysisTaskAcorde, 1); // example of analysis\r
+};\r
+\r
+#endif\r
diff --git a/ACORDE/macros/AnalysisMacros/Local/files.txt b/ACORDE/macros/AnalysisMacros/Local/files.txt
new file mode 100644 (file)
index 0000000..0a136e7
--- /dev/null
@@ -0,0 +1 @@
+http://mrodrigu.web.cern.ch/mrodrigu/testOffline/data/001/AliESDs.root
diff --git a/ACORDE/macros/AnalysisMacros/Local/runAcordeAna.C b/ACORDE/macros/AnalysisMacros/Local/runAcordeAna.C
new file mode 100755 (executable)
index 0000000..a9b2cb1
--- /dev/null
@@ -0,0 +1,48 @@
+void runAcordeAna()
+{
+  // load analysis framework
+
+  gSystem->Load("libANALYSIS.so");
+  gSystem->Load("libANALYSISalice.so");
+  gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
+  TChain* chain = CreateESDChain("files.txt",1);
+  // for includes use either global setting in $HOME/.rootrc
+  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
+  // or in each macro
+
+  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
+
+  // Create the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
+
+  AliESDInputHandler* esdH = new AliESDInputHandler();
+  esdH->SetReadFriends(kFALSE);
+  mgr->SetInputEventHandler(esdH);
+
+  // Create task
+
+  gROOT->LoadMacro("AliAnalysisTaskAcorde.cxx+g");
+  AliAnalysisTask *task = new AliAnalysisTaskAcorde("TaskAcordeTest");
+
+  // Add task
+  mgr->AddTask(task);
+
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
+  AliAnalysisDataContainer *coutput = mgr->CreateContainer("treeCosmic",TTree::Class(),AliAnalysisManager::kOutputContainer,"acordeOutput1.root");
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("treeList",TList::Class(),AliAnalysisManager::kOutputContainer,"acordeOutput2.root");
+
+  // Connect input/output
+  mgr->ConnectInput(task, 0, cinput);
+  mgr->ConnectOutput(task, 0, coutput);
+  mgr->ConnectOutput(task,1,coutput1);
+  // Enable debug printouts
+  mgr->SetDebugLevel(2);
+
+  if (!mgr->InitAnalysis())
+    return;
+
+  mgr->PrintStatus();
+
+  mgr->StartAnalysis("local", chain);
+}
diff --git a/ACORDE/macros/TestACORDEHits.C b/ACORDE/macros/TestACORDEHits.C
new file mode 100755 (executable)
index 0000000..547dcbc
--- /dev/null
@@ -0,0 +1,220 @@
+/////////////////////////////////////////////////////////////////////////
+//   This macro is a small example of a ROOT macro
+//   illustrating how to read the hits in ACORDE,
+//   fill some histograms and store it on a file
+//
+//   Author:
+//
+//     Eleazar Cuautle <ecuautle@nucleares.unam.mx>
+//
+//   Also:
+//
+//     Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
+//             
+/////////////////////////////////////////////////////////////////////////
+
+void TestACORDEHits (const char *filename="galice.root",Int_t numberOfEvents=0){
+   // delete existing gAlice
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) 
+    {
+      gROOT->LoadMacro("loadlibs.C");
+      loadlibs();
+    }
+  if (gAlice)
+    {
+      //delete gAlice->GetRunLoader();
+      delete gAlice;
+      gAlice = 0x0;
+    }
+  
+  AliRunLoader *rl = AliRunLoader::Open("galice.root",
+                                       AliConfig::GetDefaultEventFolderName(),"read");
+  if (!rl)
+    {
+      cerr<<"Can't load RunLoader from file! \n";      return 0x0;
+    }
+  
+  rl->LoadgAlice();
+  gAlice = rl->GetAliRun();
+  if (!gAlice)
+    {
+      cerr << " AliRun object not found on file \n";     return 0x0; 
+    }
+  rl->LoadHeader();
+  
+  // Get the pointer to the ACORDE detector
+  AliLoader *acordel = rl->GetLoader("ACORDELoader");
+  AliACORDE *ACORDE = (AliACORDE *) gAlice->GetDetector("ACORDE");
+  if (ACORDE == 0x0 || acordel == 0x0) {
+    cerr << " Can not find ACORDE or ACORDELoader \n";    return 0x0;  
+  }
+  //Determine how many events would you like to analyze
+  if (numberOfEvents==0) numberOfEvents=(Int_t)(rl->GetNumberOfEvents());
+  
+  //create histograms
+
+  TH1F *fACORDEEnergy = new TH1F("fACORDEEnergy","Energy distribution of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE); Energy (GeV)",1200,0,360);
+  TH1F *fACORDEEnergyLoss = new TH1F("fACORDEEnergyLoss","Loss energy distribution  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE);Energy loss (Gev)",100,0,0.030);
+  TH1F *fACORDEAzimuth = new TH1F("fACORDEAzimuth","Azimuth angle distribution of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE); Azimuth angle",360,-180,180);
+  TH1F *fACORDEPolar = new TH1F("fACORDEPolar","Polar angle distribution  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE); Polar angle",180,0,180);
+  TH2F  *fACORDExz = new TH2F("fACORDExz" ,"Distribution XZ  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE); X (cms); Z (cms) ",900,-850.,850.,1200,-500.,500.); 
+  TH2F  *fACORDEAzimPol =  new TH2F("fACORDEAzimPol" ,"Azimuth vs Polar angle distribution ",360,-180.,180.,180,0.,180.);
+  TH1F  *fACORDEPx = new TH1F("fACORDEPx" ,"P_{x} distribution  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE);GeV/c;dN/dP_{x}",60,-120.,120.);
+  TH1F  *fACORDEPy = new TH1F("fACORDEPy" ,"P_{y} distribution  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE);GeV/c;dN/dP_{y}",60,-120.,120.);
+  TH1F  *fACORDEPz = new TH1F("fACORDEPz" ,"P_{z} distribution  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE);GeV/c;dN/dP_{z}",60,-120.,120.);
+  TH1F  *fACORDEPt = new TH1F("fACORDEPt" ,"P_{t} distribution  of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE);GeV/c;dN/dP_{t}",1200,0.,360.);
+  TH2F  *fELossAzimuth = new TH2F("fELossAzimuth","Dist. Azimuth Angle VS Energy Loss; Azimuth angle; Energy (GeV)",360,0,350,100,0,0.030); 
+  TH2F  *fEnergyAzimuth = new TH2F("fEnergyAzimuth","Dist. Azimuth Angle VS Energy; Azimuth angle; Energy (GeV)",360,0,360,300,0,350); 
+  TH2F  *fELossPolar = new TH2F("fELossPolar","Dist. Polar Angle VS Energy Loss; Polar angle; Energy (GeV)",180,0,180,100,0,0.030); 
+  TH2F  *fEnergyPolar = new TH2F("fEnergyPolar","Dist. Polar Angle VS Energy; Polar angle; Energy (GeV)",180,0,180,300,0,350); 
+
+ //------------------------------------------------------------------//
+  
+  for (Int_t ievent=0; ievent<numberOfEvents; ievent++) {
+    if ((ievent%10) == 0)  printf ("Processing event %d \n", ievent);
+    rl->GetEvent(ievent);
+    
+    // Get the pointer Hit tree
+    acordel->LoadHits();
+    TTree *hitTree = acordel->TreeH();
+    ACORDE->SetTreeAddress();
+    if (!hitTree) {
+      cout << " No TreeH found" << endl;      return 0x0; //rc;
+    }
+    
+    rl->LoadKinematics();
+    Int_t nTrack = (Int_t) hitTree->GetEntries();
+    //    cout <<"<AliACORDEanalyzeHits> Found "<< nTrack <<" primary particles with hits \n";
+    
+    // Start loop on tracks in the hits containers
+    for(Int_t iTrack=0; iTrack<nTrack;iTrack++){
+      ACORDE->ResetHits();
+      hitTree->GetEvent(iTrack);          
+      if(ACORDE) {      
+       for(acordeHit=(AliACORDEhit*)ACORDE->FirstHit(-1);acordeHit;
+           acordeHit=(AliACORDEhit*)ACORDE->NextHit()) {
+               fACORDEEnergy->Fill(acordeHit->Energy());
+               fACORDEEnergyLoss->Fill(acordeHit->Eloss());
+               fACORDEAzimuth->Fill(acordeHit->AzimuthAngle());
+               fACORDEPolar->Fill(acordeHit->PolarAngle());
+               fACORDExz->Fill(acordeHit->X(),acordeHit->Z());
+               fELossAzimuth->Fill((Float_t)(acordeHit->AzimuthAngle()),(Float_t)(acordeHit->Eloss()));
+               fACORDEPx->Fill( (Float_t)(acordeHit->Px()));
+               fACORDEPy->Fill( (Float_t)(acordeHit->Py()));
+               fACORDEPz->Fill( (Float_t)(acordeHit->Pz()));
+               fACORDEPt->Fill( TMath::Sqrt( (acordeHit->Px())*(acordeHit->Px())+
+                                            (acordeHit->Py())*(acordeHit->Py())) );
+               fACORDEAzimPol->Fill( (Float_t)(acordeHit->AzimuthAngle()),
+                               (Float_t)(acordeHit->PolarAngle()));
+               fEnergyAzimuth->Fill(acordeHit->Energy(),acordeHit->AzimuthAngle());
+               fEnergyPolar->Fill(acordeHit->Energy(),acordeHit->PolarAngle());
+               fELossPolar->Fill(acordeHit->PolarAngle(),acordeHit->Eloss());
+       //cout << "Muon triggered by ACORDE "<<endl;
+       //cout << "Energy: "<<acordeHit->Energy()<<" EnergyLoss: "<<acordeHit->Eloss()<<" Polar angle: "<<acordeHit->PolarAngle()<<" Azimuth angle: "<<acordeHit->AzimuthAngle()<<endl;
+
+       } // end for acordeHits
+      } // end if ACORDE
+    } // end for iTrack  
+  }
+
+ // Put the histograms in a TCanvas
+
+       TCanvas *c1 = new TCanvas("c1","ACORDE Hits distribution of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE)");
+       c1->Divide(2,1);
+
+       c1->cd(1)->SetLogy();
+       fACORDEEnergy->SetMarkerStyle(kFullCircle);
+       fACORDEEnergy->SetMarkerSize(0.7);
+       fACORDEEnergy->Draw("E");
+
+       c1->cd(2)->SetLogy();
+       fACORDEEnergyLoss->SetMarkerStyle(kFullCircle);
+       fACORDEEnergyLoss->SetMarkerSize(0.7);
+       fACORDEEnergyLoss->Draw("E");
+       
+       c1->Draw();
+
+       TCanvas *c2 = new TCanvas("c2","ACORDE Hits distribution of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE)");
+       c2->Divide(2,2);
+       c2->cd(1);
+       fACORDEAzimuth->Draw();
+
+       c2->cd(2);
+       fACORDEPolar->Draw();
+
+       c2->cd(3);
+       gStyle->SetPalette(1);
+       fACORDExz->DrawCopy("colz");
+       
+       c2->cd(4);
+       gStyle->SetPalette(1);
+       fACORDEAzimPol->DrawCopy("colz");
+
+       c2->Draw();
+
+       TCanvas *c3 = new TCanvas("c3","ACORDE Hits distribution of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE)");
+       c3->Divide(2,2);
+
+       c3->cd(1)->SetLogy();
+       fACORDEPx->SetMarkerStyle(kFullCircle);
+       fACORDEPx->SetMarkerSize(0.7);
+       fACORDEPx->Draw("E");
+
+       c3->cd(2)->SetLogy();
+       fACORDEPy->SetMarkerStyle(kFullCircle);
+       fACORDEPy->SetMarkerSize(0.7);
+       fACORDEPy->Draw("E");
+
+       c3->cd(3)->SetLogy();
+       fACORDEPz->SetMarkerStyle(kFullCircle);
+       fACORDEPz->SetMarkerSize(0.7);
+       fACORDEPz->Draw("E");
+
+       c3->cd(4)->SetLogy();
+       fACORDEPt->SetMarkerStyle(kFullCircle);
+       fACORDEPt->SetMarkerSize(0.7);
+       fACORDEPt->Draw("E");
+
+       c3->Draw();
+
+       TCanvas *c4 = new TCanvas("c4","ACORDE Hits distribution of muons generated by AliGenCosmicParam at z = 900 cms (Just above ACORDE)");
+       c4->Divide(2,2);
+
+       c4->cd(1);
+       gStyle->SetPalette(1);
+       fEnergyPolar->DrawCopy("colz");
+
+       c4->cd(2);
+       gStyle->SetPalette(1);
+       fEnergyAzimuth->DrawCopy("colz");
+
+       c4->cd(3);
+       gStyle->SetPalette(1);
+       fELossPolar->DrawCopy("colz");
+
+       c4->cd(4);
+       gStyle->SetPalette(1);
+       fELossAzimuth->DrawCopy("colz");
+       
+       c4->Draw();
+
+
+ // save histos in a root file
+  TFile *fout = new TFile("ACORDE_hits.root","RECREATE");
+       fACORDEEnergy->Write();
+       fACORDEEnergyLoss->Write();
+       fACORDEAzimuth->Write();
+       fACORDEPolar->Write();
+       fACORDExz->Write();
+       fELossAzimuth->Write();
+       fACORDEPx->Write();
+       fACORDEPy->Write();
+       fACORDEPz->Write();
+       fACORDEPt->Write();
+       fACORDEAzimPol->Write();
+       c1->Write();
+       c2->Write();
+       c3->Write();
+       c4->Write();
+}
diff --git a/ACORDE/macros/readACORDEESD.C b/ACORDE/macros/readACORDEESD.C
new file mode 100755 (executable)
index 0000000..e2bf600
--- /dev/null
@@ -0,0 +1,112 @@
+/*************************************************************
+
+       Macro used for reading the information
+       recorded by ACORDE detector from ESD fles and test the
+       correction of ACORDE ESDs
+       
+       Author: 
+       
+               Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
+
+       Created: Sep. 24th 2009 @ CERN
+
+
+**************************************************************/
+
+void readACORDEESD()
+{
+
+       // Time's counter
+       
+       TStopwatch timer;
+       
+       timer.Start();
+
+       TH1D *h1 = new TH1D("h1","ACORDE - Single Muon Trigger Hits",60,-0.5,59.5);
+       TH1D *h2 = new TH1D("h2","ACORDE - Single Muon Trigger Hit Multiplicity",60,-1,60);
+       TH1D *h3 = new TH1D("h3","ACORDE - Multi Muon Trigger Hits",60,-0.5,59.5);
+       TH1D *h4 = new TH1D("h4","ACORDE - Multi Muon Trigger Hit Multiplicity",60,-1,60);
+
+       // Pointer to the ESD file
+       
+       TFile *ef = TFile::Open("AliESDs.root");
+    
+       // Check if the ESD file is OK
+                   
+       if (!ef || !ef->IsOpen()) 
+       {
+               cerr<<"Can't read AliESDs.root !\n"; 
+               return 1;
+       }
+       
+       // Pointer to the ESD event
+       
+       AliESDEvent* fESD = new AliESDEvent();
+       
+       // Pointer to the esdTree 
+       
+       TTree* tree = (TTree*) ef->Get("esdTree");
+       
+       // Check if the  esdTree is Ok
+       
+       if (!tree) 
+       {
+               cerr<<"no ESD tree found\n"; 
+               return 1;
+       }
+       
+       fESD->ReadFromTree(tree);
+
+       Int_t n=1;
+
+       // Loop over all events
+       
+       while (tree->GetEvent(n))
+       {
+
+               Int_t nMuons = 0;
+       
+               cout<<endl<<"Processing event number : "<<n++<<endl;
+               
+               // We select only events triggered by ACORDE
+       
+               TString ActiveTriggerDetector = fESD->GetFiredTriggerClasses();
+               printf("Event:%d, Trigger:%s\n",fESD->GetEventNumberInFile(),ActiveTriggerDetector.Data());
+
+               // if ACORDE trigger is on
+               // else if ACORDE is working as readout just comment the condition
+               if (ActiveTriggerDetector.Contains("AMU") || ActiveTriggerDetector.Contains("SL0") )            
+               {
+
+                       cout<<endl<<"Processing event number : "<<n++<<endl;
+                       printf("Trigger Mask:%s\n",ActiveTriggerDetector.Data());
+
+                       AliESDACORDE *acordeESD = fESD->GetACORDEData();
+                       Int_t contMulti = 0;
+                       for(Int_t i=0;i<60;i++)
+                       {
+                               if (acordeESD->GetHitChannel(i)==kTRUE) 
+                               //if (acordeESD->GetACORDEBitPattern(i))
+                               {
+                                       h1->Fill(i);
+                                       contMulti++;
+                               }
+                       }               
+                       h2->Fill(contMulti);
+               } //Only acorde trigger
+       } // Loop over all events from AliESDs.root             
+
+       TCanvas *c1 = new TCanvas();
+       c1->Divide(2,1);
+       c1->cd(1);
+       h1->Draw();
+       c1->cd(2);
+       h2->Draw();
+
+       timer.Stop();
+       timer.Print();  
+
+
+
+} // Main Procedure 
+
diff --git a/ACORDE/macros/readACORDERawData.C b/ACORDE/macros/readACORDERawData.C
new file mode 100644 (file)
index 0000000..26e89f7
--- /dev/null
@@ -0,0 +1,152 @@
+//////////////////////////////////////////////////////////////////
+//                                                             //
+//     readACORDERawData.C macro                               //
+//                                                             //
+//     Reads the information of ACORDE from raw data file      //
+//     from the 4-32-words (SL0 & MCN mode)                    //
+//     and draws four histograms (2 by each mode)              //
+//                                                             //
+//     Author: Mario Rodriguez Cahuantzi                       //
+//     E-MaiL: mario.rocah@gmail.com, mrodrigu@mail.cern.ch    //
+//                                                             //
+//     Created: July 1st. 2010 @ FCFM -BUAP, Puebla, MX        //
+//     Last update: created from old AcoReco.C macro           //
+//                                                             //
+//////////////////////////////////////////////////////////////////
+
+void readACORDERawData(char* fileName)
+{
+
+       TStopwatch timer;
+       timer.Start();
+       // Pointer to rawReader class
+
+       AliRawReader* rawReader = new AliRawReaderRoot(fileName); 
+       
+       // Pointer to rawData of Acorde
+
+       AliACORDERawStream* rawStream  = new AliACORDERawStream(rawReader);    
+       
+       // Create some histograms
+
+       TH1F *h1 = new TH1F("h1","ACORDE - Single Muon Hits (SL0)",60,-0.5,59.5);
+       TH1F *h2 = new TH1F("h2","ACORDE - Multiplicity of Acorde Modules (SL0)",61,-1,60);
+       TH1F *h3 = new TH1F("h3","ACORDE - Single Muon Hits (MCN)",60,-0.5,59.5);
+       TH1F *h4 = new TH1F("h4","ACORDE - Multiplicity of Acorde Modules (MCN)",61,-1,60);
+       
+       // Declare some counters
+       
+       size_t contSingle=0;
+       size_t contMulti=0;
+       UInt_t acorde_word[4]; // array to store the 4-words
+       bool word_sl0[60],word_mcn[60]; // boolean array if some hit in module
+       UInt_t shiftword; // shift word
+
+       for(Int_t m=0;m<60;m++) {word_sl0[m]=0;word_mcn[m]=0;}
+  
+       Int_t nEvents = rawStream->GetNEvents(fileName);
+  
+       printf("File: %s, Number of events: %d \n",fileName,nEvents);
+
+
+       // Loop over all the events
+
+       for (Int_t i=1; i<=nEvents; i++) 
+       {
+
+                       if (!rawReader->NextEvent()) break;
+               rawStream->Reset();
+               if (!rawStream->Next()) continue;
+
+               acorde_word[0] = rawStream->GetWord(0);
+               acorde_word[1] = rawStream->GetWord(1);
+               acorde_word[2] = rawStream->GetWord(2);
+               acorde_word[3] = rawStream->GetWord(3);
+
+               shiftword = acorde_word[0];
+               for(Int_t iaco=0;iaco<30;iaco++)
+               {
+                       word_sl0[iaco] = shiftword & 1;
+                       shiftword>>=1;
+               }
+       
+               shiftword = acorde_word[1];
+               for(Int_t iaco=30;iaco<60;iaco++)
+               {
+                       word_sl0[iaco] = shiftword & 1;
+                       shiftword>>=1;
+               }
+
+               shiftword=acorde_word[2];
+               for(Int_t iaco=0;iaco<30;iaco++)
+               {
+                       word_mcn[iaco] = shiftword & 1;
+                       shiftword>>=1;
+               }
+
+               shiftword=acorde_word[3];
+               for(Int_t iaco=30;iaco<60;iaco++)
+               {
+                       word_mcn[iaco] = shiftword & 1;
+                       shiftword>>=1;
+               }
+
+               contSingle=0;   
+               for(Int_t iaco=0;iaco<60;iaco++) 
+               {
+                       if(word_sl0[iaco]==1) 
+                       {
+                               h1->Fill(iaco);
+                               contSingle++;
+                       }
+               
+               }h2->Fill(contSingle);
+               contMulti=0;
+               for(Int_t iaco=0;iaco<60;iaco++) 
+               {
+                       if(word_mcn[iaco]==1) 
+                       {
+                               h3->Fill(iaco);
+                               contMulti++;
+                       }
+               
+               }h4->Fill(contMulti);
+
+       }
+
+       TCanvas *acorde = new TCanvas("ACORDE","ACORDE-Histograms from Raw-Data",1);
+       acorde->Divide(2,2);
+       acorde->cd(1);
+       h1->GetXaxis()->SetTitle("No. of module");
+       h1->GetYaxis()->SetTitle("No. of Hits");
+       h1->SetFillColor(kRed);
+       h1->Draw();
+
+       acorde->cd(2);
+       gPad->SetLogy();
+       h2->GetXaxis()->SetTitle("No. of fired modules");
+       h2->GetYaxis()->SetTitle("No. of events");
+       h2->SetFillColor(kBlue);
+       h2->Draw();
+
+       acorde->cd(3);
+       h3->GetXaxis()->SetTitle("No. of module");
+       h3->GetYaxis()->SetTitle("No. of events");
+       h3->SetFillColor(kRed);
+       h3->Draw();
+
+       acorde->cd(4);
+       gPad->SetLogy();
+       h4->GetXaxis()->SetTitle("No. of fired modules");
+       h4->GetYaxis()->SetTitle("No. of events");
+       h4->SetFillColor(kBlue);
+       h4->Draw();
+       
+
+       delete rawReader;
+       delete rawStream;
+
+       timer.Stop();
+       timer.Print();
+}
diff --git a/ACORDE/macros/testMC/Config_AliGenACORDE.C b/ACORDE/macros/testMC/Config_AliGenACORDE.C
new file mode 100644 (file)
index 0000000..eeaffc2
--- /dev/null
@@ -0,0 +1,406 @@
+// One can use the configuration macro in compiled mode by
+// root [0] gSystem->Load("libgeant321");
+// root [0] gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include\
+//                   -I$ALICE_ROOT -I$ALICE/geant3/TGeant3");
+// root [0] .x grun.C(1,"Config.C++")
+/*********************************************************************************
+
+       Config to simulate cosmic muons using the AliGenACORDE class
+
+
+       Comments to:
+
+               Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
+               FCFM-BUAP, Puebla, Pue. Mexico
+
+       Nov. 18th. 2009 @ INFN sez. Torino, Italy
+
+
+**********************************************************************************/
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <Riostream.h>
+#include <TRandom.h>
+#include <TSystem.h>
+#include <TVirtualMC.h>
+#include <TGeant3TGeo.h>
+#include "STEER/AliRunLoader.h"
+#include "STEER/AliRun.h"
+#include "STEER/AliConfig.h"
+#include "PYTHIA6/AliDecayerPythia.h"
+#include "EVGEN/AliGenCocktail.h"
+#include "EVGEN/AliGenCosmicsParam.h"
+#include "EVGEN/AliGenHIJINGpara.h"
+#include "STEER/AliMagFMaps.h"
+#include "STRUCT/AliBODY.h"
+#include "STRUCT/AliMAG.h"
+#include "STRUCT/AliABSOv0.h"
+#include "STRUCT/AliDIPOv2.h"
+#include "STRUCT/AliHALL.h"
+#include "STRUCT/AliFRAMEv2.h"
+#include "STRUCT/AliSHILv2.h"
+#include "STRUCT/AliPIPEv0.h"
+#include "ITS/AliITSv11Hybrid.h"
+#include "TPC/AliTPCv2.h"
+#include "TOF/AliTOFv5T0.h"
+#include "HMPID/AliHMPIDv3.h"
+#include "ZDC/AliZDCv3.h"
+#include "TRD/AliTRDv1.h"
+#include "FMD/AliFMDv1.h"
+#include "MUON/AliMUONv1.h"
+#include "PHOS/AliPHOSv1.h"
+#include "PMD/AliPMDv1.h"
+#include "START/AliSTARTv1.h"
+#include "EMCAL/AliEMCALv2.h"
+#include "ACORDE/AliACORDEv1.h"
+#include "VZERO/AliVZEROv7.h"
+#endif
+
+//--- Magnetic Field ---
+enum Mag_t
+{
+    k2kG, k4kG, k5kG
+};
+
+Float_t EtaToTheta(Float_t arg);
+
+static Mag_t         mag      = k5kG; 
+void LoadPythia();
+void Config()
+{
+    // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
+    // Theta range given through pseudorapidity limits 22/6/2001
+
+    // Set Random Number seed
+  TDatime dt;
+  UInt_t curtime=dt.Get();
+  UInt_t procid=gSystem->GetPid();
+  UInt_t seed=curtime-procid;
+  if (gSystem->Getenv("envevno")) {
+    seed=atoi(gSystem->Getenv("envevno"));
+    seed += 1000; // 0 e' il seed dall'orologio....
+    printf("...taking seed as event number + 1000...\n");
+  }
+  printf("...setting seed as %d...\n",seed);
+  gRandom->SetSeed(seed);
+  printf("Seed for random number generation = %d \n",gRandom->GetSeed());
+
+
+  //  AliLog::Message(AliLog::kInfo, Form("Seed for random number generation = %d",gRandom->GetSeed()), "Config.C", "Config.C", "Config()","Config.C", __LINE__);
+
+LoadPythia();
+   // libraries required by geant321
+#if defined(__CINT__)
+    gSystem->Load("libgeant321");
+#endif
+
+    new     TGeant3TGeo("C++ Interface to Geant3");
+
+    if(!AliCDBManager::Instance()->IsDefaultStorageSet()){
+      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+      AliCDBManager::Instance()->SetRun(0);
+    }
+
+    AliRunLoader* rl=0x0;
+
+    AliLog::Message(AliLog::kInfo, "Creating Run Loader", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);
+
+    rl = AliRunLoader::Open("galice.root",
+                           AliConfig::GetDefaultEventFolderName(),
+                           "recreate");
+    if (rl == 0x0)
+      {
+       gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
+       return;
+      }
+    rl->SetCompressionLevel(2);
+    rl->SetNumberOfEventsPerFile(100000);
+    gAlice->SetRunLoader(rl);
+
+   // to load an alternative geometry
+
+    // gAlice->SetGeometryFromFile("geometry.root");
+    // gAlice->SetGeometryFromCDB();
+
+    // Set the trigger configuration
+
+    AliSimulation::Instance()->SetTriggerConfig("ACORDE");
+    cout<<"Trigger configuration is set to  ACORDE"<<endl;
+
+    //
+    // Set External decayer
+
+    TVirtualMCDecayer *decayer = new AliDecayerPythia();
+
+    decayer->SetForceDecay(kAll);
+    decayer->Init();
+    gMC->SetExternalDecayer(decayer);
+
+
+    //=======================================================================
+    // ************* STEERING parameters FOR ALICE SIMULATION **************
+    // --- Specify event type to be tracked through the ALICE setup
+    // --- All positions are in cm, angles in degrees, and P and E in GeV
+
+
+    gMC->SetProcess("DCAY",1);
+    gMC->SetProcess("PAIR",1);
+    gMC->SetProcess("COMP",1);
+    gMC->SetProcess("PHOT",1);
+    gMC->SetProcess("PFIS",0);
+    gMC->SetProcess("DRAY",0);
+    gMC->SetProcess("ANNI",1);
+    gMC->SetProcess("BREM",1);
+    gMC->SetProcess("MUNU",1);
+    gMC->SetProcess("CKOV",1);
+    gMC->SetProcess("HADR",1);
+    gMC->SetProcess("LOSS",2);
+    gMC->SetProcess("MULS",1);
+    gMC->SetProcess("RAYL",1);
+
+    Float_t cut = 1.e-3;        // 1MeV cut by default
+    Float_t tofmax = 1.e10;
+
+    gMC->SetCut("CUTGAM", cut);
+    gMC->SetCut("CUTELE", cut);
+    gMC->SetCut("CUTNEU", cut);
+    gMC->SetCut("CUTHAD", cut);
+    gMC->SetCut("CUTMUO", cut);
+    gMC->SetCut("BCUTE",  cut); 
+    gMC->SetCut("BCUTM",  cut); 
+    gMC->SetCut("DCUTE",  cut); 
+    gMC->SetCut("DCUTM",  cut); 
+    gMC->SetCut("PPCUTM", cut);
+    gMC->SetCut("TOFMAX", tofmax); 
+
+
+
+    cout << "<<< *** Using the cosmic generator AliGenACORDE *** >>>" << endl;
+
+    AliGenACORDE *gener = new AliGenACORDE();
+    gener->SetZenithalAngleRange(0.,65.);
+    gener->SetAzimuthalAngleRange(0.,359.);
+    gener->SetMomentumResolution(1.);
+    gener->SetSigma(0,0,0);
+    gener->SetMomentumRange(10.,1000.);
+    gener->SetNumberOfParticles(100);
+    // two options
+    // kMuonMinus
+    // kMuinPlus
+    gener->SetPart(kMuonMinus);
+
+    // three options
+    // kSingleMuons
+    // kMuonBundle
+    // kMuonFlux --> not yet
+
+    gener->SetMode(kSingleMuons);
+
+    // If you choose kMuonBundle, you should set how many particles do you
+    // want and in wich region should the muons be generated, for instance
+    // if you want to generate n^2 muons, in a square of side 300 cm
+    //gener->SetRange(4, 300., 4, 300.);
+
+    // gener->SetVertexSmear(kPerEvent); // Set the smearing per Event
+
+
+    // Starts the generation
+
+    gener->Init();
+
+
+
+    // MAGNETIC FIELD IN THE BARREL, by default set to 0.5 Teslas
+   
+    TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 1., 1.,  AliMagF::k5kG));
+
+
+    // Only with ACORDE and TPC detectors
+    // for cosmic analysis TOF (iFRAME) and ITS could be set to ON
+
+    Int_t   iABSO  =  0;
+    Int_t   iDIPO  =  0;
+    Int_t   iFMD   =  0;
+    Int_t   iFRAME =  0;
+    Int_t   iHALL  =  0;
+    Int_t   iITS   =  0;
+    Int_t   iMAG   =  1;
+    Int_t   iMUON  =  0;
+    Int_t   iPHOS  =  0;
+    Int_t   iPIPE  =  0;
+    Int_t   iPMD   =  0;
+    Int_t   iHMPID =  0;
+    Int_t   iSHIL  =  0;
+    Int_t   iSTART =  0;
+    Int_t   iTOF   =  0;
+    Int_t   iTPC   =  1;
+    Int_t   iTRD   =  0;
+    Int_t   iZDC   =  0;
+    Int_t   iEMCAL =  0;
+    Int_t   iACORDE   =  1;
+    Int_t   iVZERO =  0;
+    rl->CdGAFile();
+    //=================== Alice BODY parameters =============================
+    AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
+
+    if (iMAG)
+    {
+        //=================== MAG parameters ============================
+        // --- Start with Magnet since detector layouts may be depending ---
+        // --- on the selected Magnet dimensions ---
+        AliMAG *MAG = new AliMAG("MAG", "Magnet");
+    }
+
+
+    if (iABSO)
+    {
+        //=================== ABSO parameters ============================
+        AliABSO *ABSO = new AliABSOv0("ABSO", "Muon Absorber");
+    }
+
+    if (iDIPO)
+    {
+        //=================== DIPO parameters ============================
+
+        AliDIPO *DIPO = new AliDIPOv2("DIPO", "Dipole version 2");
+    }
+
+    if (iHALL)
+    {
+        //=================== HALL parameters ============================
+
+        AliHALL *HALL = new AliHALL("HALL", "Alice Hall");
+    }
+
+
+    if (iFRAME)
+    {
+        //=================== FRAME parameters ============================
+
+        AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
+       FRAME->SetHoles(1);
+    }
+
+    if (iSHIL)
+    {
+        //=================== SHIL parameters ============================
+
+        AliSHIL *SHIL = new AliSHILv2("SHIL", "Shielding Version 2");
+    }
+
+
+    if (iPIPE)
+    {
+        //=================== PIPE parameters ============================
+
+        AliPIPE *PIPE = new AliPIPEv0("PIPE", "Beam Pipe");
+    }
+    if (iITS)
+    {
+        //=================== ITS parameters ============================
+
+       AliITS *ITS  = new AliITSv11Hybrid("ITS","ITS v11Hybrid");
+    }
+
+    if (iTPC)
+    {
+        //============================ TPC parameters ===================
+        AliTPC *TPC = new AliTPCv2("TPC", "Default");
+    }
+
+
+    if (iTOF) {
+        //=================== TOF parameters ============================
+       AliTOF *TOF = new AliTOFv5T0("TOF", "normal TOF");
+    }
+
+
+    if (iHMPID)
+    {
+        //=================== HMPID parameters ===========================
+        AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");
+
+    }
+
+
+    if (iZDC)
+    {
+        //=================== ZDC parameters ============================
+
+        AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
+    }
+
+    if (iTRD)
+    {
+        //=================== TRD parameters ============================
+
+        AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
+    }
+
+    if (iFMD)
+    {
+        //=================== FMD parameters ============================
+       AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
+   }
+
+    if (iMUON)
+    {
+        //=================== MUON parameters ===========================
+        // New MUONv1 version (geometry defined via builders)
+        AliMUON *MUON = new AliMUONv1("MUON", "default");
+    }
+    //=================== PHOS parameters ===========================
+
+    if (iPHOS)
+    {
+        AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
+    }
+
+
+    if (iPMD)
+    {
+        //=================== PMD parameters ============================
+        AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
+    }
+
+    if (iSTART)
+    {
+        //=================== START parameters ============================
+        AliSTART *START = new AliSTARTv1("START", "START Detector");
+    }
+
+    if (iEMCAL)
+    {
+        //=================== EMCAL parameters ============================
+        AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "SHISH_77_TRD1_2X2_FINAL_110DEG");
+    }
+
+     if (iACORDE)
+    {
+        //=================== ACORDE parameters ============================
+        AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
+    }
+
+     if (iVZERO)
+    {
+        //=================== ACORDE parameters ============================
+        AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
+    }
+
+     AliLog::Message(AliLog::kInfo, "End of Config", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);
+
+}
+
+Float_t EtaToTheta(Float_t arg){
+  return (180./TMath::Pi())*2.*atan(exp(-arg));
+}
+void LoadPythia()
+{
+    // Load Pythia related libraries
+
+    gSystem->Load("liblhapdf.so");      // Parton density functions
+    gSystem->Load("libEGPythia6.so");   // TGenerator interface
+    gSystem->Load("libpythia6.so");     // Pythia
+    gSystem->Load("libAliPythia6.so");  // ALICE specific implementations
+}
+
diff --git a/ACORDE/macros/testMC/cosmicSim.C b/ACORDE/macros/testMC/cosmicSim.C
new file mode 100644 (file)
index 0000000..3daff4a
--- /dev/null
@@ -0,0 +1,22 @@
+void cosmicSim(Int_t nev=10) {
+  AliSimulation simulator("Config_AliGenACORDE.C");
+  if (gSystem->Getenv("EVENT"))
+   nev = atoi(gSystem->Getenv("EVENT")) ;   
+  simulator.SetWriteRawData("ALL","raw.root",kTRUE);
+
+  simulator.SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  simulator.SetSpecificStorage("GRP/GRP/Data",
+                              Form("local://%s",gSystem->pwd()));
+  simulator.SetRunQA("ALL:ALL") ; 
+ simulator.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
+  
+  for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
+    simulator.SetQACycles(det, nev+1) ;
+  }
+simulator.SetEventSpecie(AliRecoParam::kCosmic);
+  TStopwatch timer;
+  timer.Start();
+  simulator.Run(nev);
+  timer.Stop();
+  timer.Print();
+}
diff --git a/ACORDE/macros/testMC/rec.C b/ACORDE/macros/testMC/rec.C
new file mode 100644 (file)
index 0000000..bf66f1a
--- /dev/null
@@ -0,0 +1,25 @@
+void rec() {
+  AliReconstruction reco;
+
+  reco.SetWriteESDfriend();
+  reco.SetWriteAlignmentData();
+
+  reco.SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  reco.SetSpecificStorage("GRP/GRP/Data",
+                         Form("local://%s",gSystem->pwd()));
+
+  reco.SetRunQA("ALL:ALL") ;
+  
+  reco.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
+  
+ for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
+    reco.SetQACycles(det, 999) ;
+    reco.SetQAWriteExpert(det) ; 
+  }
+  
+  TStopwatch timer;
+  timer.Start();
+  reco.Run();
+  timer.Stop();
+  timer.Print();
+}
diff --git a/ACORDE/macros/testMC/recraw/rec.C b/ACORDE/macros/testMC/recraw/rec.C
new file mode 100755 (executable)
index 0000000..3c8da5c
--- /dev/null
@@ -0,0 +1,30 @@
+void rec() {
+
+  AliReconstruction reco;
+
+  reco.SetWriteESDfriend();
+  reco.SetWriteAlignmentData();
+
+  reco.SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  reco.SetSpecificStorage("GRP/GRP/Data",
+                         Form("local://%s/..",gSystem->pwd()));
+
+  reco.SetRunQA("ALL:ALL") ;
+  
+  reco.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
+  
+  for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
+    reco.SetQACycles(det, 999) ;
+    reco.SetQAWriteExpert(det) ; 
+  }
+
+  reco.SetInput("raw.root");
+
+  reco.SetNumberOfEventsPerFile(-1); // all events in one single file
+
+  TStopwatch timer;
+  timer.Start();
+  reco.Run();
+  timer.Stop();
+  timer.Print();
+}
diff --git a/ACORDE/macros/testMC/run.sh b/ACORDE/macros/testMC/run.sh
new file mode 100755 (executable)
index 0000000..b896e92
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+echo '***** Running simulation and reconstruction Test for ACORDE Detector *****'
+echo '***** Comments to: Mario Rodriguez Cahuantzi *****'
+echo '***** <mrodrigu@mail.cern.ch>, <mario.rocah@gmail.com> *****'
+echo '***** Comments to: Pedro Podesta <podesta@cern.ch> *****'
+echo '***** FCFM - BUAP, Puebla, Pue. Mexico 2010 *****'
+echo '***** Current Date *****'
+date
+echo '************************'
+echo '***** Cleaning *****'
+rm -rf *.ps *.root *.dat *.log fort* hit hough raw* recraw/*.root recraw/*.log recraw/*.eps recraw/*.ps rm AliHL* raw* HLT GRP *.eps
+echo '***** Running cosmic simulation *****'
+aliroot -b -q  cosmicSim.C      2>&1 | tee simCosmic.log
+echo '***** Running cosmic reconstruction *****'
+aliroot -b -q  rec.C      2>&1 | tee recCosmic.log
+echo '***** Running cosmic reconstruction with RAW Input *****'
+cd recraw
+ln -s ../raw.root
+aliroot -b -q rec.C      2>&1 | tee recCosmic.log
+echo '***** Current Date *****'
+date
+echo '************************'
+echo '***** Test for ACORDE Concluded *****'
+echo '***** FCFM-BUAP, Puebla, Pue. Mexico *****'
+echo '***** MRC: <mrodrigu@mail.cern.ch>, <mario.rocah@gmail.com> *****'