1 /**************************************************************************
2 * Copyright(c) 2004, 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 **************************************************************************/
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.
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.
28 #include "AliFMDBaseDA.h"
31 #include "AliFMDRawReader.h"
32 #include "AliFMDCalibSampleRate.h"
34 //_____________________________________________________________________
35 ClassImp(AliFMDBaseDA)
37 //_____________________________________________________________________
38 AliFMDBaseDA::AliFMDBaseDA() : TNamed(),
39 fDiagnosticsFilename("diagnosticsHistograms.root"),
42 fSaveHistograms(kFALSE),
47 fDetectorArray.SetOwner();
48 fConditionsFile.open("conditions.csv");
50 //_____________________________________________________________________
51 AliFMDBaseDA::AliFMDBaseDA(const AliFMDBaseDA & baseDA) :
53 fDiagnosticsFilename(baseDA.fDiagnosticsFilename),
56 fSaveHistograms(baseDA.fSaveHistograms),
57 fDetectorArray(baseDA.fDetectorArray),
58 fRequiredEvents(baseDA.fRequiredEvents),
59 fCurrentEvent(baseDA.fCurrentEvent)
61 fDetectorArray.SetOwner();
66 //_____________________________________________________________________
67 AliFMDBaseDA::~AliFMDBaseDA() {
73 //_____________________________________________________________________
74 void AliFMDBaseDA::Run(AliRawReader* reader) {
85 diagFile = TFile::Open(fDiagnosticsFilename,"RECREATE");
86 for(UShort_t det=1;det<=3;det++) {
87 UShort_t FirstRing = (det == 1 ? 1 : 0);
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);
94 gDirectory->cd(Form("%s:/",fDiagnosticsFilename));
95 gDirectory->mkdir(Form("FMD%d%c",det,ring),Form("FMD%d%c",det,ring));
96 for(UShort_t sec =0; sec < nsec; sec++) {
97 gDirectory->cd(Form("%s:/FMD%d%c",fDiagnosticsFilename,det,ring));
98 gDirectory->mkdir(Form("sector_%d",sec));
99 for(UShort_t strip = 0; strip < nstr; strip++) {
100 gDirectory->cd(Form("%s:/FMD%d%c/sector_%d",fDiagnosticsFilename,det,ring,sec));
101 gDirectory->mkdir(Form("strip_%d",strip));
114 AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0);
115 TClonesArray* digitArray = new TClonesArray("AliFMDDigit",0);
117 WriteConditionsData();
121 int lastProgress = 0;
123 for(Int_t n =1;n <= GetRequiredEvents(); n++)
125 if(!reader->NextEvent())
128 SetCurrentEvent(*(reader->GetEventId()));
131 fmdReader->ReadAdcs(digitArray);
134 //std::cout<<"In event # "<< *(reader->GetEventId()) << " with " <<digitArray->GetEntries()<<" digits \r"<<std::flush;
137 for(Int_t i = 0; i<digitArray->GetEntriesFast();i++) {
138 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitArray->At(i));
143 int progress = int((n *100)/ GetRequiredEvents()) ;
144 if (progress <= lastProgress) continue;
145 lastProgress = progress;
146 std::cout << "Progress: " << lastProgress << " / 100 " << std::endl;
151 AliInfo(Form("Looped over %d events",GetCurrentEvent()));
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);
169 if(fOutputFile.is_open()) {
171 fOutputFile.write("# EOF\n",6);
176 if(fSaveHistograms ) {
177 AliInfo("Closing diagnostics file...please wait");
181 //_____________________________________________________________________
183 void AliFMDBaseDA::InitContainer(){
186 TObjArray* ringArray;
187 TObjArray* sectorArray;
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);
213 //_____________________________________________________________________
214 void AliFMDBaseDA::WriteConditionsData() {
216 AliFMDParameters* pars = AliFMDParameters::Instance();
217 fConditionsFile.write(Form("# %s \n",pars->GetConditionsShuttleID()),14);
218 fConditionsFile.write("# Sample Rate, timebins \n",25);
220 UInt_t defSampleRate = 4;
221 UInt_t timebins = 544;
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);
237 pars->SetSampleRate(sampleRate);
240 fConditionsFile << defSampleRate << ','
243 if(fConditionsFile.is_open()) {
245 // fConditionsFile.write("# EOF\n",6);
246 fConditionsFile.close();
252 //_____________________________________________________________________