Update for Ds
[u/mrichter/AliRoot.git] / ITS / AliITSCorrectSDDPoints.cxx
CommitLineData
f1fd6fdb 1/**************************************************************************
2 * Copyright(c) 2007-2009, 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
8102b2c9 16/* $Id$ */
f1fd6fdb 17
18///////////////////////////////////////////////////////////////////
19// //
20// Implementation of the class to apply SDD map corrections //
21// Origin: F.Prino, Torino, prino@to.infn.it //
22// //
23///////////////////////////////////////////////////////////////////
24
25#include "TString.h"
26#include "TFile.h"
27#include "AliLog.h"
28#include "AliCDBEntry.h"
29#include "AliITSCorrMapSDD.h"
30#include "AliITSCorrectSDDPoints.h"
31
32ClassImp(AliITSCorrectSDDPoints)
8102b2c9 33
f1fd6fdb 34//______________________________________________________________________
35AliITSCorrectSDDPoints::AliITSCorrectSDDPoints():
36 TObject(),
37 fArrayOfMaps(0),
38 fSegmentationSDD(0)
39{
40 // default constructor
41 TFile* fil=new TFile("$ALICE_ROOT/OCDB/ITS/Calib/MapsTimeSDD/Run0_9999999_v0_s0.root");
42 AliCDBEntry* e=(AliCDBEntry*)fil->Get("AliCDBEntry");
43 fArrayOfMaps=(TObjArray*)e->GetObject();
44 e->SetOwner(kTRUE);
45 fil->Close();
46 AliInfo(Form("%d AliITSCorrMapSDD objects in file %s",fArrayOfMaps->GetEntries(),fil->GetName()));
47 fSegmentationSDD=new AliITSsegmentationSDD();
48}
8102b2c9 49
50//______________________________________________________________________
51AliITSCorrectSDDPoints::AliITSCorrectSDDPoints(TObjArray* maps):
52 TObject(),
53 fArrayOfMaps(maps),
54 fSegmentationSDD(new AliITSsegmentationSDD())
55{
56 // constructor from external array
57}
58
f1fd6fdb 59//______________________________________________________________________
60AliITSCorrectSDDPoints::AliITSCorrectSDDPoints(TString filname):
61 TObject(),
62 fArrayOfMaps(0),
63 fSegmentationSDD(0)
64{
65 // standard constructor
66 TFile* fil=new TFile(filname.Data());
67 AliCDBEntry* e=(AliCDBEntry*)fil->Get("AliCDBEntry");
68 fArrayOfMaps=(TObjArray*)e->GetObject();
69 e->SetOwner(kTRUE);
70 fil->Close();
71 AliInfo(Form("%d AliITSCorrMapSDD objects in file %s",fArrayOfMaps->GetEntries(),fil->GetName()));
72 fSegmentationSDD=new AliITSsegmentationSDD();
73}
8102b2c9 74
f1fd6fdb 75//______________________________________________________________________
76AliITSCorrectSDDPoints::~AliITSCorrectSDDPoints(){
77 //
78 if(fArrayOfMaps) delete fArrayOfMaps;
79}
8102b2c9 80
81//______________________________________________________________________
82void AliITSCorrectSDDPoints::SetCorrectionMaps(TObjArray *arr)
83{
84 // replace the maps
85 delete fArrayOfMaps;
86 fArrayOfMaps = (TObjArray*)arr;
87}
88
f1fd6fdb 89//______________________________________________________________________
90Float_t AliITSCorrectSDDPoints::GetCorrection(Int_t modId, Float_t zloc, Float_t xloc) const{
91 // returns correction to SDD drift corrdinate in cm
92 Int_t nSide=fSegmentationSDD->GetSideFromLocalX(xloc);
93 Int_t iSide=2*(modId-240)+nSide;
94 if(iSide<0 || iSide >= 520){
95 AliError(Form("Side out of range %d",iSide));
96 return 0.;
97 }
98 AliITSCorrMapSDD* m=(AliITSCorrMapSDD*)fArrayOfMaps->At(iSide);
99 return m->GetCorrection(zloc,xloc,fSegmentationSDD);
100}