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