1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // AliCDMesonUtilsStripped
19 // Felix Reidt <Felix.Reidt@cern.ch>
23 #include <TGeoMatrix.h>
24 #include <THnSparse.h>
25 #include <TLorentzVector.h>
27 #include <TParticle.h>
29 #include "AliCDBManager.h"
30 #include "AliCDBEntry.h"
31 #include "AliCDBStorage.h"
32 #include "AliESDEvent.h"
33 #include "AliPIDResponse.h"
34 #include "AliVTrack.h"
35 #include "AliVParticle.h"
36 #include "AliESDtrack.h"
37 #include "AliESDFMD.h"
38 #include "AliGeomManager.h"
39 #include "AliITSAlignMille2Module.h"
40 #include "AliITSsegmentationSPD.h"
41 #include "AliMultiplicity.h"
42 #include "AliPIDResponse.h"
43 #include "AliSPDUtils.h"
44 #include "AliTriggerAnalysis.h"
46 #include "AliAODTracklets.h"
47 #include "AliAODEvent.h"
49 #include "AliCDMesonBaseStripped.h"
50 #include "AliCDMesonTracks.h"
52 #include "AliCDMesonUtilsStripped.h"
55 //==============================================================================
56 //------------------------------------------------------------------------------
57 Bool_t AliCDMesonUtilsStripped::CutEvent(const AliESDEvent *ESDEvent)
63 AliTriggerAnalysis triggerAnalysis;
65 // collision vertex cut
66 // A cut in XY is implicitly done during the reconstruction by constraining
67 // the vertex to the beam diamond.
71 const AliESDVertex *vertex = ESDEvent->GetPrimaryVertexTracks();
72 if(vertex->GetNContributors()<1) {
74 vertex = ESDEvent->GetPrimaryVertexSPD();
75 if(vertex->GetNContributors()<1) {
76 // NO GOOD VERTEX, SKIP EVENT
80 const Bool_t kpriv = kpr0 && (fabs(ESDEvent->GetPrimaryVertex()->GetZ())<10.);
81 // 10 is the common value, unit: cm
88 //------------------------------------------------------------------------------
89 Bool_t AliCDMesonUtilsStripped::CutEvent(const AliAODEvent *AODEvent)
92 // Cut Event for AOD Events, to be combined with the ESD Track Cut
95 // TODO: no idea about fast or yet, to be thought of
99 const AliAODVertex *vertex = AODEvent->GetPrimaryVertex();
100 if(vertex->GetNContributors()<1) {
102 vertex = AODEvent->GetPrimaryVertexSPD();
103 if(vertex->GetNContributors()<1) {
104 // NO GOOD VERTEX, SKIP EVENT
108 const Bool_t kpriv = kpr0 && (fabs(AODEvent->GetPrimaryVertex()->GetZ())<10.);
109 // 10 is the common value, unit: cm
118 //------------------------------------------------------------------------------
119 Int_t AliCDMesonUtilsStripped::GetGapConfig(const AliESDEvent *ESDEvent)
122 // GetGapConfigAndTracks
124 // retrieves the gap configuration of a track and returns it as
126 // kBaseLine ensures, that this event is valid
127 // + is equivalent to | in this case
128 return AliCDMesonBaseStripped::kBitBaseLine
129 + GetV0(ESDEvent) + GetFMD(ESDEvent) + GetSPD(ESDEvent) + GetTPC(ESDEvent);
133 //==============================================================================
134 //------------------------------------------------------------------------------
135 Int_t AliCDMesonUtilsStripped::GetV0(const AliESDEvent * ESDEvent)
141 AliTriggerAnalysis triggerAnalysis;
142 const Bool_t khw = kFALSE;
144 (triggerAnalysis.V0Trigger(ESDEvent, AliTriggerAnalysis::kASide, khw) ==
145 AliTriggerAnalysis::kV0BB);
147 (triggerAnalysis.V0Trigger(ESDEvent, AliTriggerAnalysis::kCSide, khw) ==
148 AliTriggerAnalysis::kV0BB);
150 return v0A * AliCDMesonBaseStripped::kBitV0A
151 + v0C * AliCDMesonBaseStripped::kBitV0C;
155 //------------------------------------------------------------------------------
156 Int_t AliCDMesonUtilsStripped::GetFMD(const AliESDEvent *ESDEvent)
162 AliTriggerAnalysis triggerAnalysis;
163 triggerAnalysis.SetFMDThreshold(0.3, 0.5); // parameters got from FMD
165 triggerAnalysis.FMDTrigger(ESDEvent, AliTriggerAnalysis::kASide);
167 triggerAnalysis.FMDTrigger(ESDEvent, AliTriggerAnalysis::kCSide);
169 return fmdA * AliCDMesonBaseStripped::kBitFMDA
170 + fmdC * AliCDMesonBaseStripped::kBitFMDC;
174 //------------------------------------------------------------------------------
175 Int_t AliCDMesonUtilsStripped::GetSPD(const AliESDEvent *ESDEvent)
182 GetNFO(ESDEvent, "]0.9[", nfoctr);
183 // get multiplicity from fastOR and fill corresponding hit maps
186 const Int_t ipA = nfoctr[kIPA]; // inner layer A side
187 const Int_t ipC = nfoctr[kIPC]; // inner layer C side
188 const Int_t opA = nfoctr[kOPA]; // outer layer A side
189 const Int_t opC = nfoctr[kOPC]; // outer layer C side
191 const Bool_t spdA = ipA + opA; // A side hit?
192 const Bool_t spdC = ipC + opC; // C side hit?
194 return spdA * AliCDMesonBaseStripped::kBitSPDA
195 + spdC * AliCDMesonBaseStripped::kBitSPDC;
199 //------------------------------------------------------------------------------
200 Int_t AliCDMesonUtilsStripped::GetTPC(const AliESDEvent * ESDEvent)
206 const Double_t etacut = 0.9;
209 for(Int_t itrack = 0; itrack < ESDEvent->GetNumberOfTracks(); itrack++){
210 const AliESDtrack* esdtrack = ESDEvent->GetTrack(itrack);
211 if( esdtrack->Eta() > etacut ){
214 else if( esdtrack->Eta() < -etacut ){
219 const Bool_t tpcA = nA;
220 const Bool_t tpcC = nC;
222 return tpcA * AliCDMesonBaseStripped::kBitTPCA
223 + tpcC * AliCDMesonBaseStripped::kBitTPCC;
226 //==============================================================================
227 //------------------------------------------------------------------------------
228 void AliCDMesonUtilsStripped::SPDLoadGeom(const Int_t run)
230 // method to get the gGeomanager
231 // it is called at the CreatedOutputObject stage
232 // to comply with the CAF environment
234 AliCDBManager *man = AliCDBManager::Instance();
235 // WARNING THE OCDB PATH SHOULD BE ADJUSTED TO THE RUNNING CONDITIONS
239 if (man->IsDefaultStorageSet()) {
240 const AliCDBStorage *dsto = man->GetDefaultStorage();
241 cdbpath = TString(dsto->GetBaseFolder());
244 man->SetDefaultStorage("raw://");
248 man->SetSpecificStorage("ITS/Align/Data",cdbpath);
249 man->SetSpecificStorage("GRP/Geometry/Data",cdbpath);
252 AliCDBEntry* obj = man->Get(AliCDBPath("GRP", "Geometry", "Data"));
254 printf("freidtlog failed loading geometry object\n");
257 AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());
258 AliGeomManager::ApplyAlignObjsFromCDB("ITS");
261 //------------------------------------------------------------------------------
262 Bool_t AliCDMesonUtilsStripped::SPDLoc2Glo(const Int_t id, const Double_t *loc,
266 //SPDLoc2Glo, do not touch
269 static TGeoHMatrix mat;
270 Int_t vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(id);
272 printf("freidtlog Did not find module with such ID %d\n",id);
275 AliITSAlignMille2Module::SensVolMatrix(vid,&mat);
276 mat.LocalToMaster(loc,glo);
281 //------------------------------------------------------------------------------
282 Int_t AliCDMesonUtilsStripped::CheckChipEta(const Int_t chipKey,
284 const Double_t vtxPos[])
290 // retrieves the position in eta for a given chip and applies the cut
293 // -1 <= negative pseudo-rapidity position, in range (C-Side)
294 // 1 <= positive pseudo-rapidity position, in range (A-Side)
296 // scut: "[0.9" or "]0.9", only 3 digits for the value!!
299 const Bool_t kincl = (scut[0] == '[');
300 const TString cutval = scut(1,3);
301 const Double_t etacut = fabs(cutval.Atof());
303 //no eta cut, save time
304 if(kincl && etacut>=2)
308 //------------------------------- NOT TO TOUCH ------------------------>>
309 UInt_t module=999, offchip=999;
310 AliSPDUtils::GetOfflineFromOfflineChipKey(chipKey,module,offchip);
311 UInt_t hs = AliSPDUtils::GetOnlineHSFromOffline(module);
312 if(hs<2) offchip = 4 - offchip; // inversion in the inner layer...
319 const Int_t aa[]={0, 0, 255, 255};
320 const AliITSsegmentationSPD seg;
322 for(Int_t ic=0; ic<4; ic++){
323 Float_t localchip[3]={0.,0.,0.};
324 seg.DetToLocal(aa[ic],col[ic]+32*offchip,localchip[0],localchip[2]);
325 // local coordinate of the chip center
326 //printf("local coordinates %d %d: %f %f \n",chipKey, ic, localchip[0],localchip[2]);
327 const Double_t local[3] = {localchip[0],localchip[1],localchip[2]};
328 Double_t glochip[3]={0.,0.,0.};
329 if(!SPDLoc2Glo(module,local,glochip)){
333 //-------------------------------------------------------------------<<
335 const TVector3 pos(glochip[0]-vtxPos[0], glochip[1]-vtxPos[1],
336 glochip[2]-vtxPos[2]);
339 if( kincl && fabs(pos.Eta()) > etacut)
343 if(fabs(pos.Eta()) < etacut)
356 //------------------------------------------------------------------------------
357 void AliCDMesonUtilsStripped::GetNFO(const AliESDEvent *ESDEvent,
358 const TString etacut, Int_t ctr[])
363 // analyzes the SPD fastOR for a given eta range and returns
364 // an array with the number of hits in:
366 Int_t ninner=0; // inner layer
367 Int_t nouter=0; // outer layer
368 Int_t ipA = 0; // inner layer A side
369 Int_t ipC = 0; // inner layer C side
370 Int_t opA = 0; // outer layer A side
371 Int_t opC = 0; // outer layer C side
373 const AliMultiplicity *mult = ESDEvent->GetMultiplicity();
375 // position of the primary vertex
376 Double_t tmp[3] = { 0., 0., 0. };
377 ESDEvent->GetPrimaryVertex()->GetXYZ(tmp);
378 Double_t vtxPos[3] = { tmp[0], tmp[1], tmp[2] };
381 for(Int_t iChipKey=0; iChipKey < 1200; iChipKey++){
382 if(mult->TestFastOrFiredChips(iChipKey)){
383 // here you check if the FastOr bit is 1 or 0
384 const Int_t iseta = CheckChipEta(iChipKey, etacut, vtxPos);
389 ninner++; // here you count the FastOr bits in the inner layer
396 nouter++; // here you count the FastOr bits in the outer layer
405 ctr[kInnerPixel]= ninner;
406 ctr[kOuterPixel]= nouter;