]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASSDDataMakerRec.cxx
better organization of private and protected methods. Bug fix in AliITSPlaneEff:...
[u/mrichter/AliRoot.git] / ITS / AliITSQASSDDataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 //  *************************************************************
17 //  Checks the quality assurance 
18 //  by comparing with reference data
19 //  contained in a DB
20 //  -------------------------------------------------------------
21 //  W. Ferrarese + P. Cerello Feb 2008
22 //  INFN Torino
23
24 // --- ROOT system ---
25 #include <TH2D.h>
26 #include <TTree.h>
27 #include <TString.h>
28
29 // --- Standard library ---
30
31 // --- AliRoot header files ---
32 #include "AliITSQASSDDataMakerRec.h"
33 #include "AliLog.h"
34 #include "AliQA.h"
35 #include "AliQAChecker.h"
36 #include "AliRawReader.h"
37 #include "AliITSRawStreamSSD.h"
38 #include "AliITSgeomTGeo.h"
39
40
41 ClassImp(AliITSQASSDDataMakerRec)
42
43 //____________________________________________________________________________ 
44 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Int_t ldc) :
45 TObject(),
46 fAliITSQADataMakerRec(aliITSQADataMakerRec),
47 fkOnline(kMode),
48 fLDC(ldc),
49 fSSDhRaws(0),
50 fSSDhRecs(0),
51 fRawsOffset(0),
52 fRecsOffset(0)
53 {
54   //ctor used to discriminate OnLine-Offline analysis
55   //initilize the raw signal vs strip number histograms
56   Int_t fLayer = 0,fLadder = 0, fModule = 0;
57   TString fTitle; Int_t fHistCounter = 0;
58   for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
59     AliITSgeomTGeo::GetModuleId(i,fLayer,fLadder,fModule);
60     fTitle = "SSD_RawSignal_Layer"; fTitle += fLayer;
61     fTitle += "_Ladder"; fTitle += fLadder;
62     fTitle += "_Module"; fTitle += fModule;
63     fHistSSDRawSignalModule[fHistCounter] = new TH1D(fTitle.Data(),fTitle.Data(),1540,0,1540);
64     fHistCounter++;
65   }
66 }
67
68 //____________________________________________________________________________ 
69 AliITSQASSDDataMakerRec::AliITSQASSDDataMakerRec(const AliITSQASSDDataMakerRec& qadm) :
70 TObject(),
71 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
72 fkOnline(qadm.fkOnline),
73 fLDC(qadm.fLDC),
74 fSSDhRaws(qadm.fSSDhRaws),
75 fSSDhRecs(qadm.fSSDhRecs),
76 fRawsOffset(qadm.fRawsOffset),
77 fRecsOffset(qadm.fRecsOffset)
78 {
79   //copy ctor 
80   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
81   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
82 }
83
84 //__________________________________________________________________
85 AliITSQASSDDataMakerRec& AliITSQASSDDataMakerRec::operator = (const AliITSQASSDDataMakerRec& qac )
86 {
87   // Equal operator.
88   this->~AliITSQASSDDataMakerRec();
89   new(this) AliITSQASSDDataMakerRec(qac);
90   return *this;
91 }
92
93 //____________________________________________________________________________ 
94 void AliITSQASSDDataMakerRec::StartOfDetectorCycle()
95 {
96   //Detector specific actions at start of cycle
97   AliDebug(1,"AliITSQADM::Start of SSD Cycle\n");
98 }
99
100 //____________________________________________________________________________ 
101 void AliITSQASSDDataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX /*task*/, TObjArray* /*list*/)
102 {
103   // launch the QA checking
104   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
105   
106   //SSD occupancy plots
107   if(fkOnline) {
108     Int_t fLayer = 0, fLadder = 0, fModule = 0;
109     Int_t fOccPosition = 0;
110     for(Int_t i = 0; i < fgkSSDMODULES; i++) {
111       AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule); 
112       fOccPosition  = (fLayer == 5) ? fLadder : fLadder + 34;
113       Double_t occupancy = GetSSDOccupancyRaws(fHistSSDRawSignalModule[i]);
114       //if(occupancy > 0) {
115       //AliInfo(Form("========================================="));
116       //AliInfo(Form("%s Position: %d - Initial histos: %d - Occupancy: %lf\n",fHistSSDRawSignalModule[i]->GetName(),fOccPosition,fInitialHistograms,occupancy));
117       //}
118       fAliITSQADataMakerRec->GetRawsData(fRawsOffset + fOccPosition - 1)->Fill(fModule,occupancy);
119     }
120   }//online flag for SSD
121   //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
122 }
123
124 //____________________________________________________________________________ 
125 void AliITSQASSDDataMakerRec::InitRaws() {  
126
127   // Initialization for RAW data - SSD -
128   fRawsOffset = (fAliITSQADataMakerRec->fRawsQAList)->GetEntries();
129
130   const Int_t fSSDLADDERS = 72;
131   if(fkOnline) {
132     AliInfo("Book Online Histograms for SSD\n");
133   }
134   else {
135     AliInfo("Book Offline Histograms for SSD\n ");
136   }
137   AliInfo(Form("Number of histograms (SPD+SDD): %d\n",fRawsOffset));
138   TString fTitle = 0;
139   //Int_t fLayer = 0,fLadder = 0, fModule = 0;
140   //book online QA histos
141   if(fkOnline) {
142     TH1D *hOccupancyLadder[fSSDLADDERS];
143     for(Int_t iLayer = 5; iLayer < 7; iLayer++) {
144       for(Int_t iLadder = 1; iLadder < AliITSgeomTGeo::GetNLadders(iLayer) + 1; iLadder++) {
145         fTitle = "SSD_Occupancy_Layer"; fTitle += iLayer;
146         fTitle += "_Ladder"; fTitle += iLadder;
147         hOccupancyLadder[fSSDhRaws] = new TH1D(fTitle.Data(),fTitle.Data(),AliITSgeomTGeo::GetNDetectors(iLayer),0,AliITSgeomTGeo::GetNDetectors(iLayer));
148         hOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitleColor(1);
149         hOccupancyLadder[fSSDhRaws]->GetXaxis()->SetTitle("Module number");
150         hOccupancyLadder[fSSDhRaws]->GetYaxis()->SetTitle("Occupancy [%]");
151         hOccupancyLadder[fSSDhRaws]->SetMarkerStyle(kFullCircle);
152         fAliITSQADataMakerRec->Add2RawsList(hOccupancyLadder[fSSDhRaws], fRawsOffset + fSSDhRaws);      
153         fSSDhRaws++;
154       }//ladder loop
155     }//layer loop
156   }//online flag
157   AliDebug(1,Form("%d SSD Raws histograms booked\n",fSSDhRaws));
158   AliInfo(Form("Number of histograms (SPD+SDD+SSD): %d\n",fRawsOffset+fSSDhRaws));
159   
160   
161 }
162
163 //____________________________________________________________________________
164 void AliITSQASSDDataMakerRec::MakeRaws(AliRawReader* rawReader) { 
165   // Fill QA for RAW - SSD -
166   Int_t fStripNumber;
167   Int_t fHistPosition;
168   Int_t fLayer = 0,fLadder = 0, fModule = 0;
169
170   rawReader->Select("ITSSSD",-1,-1);  
171   rawReader->Reset();                         
172   AliITSRawStreamSSD fSSDStream(rawReader);    
173   while (fSSDStream.Next()) {
174     if(fSSDStream.GetModuleID() < 0) continue;
175     AliITSgeomTGeo::GetModuleId(fSSDStream.GetModuleID(),fLayer,fLadder,fModule);
176     fStripNumber  = (fSSDStream.GetSideFlag() == 0) ? fSSDStream.GetStrip() : fSSDStream.GetStrip() + 768;
177     fHistPosition = (fLayer == 5) ? ((fLadder - 1)*22 + fModule - 1) : ((fLadder - 1)*25 + fModule + 748 - 1);
178     //AliInfo(Form("ModulePosition: %d - Layer: %d - Ladder: %d - Module: %d\n",fHistPosition,fLayer,fLadder,fModule));
179     fHistSSDRawSignalModule[fHistPosition]->Fill(fStripNumber,fSSDStream.GetSignal());
180   }//streamer loop
181 }
182
183 //____________________________________________________________________________ 
184 Double_t AliITSQASSDDataMakerRec::GetSSDOccupancyRaws(TH1 *lHisto) { 
185   // bo: TDC >0 or # of sigmas wrt noise ?
186   Int_t lNumFiredBins = 0;
187   for(Int_t iBin = 1; iBin < lHisto->GetNbinsX(); iBin++){
188     if (lHisto->GetBinContent(iBin))
189       lNumFiredBins++; 
190   }
191   Double_t lOccupancy = (100.*lNumFiredBins)/lHisto->GetNbinsX(); // percentage
192   //if(lOccupancy > 0) 
193   //AliInfo(Form("Fired strips: %d - Total strips: %d - Occupancy :%lf\n",lNumFiredBins,lHisto->GetNbinsX(),lOccupancy));
194   
195   return lOccupancy;
196 }
197
198
199 //____________________________________________________________________________ 
200 void AliITSQASSDDataMakerRec::InitRecPoints()
201 {
202   // Initialization for RECPOINTS - SSD -
203   fRecsOffset = (fAliITSQADataMakerRec->fRecPointsQAList)->GetEntries();
204
205 // custom code here
206 //fSSDhRecs must be incremented by one unit every time a histogram is ADDED to the QA List
207
208   AliDebug(1,Form("%d SSD Recs histograms booked\n",fSSDhRecs));
209 }
210
211 //____________________________________________________________________________ 
212 void AliITSQASSDDataMakerRec::MakeRecPoints(TTree * /*clustersTree*/)
213 {
214   // Fill QA for recpoints - SSD -
215 }
216
217