]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSDriftSpeedArraySDD.cxx
plitting of drift speed (updated at every physics run) from other calibration paramet...
[u/mrichter/AliRoot.git] / ITS / AliITSDriftSpeedArraySDD.cxx
CommitLineData
18da6e54 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
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////
19// //
20// Implementation of the class with array of AliITSDriftSpeedSDD //
21// Origin: F.Prino, Torino, prino@to.infn.it //
22// //
23///////////////////////////////////////////////////////////////////
24
25#include <TClonesArray.h>
26#include "AliITSDriftSpeedArraySDD.h"
27#include "AliITSDriftSpeedSDD.h"
28#include "AliLog.h"
29
30ClassImp(AliITSDriftSpeedArraySDD)
31//______________________________________________________________________
32AliITSDriftSpeedArraySDD::AliITSDriftSpeedArraySDD():
33TObject(),
34fNEvents(0),
35fDriftSpeedSDD(0){
36 // default constructor
37 fDriftSpeedSDD=new TClonesArray("AliITSDriftSpeedSDD",100);
38}
39//______________________________________________________________________
40AliITSDriftSpeedArraySDD::AliITSDriftSpeedArraySDD(Int_t numEv):
41TObject(),
42fNEvents(0),
43fDriftSpeedSDD(0){
44 // standard constructor
45 fDriftSpeedSDD=new TClonesArray("AliITSDriftSpeedSDD",numEv);
46}
47//______________________________________________________________________
48AliITSDriftSpeedArraySDD::AliITSDriftSpeedArraySDD(const AliITSDriftSpeedArraySDD& array):
49TObject(),
50fNEvents(array.fNEvents),
51fDriftSpeedSDD(array.fDriftSpeedSDD){
52 // copy constructor
53}
54//______________________________________________________________________
55AliITSDriftSpeedArraySDD& AliITSDriftSpeedArraySDD::operator=(const AliITSDriftSpeedArraySDD& array){
56 // assignment operator
57 this->~AliITSDriftSpeedArraySDD();
58 new(this) AliITSDriftSpeedArraySDD(array);
59 return *this;
60}
61
62//______________________________________________________________________
63AliITSDriftSpeedArraySDD::~AliITSDriftSpeedArraySDD(){
64 // destructor
65 if(fDriftSpeedSDD){
66 fDriftSpeedSDD->Delete();
67 delete fDriftSpeedSDD;
68 }
69}
70//______________________________________________________________________
71void AliITSDriftSpeedArraySDD::AddDriftSpeed(AliITSDriftSpeedSDD* drSpeed){
72 // adds an AliITSDriftSpeedSDD object in the array
73 TClonesArray &arr = *fDriftSpeedSDD;
74 new(arr[fNEvents]) AliITSDriftSpeedSDD(*drSpeed);
75 fNEvents++;
76
77}
78//______________________________________________________________________
79void AliITSDriftSpeedArraySDD::PrintAll() const{
80 // print drift speed parameters for all elements in the array
81 printf("Array Size=%d\n",fDriftSpeedSDD->GetSize());
82 printf("Array Elements =%d\n",fNEvents);
83 for(Int_t i=0;i<fNEvents; i++){
84 printf(" ====== Array el. #%d ======\n",i);
85 AliITSDriftSpeedSDD *d=(AliITSDriftSpeedSDD*)fDriftSpeedSDD->At(i);
86 if(d) d->PrintDriftSpeedParameters();
87 }
88}
89//______________________________________________________________________
90Float_t AliITSDriftSpeedArraySDD::GetDriftSpeed(Int_t iEvent, Float_t iAnode) const{
91 // returns drift speed for given event number and anode
92 if(!fDriftSpeedSDD->IsSorted()) fDriftSpeedSDD->Sort();
93 if(fNEvents==1){
94 AliITSDriftSpeedSDD *d=(AliITSDriftSpeedSDD*)fDriftSpeedSDD->At(0);
95 return d->GetDriftSpeedAtAnode(iAnode);
96 }else{
97 Int_t nInjEv1=-1;
98 Int_t nInjEv2=-1;
99 AliITSDriftSpeedSDD *d1=NULL;
100 AliITSDriftSpeedSDD *d2=NULL;
101 for(Int_t i=0;i<fNEvents; i++){
102 d1=d2;
103 d2=(AliITSDriftSpeedSDD*)fDriftSpeedSDD->At(i);
104 nInjEv1=nInjEv2;
105 if(d2!=0){
106 nInjEv2=d2->GetEventNumber();
107 if(nInjEv2>=iEvent){
108 if(i==0) d1=(AliITSDriftSpeedSDD*)fDriftSpeedSDD->At(i+1);
109 nInjEv1=d1->GetEventNumber();
110 break;
111 }
112 }
113 }
114 if(nInjEv1>=0 && nInjEv2>=0 && nInjEv1!=nInjEv2){
115 Float_t v1=d1->GetDriftSpeedAtAnode(iAnode);
116 Float_t v2=d2->GetDriftSpeedAtAnode(iAnode);
117 Float_t vdrift=(v2-v1)*(iEvent-nInjEv1)/(nInjEv2-nInjEv1)+v1;
118 return vdrift;
119 }
120 }
121 AliWarning("Vdrift interpolation error\n");
122 return -999.;
123}