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 //-----------------------------------------------------------------------
18 // Author : A. Mastroserio
19 //-----------------------------------------------------------------------
22 #ifndef ALIANALYSISTASKSPD_CXX
23 #define ALIANALYSISTASKSPD_CXX
25 #include "AliAnalysisTaskSPD.h"
26 #include "TClonesArray.h"
31 #include "AliSPDUtils.h"
32 #include "AliESDEvent.h"
35 #include "AliESDInputHandlerRP.h"
36 #include "AliAnalysisManager.h"
37 #include "AliMultiplicity.h"
38 #include "AliCDBPath.h"
39 #include "AliCDBManager.h"
40 #include "AliCDBEntry.h"
41 #include "AliCDBStorage.h"
42 #include "AliGeomManager.h"
43 #include "AliITSRecPoint.h"
44 #include "AliITSsegmentationSPD.h"
45 ClassImp(AliAnalysisTaskSPD)
46 //__________________________________________________________________________
47 AliAnalysisTaskSPD::AliAnalysisTaskSPD() :
51 fOCDBLocation("local://$ALICE_ROOT/OCDB")
57 //___________________________________________________________________________
58 AliAnalysisTaskSPD::AliAnalysisTaskSPD(const Char_t* name) :
59 AliAnalysisTaskSE(name),
63 fOCDBLocation("local://$ALICE_ROOT/OCDB")
66 // Constructor. Initialization of Inputs and Outputs
68 Info("AliAnalysisTaskSPD","Calling Constructor");
70 DefineOutput(1,TList::Class());
74 //___________________________________________________________________________
75 AliAnalysisTaskSPD& AliAnalysisTaskSPD::operator=(const AliAnalysisTaskSPD& c)
78 // Assignment operator
81 AliAnalysisTaskSE::operator=(c) ;
85 fOCDBLocation = c.fOCDBLocation;
90 //___________________________________________________________________________
91 AliAnalysisTaskSPD::AliAnalysisTaskSPD(const AliAnalysisTaskSPD& c) :
96 fOCDBLocation(c.fOCDBLocation)
104 //___________________________________________________________________________
105 AliAnalysisTaskSPD::~AliAnalysisTaskSPD() {
109 Info("~AliAnalysisTaskSPD","Calling Destructor");
110 if (fSegSPD) delete fSegSPD ;
116 //___________________________________________________________________________
117 void AliAnalysisTaskSPD::UserCreateOutputObjects() {
119 Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
121 LoadGeometryFromOCDB();
123 fSegSPD = new AliITSsegmentationSPD();
127 fOutput = new TList();
129 // Booking rec points related histograms
131 TH2D *hLocalMapL1 = new TH2D("hLocalMapL1"," Local coordinates - Layer 1",660,-16.5,16.5,410,-0.5,40.5); // safe limits for local coordinates in a module : z = -4,4, x = -1,1;
132 hLocalMapL1->SetXTitle("direction Z [cm]");
133 hLocalMapL1->SetYTitle("direction X [cm]");
134 fOutput->AddLast(hLocalMapL1);
136 TH2D *hLocalMapL2 = new TH2D("hLocalMapL2"," Local coordinates - Layer 2",660,-16.5,16.5,810,-0.5,80.5);
137 hLocalMapL2->SetXTitle("direction Z [cm]");
138 hLocalMapL2->SetYTitle("direction X [cm]");
139 fOutput->AddLast(hLocalMapL2);
141 TH1F *hClusterModYield = new TH1F("hClusterModYield","Cluster yield in modules",241,-0.5,240.5);
142 hClusterModYield->SetXTitle("module number");
143 fOutput->AddLast(hClusterModYield);
145 TH1F *hClusterYield = new TH1F("hClusterYield","Cluster yield per chip",1200,-0.5,1199.5) ;
146 hClusterYield->SetXTitle("chip key");
147 fOutput->AddLast(hClusterYield);
149 TH1F *hClusterYieldOnline = new TH1F("hClusterYieldOnline","Cluster yield per chip (online coord eq*60+hs*10+chip)",1200,-0.5,1199.5) ;
150 hClusterYieldOnline->SetXTitle("chip");
151 fOutput->AddLast(hClusterYieldOnline);
153 TH1F *hFiredChip = new TH1F("hFiredChip","Fired chip (at least one cluster)",1200,-0.5,1199.5);
154 hFiredChip->SetXTitle("chip key");
155 fOutput->AddLast(hFiredChip);
157 TH1F *hFOFiredChip = new TH1F("hFOFiredChip","FO Fired chip ",1200,-0.5,1199.5);
158 hFOFiredChip->SetXTitle("chip key");
159 fOutput->AddLast(hFOFiredChip);
161 TH1F *hFOgood = new TH1F("hFOgood"," FO-good (at least one cluster) ",1200,-0.5,1199.5);
162 hFOgood->SetXTitle("chip key");
163 fOutput->AddLast(hFOgood);
165 TH2F *hFOgoodPerBC = new TH2F("hFOgoodPerBCmod4"," FO-good signals in BCmod4 ",1200,-0.5,1199.5,4,-0.5,3.5);
166 hFOgoodPerBC->SetXTitle("chip key");
167 fOutput->AddLast(hFOgoodPerBC);
169 TH2F *hFiredChipsPerBC = new TH2F("hFiredChipsPerBCmod4"," fired chips in BCmod4 ",1200,-0.5,1199.5,4,-0.5,3.5);
170 hFiredChipsPerBC->SetXTitle("chip key");
171 fOutput->AddLast(hFiredChipsPerBC);
173 TH1F *hFOnoisy = new TH1F("hFOnoisy","FO-noisy (no cluster)",1200,-0.5,1199.5);
174 hFOnoisy->SetXTitle("chip key");
175 fOutput->AddLast(hFOnoisy);
178 // Booking ESD related histograms
182 TH1I *hTracklets = new TH1I("hNtracklets","Tracklet distribution",80,0,80);
183 hTracklets->SetXTitle("# Tracklets");
184 fOutput->AddLast(hTracklets);
186 TH2F *hSPDphivsSPDeta= new TH2F("hSPDphivsSPDeta", "Tracklets - #varphi vs #eta",120,-3.,3,360,0.,2*TMath::Pi());
187 hSPDphivsSPDeta->GetXaxis()->SetTitle("Pseudorapidity #eta");
188 hSPDphivsSPDeta->GetYaxis()->SetTitle("#varphi [rad]");
189 fOutput->AddLast(hSPDphivsSPDeta);
191 TH1F *hSPDphiZpos= new TH1F("hSPDphiZpos", "Tracklets - #varphi (Z>0)",360,0.,2*TMath::Pi());
192 hSPDphiZpos->SetXTitle("#varphi [rad]");
193 fOutput->AddLast(hSPDphiZpos);
195 TH1F *hSPDphiZneg= new TH1F("hSPDphiZneg", "Tracklets - #varphi (Z<0)",360,0.,2*TMath::Pi());
196 hSPDphiZneg->SetXTitle("#varphi [rad]");
197 fOutput->AddLast(hSPDphiZneg);
199 TH1F *hVertexZ = new TH1F("hVertexZ","Vertex Z distribution",300,-15,15);
200 hVertexZ->SetXTitle("Z Vertex [cm]");
201 fOutput->AddLast(hVertexZ);
203 TH1I *hEventsProcessed = new TH1I("hEventsProcessed","Number of processed events",1,0,1) ;
204 fOutput->AddLast(hEventsProcessed);
206 //_________________________________________________
207 void AliAnalysisTaskSPD::UserExec(Option_t *)
210 // Main loop function
212 AliESDInputHandlerRP *hand = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
214 printf("No AliESDInputHandlerRP \n");
218 AliESDEvent *ESD = hand->GetEvent();
220 printf("No AliESDEvent \n");
225 TTree * treeRP = hand->GetTreeR("ITS");
227 //AliWarning("No ITS RecPoints tree ");
233 // ESD related histograms
235 const AliESDVertex *vertex = ESD->GetPrimaryVertexSPD();
236 const AliMultiplicity *mult = ESD->GetMultiplicity();
240 if(!vertex->GetStatus()) return;
241 if(vertex->GetNContributors() < 1) return;
243 ((TH1I*)fOutput->At(16))->Fill(0);
245 ((TH1I*)fOutput->At(11))->Fill(mult->GetNumberOfTracklets());
246 UInt_t bc = (UInt_t)ESD->GetBunchCrossNumber();
247 for(Int_t iChipKey=0; iChipKey < 1200; iChipKey++){
248 if(mult->TestFiredChipMap(iChipKey)) {
249 ((TH1F*)fOutput->At(5))->Fill(iChipKey);
250 if(bc>0)((TH2F*)fOutput->At(9))->Fill(iChipKey,bc%4);
252 if(mult->TestFastOrFiredChips(iChipKey)) ((TH1F*)fOutput->At(6))->Fill(iChipKey);
253 if(mult->TestFastOrFiredChips(iChipKey) && mult->TestFiredChipMap(iChipKey)) {
254 ((TH1F*)fOutput->At(7))->Fill(iChipKey);
255 if(bc>0) ((TH2F*)fOutput->At(8))->Fill(iChipKey,bc%4);
258 if(mult->TestFastOrFiredChips(iChipKey) && !mult->TestFiredChipMap(iChipKey)) ((TH1F*)fOutput->At(10))->Fill(iChipKey);
262 Double_t vtxPos[3] = {999, 999, 999};
264 vertex->GetXYZ(vtxPos);
266 ((TH1F*)fOutput->At(15))->Fill(vtxPos[2]);
268 for(Int_t iTracklet =0; iTracklet < mult->GetNumberOfTracklets(); iTracklet++){
270 Float_t phiTr= mult->GetPhi(iTracklet);
271 Float_t etaTr =mult->GetEta(iTracklet);
273 ((TH2F*)fOutput->At(12))->Fill(etaTr,phiTr);
276 Float_t z = vtxPos[2] + 3.9 / TMath::Tan(2 * TMath::ATan(TMath::Exp(- etaTr)));
277 if(z>0) ((TH1F*)fOutput->At(13))->Fill(phiTr);
278 else ((TH1F*)fOutput->At(14))->Fill(phiTr);
286 TClonesArray statITSrec("AliITSRecPoint");
287 TClonesArray *ITSCluster = &statITSrec;
288 TBranch* branch=treeRP->GetBranch("ITSRecPoints");
290 printf("NO treeRP branch available. Exiting...\n");
294 branch->SetAddress(&ITSCluster);
296 for(Int_t iMod=0;iMod<240;iMod++){
297 branch->GetEvent(iMod);
298 Int_t nrecp = statITSrec.GetEntries();
299 if(nrecp>0) ((TH1F*)fOutput->At(2))->Fill(iMod,nrecp);
301 for(Int_t irec=0;irec<nrecp;irec++) {
302 AliITSRecPoint *recp = (AliITSRecPoint*)statITSrec.At(irec);
303 Int_t lay=recp->GetLayer();
306 // ---- Filling maps (local coordinates rearranged) -----
307 Float_t local[3]={-1,-1};
308 local[1]=recp->GetDetLocalX();
309 local[0]=recp->GetDetLocalZ();
310 Int_t eq = AliSPDUtils::GetOnlineEqIdFromOffline(iMod);
311 Int_t hs = AliSPDUtils::GetOnlineHSFromOffline(iMod);
313 fSegSPD->LocalToDet(0.5,local[0],row,col);
314 Int_t chip = AliSPDUtils::GetOnlineChipFromOffline(iMod,col);
316 Double_t locx, locz, equip;
317 Double_t corrlocz =0;
318 if(lay==0) corrlocz=local[0];
319 else corrlocz = -local[0];
320 // rearranging local geometry
324 if(chip<5) locz =corrlocz +8 +4;
325 else locz = corrlocz+4;
327 if(chip<5) locz = corrlocz-8-4;
328 else locz = corrlocz-4;
332 locx = (local[1]+1) + hs*2 +equip*4;
333 ((TH2D*)fOutput->At(0))->Fill(locz,locx);
336 locx = (local[1]+1) + (hs-2)*2 +equip*8;
337 ((TH2D*)fOutput->At(1))->Fill(locz,locx);
339 // ---- End Filling maps (local coordinates rearranged) -----
341 ((TH1F*)fOutput->At(3))->Fill(AliSPDUtils::GetOfflineChipKeyFromOnline(eq,hs,chip));
342 ((TH1F*)fOutput->At(4))->Fill(eq*60+hs*10+chip);
346 }// end if rec points are available
351 /* PostData(0) is taken care of by AliAnalysisTaskSE */
352 PostData(1,fOutput) ;
357 //___________________________________________________________________________
358 void AliAnalysisTaskSPD::Terminate(Option_t*)
360 // The Terminate() function is the last function to be called during
361 // a query. It always runs on the client, it can be used to present
362 // the results graphically or save the results to file.
364 AliAnalysisTaskSE::Terminate();
369 //___________________________________________________________________________
370 void AliAnalysisTaskSPD::LoadGeometryFromOCDB(){
371 //method to get the gGeomanager
372 // it is called at the CreatedOutputObject stage
373 // to comply with the CAF environment
374 AliCDBManager *man = AliCDBManager::Instance();
375 man->SetDefaultStorage(fOCDBLocation.Data());
377 AliCDBEntry* obj = man->Get(AliCDBPath("GRP", "Geometry", "Data"));
378 AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());
379 AliGeomManager::GetNalignable("ITS");
380 AliGeomManager::ApplyAlignObjsFromCDB("ITS");