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"
33 //_____________________________________________________________________
34 ClassImp(AliFMDBaseDA)
36 //_____________________________________________________________________
37 AliFMDBaseDA::AliFMDBaseDA() : TNamed(),
38 fDiagnosticsFilename("diagnosticsHistograms.root"),
41 fSaveHistograms(kFALSE),
46 fDetectorArray.SetOwner();
47 fConditionsFile.open("conditions.csv");
49 //_____________________________________________________________________
50 AliFMDBaseDA::AliFMDBaseDA(const AliFMDBaseDA & baseDA) :
52 fDiagnosticsFilename(baseDA.fDiagnosticsFilename),
55 fSaveHistograms(baseDA.fSaveHistograms),
56 fDetectorArray(baseDA.fDetectorArray),
57 fRequiredEvents(baseDA.fRequiredEvents),
58 fCurrentEvent(baseDA.fCurrentEvent)
60 fDetectorArray.SetOwner();
65 //_____________________________________________________________________
66 AliFMDBaseDA::~AliFMDBaseDA() {
72 //_____________________________________________________________________
73 void AliFMDBaseDA::Run(AliRawReader* reader) {
84 diagFile = TFile::Open(fDiagnosticsFilename,"RECREATE");
85 for(UShort_t det=1;det<=3;det++) {
86 UShort_t FirstRing = (det == 1 ? 1 : 0);
88 for (UShort_t ir = FirstRing; ir < 2; ir++) {
89 Char_t ring = (ir == 0 ? 'O' : 'I');
90 UShort_t nsec = (ir == 0 ? 40 : 20);
91 UShort_t nstr = (ir == 0 ? 256 : 512);
93 gDirectory->cd(Form("%s:/",fDiagnosticsFilename));
94 gDirectory->mkdir(Form("FMD%d%c",det,ring),Form("FMD%d%c",det,ring));
95 for(UShort_t sec =0; sec < nsec; sec++) {
96 gDirectory->cd(Form("%s:/FMD%d%c",fDiagnosticsFilename,det,ring));
97 gDirectory->mkdir(Form("sector_%d",sec));
98 for(UShort_t strip = 0; strip < nstr; strip++) {
99 gDirectory->cd(Form("%s:/FMD%d%c/sector_%d",fDiagnosticsFilename,det,ring,sec));
100 gDirectory->mkdir(Form("strip_%d",strip));
113 AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0);
114 TClonesArray* digitArray = new TClonesArray("AliFMDDigit",0);
116 WriteConditionsData();
122 for(Int_t n =1;n <= GetRequiredEvents(); n++)
124 if(!reader->NextEvent())
127 SetCurrentEvent(*(reader->GetEventId()));
130 fmdReader->ReadAdcs(digitArray);
133 //std::cout<<"In event # "<< *(reader->GetEventId()) << " with " <<digitArray->GetEntries()<<" digits \r"<<std::flush;
136 for(Int_t i = 0; i<digitArray->GetEntries();i++) {
137 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitArray->At(i));
144 AliInfo(Form("Looped over %d events",GetCurrentEvent()));
147 for(UShort_t det=1;det<=3;det++) {
148 UShort_t FirstRing = (det == 1 ? 1 : 0);
149 for (UShort_t ir = FirstRing; ir < 2; ir++) {
150 Char_t ring = (ir == 0 ? 'O' : 'I');
151 UShort_t nsec = (ir == 0 ? 40 : 20);
152 UShort_t nstr = (ir == 0 ? 256 : 512);
153 for(UShort_t sec =0; sec < nsec; sec++) {
154 for(UShort_t strip = 0; strip < nstr; strip++) {
155 Analyse(det,ring,sec,strip);
162 if(fOutputFile.is_open()) {
164 fOutputFile.write("# EOF\n",6);
169 if(fSaveHistograms ) {
170 AliInfo("Closing diagnostics file...please wait");
174 //_____________________________________________________________________
176 void AliFMDBaseDA::InitContainer(){
179 TObjArray* ringArray;
180 TObjArray* sectorArray;
182 for(UShort_t det=1;det<=3;det++) {
183 detArray = new TObjArray();
184 detArray->SetOwner();
185 fDetectorArray.AddAtAndExpand(detArray,det);
186 UShort_t FirstRing = (det == 1 ? 1 : 0);
187 for (UShort_t ir = FirstRing; ir < 2; ir++) {
188 Char_t ring = (ir == 0 ? 'O' : 'I');
189 UShort_t nsec = (ir == 0 ? 40 : 20);
190 UShort_t nstr = (ir == 0 ? 256 : 512);
191 ringArray = new TObjArray();
192 ringArray->SetOwner();
193 detArray->AddAtAndExpand(ringArray,ir);
194 for(UShort_t sec =0; sec < nsec; sec++) {
195 sectorArray = new TObjArray();
196 sectorArray->SetOwner();
197 ringArray->AddAtAndExpand(sectorArray,sec);
198 for(UShort_t strip = 0; strip < nstr; strip++) {
199 AddChannelContainer(sectorArray, det, ring, sec, strip);
206 //_____________________________________________________________________
207 void AliFMDBaseDA::WriteConditionsData() {
209 AliFMDParameters* pars = AliFMDParameters::Instance();
210 fConditionsFile.write(Form("# %s \n",pars->GetConditionsShuttleID()),14);
211 fConditionsFile.write("# Sample Rate, timebins \n",25);
213 UInt_t sampleRate = 4;
214 UInt_t timebins = 544;
215 fConditionsFile << sampleRate << ','
217 //if(fConditionsFile.is_open()) {
219 // fConditionsFile.write("# EOF\n",6);
220 // fConditionsFile.close();
226 //_____________________________________________________________________