]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliJetReader.cxx
Update
[u/mrichter/AliRoot.git] / JETAN / AliJetReader.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 //------------------------------------------------------------------------
17 // Jet reader base class
18 // manages the reading of input for jet algorithms
19 // Authors: jgcn@mda.cinvestav.mx
20 //          magali.estienne@IReS.in2p3.fr
21 //
22 // **February 2011
23 // implemented  standard geometry (AliEMCALGeometry) (was AliJetDummyGeo implented separately in ESDReader and AODReader
24 // local2master matrices are now get from $ALICE_ROOT/OADB/PWG4/JetReconstruction/EMCALlocal2master.root
25 // you can choose the geometry (EMCAL_COMPLETE, EMCAL_FIRSTYEARv1, etc) via SetEMCALgeo2bLoad('Name_of_Geometry') in the Readerheader
26 // different options for survey(ed) matrice are provided too
27 // ** August 2011
28 // OADB path changed from  '../OADB/PWG4/JetReconstruction/'  to   '../OADB/EMCAL/'
29 // marco.bregant@subatech.in2p3.fr
30 //------------------------------------------------------------------------- 
31
32 // root
33 #include <TSystem.h>
34 #include <TString.h>
35 #include <TClonesArray.h>
36 #include <TRefArray.h>
37 #include "TTask.h"
38 #include <TGeoManager.h>
39 //AliRoot
40 #include "AliLog.h"
41 #include "AliJetReader.h"
42 #include "AliJetReaderHeader.h"
43 #include "AliESDEvent.h"
44 #include "AliHeader.h"
45 #include "AliEMCALGeometry.h"
46 #include "AliEMCALEMCGeometry.h"
47 #include "AliJetESDFillUnitArrayTracks.h" 
48 #include "AliJetESDFillUnitArrayEMCalDigits.h"
49 #include "AliJetUnitArray.h"
50 #include "AliJetHadronCorrectionv1.h"
51 #include "AliOADBContainer.h"
52
53 ClassImp(AliJetReader)
54
55 ////////////////////////////////////////////////////////////////////////
56 AliEMCALGeometry *AliJetReader::fGeom=0;
57
58 AliJetReader::AliJetReader():
59   // Constructor
60   fJetanOADBpath(""),
61   fChain(0), 
62   fTree(0), 
63   fMomentumArray(new TClonesArray("TLorentzVector",4000)),
64   fArrayMC(0),
65   fFillUnitArray(new TTask("fillUnitArray","Fill unit array jet finder")),
66   fESD(0),
67   fReaderHeader(0),
68   fAliHeader(0),
69   fSignalFlag(0),
70   fCutFlag(0),
71   fUnitArray(new TClonesArray("AliJetUnitArray",60000)),
72   fArrayInitialised(0),
73   fFillUAFromTracks(new AliJetESDFillUnitArrayTracks()), 
74   fFillUAFromEMCalDigits(new AliJetESDFillUnitArrayEMCalDigits()),
75   fNumCandidate(0),
76   fNumCandidateCut(0),
77   fHadronCorrector(0),
78   fHCorrection(0),
79   fECorrection(0),
80   fEFlag(kFALSE),
81   fDebug(0)
82 {
83   // Default constructor
84   fSignalFlag = TArrayI();
85   fCutFlag    = TArrayI();
86 }
87
88 ////////////////////////////////////////////////////////////////////////
89
90 AliJetReader::~AliJetReader()
91 {
92   // Destructor
93   if (fMomentumArray) {
94       fMomentumArray->Delete();
95       delete fMomentumArray;
96   }
97   
98   if (fUnitArray) {
99       fUnitArray->Delete();
100       delete fUnitArray;
101   }
102   
103   if (fFillUnitArray) {
104     delete fFillUnitArray;
105   }
106   if (fArrayMC) {
107       fArrayMC->Delete();
108       delete fArrayMC;
109   }
110   
111 }
112
113 ////////////////////////////////////////////////////////////////////////
114
115 void AliJetReader::ClearArray()
116 {
117   if (fMomentumArray)  fMomentumArray->Clear();
118   if (fFillUnitArray)  fFillUnitArray->Clear();
119 }
120
121 Bool_t AliJetReader::SetEMCALGeometry()
122 {
123   // 
124   // Set the EMCal Geometry
125   //
126   
127   fDebug = fReaderHeader->GetDebug();
128   
129   if(fGeom != 0){
130           Info(" SetEMCALGeometry:","was already done.. it's called just once !!");
131      return kTRUE;
132      }
133      
134   if(fDebug>9) cout<<"JetReader: Setting EMCALGeometry"<<endl;
135
136 //path to the OADB file
137
138
139  TString  myPath=  fReaderHeader ->GetMyOADBfile();
140  TString OADBfile;
141
142  Bool_t customFile=kFALSE;
143
144 if(myPath.Length()) {
145         Info(" SetEMCALGeometry","custom version of OADB file: %s",myPath.Data());
146          customFile=kTRUE;
147         OADBfile=myPath;
148  } else OADBfile.Form("%s/EMCAL/EMCALlocal2master.root",(const char*) fJetanOADBpath);
149  
150  AliOADBContainer EMCALgeoCont;
151         Info(" SetEMCALGeometry"," I'm going to read the matrices from %s",OADBfile.Data()); 
152         TObjArray *EmcalMatrArray;
153         if(fDebug>19) cout<<"array definito"<<endl;
154         
155          EMCALgeoCont.InitFromFile((char*) OADBfile.Data(),"AliEMCALgeo");
156          EMCALgeoCont.GetDefaultList()->Print(); 
157         
158         const char*  geoType= fReaderHeader -> GetEMCALgeo2bLoad();
159         if(fDebug>19)  cout<<"geometry: "<<geoType<<endl;
160         
161         const char*  loc2master = ((AliJetESDReaderHeader*) fReaderHeader)->GetEMCALmatrices2bLoad();
162         if(fDebug>19) cout<<"matrices: "<<loc2master<<endl;
163         
164         
165      if(fDebug>9)       cout<<"geometry type is: "<<geoType<<endl;
166          if(fDebug>9)   cout<<"survey matrices are: "<<loc2master<<endl;
167         
168         // some crosschecks to avoid not existing cases
169         if(!(!strcmp(geoType, "EMCAL_COMPLETE") || !strcmp(geoType, "EMCAL_COMPLETEV1") || !strcmp(geoType, "EMCAL_FIRSTYEARV1")) ) 
170          Warning(" SetEMCALGeometry","%s is not a known good geometry!  either your are using an old one or everything will crash right now!",geoType);
171                 
172         if(! (!strcmp(loc2master, "survey10") || !strcmp(loc2master, "survey11") || !strcmp(loc2master, "ideal") || !strcmp(loc2master, "test")) ) {
173                 Warning(" SetEMCALGeometry"," %s is not one of the allowed cases  (listed few lines above) !!----!!!", loc2master);
174                 loc2master="survey11";
175                 Warning(" SetEMCALGeometry"," to avoid crashes, your decision has been overrulled!, matrices '%s' will be used instead",loc2master);
176                 if(fDebug>9)   cout<<"survey matrices are (new, after overrulling): "<<loc2master<<endl;
177                 }
178         
179         
180         // some warning for not so orthodox combination
181         if(!strcmp(geoType, "EMCAL_COMPLETE"))
182                  Warning(" SetEMCALGeometry:", "!!----!!  this geometry contains wrong tilt angles for stripmodules.. are you really sure?  please consider using EMCAL_COMPLETEV1 !! ---!! ");
183         if(  !strcmp(loc2master, "survey11") && strcmp(geoType, "EMCAL_COMPLETEV1") )
184                 Warning(" SetEMCALGeometry:",  "!!----!! survey11 matrices should be used with EMCAL_COMPLETEV1 geometry !!---!!");
185         if(  !strcmp(loc2master, "survey10") && strcmp(geoType, "EMCAL_FIRSTYEARV1") )
186                 Warning(" SetEMCALGeometry",  "!!----!! survey10 matrices should be used ONLY with EMCAL_FIRSTYEARV1 geometry!!");
187     if(!strcmp(loc2master,"ideal"))
188                 Warning(" SetEMCALGeometry","!!----!! ideal matrices are without any survey (misalignment correction)... is it really what you want?");
189     if(!strcmp(loc2master,"test") && !customFile)
190                 Warning(" SetEMCALGeometry","!!----!! 'test' matrices will be used. but it seems you didn't provide a custom version of OADB file, the default 'test' is as 'ideal', no survey (misalignment correction) !!----!!");
191         if(!strcmp(loc2master,"test") && customFile)
192                 Info(" SetEMCALGeometry"," !!----!! 'test' matrices read from the custom file you provided     !!----!!");
193
194         EmcalMatrArray=(TObjArray*)EMCALgeoCont.GetObject(100,(char*) loc2master);
195         
196  
197   // Define EMCAL geometry
198  
199   if(fDebug>10) cout<<"which EMCALgeometry is going to be uploaded?"<<geoType<<endl; 
200   fGeom = AliEMCALGeometry::GetInstance(geoType);
201   
202   
203         for (Int_t mod=0;mod<(fGeom->GetEMCGeometry())->GetNumberOfSuperModules();mod+=1)
204  {
205       fGeom->SetMisalMatrix(((TGeoHMatrix*) EmcalMatrArray->At(mod)),mod);
206      if(fDebug>9)  cout<<"and the matrix is: SM "<<mod<<" (to print the matrix, fDebug>11!) "<<endl;
207     if(fDebug>11) { 
208     cout<<"print the matrix, (will it work?)"<<endl;
209         ((TGeoHMatrix*) EmcalMatrArray->At(mod))->Print();
210         cout<<"if you read that, it did!"<<endl;
211         } 
212 }
213   
214   Info("\n SetEMCALGeometry:"," EMCal Geometry set ! \n");
215   
216   return kTRUE;
217 }