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: Gaute Ovrebekk <ovrebekk@ift.uib.no> *
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 Gaute Ovrebekk
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"
37 #include "AliESDEvent.h"
38 #include "AliESDtrack.h"
40 #include "AliHLTMessage.h"
42 //#include "AliHLTTPC.h"
46 /** ROOT macro for the implementation of ROOT specific class methods */
47 ClassImp(AliHLTV0HistoComponent)
49 AliHLTV0HistoComponent::AliHLTV0HistoComponent()
63 // see header file for class documentation
65 // refer to README to build package
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
71 AliHLTV0HistoComponent::~AliHLTV0HistoComponent()
73 // see header file for class documentation
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
79 const char* AliHLTV0HistoComponent::GetComponentID()
81 // see header file for class documentation
86 void AliHLTV0HistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
88 // see header file for class documentation
90 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
93 AliHLTComponentDataType AliHLTV0HistoComponent::GetOutputDataType()
95 // see header file for class documentation
96 return kAliHLTDataTypeHistogram;
99 void AliHLTV0HistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
101 // see header file for class documentation
102 // XXX TODO: Find more realistic values.
107 AliHLTComponent* AliHLTV0HistoComponent::Spawn()
109 // see header file for class documentation
110 return new AliHLTV0HistoComponent;
113 int AliHLTV0HistoComponent::DoInit( int argc, const char** argv )
117 fGamma = new TH1F("hGamma","HLT: #gamma inv mass",50,-.05,.2);
118 fGamma->SetFillColor(kGreen);
120 fKShort = new TH1F("hKShort","HLT: K_{s}^{0} inv mass",80,0.4,.6);
121 fKShort->SetFillColor(kGreen);
122 fKShort->SetStats(0);
123 fLambda = new TH1F("hLambda","HLT: #Lambda^{0} inv mass",50,1.0,1.4);
124 fLambda->SetFillColor(kGreen);
125 fLambda->SetStats(0);
127 fPi0 = new TH1F("hPi0","HLT: #Pi^{0} inv mass",50,0.0,0.2);
128 fPi0->SetFillColor(kGreen);
131 fAP = new TH2F("hAP","HLT: Armenteros-Podolanski plot",60,-1.,1.,60,0.,0.3);
132 fAP->SetMarkerStyle(8);
133 fAP->SetMarkerSize(0.4);
134 fAP->SetYTitle("p_{t}[GeV]");
135 fAP->SetXTitle("(p^{+}_{L}-p^{-}_{L})/(p^{+}_{L}+p^{-}_{L})");
137 fAP->SetOption("COLZ");
139 fGammaXY = new TH2F("hGammaXY","HLT: #gamma conversions",100,-100.,100.,100,-100.,100.);
140 fGammaXY->SetMarkerStyle(8);
141 fGammaXY->SetMarkerSize(0.4);
142 fGammaXY->SetYTitle("X[cm]");
143 fGammaXY->SetXTitle("Y[cm]");
144 fGammaXY->SetStats(0);
145 fGammaXY->SetOption("COLZ");
154 // [0] == 0 --- N clusters on each daughter track
155 // [1] == 2.5 --- (daughter-primVtx)/sigma >= cut
156 // [2] == 3.5 --- (v0 - primVtx)/sigma <= cut
157 // [3] == 3.0 --- (decay_length)/sigma >= cut
158 // [4] == 0.0 --- (decay_length)[cm] >= cut
159 // [5] == 300.0 --- (v0 radius)[cm] <= cut
160 // [6] == 3.5 --- (v0 mass - true value)/sigma <= cut (for identification)
161 // [7] == 0.05 --- (v0 mass - true value) <= cut (for identification)
168 fGammaCuts[5] = 300.0;
169 fGammaCuts[6] = 100.;
170 fGammaCuts[7] = 0.05;
191 fLambdaCuts[1] = 3.0;
192 fLambdaCuts[2] = 3.5;
193 fLambdaCuts[3] = 3.0;
194 fLambdaCuts[4] = 4.0;
195 fLambdaCuts[5] = 50.0;
196 fLambdaCuts[6] = 5.0;
197 fLambdaCuts[7] = 0.03;
200 TString configuration="";
202 for (int i=0; i<argc && iResult>=0; i++) {
204 if (!configuration.IsNull()) configuration+=" ";
205 configuration+=argument;
208 if (!configuration.IsNull()) {
209 iResult=Configure(configuration.Data());
215 int AliHLTV0HistoComponent::DoDeinit()
217 // see header file for class documentation
226 int AliHLTV0HistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
229 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
234 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
236 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
237 event->GetStdContent();
238 Int_t nV0 = event->GetNumberOfV0s();
239 AliKFParticle::SetField( event->GetMagneticField() );
241 const double kKsMass = 0.49767;
242 const double kLambdaMass = 1.11568;
243 const double kPi0Mass = 0.13498;
245 std::vector<AliKFParticle> vGammas;
247 for (Int_t iv=0; iv<nV0; iv++) {
249 AliESDtrack *t1=event->GetTrack( event->GetV0(iv)->GetNindex());
250 AliESDtrack *t2=event->GetTrack( event->GetV0(iv)->GetPindex());
252 AliKFParticle kf1( *t1->GetInnerParam(), 11 );
253 AliKFParticle kf2( *t2->GetInnerParam(), 11 );
255 AliKFVertex primVtx( *event->GetPrimaryVertexTracks() );
256 double dev1 = kf1.GetDeviationFromVertex( primVtx );
257 double dev2 = kf2.GetDeviationFromVertex( primVtx );
259 AliKFParticle v0( kf1, kf2 );
260 double devPrim = v0.GetDeviationFromVertex( primVtx );
262 v0.SetProductionVertex( primVtx );
264 Double_t length, sigmaLength;
265 if( v0.GetDecayLength( length, sigmaLength ) ) continue;
267 double dx = v0.GetX()-primVtx.GetX();
268 double dy = v0.GetY()-primVtx.GetY();
269 double r = sqrt(dx*dx + dy*dy);
276 t1->GetTPCNcls()>=fGammaCuts[0]
277 && t2->GetTPCNcls()>=fGammaCuts[0]
278 && dev1>=fGammaCuts[1]
279 && dev2>=fGammaCuts[1]
280 && devPrim <= fGammaCuts[2]
281 && length >= fGammaCuts[3]*sigmaLength
282 && length >= fGammaCuts[4]
283 && r <= fGammaCuts[5]
286 v0.GetMass(mass,error);
287 if( fGamma ) fGamma->Fill( mass );
289 if( TMath::Abs(mass)<=fGammaCuts[6]*error && TMath::Abs(mass)<=fGammaCuts[7] ){
290 AliKFParticle gamma = v0;
291 gamma.SetMassConstraint(0);
292 if( fGammaXY ) fGammaXY->Fill(gamma.GetX(), gamma.GetY());
295 vGammas.push_back( gamma );
299 if( isGamma ) continue;
305 AliKFParticle kf01 = kf1, kf02 = kf2;
306 kf01.SetProductionVertex(v0);
307 kf02.SetProductionVertex(v0);
308 kf01.TransportToProductionVertex();
309 kf02.TransportToProductionVertex();
310 double px1=kf01.GetPx(), py1=kf01.GetPy(), pz1=kf01.GetPz();
311 double px2=kf02.GetPx(), py2=kf02.GetPy(), pz2=kf02.GetPz();
312 double px = px1+px2, py = py1+py2, pz = pz1+pz2;
313 double p = sqrt(px*px+py*py+pz*pz);
314 double l1 = (px*px1 + py*py1 + pz*pz1)/p;
315 double l2 = (px*px2 + py*py2 + pz*pz2)/p;
316 pt = sqrt(px1*px1+py1*py1+pz1*pz1 - l1*l1);
317 ap = (l1-l2)/(l1+l2);
321 t1->GetTPCNcls()>=fAPCuts[0]
322 && t2->GetTPCNcls()>=fAPCuts[0]
325 && devPrim <= fAPCuts[2]
326 && length >= fAPCuts[3]*sigmaLength
327 && length >= fAPCuts[4]
330 if( fAP ) fAP->Fill( ap, pt );
339 t1->GetTPCNcls()>=fKsCuts[0]
340 && t2->GetTPCNcls()>=fKsCuts[0]
343 && devPrim <= fKsCuts[2]
344 && length >= fKsCuts[3]*sigmaLength
345 && length >= fKsCuts[4]
349 AliKFParticle piN( *t1->GetInnerParam(), 211 );
350 AliKFParticle piP( *t2->GetInnerParam(), 211 );
352 AliKFParticle Ks( piN, piP );
353 Ks.SetProductionVertex( primVtx );
356 Ks.GetMass( mass, error);
357 if( fKShort ) fKShort->Fill( mass );
359 if( TMath::Abs( mass - kKsMass )<=fKsCuts[6]*error && TMath::Abs( mass - kKsMass )<=fKsCuts[7] ){
370 t1->GetTPCNcls()>=fLambdaCuts[0]
371 && t2->GetTPCNcls()>=fLambdaCuts[0]
372 && dev1>=fLambdaCuts[1]
373 && dev2>=fLambdaCuts[1]
374 && devPrim <= fLambdaCuts[2]
375 && length >= fLambdaCuts[3]*sigmaLength
376 && length >= fLambdaCuts[4]
377 && r <= fLambdaCuts[5]
378 && TMath::Abs( ap )>.4
381 AliKFParticle kP, kpi;
383 kP = AliKFParticle( *t2->GetInnerParam(), 2212 );
384 kpi = AliKFParticle( *t1->GetInnerParam(), 211 );
386 kP = AliKFParticle( *t1->GetInnerParam(), 2212 );
387 kpi = AliKFParticle( *t2->GetInnerParam(), 211 );
390 AliKFParticle lambda = AliKFParticle( kP, kpi );
391 lambda.SetProductionVertex( primVtx );
393 lambda.GetMass( mass, error);
394 if( fLambda ) fLambda->Fill( mass );
396 if( TMath::Abs( mass - kLambdaMass )<=fLambdaCuts[6]*error && TMath::Abs( mass - kLambdaMass )<=fLambdaCuts[7] ){
406 for(UInt_t g1=0;g1<vGammas.size();g1++){
407 for(UInt_t g2=g1+1;g2<vGammas.size();g2++){
408 AliKFParticle pi0(vGammas.at(g1),vGammas.at(g2));
410 pi0.GetMass(mass,error);
412 if( TMath::Abs( mass - kPi0Mass )<=0.03 ){
419 if( fGamma ) PushBack( (TObject*) fGamma, kAliHLTDataTypeHistogram,0);
421 if( fKShort ) PushBack( (TObject*) fKShort, kAliHLTDataTypeHistogram,0);
423 if( fLambda ) PushBack( (TObject*) fLambda, kAliHLTDataTypeHistogram, 0);
425 if( fPi0 ) PushBack( (TObject*) fPi0, kAliHLTDataTypeHistogram, 0);
427 if( fAP ) PushBack( (TObject*) fAP, kAliHLTDataTypeHistogram,0);
429 if( fGammaXY ) PushBack( (TObject*) fGammaXY, kAliHLTDataTypeHistogram,0);
432 HLTWarning("Wow! Found %d Gammas, %d KShorts, %d Lambdas and even %d Pi0's !!!!! in %d events", fNGammas, fNKShorts, fNLambdas, fNPi0s, fNEvents );
434 else HLTInfo("Found %d Gammas, %d KShorts, %d Lambdas and %d Pi0's in %d events", fNGammas, fNKShorts, fNLambdas, fNPi0s, fNEvents );
439 int AliHLTV0HistoComponent::Configure(const char* arguments)
443 if (!arguments) return iResult;
445 TString allArgs=arguments;
448 TObjArray* pTokens=allArgs.Tokenize(" ");
453 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
454 argument=((TObjString*)pTokens->At(i))->GetString();
455 if (argument.IsNull()) continue;
457 if (argument.CompareTo("-cutsGamma")==0) {
459 for( int j=0; j<8; j++ ){
460 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
462 spar+=((TObjString*)pTokens->At(i))->GetString();
463 fGammaCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
465 if( !bMissingParam ){
466 HLTInfo("Gamma cuts are set to: %s", spar.Data());
469 } else if (argument.CompareTo("-cutsAP")==0) {
471 for( int j=0; j<8; j++ ){
472 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
474 spar+=((TObjString*)pTokens->At(i))->GetString();
475 fAPCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
477 if( !bMissingParam ){
478 HLTInfo("AP cuts are set to: %s", spar.Data());
482 else if (argument.CompareTo("-cutsKs")==0) {
484 for( int j=0; j<8; j++ ){
485 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
487 spar+=((TObjString*)pTokens->At(i))->GetString();
488 fKsCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
490 if( !bMissingParam ){
491 HLTInfo("KShort cuts are set to: %s", spar.Data());
494 } else if (argument.CompareTo("-cutsLambda")==0) {
496 for( int j=0; j<8; j++ ){
497 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
499 spar+=((TObjString*)pTokens->At(i))->GetString();
500 fLambdaCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
502 if( !bMissingParam ){
503 HLTInfo("Lampda cuts are set to: %s", spar.Data());
507 HLTError("unknown argument %s", argument.Data());
518 int AliHLTV0HistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
520 // see header file for class documentation
522 const char* path="HLT/ConfigTPC/KryptonHistoComponent";
523 const char* defaultNotify="";
526 defaultNotify=" (default)";
529 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
530 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
532 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
534 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
535 iResult=Configure(pString->GetString().Data());
537 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
540 HLTError("can not fetch object \"%s\" from CDB", path);