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() {
110 Info("~AliAnalysisTaskSPD","Calling Destructor");
111 if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
112 if (fSegSPD) delete fSegSPD ;
118 //___________________________________________________________________________
119 void AliAnalysisTaskSPD::UserCreateOutputObjects() {
121 Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
123 LoadGeometryFromOCDB();
125 fSegSPD = new AliITSsegmentationSPD();
129 fOutput = new TList();
133 // Booking rec points related histograms
135 TH2D *hLocalMapL1 = new TH2D("hLocalMapL1"," Local coordinates - Layer 1",330,-16.5,16.5,205,-0.5,40.5); // safe limits for local coordinates in a module : z = -4,4, x = -1,1;
136 hLocalMapL1->SetXTitle("direction Z [cm]");
137 hLocalMapL1->SetYTitle("direction X [cm]");
138 fOutput->AddLast(hLocalMapL1);
140 TH2D *hLocalMapL2 = new TH2D("hLocalMapL2"," Local coordinates - Layer 2",330,-16.5,16.5,405,-0.5,80.5);
141 hLocalMapL2->SetXTitle("direction Z [cm]");
142 hLocalMapL2->SetYTitle("direction X [cm]");
143 fOutput->AddLast(hLocalMapL2);
145 TH1F *hClusterModYield = new TH1F("hClusterModYield","Cluster yield in modules",241,-0.5,240.5);
146 hClusterModYield->SetXTitle("module number");
147 fOutput->AddLast(hClusterModYield);
149 TH1F *hClusterYield = new TH1F("hClusterYield","Cluster yield per chip",1200,-0.5,1199.5) ;
150 hClusterYield->SetXTitle("chip key");
151 fOutput->AddLast(hClusterYield);
153 TH1F *hClusterYieldOnline = new TH1F("hClusterYieldOnline","Cluster yield per chip (online coord eq*60+hs*10+chip)",1200,-0.5,1199.5) ;
154 hClusterYieldOnline->SetXTitle("chip");
155 fOutput->AddLast(hClusterYieldOnline);
157 TH1F *hFiredChip = new TH1F("hFiredChip","Fired chip (at least one cluster)",1200,-0.5,1199.5);
158 hFiredChip->SetXTitle("chip key");
159 fOutput->AddLast(hFiredChip);
161 TH1F *hFOFiredChip = new TH1F("hFOFiredChip","FO Fired chip ",1200,-0.5,1199.5);
162 hFOFiredChip->SetXTitle("chip key");
163 fOutput->AddLast(hFOFiredChip);
165 TH1F *hFOgood = new TH1F("hFOgood"," FO-good (at least one cluster) ",1200,-0.5,1199.5);
166 hFOgood->SetXTitle("chip key");
167 fOutput->AddLast(hFOgood);
169 TH2F *hFOgoodPerBC = new TH2F("hFOgoodPerBCmod4"," FO-good signals in BCmod4 ",1200,-0.5,1199.5,4,-0.5,3.5);
170 hFOgoodPerBC->SetXTitle("chip key");
171 fOutput->AddLast(hFOgoodPerBC);
173 TH2F *hFiredChipsPerBC = new TH2F("hFiredChipsPerBCmod4"," fired chips in BCmod4 ",1200,-0.5,1199.5,4,-0.5,3.5);
174 hFiredChipsPerBC->SetXTitle("chip key");
175 fOutput->AddLast(hFiredChipsPerBC);
177 TH1F *hFOnoisy = new TH1F("hFOnoisy","FO-noisy (no cluster)",1200,-0.5,1199.5);
178 hFOnoisy->SetXTitle("chip key");
179 fOutput->AddLast(hFOnoisy);
182 // Booking ESD related histograms
186 TH1I *hTracklets = new TH1I("hNtracklets","Tracklet distribution",500,0,500);
187 hTracklets->SetXTitle("# Tracklets");
188 fOutput->AddLast(hTracklets);
190 TH2F *hSPDphivsSPDeta= new TH2F("hSPDphivsSPDeta", "Tracklets - #varphi vs #eta",120,-3.,3,360,0.,2*TMath::Pi());
191 hSPDphivsSPDeta->GetXaxis()->SetTitle("Pseudorapidity #eta");
192 hSPDphivsSPDeta->GetYaxis()->SetTitle("#varphi [rad]");
193 fOutput->AddLast(hSPDphivsSPDeta);
195 TH1F *hSPDphiZpos= new TH1F("hSPDphiZpos", "Tracklets - #varphi (Z>0)",360,0.,2*TMath::Pi());
196 hSPDphiZpos->SetXTitle("#varphi [rad]");
197 fOutput->AddLast(hSPDphiZpos);
199 TH1F *hSPDphiZneg= new TH1F("hSPDphiZneg", "Tracklets - #varphi (Z<0)",360,0.,2*TMath::Pi());
200 hSPDphiZneg->SetXTitle("#varphi [rad]");
201 fOutput->AddLast(hSPDphiZneg);
203 TH1F *hVertexZ = new TH1F("hVertexZ","Vertex Z distribution",300,-15,15);
204 hVertexZ->SetXTitle("Z Vertex [cm]");
205 fOutput->AddLast(hVertexZ);
207 TH2F *hTracklVsClu1 = new TH2F("hTrackVsClu1","Tracklet Vs Clusters Layer 1",100,0,8000,300,0,12000);
208 hTracklVsClu1->SetXTitle("clusters SPD Layer 1");
209 hTracklVsClu1->SetYTitle("tracklets");
210 fOutput->AddLast(hTracklVsClu1);
212 TH2F *hTracklVsClu2 = new TH2F("hTrackVsClu2","Tracklet Vs Clusters Layer 2",100,0,8000,300,0,12000);
213 hTracklVsClu2->SetXTitle("clusters SPD Layer 2");
214 hTracklVsClu2->SetYTitle("tracklets");
215 fOutput->AddLast(hTracklVsClu2);
217 TH1I *hEventsProcessed = new TH1I("hEventsProcessed","Number of processed events",1,0,1) ;
218 fOutput->AddLast(hEventsProcessed);
222 //_________________________________________________
223 void AliAnalysisTaskSPD::UserExec(Option_t *)
226 // Main loop function
228 AliESDInputHandlerRP *hand = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
230 printf("No AliESDInputHandlerRP \n");
234 AliESDEvent *ESD = hand->GetEvent();
236 printf("No AliESDEvent \n");
241 TTree * treeRP = hand->GetTreeR("ITS");
243 //AliWarning("No ITS RecPoints tree ");
249 // ESD related histograms
251 const AliESDVertex *vertex = ESD->GetPrimaryVertexSPD();
252 const AliMultiplicity *mult = ESD->GetMultiplicity();
256 if(!vertex->GetStatus()) return;
257 if(vertex->GetNContributors() < 1) return;
259 ((TH1I*)fOutput->At(18))->Fill(0);
261 ((TH1I*)fOutput->At(11))->Fill(mult->GetNumberOfTracklets());
262 UInt_t bc = (UInt_t)ESD->GetBunchCrossNumber();
263 for(Int_t iChipKey=0; iChipKey < 1200; iChipKey++){
264 if(mult->TestFiredChipMap(iChipKey)) {
265 ((TH1F*)fOutput->At(5))->Fill(iChipKey);
266 if(bc>0)((TH2F*)fOutput->At(9))->Fill(iChipKey,bc%4);
268 if(mult->TestFastOrFiredChips(iChipKey)) ((TH1F*)fOutput->At(6))->Fill(iChipKey);
269 if(mult->TestFastOrFiredChips(iChipKey) && mult->TestFiredChipMap(iChipKey)) {
270 ((TH1F*)fOutput->At(7))->Fill(iChipKey);
271 if(bc>0) ((TH2F*)fOutput->At(8))->Fill(iChipKey,bc%4);
274 if(mult->TestFastOrFiredChips(iChipKey) && !mult->TestFiredChipMap(iChipKey)) ((TH1F*)fOutput->At(10))->Fill(iChipKey);
278 Double_t vtxPos[3] = {999, 999, 999};
280 vertex->GetXYZ(vtxPos);
282 ((TH1F*)fOutput->At(15))->Fill(vtxPos[2]);
284 ((TH2F*)fOutput->At(16))->Fill(mult->GetNumberOfITSClusters(0),mult->GetNumberOfTracklets());
285 ((TH2F*)fOutput->At(17))->Fill(mult->GetNumberOfITSClusters(1),mult->GetNumberOfTracklets());
287 for(Int_t iTracklet =0; iTracklet < mult->GetNumberOfTracklets(); iTracklet++){
289 Float_t phiTr= mult->GetPhi(iTracklet);
290 Float_t etaTr =mult->GetEta(iTracklet);
292 ((TH2F*)fOutput->At(12))->Fill(etaTr,phiTr);
295 Float_t z = vtxPos[2] + 3.9 / TMath::Tan(2 * TMath::ATan(TMath::Exp(- etaTr)));
296 if(z>0) ((TH1F*)fOutput->At(13))->Fill(phiTr);
297 else ((TH1F*)fOutput->At(14))->Fill(phiTr);
305 TClonesArray statITSrec("AliITSRecPoint");
306 TClonesArray *ITSCluster = &statITSrec;
307 TBranch* branch=treeRP->GetBranch("ITSRecPoints");
309 printf("NO treeRP branch available. Exiting...\n");
313 branch->SetAddress(&ITSCluster);
315 for(Int_t iMod=0;iMod<240;iMod++){
316 branch->GetEvent(iMod);
317 Int_t nrecp = statITSrec.GetEntries();
318 if(nrecp>0) ((TH1F*)fOutput->At(2))->Fill(iMod,nrecp);
320 for(Int_t irec=0;irec<nrecp;irec++) {
321 AliITSRecPoint *recp = (AliITSRecPoint*)statITSrec.At(irec);
322 Int_t lay=recp->GetLayer();
325 // ---- Filling maps (local coordinates rearranged) -----
326 Float_t local[3]={-1,-1};
327 local[1]=recp->GetDetLocalX();
328 local[0]=recp->GetDetLocalZ();
329 Int_t eq = AliSPDUtils::GetOnlineEqIdFromOffline(iMod);
330 Int_t hs = AliSPDUtils::GetOnlineHSFromOffline(iMod);
332 fSegSPD->LocalToDet(0.5,local[0],row,col);
333 Int_t chip = AliSPDUtils::GetOnlineChipFromOffline(iMod,col);
335 Double_t locx, locz, equip;
336 Double_t corrlocz =0;
337 if(lay==0) corrlocz=local[0];
338 else corrlocz = -local[0];
339 // rearranging local geometry
343 if(chip<5) locz =corrlocz +8 +4;
344 else locz = corrlocz+4;
346 if(chip<5) locz = corrlocz-8-4;
347 else locz = corrlocz-4;
351 locx = (local[1]+1) + hs*2 +equip*4;
352 ((TH2D*)fOutput->At(0))->Fill(locz,locx);
355 locx = (local[1]+1) + (hs-2)*2 +equip*8;
356 ((TH2D*)fOutput->At(1))->Fill(locz,locx);
358 // ---- End Filling maps (local coordinates rearranged) -----
360 ((TH1F*)fOutput->At(3))->Fill(AliSPDUtils::GetOfflineChipKeyFromOnline(eq,hs,chip));
361 ((TH1F*)fOutput->At(4))->Fill(eq*60+hs*10+chip);
365 }// end if rec points are available
370 /* PostData(0) is taken care of by AliAnalysisTaskSE */
371 PostData(1,fOutput) ;
376 //___________________________________________________________________________
377 void AliAnalysisTaskSPD::Terminate(Option_t*)
379 // The Terminate() function is the last function to be called during
380 // a query. It always runs on the client, it can be used to present
381 // the results graphically or save the results to file.
383 AliAnalysisTaskSE::Terminate();
388 //___________________________________________________________________________
389 void AliAnalysisTaskSPD::LoadGeometryFromOCDB(){
390 //method to get the gGeomanager
391 // it is called at the CreatedOutputObject stage
392 // to comply with the CAF environment
393 AliCDBManager *man = AliCDBManager::Instance();
394 man->SetDefaultStorage(fOCDBLocation.Data());
396 AliCDBEntry* obj = man->Get(AliCDBPath("GRP", "Geometry", "Data"));
398 AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());
399 AliGeomManager::GetNalignable("ITS");
400 AliGeomManager::ApplyAlignObjsFromCDB("ITS");