]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALReconstructor.cxx
Removing AliMUONTransientDigit and adding AliMUONObjectPair class (Laurent)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructor.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 //*--
20 //*-- Yves Schutz (SUBATECH) 
21 // Reconstruction class. Redesigned from the old AliReconstructionner class and 
22 // derived from STEER/AliReconstructor. 
23 // 
24 // --- ROOT system ---
25
26 // --- Standard library ---
27
28 // --- AliRoot header files ---
29 #include "AliEMCALReconstructor.h"
30
31 #include "AliESD.h"
32 #include "AliRunLoader.h"
33 #include "AliEMCALLoader.h"
34 #include "AliEMCALClusterizerv1.h"
35 #include "AliEMCALRecPoint.h"
36 #include "AliRawReader.h"
37
38
39 ClassImp(AliEMCALReconstructor)
40
41 //____________________________________________________________________________
42 AliEMCALReconstructor::AliEMCALReconstructor() 
43   : fDebug(kFALSE) 
44 {
45   // ctor
46
47
48 //____________________________________________________________________________
49 AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
50   : AliReconstructor(rec),
51     fDebug(rec.fDebug)
52 {
53   //copy ctor
54 }
55
56 //____________________________________________________________________________
57 AliEMCALReconstructor::~AliEMCALReconstructor()
58 {
59   // dtor
60
61
62 //____________________________________________________________________________
63 void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader) const 
64 {
65   // method called by AliReconstruction; 
66   // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
67   // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by 
68   // the global tracking.
69  
70   TString headerFile(runLoader->GetFileName()) ; 
71   TString branchName(runLoader->GetEventFolder()->GetName() ) ;  
72   
73   AliEMCALClusterizerv1 clu(headerFile, branchName);
74   clu.SetEventRange(0, -1) ; // do all the events
75   if ( Debug() ) 
76     clu.ExecuteTask("deb all") ; 
77   else 
78     clu.ExecuteTask("pseudo") ;  
79  
80 }
81
82 //____________________________________________________________________________
83 void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const 
84 {
85   // method called by AliReconstruction; 
86   // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
87   // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by 
88   // the global tracking.
89   // Here we reconstruct from Raw Data
90   
91   rawreader->Reset() ; 
92   TString headerFile(runLoader->GetFileName()) ; 
93   TString branchName(runLoader->GetEventFolder()->GetName()) ;  
94
95   AliEMCALClusterizerv1 clu(headerFile, branchName);
96   clu.SetEventRange(0, -1) ; // do all the events
97   if ( Debug() ) 
98     clu.ExecuteTask("deb pseudo all") ; 
99   else 
100     clu.ExecuteTask("pseudo") ;  
101
102 }
103
104 //____________________________________________________________________________
105 void AliEMCALReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
106 {
107   // Called by AliReconstruct after Reconstruct() and global tracking and vertxing 
108
109   Int_t eventNumber = runLoader->GetEventNumber() ;
110
111   TString headerFile(runLoader->GetFileName()) ; 
112   TString branchName(runLoader->GetEventFolder()->GetName()) ;  
113   // Creates AliESDCaloCluster from AliEMCALRecPoints 
114   AliRunLoader *rl = AliRunLoader::GetRunLoader();
115   AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
116   rl->LoadRecPoints();
117   rl->LoadKinematics(); // To get the primary label
118   rl->LoadDigits();     // To get the primary label
119   rl->LoadHits();       // To get the primary label
120   rl->GetEvent(eventNumber);
121   TObjArray *clusters = emcalLoader->RecPoints();
122   Int_t nClusters = clusters->GetEntries();
123   esd->SetNumberOfEMCALClusters(nClusters) ; 
124   esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()) ; 
125
126   for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
127     const AliEMCALRecPoint * clust = emcalLoader->RecPoint(iClust);
128
129     if (Debug()) clust->Print();
130     AliESDCaloCluster * ec = new AliESDCaloCluster() ; 
131     // fills the ESDCaloCluster
132     Float_t xyz[3];
133     TVector3 gpos;
134     clust->GetGlobalPosition(gpos);
135     for (Int_t ixyz=0; ixyz<3; ixyz++) 
136       xyz[ixyz] = gpos[ixyz];
137
138     Int_t digitMult = clust->GetMultiplicity();
139     UShort_t *amplList = new UShort_t[digitMult];
140     UShort_t *timeList = new UShort_t[digitMult];
141     UShort_t *digiList = new UShort_t[digitMult];
142     Float_t *amplFloat = clust->GetEnergiesList();
143     Float_t *timeFloat = clust->GetTimeList();
144     Int_t   *digitInts = clust->GetAbsId();
145     Float_t *elipAxis  = new Float_t();
146     clust->GetElipsAxis(elipAxis);
147
148    // Convert Float_t* and Int_t* to UShort_t* to save memory
149     Int_t newdigitMult = digitMult ;
150     for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
151       if(timeFloat[iDigit] < 65536/1e9*100){
152         amplList[iDigit] = (UShort_t)(amplFloat[iDigit]*500);
153         timeList[iDigit] = (UShort_t)(timeFloat[iDigit]*1e9*100); //Time in units of 100 ns = 0.1 ps
154         digiList[iDigit] = (UShort_t)(digitInts[iDigit]);
155       }
156       else
157         newdigitMult =  newdigitMult - 1 ;
158     } 
159  
160     ec->SetClusterType(clust->GetClusterType());
161     ec->SetGlobalPosition(xyz);
162     ec->SetClusterEnergy(clust->GetEnergy());
163     ec->SetDigitAmplitude(amplList); //energies
164     ec->SetDigitTime(timeList);      //times
165     ec->SetDigitIndex(digiList);     //indices
166     ec->SetNumberOfDigits(newdigitMult);
167     if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1){
168       ec->SetClusterDisp(clust->GetDispersion());
169       ec->SetClusterChi2(-1); //not yet implemented
170       ec->SetM02(elipAxis[0]*elipAxis[0]) ;
171       ec->SetM20(elipAxis[1]*elipAxis[1]) ;
172       ec->SetM11(-1) ;        //not yet implemented
173       ec->SetPrimaryIndex(clust->GetPrimaryIndex());
174     }
175     // add the cluster to the esd object
176     esd->AddCaloCluster(ec);
177     delete ec;
178   }
179 }