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"),
59 //___________________________________________________________________________
60 AliAnalysisTaskSPD::AliAnalysisTaskSPD(const Char_t* name) :
61 AliAnalysisTaskSE(name),
65 fOCDBLocation("local://$ALICE_ROOT/OCDB"),
70 // Constructor. Initialization of Inputs and Outputs
72 Info("AliAnalysisTaskSPD","Calling Constructor");
74 DefineOutput(1,TList::Class());
78 //___________________________________________________________________________
79 AliAnalysisTaskSPD& AliAnalysisTaskSPD::operator=(const AliAnalysisTaskSPD& c)
82 // Assignment operator
85 AliAnalysisTaskSE::operator=(c) ;
89 fOCDBLocation = c.fOCDBLocation;
96 //___________________________________________________________________________
97 AliAnalysisTaskSPD::AliAnalysisTaskSPD(const AliAnalysisTaskSPD& c) :
102 fOCDBLocation(c.fOCDBLocation),
112 //___________________________________________________________________________
113 AliAnalysisTaskSPD::~AliAnalysisTaskSPD() {
118 Info("~AliAnalysisTaskSPD","Calling Destructor");
119 if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
120 if (fSegSPD) delete fSegSPD ;
126 //___________________________________________________________________________
127 void AliAnalysisTaskSPD::UserCreateOutputObjects() {
129 Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
131 // Geometry is loaded (including ITS alignment) by AliTaskCDBconnect (A.G. 14/10/2011)
132 if (fTest) LoadGeometryFromOCDB();
134 fSegSPD = new AliITSsegmentationSPD();
138 fOutput = new TList();
142 // Booking rec points related histograms
144 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;
145 hLocalMapL1->SetXTitle("direction Z [cm]");
146 hLocalMapL1->SetYTitle("direction X [cm]");
147 fOutput->AddLast(hLocalMapL1);
149 TH2D *hLocalMapL2 = new TH2D("hLocalMapL2"," Local coordinates - Layer 2",330,-16.5,16.5,405,-0.5,80.5);
150 hLocalMapL2->SetXTitle("direction Z [cm]");
151 hLocalMapL2->SetYTitle("direction X [cm]");
152 fOutput->AddLast(hLocalMapL2);
154 TH1F *hClusterModYield = new TH1F("hClusterModYield","Cluster yield in modules",241,-0.5,240.5);
155 hClusterModYield->SetXTitle("module number");
156 fOutput->AddLast(hClusterModYield);
158 TH1F *hClusterYield = new TH1F("hClusterYield","Cluster yield per chip",1200,-0.5,1199.5) ;
159 hClusterYield->SetXTitle("chip key");
160 fOutput->AddLast(hClusterYield);
162 TH1F *hClusterYieldOnline = new TH1F("hClusterYieldOnline","Cluster yield per chip (online coord eq*60+hs*10+chip)",1200,-0.5,1199.5) ;
163 hClusterYieldOnline->SetXTitle("chip");
164 fOutput->AddLast(hClusterYieldOnline);
166 TH1F *hFiredChip = new TH1F("hFiredChip","Fired chip (at least one cluster)",1200,-0.5,1199.5);
167 hFiredChip->SetXTitle("chip key");
168 fOutput->AddLast(hFiredChip);
170 TH1F *hFOFiredChip = new TH1F("hFOFiredChip","FO Fired chip ",1200,-0.5,1199.5);
171 hFOFiredChip->SetXTitle("chip key");
172 fOutput->AddLast(hFOFiredChip);
174 TH1F *hFOgood = new TH1F("hFOgood"," FO-good (at least one cluster) ",1200,-0.5,1199.5);
175 hFOgood->SetXTitle("chip key");
176 fOutput->AddLast(hFOgood);
178 TH2F *hFOgoodPerBC = new TH2F("hFOgoodPerBCmod4"," FO-good signals in BCmod4 ",1200,-0.5,1199.5,4,-0.5,3.5);
179 hFOgoodPerBC->SetXTitle("chip key");
180 fOutput->AddLast(hFOgoodPerBC);
182 TH2F *hFiredChipsPerBC = new TH2F("hFiredChipsPerBCmod4"," fired chips in BCmod4 ",1200,-0.5,1199.5,4,-0.5,3.5);
183 hFiredChipsPerBC->SetXTitle("chip key");
184 fOutput->AddLast(hFiredChipsPerBC);
186 TH1F *hFOnoisy = new TH1F("hFOnoisy","FO-noisy (no cluster)",1200,-0.5,1199.5);
187 hFOnoisy->SetXTitle("chip key");
188 fOutput->AddLast(hFOnoisy);
191 // Booking ESD related histograms
204 TH1I *hTracklets = new TH1I("hNtracklets","Tracklet distribution",nbin,0,nTrMax);
205 hTracklets->SetXTitle("# Tracklets");
206 fOutput->AddLast(hTracklets);
208 TH2F *hSPDphivsSPDeta= new TH2F("hSPDphivsSPDeta", "Tracklets - #varphi vs #eta",120,-3.,3,360,0.,2*TMath::Pi());
209 hSPDphivsSPDeta->GetXaxis()->SetTitle("Pseudorapidity #eta");
210 hSPDphivsSPDeta->GetYaxis()->SetTitle("#varphi [rad]");
211 fOutput->AddLast(hSPDphivsSPDeta);
213 TH1F *hSPDphiZpos= new TH1F("hSPDphiZpos", "Tracklets - #varphi (Z>0)",360,0.,2*TMath::Pi());
214 hSPDphiZpos->SetXTitle("#varphi [rad]");
215 fOutput->AddLast(hSPDphiZpos);
217 TH1F *hSPDphiZneg= new TH1F("hSPDphiZneg", "Tracklets - #varphi (Z<0)",360,0.,2*TMath::Pi());
218 hSPDphiZneg->SetXTitle("#varphi [rad]");
219 fOutput->AddLast(hSPDphiZneg);
221 TH1F *hVertexZ = new TH1F("hVertexZ","Vertex Z distribution",300,-15,15);
222 hVertexZ->SetXTitle("Z Vertex [cm]");
223 fOutput->AddLast(hVertexZ);
225 TH2F *hTracklVsClu1 = new TH2F("hTrackVsClu1","Tracklet Vs Clusters Layer 1",nbin/2,0,1.5*nTrMax,nbin/2,0,nTrMax);
226 hTracklVsClu1->SetXTitle("clusters SPD Layer 1");
227 hTracklVsClu1->SetYTitle("tracklets");
228 fOutput->AddLast(hTracklVsClu1);
230 TH2F *hTracklVsClu2 = new TH2F("hTrackVsClu2","Tracklet Vs Clusters Layer 2",nbin/2,0,1.5*nTrMax,nbin/2,0,nTrMax);
231 hTracklVsClu2->SetXTitle("clusters SPD Layer 2");
232 hTracklVsClu2->SetYTitle("tracklets");
233 fOutput->AddLast(hTracklVsClu2);
235 TH1I *hEventsProcessed = new TH1I("hEventsProcessed","Number of processed events",1,0,1) ;
236 fOutput->AddLast(hEventsProcessed);
240 //_________________________________________________
241 void AliAnalysisTaskSPD::UserExec(Option_t *)
244 // Main loop function
246 AliESDInputHandlerRP *hand = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
248 printf("No AliESDInputHandlerRP \n");
252 AliESDEvent *ESD = hand->GetEvent();
254 printf("No AliESDEvent \n");
259 TTree * treeRP = hand->GetTreeR("ITS");
261 //AliWarning("No ITS RecPoints tree ");
267 // ESD related histograms
269 const AliESDVertex *vertex = ESD->GetPrimaryVertexSPD();
270 const AliMultiplicity *mult = ESD->GetMultiplicity();
274 if(!vertex->GetStatus()) return;
275 if(vertex->GetNContributors() < 1) return;
277 ((TH1I*)fOutput->At(18))->Fill(0);
279 ((TH1I*)fOutput->At(11))->Fill(mult->GetNumberOfTracklets());
280 UInt_t bc = (UInt_t)ESD->GetBunchCrossNumber();
281 for(Int_t iChipKey=0; iChipKey < 1200; iChipKey++){
282 if(mult->TestFiredChipMap(iChipKey)) {
283 ((TH1F*)fOutput->At(5))->Fill(iChipKey);
284 if(bc>0)((TH2F*)fOutput->At(9))->Fill(iChipKey,bc%4);
286 if(mult->TestFastOrFiredChips(iChipKey)) ((TH1F*)fOutput->At(6))->Fill(iChipKey);
287 if(mult->TestFastOrFiredChips(iChipKey) && mult->TestFiredChipMap(iChipKey)) {
288 ((TH1F*)fOutput->At(7))->Fill(iChipKey);
289 if(bc>0) ((TH2F*)fOutput->At(8))->Fill(iChipKey,bc%4);
292 if(mult->TestFastOrFiredChips(iChipKey) && !mult->TestFiredChipMap(iChipKey)) ((TH1F*)fOutput->At(10))->Fill(iChipKey);
296 Double_t vtxPos[3] = {999, 999, 999};
298 vertex->GetXYZ(vtxPos);
300 ((TH1F*)fOutput->At(15))->Fill(vtxPos[2]);
302 ((TH2F*)fOutput->At(16))->Fill(mult->GetNumberOfITSClusters(0),mult->GetNumberOfTracklets());
303 ((TH2F*)fOutput->At(17))->Fill(mult->GetNumberOfITSClusters(1),mult->GetNumberOfTracklets());
305 for(Int_t iTracklet =0; iTracklet < mult->GetNumberOfTracklets(); iTracklet++){
307 Float_t phiTr= mult->GetPhi(iTracklet);
308 Float_t etaTr =mult->GetEta(iTracklet);
310 ((TH2F*)fOutput->At(12))->Fill(etaTr,phiTr);
313 Float_t z = vtxPos[2] + 3.9 / TMath::Tan(2 * TMath::ATan(TMath::Exp(- etaTr)));
314 if(z>0) ((TH1F*)fOutput->At(13))->Fill(phiTr);
315 else ((TH1F*)fOutput->At(14))->Fill(phiTr);
323 TClonesArray statITSrec("AliITSRecPoint");
324 TClonesArray *ITSCluster = &statITSrec;
325 TBranch* branch=treeRP->GetBranch("ITSRecPoints");
327 printf("NO treeRP branch available. Exiting...\n");
331 branch->SetAddress(&ITSCluster);
333 for(Int_t iMod=0;iMod<240;iMod++){
334 branch->GetEvent(iMod);
335 Int_t nrecp = statITSrec.GetEntries();
336 if(nrecp>0) ((TH1F*)fOutput->At(2))->Fill(iMod,nrecp);
338 for(Int_t irec=0;irec<nrecp;irec++) {
339 AliITSRecPoint *recp = (AliITSRecPoint*)statITSrec.At(irec);
340 Int_t lay=recp->GetLayer();
343 // ---- Filling maps (local coordinates rearranged) -----
344 Float_t local[3]={-1,-1};
345 local[1]=recp->GetDetLocalX();
346 local[0]=recp->GetDetLocalZ();
347 Int_t eq = AliSPDUtils::GetOnlineEqIdFromOffline(iMod);
348 Int_t hs = AliSPDUtils::GetOnlineHSFromOffline(iMod);
350 fSegSPD->LocalToDet(0.5,local[0],row,col);
351 Int_t chip = AliSPDUtils::GetOnlineChipFromOffline(iMod,col);
353 Double_t locx, locz, equip;
354 Double_t corrlocz =0;
355 if(lay==0) corrlocz=local[0];
356 else corrlocz = -local[0];
357 // rearranging local geometry
361 if(chip<5) locz =corrlocz +8 +4;
362 else locz = corrlocz+4;
364 if(chip<5) locz = corrlocz-8-4;
365 else locz = corrlocz-4;
369 locx = (local[1]+1) + hs*2 +equip*4;
370 ((TH2D*)fOutput->At(0))->Fill(locz,locx);
373 locx = (local[1]+1) + (hs-2)*2 +equip*8;
374 ((TH2D*)fOutput->At(1))->Fill(locz,locx);
376 // ---- End Filling maps (local coordinates rearranged) -----
378 ((TH1F*)fOutput->At(3))->Fill(AliSPDUtils::GetOfflineChipKeyFromOnline(eq,hs,chip));
379 ((TH1F*)fOutput->At(4))->Fill(eq*60+hs*10+chip);
383 }// end if rec points are available
388 /* PostData(0) is taken care of by AliAnalysisTaskSE */
389 PostData(1,fOutput) ;
394 //___________________________________________________________________________
395 void AliAnalysisTaskSPD::Terminate(Option_t*)
397 // The Terminate() function is the last function to be called during
398 // a query. It always runs on the client, it can be used to present
399 // the results graphically or save the results to file.
401 AliAnalysisTaskSE::Terminate();
406 //___________________________________________________________________________
407 void AliAnalysisTaskSPD::LoadGeometryFromOCDB(){
408 //method to get the gGeomanager
409 // it is called at the CreatedOutputObject stage
410 // to comply with the CAF environment
413 AliCDBManager *man = AliCDBManager::Instance();
414 man->SetDefaultStorage(fOCDBLocation.Data());
418 if(!AliCDBManager::Instance()){
419 AliWarning("No CDB MANAGER, geometry can not be loaded");
423 AliCDBEntry* obj =(AliCDBManager::Instance())->Get(AliCDBPath("GRP", "Geometry", "Data"));
425 AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());
426 AliGeomManager::GetNalignable("ITS");
427 AliGeomManager::ApplyAlignObjsFromCDB("ITS");