]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/TRD/info/AliTRDeventInfo.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / TRD / info / AliTRDeventInfo.cxx
CommitLineData
61f6b45e 1////////////////////////////////////////////////////////////////////////////
2// //
3// Event info for TRD performance train //
4// //
5// Authors: //
6// Markus Fasel <M.Fasel@gsi.de> //
7// //
8////////////////////////////////////////////////////////////////////////////
9
35983729 10#include "TH1.h"
11#include "TMath.h"
12
1ee39b3a 13#include "AliESDHeader.h"
14#include "AliESDRun.h"
15
16#include "AliTRDeventInfo.h"
17
18ClassImp(AliTRDeventInfo)
5591f3d6 19Int_t const AliTRDeventInfo::fgkMultBin[AliTRDeventInfo::kCentralityClasses-1] = {
20 700, 1400, 2100, 2800/*, 3500*/
4b50bb6a 21};
5591f3d6 22Float_t const AliTRDeventInfo::fgkCentBin[AliTRDeventInfo::kCentralityClasses-1] = {
23 0.1, 0.2, 0.5, 0.8/*, 1.*/
4b50bb6a 24};
35983729 25//____________________________________________________________________
1ee39b3a 26AliTRDeventInfo::AliTRDeventInfo():
27 TObject()
4b50bb6a 28 ,fHeader(NULL)
29 ,fRun(NULL)
74427277 30 ,fCentrality(-1)
4b50bb6a 31 ,fMult(-1)
1ee39b3a 32{
33 //
34 // Default Constructor
35 //
36 SetBit(kOwner, 0);
37}
38
35983729 39//____________________________________________________________________
1ee39b3a 40AliTRDeventInfo::AliTRDeventInfo(AliESDHeader *header, AliESDRun *run):
41 TObject()
42 ,fHeader(header)
43 ,fRun(run)
74427277 44 ,fCentrality(-1)
4b50bb6a 45 ,fMult(-1)
1ee39b3a 46{
47 //
48 // Constructor with Arguments
49 //
50 SetBit(kOwner, 0);
35983729 51// fHeader->Print();
52/* for(Int_t ilevel(0); ilevel<3; ilevel++){
53 printf("L%d :: ", ilevel);
54 Int_t itrig(0); TString tn;
55 do{
56 tn = fHeader->GetTriggerInputName(itrig++, ilevel);
57 printf("%s ", tn.Data());
58 } while(tn.CompareTo(""));
59 printf("\n");
60 }*/
1ee39b3a 61}
62
35983729 63//____________________________________________________________________
1ee39b3a 64AliTRDeventInfo::AliTRDeventInfo(const AliTRDeventInfo &info):
65 TObject()
66 ,fHeader(info.fHeader)
67 ,fRun(info.fRun)
34b8a3ce 68 ,fCentrality(info.fCentrality)
4b50bb6a 69 ,fMult(info.fMult)
1ee39b3a 70{
71 //
72 // Copy Constructor
73 // Flat Copy
74 //
75 SetBit(kOwner, 0);
76}
77
35983729 78//____________________________________________________________________
1ee39b3a 79AliTRDeventInfo& AliTRDeventInfo::operator=(const AliTRDeventInfo& info){
80 //
81 // Operator=
82 // Flat Copy
83 //
01ccc21a 84 if(this == &info) return *this;
85 fHeader = info.fHeader;
86 fRun = info.fRun;
34b8a3ce 87 fCentrality = info.fCentrality;
4b50bb6a 88 fMult = info.fMult;
1ee39b3a 89 SetBit(kOwner, 0);
90 return *this;
91}
92
35983729 93//____________________________________________________________________
1ee39b3a 94AliTRDeventInfo::~AliTRDeventInfo(){
95 //
96 // Destructor
97 // Delete the entries if it is the Owner
98 //
99 Delete("");
100}
101
35983729 102//____________________________________________________________________
1ee39b3a 103void AliTRDeventInfo::Delete(const Option_t *){
104 //
105 // Delete the Object
106 // Delete the entries if it is the Owner
107 //
108 if(IsOwner()){
109 if(fHeader) delete fHeader;
110 if(fRun) delete fRun;
111 };
4b50bb6a 112 fHeader = NULL;
113 fRun = NULL;
1ee39b3a 114}
115
35983729 116//____________________________________________________________________
61f6b45e 117void AliTRDeventInfo::SetOwner()
118{
1ee39b3a 119 // Do deep copy
61f6b45e 120
121 SetBit(kOwner, 1);
1ee39b3a 122 fHeader = new AliESDHeader(*fHeader);
123 fRun = new AliESDRun(*fRun);
124}
35983729 125
566c3d46 126//____________________________________________________________________
127UShort_t AliTRDeventInfo::GetBunchFill() const
128{
129 // wrapper
130 return fHeader->GetBunchCrossNumber();
131}
132
4b50bb6a 133//____________________________________________________________________
134Int_t AliTRDeventInfo::GetCentralityBin(Float_t cenPer)
135{
136// calculate centrality bin
5591f3d6 137 for(Int_t icen(0); icen<kCentralityClasses-1; icen++){
4b50bb6a 138 if(cenPer<fgkCentBin[icen]) return icen;
139 }
140 return -1;
141}
142
dffc3357 143//____________________________________________________________________
144TString AliTRDeventInfo::GetFiredTriggerClasses()
145{
146// copy of similar function from AliESDEvent
147 return (fRun&&fHeader)?fRun->GetFiredTriggerClasses(fHeader->GetTriggerMask()):"";
148}
149
4b50bb6a 150//____________________________________________________________________
151Int_t AliTRDeventInfo::GetMultiplicityBin(Int_t n)
152{
153// calculate centrality bin
5591f3d6 154 for(Int_t im(0); im<kCentralityClasses-1; im++){
4b50bb6a 155 if(n<fgkMultBin[im]) return kCentralityClasses-im-1;
156 }
157 return 0;
158}
159
35983729 160//____________________________________________________________________
161void AliTRDeventInfo::GetListOfIsolatedBunches(TH1D* hbc, Int_t bunchSpacing) {
162 //
163 // Find the isolated bunch crossings
164 //
165 // from I.Arsene first implementation in AliTRDcheckESD
166
167 Int_t nBunches(0);
168 Bool_t isIsolated[kLHCbunches]; memset(isIsolated, 0, kLHCbunches*sizeof(Bool_t));
169 for(Int_t bcBin(1); bcBin<=hbc->GetNbinsX(); bcBin++) {
170 Int_t bc(TMath::Nint(hbc->GetBinCenter(bcBin)));
01ccc21a 171 if(bc<0 || bc>=kLHCbunches) continue; // outside LHC range
35983729 172 Double_t entries(hbc->GetBinContent(bcBin));
173 if(entries<1.) continue; // not filled
174
175 // check isolation
176 Bool_t kFOUND(kTRUE);
177 for(Int_t ibc = TMath::Max(1,bcBin-bunchSpacing); ibc <= TMath::Min(Int_t(kLHCbunches), bcBin+bunchSpacing); ibc++) {
178 if(ibc==bcBin) continue;
179 if(hbc->GetBinContent(ibc)>0.) {
180 kFOUND = kFALSE;
181 break;
182 }
183 }
184 isIsolated[bc] = kFOUND;
185 if(kFOUND) nBunches++;
186 } // end loop over BC bins
187
188 printf("Isolated bunches [%d] @ min bunch spacing [%d]:\n{", nBunches, bunchSpacing);
189 for(Int_t ibc(0); ibc<kLHCbunches; ++ibc) if(isIsolated[ibc]) printf("%4d, ", ibc);
190 printf("};\n");
191}