]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/FMD/AliHLTFMDReconstructionComponent.cxx
more consistent use of cuts, new cut number 1008
[u/mrichter/AliRoot.git] / HLT / FMD / AliHLTFMDReconstructionComponent.cxx
1 #include "AliHLTSystem.h"
2 #include "AliRawReaderMemory.h"
3 #include "AliFMDRawReader.h"
4 #include "AliESDFMD.h"
5 #include "AliHLTDataTypes.h"
6 #include "TClonesArray.h"
7 #include "AliHLTFMDReconstructionComponent.h"
8 #include "AliHLTDefinitions.h"
9 #include "AliCDBManager.h"
10 #include "AliFMDParameters.h"
11 #include "AliHLTDataTypes.h"
12 #include "TH1F.h"
13 #include "AliLog.h"
14 #include "AliGeomManager.h"
15 #include "AliFMDGeometry.h"
16 #include <cstdlib>
17 #include <cerrno>
18
19 using namespace std;
20
21 ClassImp(AliHLTFMDReconstructionComponent)
22
23 //_____________________________________________________________________
24
25 AliHLTFMDReconstructionComponent::AliHLTFMDReconstructionComponent()
26   : fRunNumber(0)
27 {
28   
29 }
30
31 //_____________________________________________________________________
32
33 AliHLTFMDReconstructionComponent::~AliHLTFMDReconstructionComponent()
34 {
35    // see header file for class documentation
36 }
37
38 //_____________________________________________________________________
39 AliHLTFMDReconstructionComponent::AliHLTFMDReconstructor::AliHLTFMDReconstructor() 
40   : AliFMDReconstructor()
41 {
42   fDiagnostics = kFALSE;
43   
44 }
45
46 //_____________________________________________________________________
47 void AliHLTFMDReconstructionComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
48 {
49       list.push_back(kAliHLTDataTypeDDLRaw);
50       
51 }
52
53 //______________________________________________________________________
54 AliHLTComponentDataType AliHLTFMDReconstructionComponent::GetOutputDataType()
55 {
56       return kAliHLTDataTypeESDTree;
57 }
58
59 //______________________________________________________________________
60 void AliHLTFMDReconstructionComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
61 {
62   
63   constBase = 2000000;
64   inputMultiplier = 1;
65 }
66
67 //______________________________________________________________________
68
69 AliHLTComponent* AliHLTFMDReconstructionComponent::Spawn()
70 {
71   
72   return new AliHLTFMDReconstructionComponent;
73 }
74
75 //______________________________________________________________________
76 int AliHLTFMDReconstructionComponent::DoInit( int argc, const char** argv )
77 {
78   char* cpErr;
79   Int_t i = 0;
80   while ( i < argc )
81     {
82       if ( !strcmp( argv[i], "run_number" ) ||
83            !strcmp( argv[i], "-run_number" ))
84         {
85           if ( i+1>=argc )
86             {
87               HLTError("Missing run_number parameter");
88               return -EINVAL;
89             }
90           fRunNumber = strtoul( argv[i+1], &cpErr, 0 );
91           if ( *cpErr )
92             {
93               HLTError("Cannot convert run_number parameter '%s'", argv[i+1] );
94               return -EINVAL;
95             }
96           HLTInfo("Run Number set to %lu %%", fRunNumber );
97           i += 2;
98           continue;
99         }
100       HLTError("Unknown option '%s'", argv[i] );
101       return -EINVAL;
102     }
103   
104   AliLog::EnableDebug(kFALSE);
105
106   if (GetRunNo() == kAliHLTVoidRunNo) {
107     AliCDBManager* cdb = AliCDBManager::Instance();
108     cdb->SetRun(fRunNumber);
109   }
110   AliFMDParameters::Instance()->Init();
111   
112   if (AliGeomManager::GetGeometry() == NULL)
113     AliGeomManager::LoadGeometry();
114   
115   AliFMDGeometry* geo = AliFMDGeometry::Instance();
116   geo->Init();
117   geo->InitTransformations();
118   
119   return 0;
120 }
121
122 //______________________________________________________________________
123 int AliHLTFMDReconstructionComponent::DoDeinit()
124 {
125   
126   
127   return 0;
128 }
129
130 //______________________________________________________________________
131 int AliHLTFMDReconstructionComponent::DoEvent( const AliHLTComponentEventData& evtData, 
132                                                const AliHLTComponentBlockData* blocks, 
133                                                AliHLTComponentTriggerData& /*trigData*/, 
134                                                AliHLTUInt8_t* /*outputPtr*/, 
135                                                AliHLTUInt32_t& size, 
136                                                vector<AliHLTComponentBlockData>& /*outputBlocks*/ )
137 {
138   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
139     size=0;
140     return 0;
141   }
142   // -- Iterator over Data Blocks --
143   const AliHLTComponentBlockData* iter = NULL;
144   
145   AliESDEvent  esd;
146   esd.CreateStdContent();
147     
148   // Process an event
149   //unsigned long totalSize = 0;
150   // Loop over all input blocks in the event
151   
152   AliHLTFMDReconstructor rec;
153   rec.Init();
154   for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ ) {   
155       
156     iter = blocks + n;
157     
158     // -- Check for the correct data type
159     if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginFMD) )
160       continue;
161     
162     AliRawReaderMemory* reader = new AliRawReaderMemory();
163     
164     reader->SetMemory((UChar_t*) iter->fPtr, iter->fSize );
165     
166     AliHLTUInt32_t spec = iter->fSpecification;
167     
168     Int_t id = 3072;
169     for ( Int_t ii = 0; ii < 24 ; ii++ ) {
170       if ( spec & 0x00000001 ) {
171         id += ii;
172         break;
173       }
174       spec = spec >> 1 ;
175     }
176     
177     reader->SetEquipmentID( id );
178     
179     AliFMDRawReader* fmdReader  = new AliFMDRawReader(reader,0);
180     TClonesArray*    digitArray = new TClonesArray("AliFMDDigit",0);
181     
182     digitArray->Clear();
183     fmdReader->ReadAdcs(digitArray);
184     rec.ReconstructDigits(digitArray);
185     
186     delete reader;
187     delete fmdReader;
188     delete digitArray;
189     
190     reader = NULL;
191     fmdReader = NULL;
192     digitArray = NULL;
193   }
194   
195   Int_t iResult = 0;
196   
197   esd.SetFMDData(rec.GetFMDData());
198   
199   iResult=PushBack(&esd, kAliHLTDataTypeESDObject|kAliHLTDataOriginFMD, 0);
200   
201   return iResult;
202 }
203