]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCCalibTimeGainComponent.cxx
609b86e330109f03d1df667c22e293a2c264abb1
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCalibTimeGainComponent.cxx
1 // $Id$
2 /**************************************************************************
3  * This file is property of and copyright by the ALICE HLT Project        * 
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  *                                                                        *
6  * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
7  *                  for The ALICE HLT Project.                            *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 /** @file   AliHLTTPCCalibTimeGainComponent.cxx
19     @author Kalliopi Kanaki
20     @date   2009-07-08
21     @brief  A calibration component for the TPC gain variation vs. time. 
22 */
23
24 // see header file for class documentation
25 // or
26 // refer to README to build package
27 // or
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
29
30 #if __GNUC__>= 3
31 using namespace std;
32 #endif
33
34 #include "AliHLTTPCCalibTimeGainComponent.h"
35
36 #include "AliHLTTPCDefinitions.h"
37 #include "AliTPCcalibTimeGain.h"
38 #include "AliESDEvent.h"
39 #include <cstdlib>
40 #include <cerrno>
41 #include "TString.h"
42 #include "TObjArray.h"
43
44 ClassImp(AliHLTTPCCalibTimeGainComponent) // ROOT macro for the implementation of ROOT specific class methods
45
46 AliHLTTPCCalibTimeGainComponent::AliHLTTPCCalibTimeGainComponent()
47   :
48   fCalibTimeGain(NULL),
49   fESDEvent(NULL),
50   fSeedArray(NULL),
51   fMinPartition(5),
52   fMaxPartition(0),
53   fMinSlice(35),
54   fMaxSlice(0),
55   fSpecification(0) ,
56   fEnableAnalysis(kTRUE)
57 {
58   // see header file for class documentation
59   // or
60   // refer to README to build package
61   // or
62   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 }
64
65 AliHLTTPCCalibTimeGainComponent::~AliHLTTPCCalibTimeGainComponent() {
66 // see header file for class documentation
67 }
68
69 const char* AliHLTTPCCalibTimeGainComponent::GetComponentID() {
70 // see header file for class documentation
71
72   return "TPCCalibTimeGain";
73 }
74
75 void AliHLTTPCCalibTimeGainComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
76 // see header file for class documentation
77
78   list.clear();   
79   list.push_back( kAliHLTDataTypeTObjArray ); // output of TPCCalibSeedMaker
80   list.push_back( kAliHLTDataTypeESDObject ); // output of TPCEsdConverter 
81 }
82
83 AliHLTComponentDataType AliHLTTPCCalibTimeGainComponent::GetOutputDataType() {
84 // see header file for class documentation
85
86   return AliHLTTPCDefinitions::fgkCalibCEDataType;
87 }
88
89 void AliHLTTPCCalibTimeGainComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
90 // see header file for class documentation
91
92   constBase = 0;
93   inputMultiplier = (2.0); // to be estimated
94 }
95
96 AliHLTComponent* AliHLTTPCCalibTimeGainComponent::Spawn() {
97 // see header file for class documentation
98
99   return new AliHLTTPCCalibTimeGainComponent();
100 }  
101
102
103 Int_t AliHLTTPCCalibTimeGainComponent::ScanArgument( Int_t argc, const char** argv ) {
104 // see header file for class documentation
105
106   Int_t iResult = 0;
107   TString argument = "";
108   TString parameter = "";
109
110   if(!argc) return -EINVAL;
111
112   argument = argv[iResult];
113   
114   if(argument.IsNull()) return -EINVAL;
115
116   if( argument.CompareTo("-enable-analysis") == 0 ){
117     HLTInfo( "Analysis before shipping data to FXS enabled." );
118     fEnableAnalysis = kTRUE;
119   }
120   else {
121     iResult = -EINVAL;
122   }
123       
124   return iResult;
125 }
126
127 Int_t AliHLTTPCCalibTimeGainComponent::InitCalibration() {
128 // see header file for class documentation
129     
130   if(fCalibTimeGain) return EINPROGRESS;
131   fCalibTimeGain = new AliTPCcalibTimeGain();
132   //AliTPCcalibTimeGain::AliTPCcalibTimeGain(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeGain)
133   return 0;
134 }
135
136 Int_t AliHLTTPCCalibTimeGainComponent::DeinitCalibration() {
137 // see header file for class documentation
138
139   if(fCalibTimeGain) delete fCalibTimeGain;
140   fCalibTimeGain = NULL;
141
142   return 0;
143 }
144
145 Int_t AliHLTTPCCalibTimeGainComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,  AliHLTComponentTriggerData& /*trigData*/ ){
146 // see header file for class documentation
147   
148   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
149
150   TObject *iterESD, *iterSEED = NULL;
151
152   //----------- loop over output of TPCEsdConverter ----------------//
153   
154   for(iterESD = (TObject*)GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC); iterESD != NULL; iterESD = (TObject*)GetNextInputObject()){   
155        
156       if(GetDataType(iterSEED) != (kAliHLTDataTypeESDObject | kAliHLTDataOriginTPC)) continue;
157   
158       AliHLTUInt8_t slice     = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iterESD)); 
159       AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iterESD));
160       
161       if( partition < fMinPartition ) fMinPartition = partition;
162       if( partition > fMaxPartition ) fMaxPartition = partition;
163       if( slice < fMinSlice ) fMinSlice = slice;
164       if( slice > fMaxSlice ) fMaxSlice = slice;
165       
166       fESDEvent = dynamic_cast<AliESDEvent*>(iterESD);
167       fESDEvent->CreateStdContent();
168   } 
169
170  
171   //--------------- output over TObjArray of AliTPCseed objects (output of TPCSeedMaker) -------------------//
172   
173   for(iterSEED = (TObject*)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); iterSEED != NULL; iterSEED = (TObject*)GetNextInputObject()){  
174               
175        if(GetDataType(iterSEED) != (kAliHLTDataTypeTObjArray | kAliHLTDataOriginTPC)) continue;
176
177        fSeedArray = dynamic_cast<TObjArray*>(iterSEED); 
178   }
179  
180   fCalibTimeGain->Process(fESDEvent);
181
182   fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( fMinSlice, fMaxSlice, fMinPartition, fMaxPartition );
183   PushBack( (TObject*) fCalibTimeGain, AliHLTTPCDefinitions::fgkCalibCEDataType, fSpecification);
184   
185   return 0;
186 }
187
188 Int_t AliHLTTPCCalibTimeGainComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,  AliHLTComponentTriggerData& /*trigData*/ ){
189   // see header file for class documentation
190     
191   if(fEnableAnalysis) fCalibTimeGain->Analyze();  
192   PushToFXS( (TObject*) fCalibTimeGain, "TPC", "TimeGain" ) ;
193   
194   return 0;
195
196
197