]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackerRawDataMaker.cxx
Corrected file name for Doxygen
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerRawDataMaker.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 // $Id$
17
18 #include "AliMUONTrackerRawDataMaker.h"
19
20 #include "AliCodeTimer.h"
21 #include "AliLog.h"
22 #include "AliMUON2DMap.h"
23 #include "AliMUONCalibParamND.h"
24 #include "AliMUONCalibrationData.h"
25 #include "AliMUONDigitCalibrator.h"
26 #include "AliMUONDigitMaker.h"
27 #include "AliMUONDigitStoreV2R.h"
28 #include "AliMUONTrackerData.h"
29 #include "AliMUONVDigit.h"
30 #include "AliMUONVDigitStore.h"
31 #include "AliMpDDLStore.h"
32 #include "AliCDBManager.h"
33 #include "AliCDBStorage.h"
34 #include "AliRawEventHeaderBase.h"
35 #include "AliRawReader.h"
36 #include "AliLog.h"
37 #include <Riostream.h>
38 #include "AliMUONRawStreamTracker.h"
39
40 ///\class AliMUONTrackerRawDataMaker
41 ///
42 /// Creator of raw AliMUONVTrackerData from AliRawReader
43 /// 
44 ///\author Laurent Aphecetche, Subatech
45
46 ///\cond CLASSIMP
47 ClassImp(AliMUONTrackerRawDataMaker)
48 ///\endcond
49
50 Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
51
52 //_____________________________________________________________________________
53 AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, Bool_t histogram)
54 : AliMUONVTrackerDataMaker(),
55   fRawReader(reader),
56   fAccumulatedData(0x0),
57   fOneEventData(new AliMUON2DMap(true)),
58   fIsOwner(kTRUE),
59   fSource("unspecified"),
60   fIsRunning(kFALSE),
61   fNumberOfEvents(0)
62 {
63   /// Ctor
64   reader->NextEvent(); // to be sure to get run number available
65   
66   Int_t runNumber = reader->GetRunNumber();
67   
68   TString name;
69   
70   if (!runNumber)
71   {
72     ++fgkCounter;    
73     name = Form("%sRAW(%d)",(histogram?"H":""),fgkCounter);
74   }
75   else
76   {
77     name = Form("%sRAW%d",(histogram?"H":""),runNumber);
78   }
79   
80   fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
81   fAccumulatedData->SetDimensionName(0,"Raw charge");
82   if ( histogram ) 
83   {
84     fAccumulatedData->MakeHistogramForDimension(0,kTRUE);
85   }
86   
87   reader->RewindEvents();
88 }
89
90 //_____________________________________________________________________________
91 AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
92 {
93   /// dtor
94   delete fOneEventData;
95   if ( fIsOwner ) delete fAccumulatedData;
96 }
97
98 //_____________________________________________________________________________
99 Bool_t 
100 AliMUONTrackerRawDataMaker::NextEvent()
101 {
102   /// Read next event
103  
104   AliCodeTimerAuto("");
105   
106   static Int_t nphysics(0);
107   static Int_t ngood(0);
108
109   fOneEventData->Clear();
110   
111   if ( !IsRunning() ) return kTRUE;
112   
113   Bool_t ok = fRawReader->NextEvent();
114
115   if (!ok) 
116   {
117     return kFALSE;
118   }
119   
120   Int_t eventType = fRawReader->GetType();
121
122   ++fNumberOfEvents;
123   
124   if (eventType != AliRawEventHeaderBase::kPhysicsEvent ) 
125   {
126     return kTRUE; // for the moment
127   }
128
129   ++nphysics;
130
131   AliMUONVRawStreamTracker* stream = new AliMUONRawStreamTracker(fRawReader);
132     
133   stream->First();
134     
135   Int_t buspatchId;
136   UShort_t manuId;
137   UChar_t manuChannel;
138         UShort_t adc;
139   
140   while ( stream->Next(buspatchId,manuId,manuChannel,adc) )
141   {    
142     Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId);
143     
144     AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId));
145     if (!param)
146     {
147       param = new AliMUONCalibParamND(1,64,detElemId,manuId,
148                                       AliMUONVCalibParam::InvalidFloatValue());
149       fOneEventData->Add(param);
150     }
151     
152     param->SetValueAsDouble(manuChannel,0,adc);    
153   }    
154   
155   if ( !stream->IsErrorMessage() )
156   {
157     ++ngood;
158     fAccumulatedData->Add(*fOneEventData);
159   }
160
161   AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
162
163   delete stream;
164   
165   return kTRUE;
166 }
167
168 //_____________________________________________________________________________
169 void
170 AliMUONTrackerRawDataMaker::Print(Option_t*) const
171 {
172   /// Printout
173   
174   cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO")
175   << endl;
176   
177 }
178
179 //_____________________________________________________________________________
180 void 
181 AliMUONTrackerRawDataMaker::Rewind()
182 {
183   /// Rewind events
184   fRawReader->RewindEvents();
185   fNumberOfEvents=0;
186 }