]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDBaseDA.cxx
Removed a std::cout statement
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.cxx
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"
32 #include "AliLog.h"
33 //_____________________________________________________________________
34 ClassImp(AliFMDBaseDA)
35
36 //_____________________________________________________________________
37 AliFMDBaseDA::AliFMDBaseDA() : TNamed(),
38   fDiagnosticsFilename("diagnosticsHistograms.root"),
39   fOutputFile(),
40   fSaveHistograms(kFALSE),
41   fDetectorArray(),
42   fRequiredEvents(0),
43   fCurrentEvent(0)
44 {
45   fDetectorArray.SetOwner();
46   
47 }
48 //_____________________________________________________________________
49 AliFMDBaseDA::AliFMDBaseDA(const AliFMDBaseDA & baseDA) : 
50   TNamed(baseDA),
51   fDiagnosticsFilename(baseDA.fDiagnosticsFilename),
52   fOutputFile(),
53   fSaveHistograms(baseDA.fSaveHistograms),
54   fDetectorArray(baseDA.fDetectorArray),
55   fRequiredEvents(baseDA.fRequiredEvents),
56   fCurrentEvent(baseDA.fCurrentEvent)
57 {
58   fDetectorArray.SetOwner();
59   
60 }
61
62 //_____________________________________________________________________
63 AliFMDBaseDA::~AliFMDBaseDA() {
64
65   //destructor
66   
67 }
68
69 //_____________________________________________________________________
70 void AliFMDBaseDA::Run(AliRawReader* reader) {
71   
72   
73   
74   InitContainer();
75
76   Init();
77
78   TFile* diagFile = 0;
79   if(fSaveHistograms)
80     {
81       diagFile = TFile::Open(fDiagnosticsFilename,"RECREATE");
82       for(UShort_t det=1;det<=3;det++) {
83         UShort_t FirstRing = (det == 1 ? 1 : 0);
84         
85         for (UShort_t ir = FirstRing; ir < 2; ir++) {
86           Char_t   ring = (ir == 0 ? 'O' : 'I');
87           UShort_t nsec = (ir == 0 ? 40  : 20);
88           UShort_t nstr = (ir == 0 ? 256 : 512);
89           
90           gDirectory->cd(Form("%s:/",fDiagnosticsFilename));
91           gDirectory->mkdir(Form("FMD%d%c",det,ring),Form("FMD%d%c",det,ring));
92           for(UShort_t sec =0; sec < nsec;  sec++)  {
93             gDirectory->cd(Form("%s:/FMD%d%c",fDiagnosticsFilename,det,ring));
94             gDirectory->mkdir(Form("sector_%d",sec));
95             for(UShort_t strip = 0; strip < nstr; strip++) {
96               gDirectory->cd(Form("%s:/FMD%d%c/sector_%d",fDiagnosticsFilename,det,ring,sec));
97               gDirectory->mkdir(Form("strip_%d",strip));
98               
99              }
100           }
101         }
102       }
103       
104     }
105     
106   reader->Reset();
107   AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0);
108   TClonesArray* digitArray   = new TClonesArray("AliFMDDigit",0);
109   
110   reader->NextEvent();
111   reader->NextEvent();
112   
113   
114   for(Int_t n =1;n <= GetRequiredEvents(); n++)
115     {
116       if(!reader->NextEvent()) 
117         continue;
118       
119       SetCurrentEvent(*(reader->GetEventId()));
120       
121       digitArray->Clear();
122       fmdReader->ReadAdcs(digitArray);
123       
124       // std::cout<<"In event # "<< *(reader->GetEventId()) << "\r"<<std::flush;
125             
126       for(Int_t i = 0; i<digitArray->GetEntries();i++) {
127         AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitArray->At(i));
128         FillChannels(digit);
129       }
130       
131       FinishEvent();
132       
133     }
134   AliInfo(Form("Looped over %d events",GetCurrentEvent()));
135   WriteHeaderToFile();
136   
137   for(UShort_t det=1;det<=3;det++) {
138     UShort_t FirstRing = (det == 1 ? 1 : 0);
139     for (UShort_t ir = FirstRing; ir < 2; ir++) {
140       Char_t   ring = (ir == 0 ? 'O' : 'I');
141       UShort_t nsec = (ir == 0 ? 40  : 20);
142       UShort_t nstr = (ir == 0 ? 256 : 512);
143       for(UShort_t sec =0; sec < nsec;  sec++)  {
144         for(UShort_t strip = 0; strip < nstr; strip++) {
145           Analyse(det,ring,sec,strip);
146           
147         }
148       }
149     }
150   }
151   if(fOutputFile.is_open()) {
152    
153     fOutputFile.write("# EOF\n",6);
154     fOutputFile.close();
155     
156   }
157   
158   if(fSaveHistograms ) {
159     AliInfo("Closing diagnostics file...please wait");
160        
161     delete diagFile;
162   }
163 }
164 //_____________________________________________________________________
165
166 void AliFMDBaseDA::InitContainer(){
167
168   TObjArray* detArray;
169   TObjArray* ringArray;
170   TObjArray* sectorArray;
171     
172   for(UShort_t det=1;det<=3;det++) {
173     detArray = new TObjArray();
174     detArray->SetOwner();
175     fDetectorArray.AddAtAndExpand(detArray,det);
176     UShort_t FirstRing = (det == 1 ? 1 : 0);
177     for (UShort_t ir = FirstRing; ir < 2; ir++) {
178       Char_t   ring = (ir == 0 ? 'O' : 'I');
179       UShort_t nsec = (ir == 0 ? 40  : 20);
180       UShort_t nstr = (ir == 0 ? 256 : 512);
181       ringArray = new TObjArray();
182       ringArray->SetOwner();
183       detArray->AddAtAndExpand(ringArray,ir);
184       for(UShort_t sec =0; sec < nsec;  sec++)  {
185         sectorArray = new TObjArray();
186         sectorArray->SetOwner();
187         ringArray->AddAtAndExpand(sectorArray,sec);
188         for(UShort_t strip = 0; strip < nstr; strip++) {
189           AddChannelContainer(sectorArray, det, ring, sec, strip);
190         }
191       }
192     }
193   }
194 }
195 //_____________________________________________________________________ 
196 //
197 // EOF
198 //