]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/calibration/AliHLTTPCCalibTimeGainComponent.cxx
3b12869ec0501fe2fe1af65bd102e73585c40ac4
[u/mrichter/AliRoot.git] / HLT / TPCLib / calibration / 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 #include "AliHLTTPCDefinitions.h"
36 #include "AliHLTReadoutList.h"
37
38 #include "AliESDEvent.h"
39 #include "AliESDtrack.h"
40
41 #include "AliTPCcalibTimeGain.h"
42 #include "AliTPCseed.h"
43
44 #include "TObjArray.h"
45 #include "TString.h"
46
47 #include <cstdlib>
48 #include <cerrno>
49
50
51 ClassImp(AliHLTTPCCalibTimeGainComponent) // ROOT macro for the implementation of ROOT specific class methods
52
53 AliHLTTPCCalibTimeGainComponent::AliHLTTPCCalibTimeGainComponent()
54   :
55   fCalibTimeGain(NULL),
56   fESDEvent(NULL),
57   fSeedArray(NULL),
58   fMinPartition(5),
59   fMaxPartition(0),
60   fMinSlice(35),
61   fMaxSlice(0),
62   fSpecification(0) ,
63   fEnableAnalysis(kTRUE)
64 {
65   // see header file for class documentation
66   // or
67   // refer to README to build package
68   // or
69   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70 }
71
72 AliHLTTPCCalibTimeGainComponent::~AliHLTTPCCalibTimeGainComponent() {
73 // see header file for class documentation
74 }
75
76 const char* AliHLTTPCCalibTimeGainComponent::GetComponentID() {
77 // see header file for class documentation
78
79   return "TPCCalibTimeGain";
80 }
81
82 void AliHLTTPCCalibTimeGainComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
83 // see header file for class documentation
84
85   list.clear();   
86   list.push_back( kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC ); // output of TPCCalibSeedMaker
87   list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut ); // output of global esd converter 
88 }
89
90 AliHLTComponentDataType AliHLTTPCCalibTimeGainComponent::GetOutputDataType() {
91 // see header file for class documentation
92
93   return AliHLTTPCDefinitions::fgkCalibCEDataType|kAliHLTDataOriginOut;
94 }
95
96 void AliHLTTPCCalibTimeGainComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
97 // see header file for class documentation
98
99   constBase = 0;
100   inputMultiplier = (2.0); // to be estimated
101 }
102
103 AliHLTComponent* AliHLTTPCCalibTimeGainComponent::Spawn() {
104 // see header file for class documentation
105
106   return new AliHLTTPCCalibTimeGainComponent();
107 }  
108
109
110 Int_t AliHLTTPCCalibTimeGainComponent::ScanArgument( Int_t argc, const char** argv ) {
111 // see header file for class documentation
112
113   Int_t iResult = 0;
114   TString argument = "";
115   TString parameter = "";
116
117   if(!argc) return -EINVAL;
118
119   argument = argv[iResult];
120   
121   if(argument.IsNull()) return -EINVAL;
122
123   if( argument.CompareTo("-enable-analysis") == 0 ){
124     HLTInfo( "Analysis before shipping data to FXS enabled." );
125     fEnableAnalysis = kTRUE;
126   }
127   else {
128     iResult = -EINVAL;
129   }
130       
131   return iResult;
132 }
133
134 Int_t AliHLTTPCCalibTimeGainComponent::InitCalibration() {
135 // see header file for class documentation
136     
137   if(fCalibTimeGain) return EINPROGRESS;
138   //fCalibTimeGain = new AliTPCcalibTimeGain();
139   fCalibTimeGain = new AliTPCcalibTimeGain("calibTimeGain","time dependent gain calibration",-2, 2, 1);
140   return 0;
141 }
142
143 Int_t AliHLTTPCCalibTimeGainComponent::DeinitCalibration() {
144 // see header file for class documentation
145
146   if(fCalibTimeGain) delete fCalibTimeGain; fCalibTimeGain = NULL;
147
148   return 0;
149 }
150
151 Int_t AliHLTTPCCalibTimeGainComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/,  AliHLTComponentTriggerData& /*trigData*/ ){
152 // see header file for class documentation
153   
154   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
155
156   TObject *iter = NULL;
157
158   //--------------- loop over the TObjArray output of AliTPCseed objects (output of TPCSeedMaker) -------------------//
159   
160   for(iter = (TObject*)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); iter != NULL; iter = (TObject*)GetNextInputObject()){  
161               
162       if(GetDataType(iter) != (kAliHLTDataTypeTObjArray | kAliHLTDataOriginTPC)) continue;
163       fSeedArray = dynamic_cast<TObjArray*>(iter); 
164   }
165  
166   //----------- loop over output of global esd converter ----------------//
167   
168   for(iter = (TObject*)GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = (TObject*)GetNextInputObject()){   
169       
170       if(GetDataType(iter) != (kAliHLTDataTypeESDObject | kAliHLTDataOriginOut)) continue;
171   
172       AliHLTUInt8_t slice     = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter)); 
173       AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
174       
175       if( partition < fMinPartition ) fMinPartition = partition;
176       if( partition > fMaxPartition ) fMaxPartition = partition;
177       if( slice < fMinSlice ) fMinSlice = slice;
178       if( slice > fMaxSlice ) fMaxSlice = slice;
179       
180       fESDEvent = dynamic_cast<AliESDEvent*>(iter);
181       fESDEvent->CreateStdContent();
182      
183       HLTDebug("# Seeds: %i\n", fSeedArray->GetEntriesFast());
184       
185       for(Int_t i=0; i<fSeedArray->GetEntriesFast(); i++){
186           
187           AliTPCseed *seed = (AliTPCseed*)fSeedArray->UncheckedAt(i);
188           if(!seed) continue;
189           AliESDtrack *esd = fESDEvent->GetTrack(i);    
190           AliTPCseed *seedCopy = new AliTPCseed(*seed, kTRUE); 
191           esd->AddCalibObject(seedCopy);
192       }      
193   } 
194    
195   fCalibTimeGain->Process(fESDEvent);
196
197   fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( fMinSlice, fMaxSlice, fMinPartition, fMaxPartition );
198   PushBack( (TObject*) fCalibTimeGain, AliHLTTPCDefinitions::fgkCalibCEDataType| kAliHLTDataOriginOut, fSpecification);
199   
200   return 0;
201 }
202
203 Int_t AliHLTTPCCalibTimeGainComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,  AliHLTComponentTriggerData& /*trigData*/ ){
204   // see header file for class documentation
205     
206   if(fEnableAnalysis) fCalibTimeGain->Analyze();  
207   static AliHLTReadoutList rdList(AliHLTReadoutList::kTPC);
208   PushToFXS( (TObject*) fCalibTimeGain, "TPC", "TimeGain", &rdList ) ;
209   
210   return 0;
211
212
213