1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliAnalysisManager.h"
18 #include "AliAnalysisTaskSE.h"
19 #include "AliAnalysisTaskPHOSPbPbQA.h"
20 #include "AliCaloPhoton.h"
21 #include "AliPHOSGeometry.h"
22 #include "AliESDEvent.h"
23 #include "AliESDCaloCells.h"
24 #include "AliCentrality.h"
26 #include "TObjArray.h"
31 // Stripped-down version of Dmitri Peressounko' AliAnalysisTaskPi0Flow class
32 // used for the fast QA of PbPb data.
34 // Author: Boris Polishchuk
37 ClassImp(AliAnalysisTaskPHOSPbPbQA)
39 //________________________________________________________________________
40 AliAnalysisTaskPHOSPbPbQA::AliAnalysisTaskPHOSPbPbQA() : AliAnalysisTaskSE(),
41 fOutputContainer(0),fPHOSEvent(0),fCentrality(0),fCenBin(0),
42 fPHOSGeo(0),fEventCounter(0)
46 for(Int_t i=0;i<1;i++){
47 for(Int_t j=0;j<2;j++)
51 // Initialize the PHOS geometry
52 fPHOSGeo = AliPHOSGeometry::GetInstance("IHEP") ;
56 //________________________________________________________________________
57 AliAnalysisTaskPHOSPbPbQA::AliAnalysisTaskPHOSPbPbQA(const char *name)
58 : AliAnalysisTaskSE(name),
61 fCentrality(0),fCenBin(0),
66 for(Int_t i=0;i<1;i++){
67 for(Int_t j=0;j<2;j++)
71 // Output slots #0 write into a TH1 container
72 DefineOutput(1,TList::Class());
74 // Initialize the PHOS geometry
75 fPHOSGeo = AliPHOSGeometry::GetInstance("IHEP") ;
79 //________________________________________________________________________
80 void AliAnalysisTaskPHOSPbPbQA::UserCreateOutputObjects()
86 if(fOutputContainer != NULL){
87 delete fOutputContainer;
90 fOutputContainer = new TList();
91 fOutputContainer->SetOwner(kTRUE);
94 fOutputContainer->Add(new TH2F("hCenPHOS","Centrality vs PHOSclusters", 100,0.,100.,200,0.,200.)) ;
95 fOutputContainer->Add(new TH2F("hCenPHOSCells","Centrality vs PHOS cells", 100,0.,100.,100,0.,1000.)) ;
96 fOutputContainer->Add(new TH2F("hCenTrack","Centrality vs tracks", 100,0.,100.,100,0.,15000.)) ;
100 Double_t ptPhotMax = 30 ;
106 for(Int_t cent=0; cent<2; cent++){
108 snprintf(key,55,"hPi0All_cen%d",cent) ;
109 fOutputContainer->Add(new TH2F(key,"All clusters",nM,mMin,mMax,nPtPhot,0.,ptPhotMax));
111 snprintf(key,55,"hMiPi0All_cen%d",cent) ;
112 fOutputContainer->Add(new TH2F(key,"All clusters",nM,mMin,mMax,nPtPhot,0.,ptPhotMax));
116 for(Int_t cent=0; cent<2; cent++){
117 for(Int_t sm=1; sm<4; sm++) {
119 snprintf(key,55,"hPi0AllSM%d_cen%d",sm,cent) ;
120 fOutputContainer->Add(new TH2F(key,"All clusters",nM,mMin,mMax,nPtPhot,0.,ptPhotMax));
122 snprintf(key,55,"hMiPi0AllSM%d_cen%d",sm,cent) ;
123 fOutputContainer->Add(new TH2F(key,"All clusters",nM,mMin,mMax,nPtPhot,0.,ptPhotMax));
127 PostData(1, fOutputContainer);
131 //________________________________________________________________________
132 void AliAnalysisTaskPHOSPbPbQA::UserExec(Option_t *)
134 // Main loop, called for each event
137 AliESDEvent *event = dynamic_cast<AliESDEvent*>(InputEvent());
140 Printf("ERROR: Could not retrieve event");
141 PostData(1, fOutputContainer);
145 // Get PHOS rotation matrices from ESD and set them to the PHOS geometry
148 if(fEventCounter == 0) {
149 for(Int_t mod=0; mod<5; mod++) {
150 if(!event->GetPHOSMatrix(mod)) continue;
151 fPHOSGeo->SetMisalMatrix(event->GetPHOSMatrix(mod),mod) ;
158 AliCentrality *centrality = event->GetCentrality();
159 fCentrality=centrality->GetCentralityPercentile("V0M");
161 if( fCentrality < 0. ){
162 PostData(1, fOutputContainer);
166 if(fCentrality < 20.) fCenBin = 0;
169 printf("centrality %.3f [%d]\n",fCentrality,fCenBin);
171 if(!fPHOSEvents[zvtx][fCenBin])
172 fPHOSEvents[zvtx][fCenBin]=new TList() ;
174 TList * prevPHOS = fPHOSEvents[zvtx][fCenBin] ;
177 fPHOSEvent->Clear() ;
179 fPHOSEvent = new TClonesArray("AliCaloPhoton",200) ;
181 Int_t multClust = event->GetNumberOfCaloClusters();
182 AliESDCaloCells * cells = event->GetPHOSCells() ;
184 FillHistogram("hCenPHOSCells",fCentrality,cells->GetNumberOfCells()) ;
185 FillHistogram("hCenTrack",fCentrality,event->GetNumberOfTracks()) ;
188 Double_t vtx0[3] = {0,0,0}; // vertex
190 for (Int_t i=0; i<multClust; i++) {
192 AliESDCaloCluster *clu = event->GetCaloCluster(i);
194 if ( !clu->IsPHOS() || clu->E()<0.3) continue;
195 if(clu->GetNCells()<3) continue;
198 clu->GetPosition(position);
199 TVector3 global(position) ;
201 fPHOSGeo->GlobalPos2RelId(global,relId) ;
202 Int_t mod = relId[0] ;
203 Int_t cellX = relId[2];
204 Int_t cellZ = relId[3] ;
207 clu->GetMomentum(pv1 ,vtx0);
209 if(inPHOS>=fPHOSEvent->GetSize()){
210 fPHOSEvent->Expand(inPHOS+50) ;
213 new((*fPHOSEvent)[inPHOS]) AliCaloPhoton(pv1.X(),pv1.Py(),pv1.Z(),pv1.E()) ;
214 AliCaloPhoton * ph = (AliCaloPhoton*)fPHOSEvent->At(inPHOS) ;
217 ph->SetNCells(clu->GetNCells());
219 ph->SetEMCx(float(cellX)) ;
220 ph->SetEMCz(float(cellZ)) ;
225 FillHistogram("hCenPHOS",fCentrality,inPHOS) ;
228 for (Int_t i1=0; i1<inPHOS-1; i1++) {
229 AliCaloPhoton * ph1=(AliCaloPhoton*)fPHOSEvent->At(i1) ;
230 Int_t sm1 = ph1->Module();
232 for (Int_t i2=i1+1; i2<inPHOS; i2++) {
233 AliCaloPhoton * ph2=(AliCaloPhoton*)fPHOSEvent->At(i2) ;
235 Int_t sm2 = ph2->Module();
236 TLorentzVector p12 = *ph1 + *ph2;
238 snprintf(key,55,"hPi0All_cen%d",fCenBin) ;
239 FillHistogram(key,p12.M() ,p12.Pt()) ;
242 snprintf(key,55,"hPi0AllSM%d_cen%d",sm1,fCenBin) ;
243 FillHistogram(key,p12.M() ,p12.Pt()) ;
250 for (Int_t i1=0; i1<inPHOS; i1++) {
251 AliCaloPhoton * ph1=(AliCaloPhoton*)fPHOSEvent->At(i1) ;
252 Int_t sm1 = ph1->Module();
254 for(Int_t ev=0; ev<prevPHOS->GetSize();ev++){
255 TClonesArray * mixPHOS = static_cast<TClonesArray*>(prevPHOS->At(ev)) ;
257 for(Int_t i2=0; i2<mixPHOS->GetEntriesFast();i2++){
258 AliCaloPhoton * ph2=(AliCaloPhoton*)mixPHOS->At(i2) ;
260 Int_t sm2 = ph2->Module();
261 TLorentzVector p12 = *ph1 + *ph2;
263 snprintf(key,55,"hMiPi0All_cen%d",fCenBin) ;
264 FillHistogram(key,p12.M() ,p12.Pt()) ;
267 snprintf(key,55,"hMiPi0AllSM%d_cen%d",sm1,fCenBin) ;
268 FillHistogram(key,p12.M() ,p12.Pt()) ;
276 //Now we either add current events to stack or remove
277 //If no photons in current event - no need to add it to mixed
278 if(fPHOSEvent->GetEntriesFast()>0){
279 prevPHOS->AddFirst(fPHOSEvent) ;
281 if(prevPHOS->GetSize()>100){//Remove redundant events
282 TClonesArray * tmp = static_cast<TClonesArray*>(prevPHOS->Last()) ;
283 prevPHOS->RemoveLast() ;
288 PostData(1, fOutputContainer);
292 //_____________________________________________________________________________
293 void AliAnalysisTaskPHOSPbPbQA::FillHistogram(const char * key,Double_t x)const{
295 TH1I * tmpI = dynamic_cast<TH1I*>(fOutputContainer->FindObject(key)) ;
300 TH1F * tmpF = dynamic_cast<TH1F*>(fOutputContainer->FindObject(key)) ;
305 TH1D * tmpD = dynamic_cast<TH1D*>(fOutputContainer->FindObject(key)) ;
310 AliInfo(Form("can not find histogram <%s> ",key)) ;
312 //_____________________________________________________________________________
313 void AliAnalysisTaskPHOSPbPbQA::FillHistogram(const char * key,Double_t x,Double_t y)const{
315 TObject * tmp = fOutputContainer->FindObject(key) ;
317 AliInfo(Form("can not find histogram <%s> ",key)) ;
320 if(tmp->IsA() == TClass::GetClass("TH1F")){
321 ((TH1F*)tmp)->Fill(x,y) ;
324 if(tmp->IsA() == TClass::GetClass("TH2F")){
325 ((TH2F*)tmp)->Fill(x,y) ;
328 AliError(Form("Calling FillHistogram with 2 parameters for histo <%s> of type %s",key,tmp->IsA()->GetName())) ;