1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: S.Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6 //* for The ALICE HLT Project. *
8 //* Permission to use, copy, modify and distribute this software and its *
9 //* documentation strictly for non-commercial purposes is hereby granted *
10 //* without fee, provided that the above copyright notice appears in all *
11 //* copies and that both the copyright notice and this permission notice *
12 //* appear in the supporting documentation. The authors make no claims *
13 //* about the suitability of this software for any purpose. It is *
14 //* provided "as is" without express or implied warranty. *
15 //**************************************************************************
17 /** @file AliHLTV0HistoComponent.cxx
18 @author Sergey Gorbunov
19 @brief Component for ploting charge in clusters
26 #include "AliHLTV0HistoComponent.h"
27 #include "AliCDBEntry.h"
28 #include "AliCDBManager.h"
31 #include "TObjString.h"
32 #include "TObjArray.h"
33 #include "AliKFParticle.h"
34 #include "AliKFVertex.h"
38 #include "AliESDEvent.h"
39 #include "AliESDtrack.h"
41 #include "AliHLTMessage.h"
42 #include "TTimeStamp.h"
44 //#include "AliHLTTPC.h"
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTV0HistoComponent)
51 AliHLTV0HistoComponent::AliHLTV0HistoComponent() :
65 // see header file for class documentation
67 // refer to README to build package
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
73 AliHLTV0HistoComponent::~AliHLTV0HistoComponent()
75 // see header file for class documentation
78 // Public functions to implement AliHLTComponent's interface.
79 // These functions are required for the registration process
81 const char* AliHLTV0HistoComponent::GetComponentID()
83 // see header file for class documentation
88 void AliHLTV0HistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
90 // see header file for class documentation
92 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
95 AliHLTComponentDataType AliHLTV0HistoComponent::GetOutputDataType()
97 // see header file for class documentation
98 return kAliHLTDataTypeHistogram | kAliHLTDataOriginOut;
101 void AliHLTV0HistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
103 // see header file for class documentation
104 // XXX TODO: Find more realistic values.
109 AliHLTComponent* AliHLTV0HistoComponent::Spawn()
111 // see header file for class documentation
112 return new AliHLTV0HistoComponent;
115 int AliHLTV0HistoComponent::DoInit( int argc, const char** argv ) {
120 fGamma = new TH1F("hGamma","HLT: #gamma inv mass",50,-.06,.2);
121 fGamma->SetFillColor(kGreen);
123 fKShort = new TH1F("hKShort","HLT: K_{s}^{0} inv mass",80,0.4,.6);
124 fKShort->SetFillColor(kGreen);
125 fKShort->SetStats(0);
126 fLambda = new TH1F("hLambda","HLT: #Lambda^{0} inv mass",50,1.0,1.36);
127 fLambda->SetFillColor(kGreen);
128 fLambda->SetStats(0);
130 fPi0 = new TH1F("hPi0","HLT: #Pi^{0} inv mass",50,0.0,0.38);
131 fPi0->SetFillColor(kGreen);
134 fAP = new TH2F("hAP","HLT: Armenteros-Podolanski plot",60,-1.,1.,60,-0.02,0.3);
135 fAP->SetMarkerStyle(8);
136 fAP->SetMarkerSize(0.4);
137 fAP->SetYTitle("p_{t}[GeV]");
138 fAP->SetXTitle("(p^{+}_{L}-p^{-}_{L})/(p^{+}_{L}+p^{-}_{L})");
140 fAP->SetOption("CONT4 Z");
142 fGammaXY = new TH2F("hGammaXY","HLT: #gamma conversions",100,-100.,100.,100,-100.,100.);
143 fGammaXY->SetMarkerStyle(8);
144 fGammaXY->SetMarkerSize(0.4);
145 fGammaXY->SetYTitle("X[cm]");
146 fGammaXY->SetXTitle("Y[cm]");
147 fGammaXY->SetStats(0);
148 fGammaXY->SetOption("COLZ");
157 // [0] == 0 --- N clusters on each daughter track
158 // [1] == 2.5 --- (daughter-primVtx)/sigma >= cut
159 // [2] == 3.5 --- (v0 - primVtx)/sigma <= cut
160 // [3] == 3.0 --- (decay_length)/sigma >= cut
161 // [4] == 0.0 --- (decay_length)[cm] >= cut
162 // [5] == 300.0 --- (v0 radius)[cm] <= cut
163 // [6] == 3.5 --- (v0 mass - true value)/sigma <= cut (for identification)
164 // [7] == 0.05 --- (v0 mass - true value) <= cut (for identification)
171 fGammaCuts[5] = 300.0;
173 fGammaCuts[7] = 0.05;
193 fLambdaCuts[0] = 60; // [0] == 60 --- N clusters on each daughter track
194 fLambdaCuts[1] = 3.0; // [1] == 3.0 --- (daughter-primVtx)/sigma >= cut
195 fLambdaCuts[2] = 3.0; // [2] == 3.0 --- (v0 - primVtx)/sigma <= cut
196 fLambdaCuts[3] = 3.5; // [3] == 3.5 --- (decay_length)/sigma >= cut
197 fLambdaCuts[4] = 4.0; // [4] == 0.0 --- (decay_length)[cm] >= cut
198 fLambdaCuts[5] = 50.0; // [5] == 300.0 --- (v0 radius)[cm] <= cut
199 fLambdaCuts[6] = 4.0; // [6] == 3.5 --- (v0 mass - true value)/sigma <= cut (for identification)
200 fLambdaCuts[7] = 0.03; // [7] == 0.05 --- (v0 mass - true value) <= cut (for identification)
203 TString configuration="";
205 for (int i=0; i<argc && iResult>=0; i++) {
207 if (!configuration.IsNull()) configuration+=" ";
208 configuration+=argument;
211 if (!configuration.IsNull()) {
212 iResult=Configure(configuration.Data());
218 int AliHLTV0HistoComponent::DoDeinit()
220 // see header file for class documentation
230 int AliHLTV0HistoComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/)
233 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
238 fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
243 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
245 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
246 event->GetStdContent();
247 Int_t nV0 = event->GetNumberOfV0s();
248 AliKFParticle::SetField( event->GetMagneticField() );
250 const double kKsMass = 0.49767;
251 const double kLambdaMass = 1.11568;
252 const double kPi0Mass = 0.13498;
254 std::vector<AliKFParticle> vGammas;
256 for (Int_t iv=0; iv<nV0; iv++) {
258 AliESDtrack *t1=event->GetTrack( event->GetV0(iv)->GetNindex());
259 AliESDtrack *t2=event->GetTrack( event->GetV0(iv)->GetPindex());
261 AliKFParticle kf1( *t1, 11 );
262 AliKFParticle kf2( *t2, 11 );
264 AliKFVertex primVtx( *event->GetPrimaryVertexTracks() );
265 double dev1 = kf1.GetDeviationFromVertex( primVtx );
266 double dev2 = kf2.GetDeviationFromVertex( primVtx );
268 AliKFParticle v0( kf1, kf2 );
269 double devPrim = v0.GetDeviationFromVertex( primVtx );
271 v0.SetProductionVertex( primVtx );
273 Double_t length, sigmaLength;
274 if( v0.GetDecayLength( length, sigmaLength ) ) continue;
276 double dx = v0.GetX()-primVtx.GetX();
277 double dy = v0.GetY()-primVtx.GetY();
278 double r = sqrt(dx*dx + dy*dy);
284 AliKFParticle kf01 = kf1, kf02 = kf2;
285 kf01.SetProductionVertex(v0);
286 kf02.SetProductionVertex(v0);
287 kf01.TransportToProductionVertex();
288 kf02.TransportToProductionVertex();
289 double px1=kf01.GetPx(), py1=kf01.GetPy(), pz1=kf01.GetPz();
290 double px2=kf02.GetPx(), py2=kf02.GetPy(), pz2=kf02.GetPz();
291 double px = px1+px2, py = py1+py2, pz = pz1+pz2;
292 double p = sqrt(px*px+py*py+pz*pz);
293 double l1 = (px*px1 + py*py1 + pz*pz1)/p;
294 double l2 = (px*px2 + py*py2 + pz*pz2)/p;
295 pt = sqrt(px1*px1+py1*py1+pz1*pz1 - l1*l1);
296 ap = (l2-l1)/(l1+l2);
300 t1->GetTPCNcls()>=fAPCuts[0]
301 && t2->GetTPCNcls()>=fAPCuts[0]
304 && devPrim <= fAPCuts[2]
305 && length >= fAPCuts[3]*sigmaLength
306 && length >= fAPCuts[4]
309 if( fAP ) fAP->Fill( ap, pt );
317 t1->GetTPCNcls()>=fGammaCuts[0]
318 && t2->GetTPCNcls()>=fGammaCuts[0]
319 && dev1>=fGammaCuts[1]
320 && dev2>=fGammaCuts[1]
321 && devPrim <= fGammaCuts[2]
322 && length >= fGammaCuts[3]*sigmaLength
323 && length >= fGammaCuts[4]
324 && r <= fGammaCuts[5]
327 v0.GetMass(mass,error);
328 if( fGamma ) fGamma->Fill( mass );
330 if( TMath::Abs(mass)<=fGammaCuts[6]*error || TMath::Abs(mass)<=fGammaCuts[7] ){
331 AliKFParticle gamma = v0;
332 gamma.SetMassConstraint(0);
334 && t1->GetTPCNcls()>=60
335 && t2->GetTPCNcls()>=60
336 ) fGammaXY->Fill(gamma.GetX(), gamma.GetY());
339 vGammas.push_back( gamma );
343 if( isGamma ) continue;
351 t1->GetTPCNcls()>=fKsCuts[0]
352 && t2->GetTPCNcls()>=fKsCuts[0]
355 && devPrim <= fKsCuts[2]
356 && length >= fKsCuts[3]*sigmaLength
357 && length >= fKsCuts[4]
361 AliKFParticle piN( *t1, 211 );
362 AliKFParticle piP( *t2, 211 );
364 AliKFParticle Ks( piN, piP );
365 Ks.SetProductionVertex( primVtx );
368 Ks.GetMass( mass, error);
369 if( fKShort ) fKShort->Fill( mass );
370 if( TMath::Abs( mass - kKsMass )<=fKsCuts[6]*error || TMath::Abs( mass - kKsMass )<=fKsCuts[7] ){
381 t1->GetTPCNcls()>=fLambdaCuts[0]
382 && t2->GetTPCNcls()>=fLambdaCuts[0]
383 && dev1>=fLambdaCuts[1]
384 && dev2>=fLambdaCuts[1]
385 && devPrim <= fLambdaCuts[2]
386 && length >= fLambdaCuts[3]*sigmaLength
387 && length >= fLambdaCuts[4]
388 && r <= fLambdaCuts[5]
389 && TMath::Abs( ap )>.4
392 AliKFParticle kP, kpi;
394 kP = AliKFParticle( *t2, 2212 );
395 kpi = AliKFParticle( *t1, 211 );
397 kP = AliKFParticle( *t1, 2212 );
398 kpi = AliKFParticle( *t2, 211 );
401 AliKFParticle lambda = AliKFParticle( kP, kpi );
402 lambda.SetProductionVertex( primVtx );
404 lambda.GetMass( mass, error);
405 if( fLambda ) fLambda->Fill( mass );
406 if( TMath::Abs( mass - kLambdaMass )<=fLambdaCuts[6]*error || TMath::Abs( mass - kLambdaMass )<=fLambdaCuts[7] ){
416 for(UInt_t g1=0;g1<vGammas.size();g1++){
417 for(UInt_t g2=g1+1;g2<vGammas.size();g2++){
418 AliKFParticle pi0(vGammas.at(g1),vGammas.at(g2));
420 pi0.GetMass(mass,error);
422 if( TMath::Abs( mass - kPi0Mass )<=0.03 ){
429 if( fGamma ) PushBack( (TObject*) fGamma, kAliHLTDataTypeHistogram,fUID);
431 if( fKShort ) PushBack( (TObject*) fKShort, kAliHLTDataTypeHistogram,fUID);
433 if( fLambda ) PushBack( (TObject*) fLambda, kAliHLTDataTypeHistogram, fUID);
435 if( fPi0 ) PushBack( (TObject*) fPi0, kAliHLTDataTypeHistogram, fUID);
437 if( fAP ) PushBack( (TObject*) fAP, kAliHLTDataTypeHistogram, fUID);
439 if( fGammaXY ) PushBack( (TObject*) fGammaXY, kAliHLTDataTypeHistogram, fUID);
442 HLTInfo("Found %d Gammas, %d KShorts, %d Lambdas and %d Pi0's in %d events", fNGammas, fNKShorts, fNLambdas, fNPi0s, fNEvents );
444 else HLTInfo("Found %d Gammas, %d KShorts and %d Lambdas in %d events", fNGammas, fNKShorts, fNLambdas, fNEvents );
449 int AliHLTV0HistoComponent::Configure(const char* arguments)
453 if (!arguments) return iResult;
455 TString allArgs=arguments;
458 TObjArray* pTokens=allArgs.Tokenize(" ");
462 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
463 argument=((TObjString*)pTokens->At(i))->GetString();
464 if (argument.IsNull()) continue;
466 if (argument.CompareTo("-cutsGamma")==0) {
468 for( int j=0; j<8; j++ ){
469 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
471 spar+=((TObjString*)pTokens->At(i))->GetString();
472 fGammaCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
474 if( !bMissingParam ){
475 HLTInfo("Gamma cuts are set to: %s", spar.Data());
478 } else if (argument.CompareTo("-cutsAP")==0) {
480 for( int j=0; j<8; j++ ){
481 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
483 spar+=((TObjString*)pTokens->At(i))->GetString();
484 fAPCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
486 if( !bMissingParam ){
487 HLTInfo("AP cuts are set to: %s", spar.Data());
491 else if (argument.CompareTo("-cutsKs")==0) {
493 for( int j=0; j<8; j++ ){
494 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
496 spar+=((TObjString*)pTokens->At(i))->GetString();
497 fKsCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
499 if( !bMissingParam ){
500 HLTInfo("KShort cuts are set to: %s", spar.Data());
503 } else if (argument.CompareTo("-cutsLambda")==0) {
505 for( int j=0; j<8; j++ ){
506 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
508 spar+=((TObjString*)pTokens->At(i))->GetString();
509 fLambdaCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
511 if( !bMissingParam ){
512 HLTInfo("Lampda cuts are set to: %s", spar.Data());
516 HLTError("unknown argument %s", argument.Data());
527 int AliHLTV0HistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
529 // see header file for class documentation
531 const char* path="HLT/ConfigTPC/KryptonHistoComponent";
532 const char* defaultNotify="";
535 defaultNotify=" (default)";
538 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
539 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
541 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
543 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
544 iResult=Configure(pString->GetString().Data());
546 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
549 HLTError("can not fetch object \"%s\" from CDB", path);