]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TRD/info/AliTRDeventInfo.cxx
previous fix adjuested
[u/mrichter/AliRoot.git] / PWG1 / 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)
19
35983729 20//____________________________________________________________________
1ee39b3a 21AliTRDeventInfo::AliTRDeventInfo():
22 TObject()
23 ,fHeader(0x0)
24 ,fRun(0x0)
74427277 25 ,fCentrality(-1)
1ee39b3a 26{
27 //
28 // Default Constructor
29 //
30 SetBit(kOwner, 0);
31}
32
35983729 33//____________________________________________________________________
1ee39b3a 34AliTRDeventInfo::AliTRDeventInfo(AliESDHeader *header, AliESDRun *run):
35 TObject()
36 ,fHeader(header)
37 ,fRun(run)
74427277 38 ,fCentrality(-1)
1ee39b3a 39{
40 //
41 // Constructor with Arguments
42 //
43 SetBit(kOwner, 0);
35983729 44// fHeader->Print();
45/* for(Int_t ilevel(0); ilevel<3; ilevel++){
46 printf("L%d :: ", ilevel);
47 Int_t itrig(0); TString tn;
48 do{
49 tn = fHeader->GetTriggerInputName(itrig++, ilevel);
50 printf("%s ", tn.Data());
51 } while(tn.CompareTo(""));
52 printf("\n");
53 }*/
1ee39b3a 54}
55
35983729 56//____________________________________________________________________
1ee39b3a 57AliTRDeventInfo::AliTRDeventInfo(const AliTRDeventInfo &info):
58 TObject()
59 ,fHeader(info.fHeader)
60 ,fRun(info.fRun)
34b8a3ce 61 ,fCentrality(info.fCentrality)
1ee39b3a 62{
63 //
64 // Copy Constructor
65 // Flat Copy
66 //
67 SetBit(kOwner, 0);
68}
69
35983729 70//____________________________________________________________________
1ee39b3a 71AliTRDeventInfo& AliTRDeventInfo::operator=(const AliTRDeventInfo& info){
72 //
73 // Operator=
74 // Flat Copy
75 //
76 this->fHeader = info.fHeader;
77 this->fRun = info.fRun;
34b8a3ce 78 fCentrality = info.fCentrality;
1ee39b3a 79 SetBit(kOwner, 0);
80 return *this;
81}
82
35983729 83//____________________________________________________________________
1ee39b3a 84AliTRDeventInfo::~AliTRDeventInfo(){
85 //
86 // Destructor
87 // Delete the entries if it is the Owner
88 //
89 Delete("");
90}
91
35983729 92//____________________________________________________________________
1ee39b3a 93void AliTRDeventInfo::Delete(const Option_t *){
94 //
95 // Delete the Object
96 // Delete the entries if it is the Owner
97 //
98 if(IsOwner()){
99 if(fHeader) delete fHeader;
100 if(fRun) delete fRun;
101 };
102 fHeader = 0x0;
103 fRun = 0x0;
104}
105
35983729 106//____________________________________________________________________
61f6b45e 107void AliTRDeventInfo::SetOwner()
108{
1ee39b3a 109 // Do deep copy
61f6b45e 110
111 SetBit(kOwner, 1);
1ee39b3a 112 fHeader = new AliESDHeader(*fHeader);
113 fRun = new AliESDRun(*fRun);
114}
35983729 115
566c3d46 116//____________________________________________________________________
117UShort_t AliTRDeventInfo::GetBunchFill() const
118{
119 // wrapper
120 return fHeader->GetBunchCrossNumber();
121}
122
35983729 123//____________________________________________________________________
124void AliTRDeventInfo::GetListOfIsolatedBunches(TH1D* hbc, Int_t bunchSpacing) {
125 //
126 // Find the isolated bunch crossings
127 //
128 // from I.Arsene first implementation in AliTRDcheckESD
129
130 Int_t nBunches(0);
131 Bool_t isIsolated[kLHCbunches]; memset(isIsolated, 0, kLHCbunches*sizeof(Bool_t));
132 for(Int_t bcBin(1); bcBin<=hbc->GetNbinsX(); bcBin++) {
133 Int_t bc(TMath::Nint(hbc->GetBinCenter(bcBin)));
134 if(bc<0 || bc>kLHCbunches) continue; // outside LHC range
135 Double_t entries(hbc->GetBinContent(bcBin));
136 if(entries<1.) continue; // not filled
137
138 // check isolation
139 Bool_t kFOUND(kTRUE);
140 for(Int_t ibc = TMath::Max(1,bcBin-bunchSpacing); ibc <= TMath::Min(Int_t(kLHCbunches), bcBin+bunchSpacing); ibc++) {
141 if(ibc==bcBin) continue;
142 if(hbc->GetBinContent(ibc)>0.) {
143 kFOUND = kFALSE;
144 break;
145 }
146 }
147 isIsolated[bc] = kFOUND;
148 if(kFOUND) nBunches++;
149 } // end loop over BC bins
150
151 printf("Isolated bunches [%d] @ min bunch spacing [%d]:\n{", nBunches, bunchSpacing);
152 for(Int_t ibc(0); ibc<kLHCbunches; ++ibc) if(isIsolated[ibc]) printf("%4d, ", ibc);
153 printf("};\n");
154}