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