]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDBaseDA.cxx
removing old documentation
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.cxx
CommitLineData
a0180e76 1/**************************************************************************
2 * Copyright(c) 2004, 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/** @file AliFMDBaseDA.cxx
17 @author Hans Hjersing Dalsgaard <canute@nbi.dk>
18 @date Wed Mar 26 11:30:45 2008
19 @brief Base class for detector algorithms.
20*/
21//
22//This is the implementation of the (virtual) base class for the FMD detector
23//algorithms(DA). It implements the creation of the relevant containers and handles the
24//loop over the raw data. The derived classes can control the parameters and action
25//to be taken making this the base class for the Pedestal, Gain and Physics DA.
26//
27
28#include "AliFMDBaseDA.h"
29#include "iostream"
30
31#include "AliFMDRawReader.h"
1656783c 32#include "AliFMDCalibSampleRate.h"
a0180e76 33#include "AliLog.h"
34//_____________________________________________________________________
35ClassImp(AliFMDBaseDA)
36
37//_____________________________________________________________________
38AliFMDBaseDA::AliFMDBaseDA() : TNamed(),
39 fDiagnosticsFilename("diagnosticsHistograms.root"),
40 fOutputFile(),
ce5a8b1a 41 fConditionsFile(),
a0180e76 42 fSaveHistograms(kFALSE),
43 fDetectorArray(),
44 fRequiredEvents(0),
45 fCurrentEvent(0)
46{
47 fDetectorArray.SetOwner();
ce5a8b1a 48 fConditionsFile.open("conditions.csv");
a0180e76 49}
50//_____________________________________________________________________
51AliFMDBaseDA::AliFMDBaseDA(const AliFMDBaseDA & baseDA) :
52 TNamed(baseDA),
a7e41e8d 53 fDiagnosticsFilename(baseDA.fDiagnosticsFilename.Data()),
a0180e76 54 fOutputFile(),
ce5a8b1a 55 fConditionsFile(),
a0180e76 56 fSaveHistograms(baseDA.fSaveHistograms),
57 fDetectorArray(baseDA.fDetectorArray),
58 fRequiredEvents(baseDA.fRequiredEvents),
59 fCurrentEvent(baseDA.fCurrentEvent)
60{
61 fDetectorArray.SetOwner();
62
63}
64
82d71828 65
a0180e76 66//_____________________________________________________________________
67AliFMDBaseDA::~AliFMDBaseDA() {
68
69 //destructor
70
71}
72
73//_____________________________________________________________________
74void AliFMDBaseDA::Run(AliRawReader* reader) {
75
76
77
78 InitContainer();
79
80 Init();
81
82 TFile* diagFile = 0;
83 if(fSaveHistograms)
84 {
a7e41e8d 85 diagFile = TFile::Open(fDiagnosticsFilename.Data(),"RECREATE");
a0180e76 86 for(UShort_t det=1;det<=3;det++) {
87 UShort_t FirstRing = (det == 1 ? 1 : 0);
88
89 for (UShort_t ir = FirstRing; ir < 2; ir++) {
90 Char_t ring = (ir == 0 ? 'O' : 'I');
91 UShort_t nsec = (ir == 0 ? 40 : 20);
92 UShort_t nstr = (ir == 0 ? 256 : 512);
93
a7e41e8d 94 gDirectory->cd(Form("%s:/",fDiagnosticsFilename.Data()));
a0180e76 95 gDirectory->mkdir(Form("FMD%d%c",det,ring),Form("FMD%d%c",det,ring));
96 for(UShort_t sec =0; sec < nsec; sec++) {
a7e41e8d 97 gDirectory->cd(Form("%s:/FMD%d%c",fDiagnosticsFilename.Data(),det,ring));
a0180e76 98 gDirectory->mkdir(Form("sector_%d",sec));
99 for(UShort_t strip = 0; strip < nstr; strip++) {
a7e41e8d 100 gDirectory->cd(Form("%s:/FMD%d%c/sector_%d",fDiagnosticsFilename.Data(),det,ring,sec));
a0180e76 101 gDirectory->mkdir(Form("strip_%d",strip));
102
103 }
104 }
105 }
106 }
107
108 }
109
110 reader->Reset();
ce5a8b1a 111
112
113
a0180e76 114 AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0);
115 TClonesArray* digitArray = new TClonesArray("AliFMDDigit",0);
116
ce5a8b1a 117 WriteConditionsData();
118
a0180e76 119 reader->NextEvent();
120 reader->NextEvent();
1656783c 121 int lastProgress = 0;
a0180e76 122
123 for(Int_t n =1;n <= GetRequiredEvents(); n++)
124 {
125 if(!reader->NextEvent())
126 continue;
127
128 SetCurrentEvent(*(reader->GetEventId()));
129
130 digitArray->Clear();
131 fmdReader->ReadAdcs(digitArray);
132
ce5a8b1a 133
134 //std::cout<<"In event # "<< *(reader->GetEventId()) << " with " <<digitArray->GetEntries()<<" digits \r"<<std::flush;
135
136
6c510686 137 for(Int_t i = 0; i<digitArray->GetEntriesFast();i++) {
a0180e76 138 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitArray->At(i));
139 FillChannels(digit);
140 }
141
142 FinishEvent();
1656783c 143 int progress = int((n *100)/ GetRequiredEvents()) ;
144 if (progress <= lastProgress) continue;
145 lastProgress = progress;
146 std::cout << "Progress: " << lastProgress << " / 100 " << std::endl;
147
148
a0180e76 149
150 }
151 AliInfo(Form("Looped over %d events",GetCurrentEvent()));
152 WriteHeaderToFile();
153
154 for(UShort_t det=1;det<=3;det++) {
155 UShort_t FirstRing = (det == 1 ? 1 : 0);
156 for (UShort_t ir = FirstRing; ir < 2; ir++) {
157 Char_t ring = (ir == 0 ? 'O' : 'I');
158 UShort_t nsec = (ir == 0 ? 40 : 20);
159 UShort_t nstr = (ir == 0 ? 256 : 512);
160 for(UShort_t sec =0; sec < nsec; sec++) {
161 for(UShort_t strip = 0; strip < nstr; strip++) {
162 Analyse(det,ring,sec,strip);
163
164 }
165 }
166 }
167 }
ce5a8b1a 168
a0180e76 169 if(fOutputFile.is_open()) {
ce5a8b1a 170
a0180e76 171 fOutputFile.write("# EOF\n",6);
172 fOutputFile.close();
173
174 }
175
176 if(fSaveHistograms ) {
177 AliInfo("Closing diagnostics file...please wait");
ce5a8b1a 178 diagFile->Close();
a0180e76 179 }
180}
181//_____________________________________________________________________
182
183void AliFMDBaseDA::InitContainer(){
184
185 TObjArray* detArray;
186 TObjArray* ringArray;
187 TObjArray* sectorArray;
188
189 for(UShort_t det=1;det<=3;det++) {
190 detArray = new TObjArray();
191 detArray->SetOwner();
192 fDetectorArray.AddAtAndExpand(detArray,det);
193 UShort_t FirstRing = (det == 1 ? 1 : 0);
194 for (UShort_t ir = FirstRing; ir < 2; ir++) {
195 Char_t ring = (ir == 0 ? 'O' : 'I');
196 UShort_t nsec = (ir == 0 ? 40 : 20);
197 UShort_t nstr = (ir == 0 ? 256 : 512);
198 ringArray = new TObjArray();
199 ringArray->SetOwner();
200 detArray->AddAtAndExpand(ringArray,ir);
201 for(UShort_t sec =0; sec < nsec; sec++) {
202 sectorArray = new TObjArray();
203 sectorArray->SetOwner();
204 ringArray->AddAtAndExpand(sectorArray,sec);
205 for(UShort_t strip = 0; strip < nstr; strip++) {
206 AddChannelContainer(sectorArray, det, ring, sec, strip);
207 }
208 }
209 }
210 }
211}
ce5a8b1a 212
213//_____________________________________________________________________
214void AliFMDBaseDA::WriteConditionsData() {
215
216 AliFMDParameters* pars = AliFMDParameters::Instance();
217 fConditionsFile.write(Form("# %s \n",pars->GetConditionsShuttleID()),14);
218 fConditionsFile.write("# Sample Rate, timebins \n",25);
219
1656783c 220 UInt_t defSampleRate = 4;
ce5a8b1a 221 UInt_t timebins = 544;
1656783c 222 AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate();
223 for(UShort_t det=1;det<=3;det++) {
224 UShort_t FirstRing = (det == 1 ? 1 : 0);
225 for (UShort_t ir = FirstRing; ir < 2; ir++) {
226 Char_t ring = (ir == 0 ? 'O' : 'I');
227 UShort_t nsec = (ir == 0 ? 40 : 20);
228 UShort_t nstr = (ir == 0 ? 256 : 512);
229 for(UShort_t sec =0; sec < nsec; sec++) {
230 for(UShort_t strip = 0; strip < nstr; strip++) {
231 sampleRate->Set(det,ring,sec,strip,defSampleRate);
232 }
233 }
234 }
235 }
236
237 pars->SetSampleRate(sampleRate);
238
239
240 fConditionsFile << defSampleRate << ','
ce5a8b1a 241 << timebins <<"\n";
1656783c 242
243 if(fConditionsFile.is_open()) {
ce5a8b1a 244
1656783c 245 // fConditionsFile.write("# EOF\n",6);
246 fConditionsFile.close();
247
248 }
ce5a8b1a 249
250}
251
a0180e76 252//_____________________________________________________________________
253//
254// EOF
255//