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();
64 //_____________________________________________________________________
65 AliFMDBaseDA::~AliFMDBaseDA() {
71 //_____________________________________________________________________
72 void AliFMDBaseDA::Run(AliRawReader* reader) {
83 diagFile = TFile::Open(fDiagnosticsFilename,"RECREATE");
84 for(UShort_t det=1;det<=3;det++) {
85 UShort_t FirstRing = (det == 1 ? 1 : 0);
87 for (UShort_t ir = FirstRing; ir < 2; ir++) {
88 Char_t ring = (ir == 0 ? 'O' : 'I');
89 UShort_t nsec = (ir == 0 ? 40 : 20);
90 UShort_t nstr = (ir == 0 ? 256 : 512);
92 gDirectory->cd(Form("%s:/",fDiagnosticsFilename));
93 gDirectory->mkdir(Form("FMD%d%c",det,ring),Form("FMD%d%c",det,ring));
94 for(UShort_t sec =0; sec < nsec; sec++) {
95 gDirectory->cd(Form("%s:/FMD%d%c",fDiagnosticsFilename,det,ring));
96 gDirectory->mkdir(Form("sector_%d",sec));
97 for(UShort_t strip = 0; strip < nstr; strip++) {
98 gDirectory->cd(Form("%s:/FMD%d%c/sector_%d",fDiagnosticsFilename,det,ring,sec));
99 gDirectory->mkdir(Form("strip_%d",strip));
112 AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0);
113 TClonesArray* digitArray = new TClonesArray("AliFMDDigit",0);
115 WriteConditionsData();
121 for(Int_t n =1;n <= GetRequiredEvents(); n++)
123 if(!reader->NextEvent())
126 SetCurrentEvent(*(reader->GetEventId()));
129 fmdReader->ReadAdcs(digitArray);
132 //std::cout<<"In event # "<< *(reader->GetEventId()) << " with " <<digitArray->GetEntries()<<" digits \r"<<std::flush;
135 for(Int_t i = 0; i<digitArray->GetEntries();i++) {
136 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitArray->At(i));
143 AliInfo(Form("Looped over %d events",GetCurrentEvent()));
146 for(UShort_t det=1;det<=3;det++) {
147 UShort_t FirstRing = (det == 1 ? 1 : 0);
148 for (UShort_t ir = FirstRing; ir < 2; ir++) {
149 Char_t ring = (ir == 0 ? 'O' : 'I');
150 UShort_t nsec = (ir == 0 ? 40 : 20);
151 UShort_t nstr = (ir == 0 ? 256 : 512);
152 for(UShort_t sec =0; sec < nsec; sec++) {
153 for(UShort_t strip = 0; strip < nstr; strip++) {
154 Analyse(det,ring,sec,strip);
161 if(fOutputFile.is_open()) {
163 fOutputFile.write("# EOF\n",6);
168 if(fSaveHistograms ) {
169 AliInfo("Closing diagnostics file...please wait");
173 //_____________________________________________________________________
175 void AliFMDBaseDA::InitContainer(){
178 TObjArray* ringArray;
179 TObjArray* sectorArray;
181 for(UShort_t det=1;det<=3;det++) {
182 detArray = new TObjArray();
183 detArray->SetOwner();
184 fDetectorArray.AddAtAndExpand(detArray,det);
185 UShort_t FirstRing = (det == 1 ? 1 : 0);
186 for (UShort_t ir = FirstRing; ir < 2; ir++) {
187 Char_t ring = (ir == 0 ? 'O' : 'I');
188 UShort_t nsec = (ir == 0 ? 40 : 20);
189 UShort_t nstr = (ir == 0 ? 256 : 512);
190 ringArray = new TObjArray();
191 ringArray->SetOwner();
192 detArray->AddAtAndExpand(ringArray,ir);
193 for(UShort_t sec =0; sec < nsec; sec++) {
194 sectorArray = new TObjArray();
195 sectorArray->SetOwner();
196 ringArray->AddAtAndExpand(sectorArray,sec);
197 for(UShort_t strip = 0; strip < nstr; strip++) {
198 AddChannelContainer(sectorArray, det, ring, sec, strip);
205 //_____________________________________________________________________
206 void AliFMDBaseDA::WriteConditionsData() {
208 AliFMDParameters* pars = AliFMDParameters::Instance();
209 fConditionsFile.write(Form("# %s \n",pars->GetConditionsShuttleID()),14);
210 fConditionsFile.write("# Sample Rate, timebins \n",25);
212 UInt_t sampleRate = 4;
213 UInt_t timebins = 544;
214 fConditionsFile << sampleRate << ','
216 //if(fConditionsFile.is_open()) {
218 // fConditionsFile.write("# EOF\n",6);
219 // fConditionsFile.close();
225 //_____________________________________________________________________