2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: S.Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 //* for The ALICE HLT Project. *
9 //* Permission to use, copy, modify and distribute this software and its *
10 //* documentation strictly for non-commercial purposes is hereby granted *
11 //* without fee, provided that the above copyright notice appears in all *
12 //* copies and that both the copyright notice and this permission notice *
13 //* appear in the supporting documentation. The authors make no claims *
14 //* about the suitability of this software for any purpose. It is *
15 //* provided "as is" without express or implied warranty. *
16 //**************************************************************************
18 /** @file AliHLTV0HistoComponent.cxx
19 @author Sergey Gorbunov
20 @brief Component for ploting charge in clusters
27 #include "AliHLTV0HistoComponent.h"
28 #include "AliCDBEntry.h"
29 #include "AliCDBManager.h"
32 #include "TObjString.h"
33 #include "TObjArray.h"
34 #include "AliKFParticle.h"
35 #include "AliKFVertex.h"
39 #include "AliESDEvent.h"
40 #include "AliESDtrack.h"
42 #include "AliHLTMessage.h"
43 #include "TTimeStamp.h"
45 //#include "AliHLTTPC.h"
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTV0HistoComponent)
52 AliHLTV0HistoComponent::AliHLTV0HistoComponent() :
66 // see header file for class documentation
68 // refer to README to build package
70 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
71 for( int i=0; i<8; i++){
79 AliHLTV0HistoComponent::~AliHLTV0HistoComponent()
81 // see header file for class documentation
84 // Public functions to implement AliHLTComponent's interface.
85 // These functions are required for the registration process
87 const char* AliHLTV0HistoComponent::GetComponentID()
89 // see header file for class documentation
94 void AliHLTV0HistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
96 // see header file for class documentation
98 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
101 AliHLTComponentDataType AliHLTV0HistoComponent::GetOutputDataType()
103 // see header file for class documentation
104 return kAliHLTDataTypeHistogram | kAliHLTDataOriginOut;
107 void AliHLTV0HistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
109 // see header file for class documentation
110 // XXX TODO: Find more realistic values.
115 AliHLTComponent* AliHLTV0HistoComponent::Spawn()
117 // see header file for class documentation
118 return new AliHLTV0HistoComponent;
121 int AliHLTV0HistoComponent::DoInit( int argc, const char** argv ) {
126 fGamma = new TH1F("hGamma","HLT: #gamma inv mass",50,-.06,.2);
127 fGamma->SetFillColor(kGreen);
129 fKShort = new TH1F("hKShort","HLT: K_{s}^{0} inv mass",80,0.4,.6);
130 fKShort->SetFillColor(kGreen);
131 fKShort->SetStats(0);
132 fLambda = new TH1F("hLambda","HLT: #Lambda^{0} inv mass",50,1.0,1.36);
133 fLambda->SetFillColor(kGreen);
134 fLambda->SetStats(0);
136 fPi0 = new TH1F("hPi0","HLT: #Pi^{0} inv mass",50,0.0,0.38);
137 fPi0->SetFillColor(kGreen);
140 fAP = new TH2F("hAP","HLT: Armenteros-Podolanski plot",60,-1.,1.,60,-0.02,0.3);
141 fAP->SetMarkerStyle(8);
142 fAP->SetMarkerSize(0.4);
143 fAP->SetYTitle("p_{t}[GeV]");
144 fAP->SetXTitle("(p^{+}_{L}-p^{-}_{L})/(p^{+}_{L}+p^{-}_{L})");
146 fAP->SetOption("CONT4 Z");
148 fGammaXY = new TH2F("hGammaXY","HLT: #gamma conversions",100,-100.,100.,100,-100.,100.);
149 fGammaXY->SetMarkerStyle(8);
150 fGammaXY->SetMarkerSize(0.4);
151 fGammaXY->SetYTitle("X[cm]");
152 fGammaXY->SetXTitle("Y[cm]");
153 fGammaXY->SetStats(0);
154 fGammaXY->SetOption("COLZ");
163 // [0] == 0 --- N clusters on each daughter track
164 // [1] == 2.5 --- (daughter-primVtx)/sigma >= cut
165 // [2] == 3.5 --- (v0 - primVtx)/sigma <= cut
166 // [3] == 3.0 --- (decay_length)/sigma >= cut
167 // [4] == 0.0 --- (decay_length)[cm] >= cut
168 // [5] == 300.0 --- (v0 radius)[cm] <= cut
169 // [6] == 3.5 --- (v0 mass - true value)/sigma <= cut (for identification)
170 // [7] == 0.05 --- (v0 mass - true value) <= cut (for identification)
177 fGammaCuts[5] = 300.0;
179 fGammaCuts[7] = 0.05;
199 fLambdaCuts[0] = 60; // [0] == 60 --- N clusters on each daughter track
200 fLambdaCuts[1] = 3.0; // [1] == 3.0 --- (daughter-primVtx)/sigma >= cut
201 fLambdaCuts[2] = 3.0; // [2] == 3.0 --- (v0 - primVtx)/sigma <= cut
202 fLambdaCuts[3] = 3.5; // [3] == 3.5 --- (decay_length)/sigma >= cut
203 fLambdaCuts[4] = 4.0; // [4] == 0.0 --- (decay_length)[cm] >= cut
204 fLambdaCuts[5] = 50.0; // [5] == 300.0 --- (v0 radius)[cm] <= cut
205 fLambdaCuts[6] = 4.0; // [6] == 3.5 --- (v0 mass - true value)/sigma <= cut (for identification)
206 fLambdaCuts[7] = 0.03; // [7] == 0.05 --- (v0 mass - true value) <= cut (for identification)
209 TString configuration="";
211 for (int i=0; i<argc && iResult>=0; i++) {
213 if (!configuration.IsNull()) configuration+=" ";
214 configuration+=argument;
217 if (!configuration.IsNull()) {
218 iResult=Configure(configuration.Data());
224 int AliHLTV0HistoComponent::DoDeinit()
226 // see header file for class documentation
236 int AliHLTV0HistoComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/)
239 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
244 fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
249 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
251 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
252 event->GetStdContent();
253 Int_t nV0 = event->GetNumberOfV0s();
254 AliKFParticle::SetField( event->GetMagneticField() );
256 const double kKsMass = 0.49767;
257 const double kLambdaMass = 1.11568;
258 const double kPi0Mass = 0.13498;
260 std::vector<AliKFParticle> vGammas;
262 for (Int_t iv=0; iv<nV0; iv++) {
264 AliESDtrack *t1=event->GetTrack( event->GetV0(iv)->GetNindex());
265 AliESDtrack *t2=event->GetTrack( event->GetV0(iv)->GetPindex());
267 AliKFParticle kf1( *t1, 11 );
268 AliKFParticle kf2( *t2, 11 );
270 AliKFVertex primVtx( *event->GetPrimaryVertexTracks() );
271 double dev1 = kf1.GetDeviationFromVertex( primVtx );
272 double dev2 = kf2.GetDeviationFromVertex( primVtx );
274 AliKFParticle v0( kf1, kf2 );
275 double devPrim = v0.GetDeviationFromVertex( primVtx );
277 v0.SetProductionVertex( primVtx );
279 Double_t length, sigmaLength;
280 if( v0.GetDecayLength( length, sigmaLength ) ) continue;
282 double dx = v0.GetX()-primVtx.GetX();
283 double dy = v0.GetY()-primVtx.GetY();
284 double r = sqrt(dx*dx + dy*dy);
290 AliKFParticle kf01 = kf1, kf02 = kf2;
291 kf01.SetProductionVertex(v0);
292 kf02.SetProductionVertex(v0);
293 kf01.TransportToProductionVertex();
294 kf02.TransportToProductionVertex();
295 double px1=kf01.GetPx(), py1=kf01.GetPy(), pz1=kf01.GetPz();
296 double px2=kf02.GetPx(), py2=kf02.GetPy(), pz2=kf02.GetPz();
297 double px = px1+px2, py = py1+py2, pz = pz1+pz2;
298 double p = sqrt(px*px+py*py+pz*pz);
299 double l1 = (px*px1 + py*py1 + pz*pz1)/p;
300 double l2 = (px*px2 + py*py2 + pz*pz2)/p;
301 pt = sqrt(px1*px1+py1*py1+pz1*pz1 - l1*l1);
302 ap = (l2-l1)/(l1+l2);
306 t1->GetTPCNcls()>=fAPCuts[0]
307 && t2->GetTPCNcls()>=fAPCuts[0]
310 && devPrim <= fAPCuts[2]
311 && length >= fAPCuts[3]*sigmaLength
312 && length >= fAPCuts[4]
315 if( fAP ) fAP->Fill( ap, pt );
323 t1->GetTPCNcls()>=fGammaCuts[0]
324 && t2->GetTPCNcls()>=fGammaCuts[0]
325 && dev1>=fGammaCuts[1]
326 && dev2>=fGammaCuts[1]
327 && devPrim <= fGammaCuts[2]
328 && length >= fGammaCuts[3]*sigmaLength
329 && length >= fGammaCuts[4]
330 && r <= fGammaCuts[5]
333 v0.GetMass(mass,error);
334 if( fGamma ) fGamma->Fill( mass );
336 if( TMath::Abs(mass)<=fGammaCuts[6]*error || TMath::Abs(mass)<=fGammaCuts[7] ){
337 AliKFParticle gamma = v0;
338 gamma.SetMassConstraint(0);
340 && t1->GetTPCNcls()>=60
341 && t2->GetTPCNcls()>=60
342 ) fGammaXY->Fill(gamma.GetX(), gamma.GetY());
345 vGammas.push_back( gamma );
349 if( isGamma ) continue;
357 t1->GetTPCNcls()>=fKsCuts[0]
358 && t2->GetTPCNcls()>=fKsCuts[0]
361 && devPrim <= fKsCuts[2]
362 && length >= fKsCuts[3]*sigmaLength
363 && length >= fKsCuts[4]
367 AliKFParticle piN( *t1, 211 );
368 AliKFParticle piP( *t2, 211 );
370 AliKFParticle Ks( piN, piP );
371 Ks.SetProductionVertex( primVtx );
374 Ks.GetMass( mass, error);
375 if( fKShort ) fKShort->Fill( mass );
376 if( TMath::Abs( mass - kKsMass )<=fKsCuts[6]*error || TMath::Abs( mass - kKsMass )<=fKsCuts[7] ){
387 t1->GetTPCNcls()>=fLambdaCuts[0]
388 && t2->GetTPCNcls()>=fLambdaCuts[0]
389 && dev1>=fLambdaCuts[1]
390 && dev2>=fLambdaCuts[1]
391 && devPrim <= fLambdaCuts[2]
392 && length >= fLambdaCuts[3]*sigmaLength
393 && length >= fLambdaCuts[4]
394 && r <= fLambdaCuts[5]
395 && TMath::Abs( ap )>.4
398 AliKFParticle kP, kpi;
400 kP = AliKFParticle( *t2, 2212 );
401 kpi = AliKFParticle( *t1, 211 );
403 kP = AliKFParticle( *t1, 2212 );
404 kpi = AliKFParticle( *t2, 211 );
407 AliKFParticle lambda = AliKFParticle( kP, kpi );
408 lambda.SetProductionVertex( primVtx );
410 lambda.GetMass( mass, error);
411 if( fLambda ) fLambda->Fill( mass );
412 if( TMath::Abs( mass - kLambdaMass )<=fLambdaCuts[6]*error || TMath::Abs( mass - kLambdaMass )<=fLambdaCuts[7] ){
422 for(UInt_t g1=0;g1<vGammas.size();g1++){
423 for(UInt_t g2=g1+1;g2<vGammas.size();g2++){
424 AliKFParticle pi0(vGammas.at(g1),vGammas.at(g2));
426 pi0.GetMass(mass,error);
428 if( TMath::Abs( mass - kPi0Mass )<=0.03 ){
435 if( fGamma ) PushBack( (TObject*) fGamma, kAliHLTDataTypeHistogram,fUID);
437 if( fKShort ) PushBack( (TObject*) fKShort, kAliHLTDataTypeHistogram,fUID);
439 if( fLambda ) PushBack( (TObject*) fLambda, kAliHLTDataTypeHistogram, fUID);
441 if( fPi0 ) PushBack( (TObject*) fPi0, kAliHLTDataTypeHistogram, fUID);
443 if( fAP ) PushBack( (TObject*) fAP, kAliHLTDataTypeHistogram, fUID);
445 if( fGammaXY ) PushBack( (TObject*) fGammaXY, kAliHLTDataTypeHistogram, fUID);
448 HLTInfo("Found %d Gammas, %d KShorts, %d Lambdas and %d Pi0's in %d events", fNGammas, fNKShorts, fNLambdas, fNPi0s, fNEvents );
450 else HLTInfo("Found %d Gammas, %d KShorts and %d Lambdas in %d events", fNGammas, fNKShorts, fNLambdas, fNEvents );
455 int AliHLTV0HistoComponent::Configure(const char* arguments)
459 if (!arguments) return iResult;
461 TString allArgs=arguments;
464 TObjArray* pTokens=allArgs.Tokenize(" ");
468 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
469 argument=((TObjString*)pTokens->At(i))->GetString();
470 if (argument.IsNull()) continue;
472 if (argument.CompareTo("-cutsGamma")==0) {
474 for( int j=0; j<8; j++ ){
475 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
477 spar+=((TObjString*)pTokens->At(i))->GetString();
478 fGammaCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
480 if( !bMissingParam ){
481 HLTInfo("Gamma cuts are set to: %s", spar.Data());
484 } else if (argument.CompareTo("-cutsAP")==0) {
486 for( int j=0; j<8; j++ ){
487 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
489 spar+=((TObjString*)pTokens->At(i))->GetString();
490 fAPCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
492 if( !bMissingParam ){
493 HLTInfo("AP cuts are set to: %s", spar.Data());
497 else if (argument.CompareTo("-cutsKs")==0) {
499 for( int j=0; j<8; j++ ){
500 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
502 spar+=((TObjString*)pTokens->At(i))->GetString();
503 fKsCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
505 if( !bMissingParam ){
506 HLTInfo("KShort cuts are set to: %s", spar.Data());
509 } else if (argument.CompareTo("-cutsLambda")==0) {
511 for( int j=0; j<8; j++ ){
512 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
514 spar+=((TObjString*)pTokens->At(i))->GetString();
515 fLambdaCuts[j]=((TObjString*)pTokens->At(i))->GetString().Atof();
517 if( !bMissingParam ){
518 HLTInfo("Lampda cuts are set to: %s", spar.Data());
522 HLTError("unknown argument %s", argument.Data());
533 int AliHLTV0HistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
535 // see header file for class documentation
537 const char* path="HLT/ConfigHLT/V0Histo";
538 const char* defaultNotify="";
541 defaultNotify=" (default)";
544 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
545 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
547 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
549 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
550 iResult=Configure(pString->GetString().Data());
552 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
555 HLTError("can not fetch object \"%s\" from CDB", path);