]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/physics/AliHLTMultiplicityCorrelationsComponent.cxx
add SPD to plots
[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
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 }
89
90 // #################################################################################
91 AliHLTComponentDataType AliHLTMultiplicityCorrelationsComponent::GetOutputDataType() {
92   // see header file for class documentation
93   return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT;
94 }
95
96 // #################################################################################
97 void AliHLTMultiplicityCorrelationsComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
98   // see header file for class documentation
99   constBase = 1000;
100   inputMultiplier = 0.5;
101 }
102
103 // #################################################################################
104 void AliHLTMultiplicityCorrelationsComponent::GetOCDBObjectDescription( TMap* const targetMap) {
105   // see header file for class documentation
106
107   if (!targetMap) return;
108   targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"),
109                  new TObjString("configuration object"));
110
111   return;
112 }
113
114 // #################################################################################
115 AliHLTComponent* AliHLTMultiplicityCorrelationsComponent::Spawn() {
116   // see header file for class documentation
117   return new AliHLTMultiplicityCorrelationsComponent;
118 }
119
120 /*
121  * ---------------------------------------------------------------------------------
122  * Protected functions to implement AliHLTComponent's interface.
123  * These functions provide initialization as well as the actual processing
124  * capabilities of the component. 
125  * ---------------------------------------------------------------------------------
126  */
127
128 // #################################################################################
129 Int_t AliHLTMultiplicityCorrelationsComponent::DoInit( Int_t argc, const Char_t** argv ) {
130   // see header file for class documentation
131
132   Int_t iResult=0;
133
134   // -- Initialize members
135   // -----------------------
136   do {
137     if (iResult<0) break;
138
139
140     fCorrObj = new AliHLTMultiplicityCorrelations;
141     if (!fCorrObj) {
142       iResult=-ENOMEM;
143       break;
144     }
145
146     fESDTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","HLT");
147     if (!fESDTrackCuts) {
148       iResult=-ENOMEM;
149       break;
150     }
151
152     // implement further initialization
153   } while (0);
154
155   if (iResult<0) {
156     // implement cleanup
157
158     if (fCorrObj) 
159       delete fCorrObj;
160     fCorrObj = NULL;
161
162     if (fESDTrackCuts) 
163       delete fESDTrackCuts;
164     fESDTrackCuts = NULL;
165   }
166
167   if (iResult>=0) {
168     SetDefaultConfiguration();
169
170     // -- Read configuration object : HLT/ConfigGlobal/MultiplicityCorrelations
171     TString cdbPath="HLT/ConfigGlobal/";
172     cdbPath+=GetComponentID();
173     iResult=ConfigureFromCDBTObjString(cdbPath);
174     
175     // -- Read the component arguments
176     if (iResult>=0) {
177       iResult=ConfigureFromArgumentString(argc, argv);
178     }
179   }
180
181   if (iResult>=0) {
182     HLTInfo("ESD track cuts : %s",fESDTrackCuts->GetTitle() );
183
184     fCorrObj->SetESDTrackCuts(fESDTrackCuts);
185     fCorrObj->Initialize();
186   }
187
188   return iResult;
189 }
190
191 // #################################################################################
192 void AliHLTMultiplicityCorrelationsComponent::SetDefaultConfiguration() {
193   // see header file for class documentation
194
195   if (fESDTrackCuts) {
196     fESDTrackCuts->SetEtaRange(-0.9,0.9);
197     fESDTrackCuts->SetPtRange(0.2,200);
198     fESDTrackCuts->SetMinNClustersTPC(80);
199     
200     fESDTrackCuts->SetDCAToVertex2D(kFALSE);
201     fESDTrackCuts->SetRequireSigmaToVertex(kFALSE);
202     
203     fESDTrackCuts->SetMaxDCAToVertexXY(3.0);
204     fESDTrackCuts->SetMaxDCAToVertexZ(3.0);
205     
206     fESDTrackCuts->SetRequireTPCRefit(kFALSE);
207     fESDTrackCuts->SetRequireITSRefit(kFALSE);
208   }
209  
210   return;
211 }
212
213 // #################################################################################
214 Int_t AliHLTMultiplicityCorrelationsComponent::ScanConfigurationArgument(Int_t argc, const Char_t** argv) {
215   // Scan configuration arguments
216   // Return the number of processed arguments
217   //        -EPROTO if argument format error (e.g. number expected but not found)
218   //
219   // The AliHLTComponent base class implements a parsing loop for argument strings and
220   // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
221   // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
222
223   if (argc<=0) return 0;
224   Int_t ii =0;
225   TString argument=argv[ii];
226   
227   if (argument.IsNull()) return 0;
228
229   if( !fESDTrackCuts){
230     HLTError("No ESD track cuts availible");
231     return -ENOMEM;
232   }
233
234   // ---------------------
235
236  // -maxpt
237   if (argument.CompareTo("-maxpt")==0) {
238     if (++ii>=argc) return -EPROTO;
239     argument=argv[ii];
240
241     Float_t minPt, maxPt;
242     fESDTrackCuts->GetPtRange(minPt,maxPt);
243     maxPt = argument.Atof(); 
244     fESDTrackCuts->SetPtRange(minPt,maxPt);
245
246     TString title = fESDTrackCuts->GetTitle();
247     if (!title.CompareTo("No track cuts")) title = "";
248     else title += " && ";
249     title += Form("p_t < %f", maxPt);
250     fESDTrackCuts->SetTitle(title);
251     return 2;
252   }    
253
254   // -minpt
255   if (argument.CompareTo("-minpt")==0) {
256     if (++ii>=argc) return -EPROTO;
257     argument=argv[ii];
258
259     Float_t minPt, maxPt;
260     fESDTrackCuts->GetPtRange(minPt,maxPt);
261     minPt = argument.Atof(); 
262     fESDTrackCuts->SetPtRange(minPt,maxPt);
263
264     TString title = fESDTrackCuts->GetTitle();
265     if (!title.CompareTo("No track cuts")) title = "";
266     else title += " && ";
267     title += Form("p_t > %f", minPt);
268     fESDTrackCuts->SetTitle(title);
269     return 2;
270   }    
271
272   // -min-ldca
273   // minimum longitudinal dca to vertex
274   if (argument.CompareTo("-min-ldca")==0) {
275     if (++ii>=argc) return -EPROTO;
276     argument=argv[ii];
277
278     fESDTrackCuts->SetMinDCAToVertexZ(argument.Atof());
279     TString title = fESDTrackCuts->GetTitle();
280     if (!title.CompareTo("No track cuts")) title = "";
281     else title += " && ";
282     title += Form("DCAz > %f", argument.Atof());
283     fESDTrackCuts->SetTitle(title);
284     return 2;
285   }
286   
287   // -max-ldca
288   // maximum longitudinal dca to vertex
289   if (argument.CompareTo("-max-ldca")==0) {
290     if (++ii>=argc) return -EPROTO;
291     argument=argv[ii];
292
293     fESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof());
294     TString title = fESDTrackCuts->GetTitle();
295     if (!title.CompareTo("No track cuts")) title = "";
296     else title += " && ";
297     title += Form("DCAz < %f", argument.Atof());
298     fESDTrackCuts->SetTitle(title);
299     return 2;
300   }
301
302   // -min-tdca
303   // minimum transverse dca to vertex
304   if (argument.CompareTo("-min-tdca")==0) {
305     if (++ii>=argc) return -EPROTO;
306     argument=argv[ii];
307
308     fESDTrackCuts->SetMinDCAToVertexXY(argument.Atof());
309     TString title = fESDTrackCuts->GetTitle();
310     if (!title.CompareTo("No track cuts")) title = "";
311     else title += " && ";
312     title += Form("DCAr > %f", argument.Atof());
313     fESDTrackCuts->SetTitle(title);
314     return 2;
315   }
316   
317   // -max-tdca
318   // maximum transverse dca to vertex
319   if (argument.CompareTo("-max-tdca")==0) {
320     if (++ii>=argc) return -EPROTO;
321     argument=argv[ii];
322
323     fESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof());
324     TString title = fESDTrackCuts->GetTitle();
325     if (!title.CompareTo("No track cuts")) title = "";
326     else title += " && ";
327     title += Form("DCAr < %f", argument.Atof());
328     fESDTrackCuts->SetTitle(title);
329     return 2;
330   }
331
332   // -etarange
333   // +/- eta 
334   if (argument.CompareTo("-etarange")==0) {
335     if (++ii>=argc) return -EPROTO;
336     argument=argv[ii];
337     Float_t eta = argument.Atof();
338
339     fESDTrackCuts->SetEtaRange(-eta,eta);     
340     TString title = fESDTrackCuts->GetTitle();
341     if (!title.CompareTo("No track cuts")) title = "";
342     else title += " && ";
343     title += Form("Eta[%f,%f]", argument.Atof());
344     fESDTrackCuts->SetTitle(title);
345     return 2;
346   }
347
348
349   // -- BINNING --------------
350
351   // binningVzero
352   if (argument.CompareTo("-binningVzero")==0) {
353     if (++ii>=argc) return -EPROTO;
354     argument=argv[ii];
355     Int_t binning = argument.Atoi();
356     if (++ii>=argc) return -EPROTO;
357     argument=argv[ii];
358     Float_t min = argument.Atof();
359     if (++ii>=argc) return -EPROTO;
360     argument=argv[ii];
361     Float_t max = argument.Atof();
362
363     fCorrObj->SetBinningVzero(binning, min, max);
364     return 4;
365   }
366
367   // binningTpc
368   if (argument.CompareTo("-binningTpc")==0) {
369     if (++ii>=argc) return -EPROTO;
370     argument=argv[ii];
371     Int_t binning = argument.Atoi();
372     if (++ii>=argc) return -EPROTO;
373     argument=argv[ii];
374     Float_t min = argument.Atof();
375     if (++ii>=argc) return -EPROTO;
376     argument=argv[ii];
377     Float_t max = argument.Atof();
378
379     fCorrObj->SetBinningTpc(binning, min, max);
380     return 4;
381   }
382
383   // binningSpd
384   if (argument.CompareTo("-binningSpd")==0) {
385     if (++ii>=argc) return -EPROTO;
386     argument=argv[ii];
387     Int_t binning = argument.Atoi();
388     if (++ii>=argc) return -EPROTO;
389     argument=argv[ii];
390     Float_t min = argument.Atof();
391     if (++ii>=argc) return -EPROTO;
392     argument=argv[ii];
393     Float_t max = argument.Atof();
394
395     fCorrObj->SetBinningSpd(binning, min, max);
396     return 4;
397   }
398
399   // binningZdc
400   if (argument.CompareTo("-binningZdc")==0) {
401     if (++ii>=argc) return -EPROTO;
402     argument=argv[ii];
403     Int_t binning = argument.Atoi();
404     if (++ii>=argc) return -EPROTO;
405     argument=argv[ii];
406     Float_t min = argument.Atof();
407     if (++ii>=argc) return -EPROTO;
408     argument=argv[ii];
409     Float_t max = argument.Atof();
410
411     fCorrObj->SetBinningZdc(binning, min, max);
412     return 4;
413   }
414
415   // binningZnp
416   if (argument.CompareTo("-binningZnp")==0) {
417     if (++ii>=argc) return -EPROTO;
418     argument=argv[ii];
419     Int_t binning = argument.Atoi();
420     if (++ii>=argc) return -EPROTO;
421     argument=argv[ii];
422     Float_t min = argument.Atof();
423     if (++ii>=argc) return -EPROTO;
424     argument=argv[ii];
425     Float_t max = argument.Atof();
426
427     fCorrObj->SetBinningZnp(binning, min, max);
428     return 4;
429   }
430
431   // binningZem
432   if (argument.CompareTo("-binningZem")==0) {
433     if (++ii>=argc) return -EPROTO;
434     argument=argv[ii];
435     Int_t binning = argument.Atoi();
436     if (++ii>=argc) return -EPROTO;
437     argument=argv[ii];
438     Float_t min = argument.Atof();
439     if (++ii>=argc) return -EPROTO;
440     argument=argv[ii];
441     Float_t max = argument.Atof();
442
443     fCorrObj->SetBinningZem(binning, min, max);
444     return 4;
445   }
446   // binningZem
447   if (argument.CompareTo("-binningCalo")==0) {
448     if (++ii>=argc) return -EPROTO;
449     argument=argv[ii];
450     Int_t binning = argument.Atoi();
451     if (++ii>=argc) return -EPROTO;
452     argument=argv[ii];
453     Float_t min = argument.Atof();
454     if (++ii>=argc) return -EPROTO;
455     argument=argv[ii];
456     Float_t max = argument.Atof();
457
458     fCorrObj->SetBinningCalo(binning, min, max);
459     return 4;
460   }
461   if (argument.CompareTo("-enablePhos")==0) {
462     if (++ii>=argc) return -EPROTO;
463     argument=argv[ii];
464     Int_t enabled = argument.Atoi();
465     fCorrObj->SetProcessPhos(enabled);
466     return 2;
467   }
468   if (argument.CompareTo("-enableEmcal")==0) {
469     if (++ii>=argc) return -EPROTO;
470     argument=argv[ii];
471     Int_t enabled = argument.Atoi();
472     fCorrObj->SetProcessEmcal(enabled);
473     return 2;
474   }
475   // unknown argument
476   return -EINVAL;
477 }
478
479 // #################################################################################
480 Int_t AliHLTMultiplicityCorrelationsComponent::DoDeinit() {
481   // see header file for class documentation
482
483   if (fCorrObj) 
484     delete fCorrObj;
485   fCorrObj = NULL;
486   
487   if (fESDTrackCuts) 
488     delete fESDTrackCuts;
489   fESDTrackCuts = NULL;
490   
491   return 0;
492 }
493
494 // #################################################################################
495 Int_t AliHLTMultiplicityCorrelationsComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
496                                         AliHLTComponentTriggerData& /*trigData*/) {
497   // see header file for class documentation
498
499   Int_t iResult=0;
500
501   // -- Only use data event
502   if (!IsDataEvent()) 
503     return 0;
504
505
506   // -- Get ESD object 
507   AliESDEvent *esdEvent = NULL;
508   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
509     esdEvent = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
510     if( !esdEvent ){ 
511       HLTWarning("Wrong ESDEvent object received");
512       iResult = -1;
513       continue;
514     }
515     esdEvent->GetStdContent();
516   }
517
518   // -- Get SPD clusters
519   // ---------------------
520   const AliHLTComponentBlockData* iter = NULL;
521   Int_t totalSpacePoint = 0;
522
523   for ( iter = GetFirstInputBlock(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD); 
524         iter != NULL; iter = GetNextInputBlock() ) {
525     
526     const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr;
527     Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
528     totalSpacePoint += nSpacepoint;
529   }
530
531   // -- Process Event
532   // ------------------
533   if (esdEvent)
534     iResult = fCorrObj->ProcessEvent(esdEvent,totalSpacePoint);
535
536   if (iResult) {
537     HLTError("Error while processing event inside multiplicity correlation object");
538     return iResult;
539   }
540
541   // -- Send histlist
542   PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()),
543            kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,0);
544  
545   return iResult;
546 }
547
548 // #################################################################################
549 Int_t AliHLTMultiplicityCorrelationsComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) {
550   // see header file for class documentation
551
552   Int_t iResult=0;
553   TString cdbPath;
554   if (cdbEntry) {
555     cdbPath=cdbEntry;
556   } else {
557     cdbPath="HLT/ConfigGlobal/";
558     cdbPath+=GetComponentID();
559   }
560
561   AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
562   iResult=ConfigureFromCDBTObjString(cdbPath);
563
564   return iResult;
565 }
566
567 // #################################################################################
568 Int_t AliHLTMultiplicityCorrelationsComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
569   // see header file for class documentation
570   ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
571   return 0;
572 }