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