]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/physics/AliHLTMultiplicityCorrelationsComponent.cxx
Add output of VZERO reco directly to multCorr
[u/mrichter/AliRoot.git] / HLT / global / physics / AliHLTMultiplicityCorrelationsComponent.cxx
1 //-*- Mode: C++ -*-
2 // $Id: AliHLTMultiplicityCorrelationsComponent.cxx $
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Jochen Thaeder <jochen@thaeder.de>                    *
8  *                  for The ALICE HLT Project.                            *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /** @file    AliHLTMultiplicityCorrelationsComponent.cxx
20     @author  Jochen Thaeder <jochen@thaeder.de>
21     @brief   Component for Multiplicty Correlations
22 */
23
24 #if __GNUC__>= 3
25 using namespace std;
26 #endif
27
28 #include "TMap.h"
29 #include "TObjString.h"
30 #include "AliESDVZERO.h"
31 #include "AliESDtrackCuts.h"
32 #include "AliHLTMultiplicityCorrelations.h"
33
34 #include "AliHLTErrorGuard.h"
35 #include "AliHLTDataTypes.h"
36 #include "AliHLTMultiplicityCorrelationsComponent.h"
37 #include "AliHLTITSClusterDataFormat.h"
38
39 /** ROOT macro for the implementation of ROOT specific class methods */
40 ClassImp(AliHLTMultiplicityCorrelationsComponent)
41
42 /*
43  * ---------------------------------------------------------------------------------
44  *                            Constructor / Destructor
45  * ---------------------------------------------------------------------------------
46  */
47
48 // #################################################################################
49 AliHLTMultiplicityCorrelationsComponent::AliHLTMultiplicityCorrelationsComponent() :
50   AliHLTProcessor(),
51   fESDTrackCuts(NULL),  
52   fCorrObj(NULL) {
53   // an example component which implements the ALICE HLT processor
54   // interface and does some analysis on the input raw data
55   //
56   // see header file for class documentation
57   // or
58   // refer to README to build package
59   // or
60   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61   //
62   // NOTE: all helper classes should be instantiated in DoInit()
63 }
64
65 // #################################################################################
66 AliHLTMultiplicityCorrelationsComponent::~AliHLTMultiplicityCorrelationsComponent() {
67   // see header file for class documentation
68 }
69
70 /*
71  * ---------------------------------------------------------------------------------
72  * Public functions to implement AliHLTComponent's interface.
73  * These functions are required for the registration process
74  * ---------------------------------------------------------------------------------
75  */
76
77 // #################################################################################
78 const Char_t* AliHLTMultiplicityCorrelationsComponent::GetComponentID() { 
79   // see header file for class documentation
80   return "MultiplicityCorrelations";
81 }
82
83 // #################################################################################
84 void AliHLTMultiplicityCorrelationsComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
85   // see header file for class documentation
86   list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginAny);
87   list.push_back(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD);
88   list.push_back(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
89 }
90
91 // #################################################################################
92 AliHLTComponentDataType AliHLTMultiplicityCorrelationsComponent::GetOutputDataType() {
93   // see header file for class documentation
94   return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT;
95 }
96
97 // #################################################################################
98 void AliHLTMultiplicityCorrelationsComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
99   // see header file for class documentation
100   constBase = 1000;
101   inputMultiplier = 0.5;
102 }
103
104 // #################################################################################
105 void AliHLTMultiplicityCorrelationsComponent::GetOCDBObjectDescription( TMap* const targetMap) {
106   // see header file for class documentation
107
108   if (!targetMap) return;
109   targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"),
110                  new TObjString("configuration object"));
111
112   return;
113 }
114
115 // #################################################################################
116 AliHLTComponent* AliHLTMultiplicityCorrelationsComponent::Spawn() {
117   // see header file for class documentation
118   return new AliHLTMultiplicityCorrelationsComponent;
119 }
120
121 /*
122  * ---------------------------------------------------------------------------------
123  * Protected functions to implement AliHLTComponent's interface.
124  * These functions provide initialization as well as the actual processing
125  * capabilities of the component. 
126  * ---------------------------------------------------------------------------------
127  */
128
129 // #################################################################################
130 Int_t AliHLTMultiplicityCorrelationsComponent::DoInit( Int_t argc, const Char_t** argv ) {
131   // see header file for class documentation
132
133   Int_t iResult=0;
134
135   // -- Initialize members
136   // -----------------------
137   do {
138     if (iResult<0) break;
139
140
141     fCorrObj = new AliHLTMultiplicityCorrelations;
142     if (!fCorrObj) {
143       iResult=-ENOMEM;
144       break;
145     }
146
147     fESDTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","HLT");
148     if (!fESDTrackCuts) {
149       iResult=-ENOMEM;
150       break;
151     }
152
153     // implement further initialization
154   } while (0);
155
156   if (iResult<0) {
157     // implement cleanup
158
159     if (fCorrObj) 
160       delete fCorrObj;
161     fCorrObj = NULL;
162
163     if (fESDTrackCuts) 
164       delete fESDTrackCuts;
165     fESDTrackCuts = NULL;
166   }
167
168   if (iResult>=0) {
169     SetDefaultConfiguration();
170
171     // -- Read configuration object : HLT/ConfigGlobal/MultiplicityCorrelations
172     TString cdbPath="HLT/ConfigGlobal/";
173     cdbPath+=GetComponentID();
174     iResult=ConfigureFromCDBTObjString(cdbPath);
175     
176     // -- Read the component arguments
177     if (iResult>=0) {
178       iResult=ConfigureFromArgumentString(argc, argv);
179     }
180   }
181
182   if (iResult>=0) {
183     HLTInfo("ESD track cuts : %s",fESDTrackCuts->GetTitle() );
184
185     fCorrObj->SetESDTrackCuts(fESDTrackCuts);
186     fCorrObj->Initialize();
187   }
188
189   return iResult;
190 }
191
192 // #################################################################################
193 void AliHLTMultiplicityCorrelationsComponent::SetDefaultConfiguration() {
194   // see header file for class documentation
195
196   if (fESDTrackCuts) {
197     fESDTrackCuts->SetEtaRange(-0.9,0.9);
198     fESDTrackCuts->SetPtRange(0.2,200);
199     fESDTrackCuts->SetMinNClustersTPC(80);
200     
201     fESDTrackCuts->SetDCAToVertex2D(kFALSE);
202     fESDTrackCuts->SetRequireSigmaToVertex(kFALSE);
203     
204     fESDTrackCuts->SetMaxDCAToVertexXY(3.0);
205     fESDTrackCuts->SetMaxDCAToVertexZ(3.0);
206     
207     fESDTrackCuts->SetRequireTPCRefit(kFALSE);
208     fESDTrackCuts->SetRequireITSRefit(kFALSE);
209   }
210  
211   return;
212 }
213
214 // #################################################################################
215 Int_t AliHLTMultiplicityCorrelationsComponent::ScanConfigurationArgument(Int_t argc, const Char_t** argv) {
216   // Scan configuration arguments
217   // Return the number of processed arguments
218   //        -EPROTO if argument format error (e.g. number expected but not found)
219   //
220   // The AliHLTComponent base class implements a parsing loop for argument strings and
221   // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
222   // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
223
224   if (argc<=0) return 0;
225   Int_t ii =0;
226   TString argument=argv[ii];
227   
228   if (argument.IsNull()) return 0;
229
230   if( !fESDTrackCuts){
231     HLTError("No ESD track cuts availible");
232     return -ENOMEM;
233   }
234
235   // ---------------------
236
237  // -maxpt
238   if (argument.CompareTo("-maxpt")==0) {
239     if (++ii>=argc) return -EPROTO;
240     argument=argv[ii];
241
242     Float_t minPt, maxPt;
243     fESDTrackCuts->GetPtRange(minPt,maxPt);
244     maxPt = argument.Atof(); 
245     fESDTrackCuts->SetPtRange(minPt,maxPt);
246
247     TString title = fESDTrackCuts->GetTitle();
248     if (!title.CompareTo("No track cuts")) title = "";
249     else title += " && ";
250     title += Form("p_t < %f", maxPt);
251     fESDTrackCuts->SetTitle(title);
252     return 2;
253   }    
254
255   // -minpt
256   if (argument.CompareTo("-minpt")==0) {
257     if (++ii>=argc) return -EPROTO;
258     argument=argv[ii];
259
260     Float_t minPt, maxPt;
261     fESDTrackCuts->GetPtRange(minPt,maxPt);
262     minPt = argument.Atof(); 
263     fESDTrackCuts->SetPtRange(minPt,maxPt);
264
265     TString title = fESDTrackCuts->GetTitle();
266     if (!title.CompareTo("No track cuts")) title = "";
267     else title += " && ";
268     title += Form("p_t > %f", minPt);
269     fESDTrackCuts->SetTitle(title);
270     return 2;
271   }    
272
273   // -min-ldca
274   // minimum longitudinal dca to vertex
275   if (argument.CompareTo("-min-ldca")==0) {
276     if (++ii>=argc) return -EPROTO;
277     argument=argv[ii];
278
279     fESDTrackCuts->SetMinDCAToVertexZ(argument.Atof());
280     TString title = fESDTrackCuts->GetTitle();
281     if (!title.CompareTo("No track cuts")) title = "";
282     else title += " && ";
283     title += Form("DCAz > %f", argument.Atof());
284     fESDTrackCuts->SetTitle(title);
285     return 2;
286   }
287   
288   // -max-ldca
289   // maximum longitudinal dca to vertex
290   if (argument.CompareTo("-max-ldca")==0) {
291     if (++ii>=argc) return -EPROTO;
292     argument=argv[ii];
293
294     fESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof());
295     TString title = fESDTrackCuts->GetTitle();
296     if (!title.CompareTo("No track cuts")) title = "";
297     else title += " && ";
298     title += Form("DCAz < %f", argument.Atof());
299     fESDTrackCuts->SetTitle(title);
300     return 2;
301   }
302
303   // -min-tdca
304   // minimum transverse dca to vertex
305   if (argument.CompareTo("-min-tdca")==0) {
306     if (++ii>=argc) return -EPROTO;
307     argument=argv[ii];
308
309     fESDTrackCuts->SetMinDCAToVertexXY(argument.Atof());
310     TString title = fESDTrackCuts->GetTitle();
311     if (!title.CompareTo("No track cuts")) title = "";
312     else title += " && ";
313     title += Form("DCAr > %f", argument.Atof());
314     fESDTrackCuts->SetTitle(title);
315     return 2;
316   }
317   
318   // -max-tdca
319   // maximum transverse dca to vertex
320   if (argument.CompareTo("-max-tdca")==0) {
321     if (++ii>=argc) return -EPROTO;
322     argument=argv[ii];
323
324     fESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof());
325     TString title = fESDTrackCuts->GetTitle();
326     if (!title.CompareTo("No track cuts")) title = "";
327     else title += " && ";
328     title += Form("DCAr < %f", argument.Atof());
329     fESDTrackCuts->SetTitle(title);
330     return 2;
331   }
332
333   // -etarange
334   // +/- eta 
335   if (argument.CompareTo("-etarange")==0) {
336     if (++ii>=argc) return -EPROTO;
337     argument=argv[ii];
338     Float_t eta = argument.Atof();
339
340     fESDTrackCuts->SetEtaRange(-eta,eta);     
341     TString title = fESDTrackCuts->GetTitle();
342     if (!title.CompareTo("No track cuts")) title = "";
343     else title += " && ";
344     title += Form("Eta[%f,%f]", argument.Atof());
345     fESDTrackCuts->SetTitle(title);
346     return 2;
347   }
348
349
350   // -- BINNING --------------
351
352   // binningVzero
353   if (argument.CompareTo("-binningVzero")==0) {
354     if (++ii>=argc) return -EPROTO;
355     argument=argv[ii];
356     Int_t binning = argument.Atoi();
357     if (++ii>=argc) return -EPROTO;
358     argument=argv[ii];
359     Float_t min = argument.Atof();
360     if (++ii>=argc) return -EPROTO;
361     argument=argv[ii];
362     Float_t max = argument.Atof();
363
364     fCorrObj->SetBinningVzero(binning, min, max);
365     return 4;
366   }
367
368   // binningTpc
369   if (argument.CompareTo("-binningTpc")==0) {
370     if (++ii>=argc) return -EPROTO;
371     argument=argv[ii];
372     Int_t binning = argument.Atoi();
373     if (++ii>=argc) return -EPROTO;
374     argument=argv[ii];
375     Float_t min = argument.Atof();
376     if (++ii>=argc) return -EPROTO;
377     argument=argv[ii];
378     Float_t max = argument.Atof();
379
380     fCorrObj->SetBinningTpc(binning, min, max);
381     return 4;
382   }
383
384   // binningSpd
385   if (argument.CompareTo("-binningSpd")==0) {
386     if (++ii>=argc) return -EPROTO;
387     argument=argv[ii];
388     Int_t binning = argument.Atoi();
389     if (++ii>=argc) return -EPROTO;
390     argument=argv[ii];
391     Float_t min = argument.Atof();
392     if (++ii>=argc) return -EPROTO;
393     argument=argv[ii];
394     Float_t max = argument.Atof();
395
396     fCorrObj->SetBinningSpd(binning, min, max);
397     return 4;
398   }
399
400   // binningZdc
401   if (argument.CompareTo("-binningZdc")==0) {
402     if (++ii>=argc) return -EPROTO;
403     argument=argv[ii];
404     Int_t binning = argument.Atoi();
405     if (++ii>=argc) return -EPROTO;
406     argument=argv[ii];
407     Float_t min = argument.Atof();
408     if (++ii>=argc) return -EPROTO;
409     argument=argv[ii];
410     Float_t max = argument.Atof();
411
412     fCorrObj->SetBinningZdc(binning, min, max);
413     return 4;
414   }
415
416   // binningZnp
417   if (argument.CompareTo("-binningZnp")==0) {
418     if (++ii>=argc) return -EPROTO;
419     argument=argv[ii];
420     Int_t binning = argument.Atoi();
421     if (++ii>=argc) return -EPROTO;
422     argument=argv[ii];
423     Float_t min = argument.Atof();
424     if (++ii>=argc) return -EPROTO;
425     argument=argv[ii];
426     Float_t max = argument.Atof();
427
428     fCorrObj->SetBinningZnp(binning, min, max);
429     return 4;
430   }
431
432   // binningZem
433   if (argument.CompareTo("-binningZem")==0) {
434     if (++ii>=argc) return -EPROTO;
435     argument=argv[ii];
436     Int_t binning = argument.Atoi();
437     if (++ii>=argc) return -EPROTO;
438     argument=argv[ii];
439     Float_t min = argument.Atof();
440     if (++ii>=argc) return -EPROTO;
441     argument=argv[ii];
442     Float_t max = argument.Atof();
443
444     fCorrObj->SetBinningZem(binning, min, max);
445     return 4;
446   }
447   // binningZem
448   if (argument.CompareTo("-binningCalo")==0) {
449     if (++ii>=argc) return -EPROTO;
450     argument=argv[ii];
451     Int_t binning = argument.Atoi();
452     if (++ii>=argc) return -EPROTO;
453     argument=argv[ii];
454     Float_t min = argument.Atof();
455     if (++ii>=argc) return -EPROTO;
456     argument=argv[ii];
457     Float_t max = argument.Atof();
458
459     fCorrObj->SetBinningCalo(binning, min, max);
460     return 4;
461   }
462   if (argument.CompareTo("-enablePhos")==0) {
463     if (++ii>=argc) return -EPROTO;
464     argument=argv[ii];
465     Int_t enabled = argument.Atoi();
466     fCorrObj->SetProcessPhos(enabled);
467     return 2;
468   }
469   if (argument.CompareTo("-enableEmcal")==0) {
470     if (++ii>=argc) return -EPROTO;
471     argument=argv[ii];
472     Int_t enabled = argument.Atoi();
473     fCorrObj->SetProcessEmcal(enabled);
474     return 2;
475   }
476   // unknown argument
477   return -EINVAL;
478 }
479
480 // #################################################################################
481 Int_t AliHLTMultiplicityCorrelationsComponent::DoDeinit() {
482   // see header file for class documentation
483
484   if (fCorrObj) 
485     delete fCorrObj;
486   fCorrObj = NULL;
487   
488   if (fESDTrackCuts) 
489     delete fESDTrackCuts;
490   fESDTrackCuts = NULL;
491   
492   return 0;
493 }
494
495 // #################################################################################
496 Int_t AliHLTMultiplicityCorrelationsComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
497                                         AliHLTComponentTriggerData& /*trigData*/) {
498   // see header file for class documentation
499
500   Int_t iResult=0;
501
502   // -- Only use data event
503   if (!IsDataEvent()) 
504     return 0;
505
506
507   // -- Get ESD object 
508   AliESDEvent *esdEvent = NULL;
509   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
510     esdEvent = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
511     if( !esdEvent ){ 
512       HLTWarning("Wrong ESDEvent object received");
513       iResult = -1;
514       continue;
515     }
516     esdEvent->GetStdContent();
517   }
518
519   // -- Get VZEROESD object 
520   AliESDVZERO *esdVZERO = NULL;
521   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO); 
522         iter != NULL; iter = GetNextInputObject() ) {
523     esdVZERO = dynamic_cast<AliESDVZERO*>(const_cast<TObject*>( iter ) );
524     if( !esdVZERO ){ 
525       HLTWarning("Wrong VZERO ESDEvent object received");
526       iResult = -1;
527       continue;
528     }
529   }
530
531   // -- Get SPD clusters
532   // ---------------------
533   const AliHLTComponentBlockData* iter = NULL;
534   Int_t totalSpacePoint = 0;
535
536   for ( iter = GetFirstInputBlock(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD); 
537         iter != NULL; iter = GetNextInputBlock() ) {
538     
539     const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr;
540     Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
541     totalSpacePoint += nSpacepoint;
542   }
543
544   // -- Process Event
545   // ------------------
546   if (esdEvent)
547     iResult = fCorrObj->ProcessEvent(esdEvent,esdVZERO,totalSpacePoint);
548
549   if (iResult) {
550     HLTError("Error while processing event inside multiplicity correlation object");
551     return iResult;
552   }
553
554   // -- Send histlist
555   PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()),
556            kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,0);
557  
558   return iResult;
559 }
560
561 // #################################################################################
562 Int_t AliHLTMultiplicityCorrelationsComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) {
563   // see header file for class documentation
564
565   Int_t iResult=0;
566   TString cdbPath;
567   if (cdbEntry) {
568     cdbPath=cdbEntry;
569   } else {
570     cdbPath="HLT/ConfigGlobal/";
571     cdbPath+=GetComponentID();
572   }
573
574   AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
575   iResult=ConfigureFromCDBTObjString(cdbPath);
576
577   return iResult;
578 }
579
580 // #################################################################################
581 Int_t AliHLTMultiplicityCorrelationsComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
582   // see header file for class documentation
583   ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
584   return 0;
585 }