1 // $Id: AliHLTD0Trigger.cxx
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: Gaute Ovrebekk *
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 AliHLTD0Trigger.cxx
19 /// @author Gaute Ovrebekk
21 /// @brief HLT trigger component for D0->Kpi
23 // see header file for class documentation
25 // refer to README to build package
27 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29 #include "AliHLTD0Trigger.h"
30 #include "AliESDEvent.h"
32 #include "AliHLTTriggerDecision.h"
33 #include "AliHLTDomainEntry.h"
34 #include "AliHLTGlobalBarrelTrack.h"
35 #include "TObjArray.h"
36 #include "TObjString.h"
37 #include "TDatabasePDG.h"
38 #include "AliESDVertex.h"
40 #include "AliHLTD0toKpi.h"
41 #include "AliAODVertex.h"
42 #include "AliESDVertex.h"
43 #include "AliAODRecoDecay.h"
44 #include "AliHLTMCEvent.h"
46 #include "TParticle.h"
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTD0Trigger)
52 AliHLTD0Trigger::AliHLTD0Trigger()
63 , mD0PDG(TDatabasePDG::Instance()->GetParticle(421)->Mass())
69 , ftwoTrackArray(NULL)
79 // see header file for class documentation
81 // refer to README to build package
83 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
87 const char* AliHLTD0Trigger::fgkOCDBEntry="HLT/ConfigHLT/D0Trigger";
89 AliHLTD0Trigger::~AliHLTD0Trigger()
91 // TODO: code audit 2010-07-23 delete obsolete code
92 //if(fd0calc){delete fd0calc;}
93 //if(fD0mass){delete fD0mass;}
94 //if(ftwoTrackArray){delete ftwoTrackArray;}
95 // see header file for class documentation
98 const char* AliHLTD0Trigger::GetTriggerName() const
100 // see header file for class documentation
104 AliHLTComponent* AliHLTD0Trigger::Spawn()
106 // see header file for class documentation
107 return new AliHLTD0Trigger;
110 int AliHLTD0Trigger::DoTrigger()
112 // -- Iterator over Data Blocks --
113 //const AliHLTComponentBlockData* iter = NULL;
115 if (!IsDataEvent()) return 0;
117 HLTDebug("Used Cuts: pT: %f , DCA: %f , InvMass: %f , CosThetaStar: %f , d0: %f , d0xd0: %f , CosPointingAngle: %f",fPtMin,fdca,finvMass,fcosThetaStar,fd0,fd0d0,fcosPoint);
124 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT); iter != NULL; iter = GetNextInputObject() ) {
125 fEvent = dynamic_cast<AliHLTMCEvent*>(const_cast<TObject*>( iter ) );
127 HLTError( "No MC Event present!" );
132 // TODO: code audit 2010-07-23 get rid of fVertex as member variable, the object
133 // is changing every event and already available after the object extraction
134 // change internal functions to pass the vertex as parameter. Setting the variable
135 // to NULL here to be coherent with checks further down.
138 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
143 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
144 event->GetStdContent();
145 fField = event->GetMagneticField();
146 const AliESDVertex* pv = event->GetPrimaryVertexTracks();
147 // TODO: code audit 2010-07-23 this is a memory leak, fVertex is not deleted
148 //fVertex = new AliESDVertex(*pv);
149 // use the vertex object from the ESD, right now we need to cast away the
150 // const'ness, think about changing the functions to use const AliESDVertex* objects
151 fVertex = const_cast<AliESDVertex*>(pv);
152 if(fVertex->GetNContributors()<2){
153 HLTDebug("Contributors in ESD vertex to low or not been set");
156 for(Int_t it=0;it<event->GetNumberOfTracks();it++){
157 // TODO: code audit 2010-07-23 pass vertex object as parameter
158 SingleTrackSelect(event->GetTrack(it));
161 // TODO: code audit 2010-07-23 pass vertex object as parameter
162 if (fVertex) RecD0(nD0,nD0Onetrue,nD0true);
166 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut);
167 iter != NULL; iter = GetNextInputObject() ) {
168 fVertex = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ));
170 HLTError("Vertex object is corrupted");
175 for ( const AliHLTComponentBlockData* iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
176 iter != NULL; iter = GetNextInputBlock() ) {
177 vector<AliHLTGlobalBarrelTrack> tracksVector;
178 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
181 for(UInt_t i=0;i<tracksVector.size();i++){
182 SingleTrackSelect(&tracksVector[i]);
184 // TODO: code audit 2010-07-23 pass vertex object as parameter
185 if (fVertex) RecD0(nD0,nD0Onetrue,nD0true);
189 fTotalD0Onetrue += nD0Onetrue;
190 fTotalD0true += nD0true;
192 ftwoTrackArray->Clear();
196 HLTDebug("Number of D0 found: %d",nD0);
197 HLTDebug("Number of D0 candidates with one track as D0 decay: %d",nD0Onetrue);
198 HLTDebug("Number of True D0 found: %d",nD0true);
199 HLTDebug("Total Number of D0 found: %d",fTotalD0);
200 HLTDebug("Number of D0 candidates with one track as D0 decay: %d",fTotalD0Onetrue);
201 HLTDebug("Total Number of True D0 found: %d",fTotalD0true);
204 PushBack( (TObject*) fD0mass, kAliHLTDataTypeHistogram,0);
205 PushBack( (TObject*) fD0pt, kAliHLTDataTypeHistogram,0);
212 description.Form("Event contains %d D0(s)", nD0);
213 SetDescription(description.Data());
214 // Enable the central detectors for readout.
215 GetReadoutList().Enable(
216 AliHLTReadoutList::kITSSPD |
217 AliHLTReadoutList::kITSSDD |
218 AliHLTReadoutList::kITSSSD |
219 AliHLTReadoutList::kTPC |
220 AliHLTReadoutList::kTRD |
221 AliHLTReadoutList::kTOF |
222 AliHLTReadoutList::kHMPID |
223 AliHLTReadoutList::kPHOS
225 // Add the available HLT information for readout too.
226 GetTriggerDomain().Add("CLUSTERS", "TPC ");
230 description.Form("No D0");
232 description.Form("No input blocks found");
234 SetDescription(description.Data());
240 int AliHLTD0Trigger::DoInit(int argc, const char** argv)
243 fd0calc = new AliHLTD0toKpi();
244 ftwoTrackArray = new TObjArray(2);
247 // see header file for class documentation
248 fD0mass = new TH1F("hMass","D^{0} mass plot",100,1.7,2);
249 fD0pt = new TH1F("hPt","D^{0} Pt plot",20,0,20);
250 // first configure the default
252 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
254 // configure from the command line parameters if specified
255 if (iResult>=0 && argc>0)
256 iResult=ConfigureFromArgumentString(argc, argv);
260 int AliHLTD0Trigger::DoDeinit()
262 // see header file for class documentation
264 // TODO: code audit 2010-07-23 deleted variables to be set to NULL
265 if(fd0calc){delete fd0calc;}
266 if(fD0mass){delete fD0mass;}
267 // TODO: code audit 2010-07-23 delete obsolete code
268 //if(ftwoTrackArray){delete ftwoTrackArray;}
269 //if(fVertex){delete fVertex;}
273 int AliHLTD0Trigger::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
275 // see header file for class documentation
277 // configure from the specified antry or the default one
278 const char* entry=cdbEntry;
279 if (!entry || entry[0]==0) {
283 return ConfigureFromCDBTObjString(entry);
286 int AliHLTD0Trigger::ScanConfigurationArgument(int argc, const char** argv)
288 // see header file for class documentation
289 if (argc<=0) return 0;
291 TString argument=argv[i];
293 if (argument.CompareTo("-pt")==0) {
294 if (++i>=argc) return -EPROTO;
296 fPtMin=argument.Atof();
299 // minimum dca for decay tracks
300 if (argument.CompareTo("-dca")==0) {
301 if (++i>=argc) return -EPROTO;
303 fdca=argument.Atof();
306 // inv. mass half width.
307 if (argument.CompareTo("-invmass")==0) {
308 if (++i>=argc) return -EPROTO;
310 finvMass=argument.Atof();
314 // cos theta for decay angle
315 if (argument.CompareTo("-costhetastar")==0) {
316 if (++i>=argc) return -EPROTO;
318 fcosThetaStar=argument.Atof();
322 // impact parameter for decay
323 if (argument.CompareTo("-d0")==0) {
324 if (++i>=argc) return -EPROTO;
329 // product of impact parameter
330 if (argument.CompareTo("-d0d0")==0) {
331 if (++i>=argc) return -EPROTO;
333 fd0d0=argument.Atof();
336 // product of impact parameter
337 if (argument.CompareTo("-cospoint")==0) {
338 if (++i>=argc) return -EPROTO;
340 fcosPoint=argument.Atof();
343 if (argument.CompareTo("-plothistogram")==0) {
347 if (argument.CompareTo("-usev0")==0) {
351 if (argument.CompareTo("-useKF")==0) {
359 void AliHLTD0Trigger::SingleTrackSelect(AliExternalTrackParam* t){
360 // Offline har || på disse kuttene på de to henfallsproduktene
361 // TODO: code audit 2010-07-23 translate all comments
362 if (!fVertex) return;
367 if(t->Pt()<fPtMin){return;}
368 if(TMath::Abs(t->GetD(pv[0],pv[1],fField)) > fd0){return;}
378 void AliHLTD0Trigger::RecD0(Int_t& nD0,Int_t& nD0Onetrue ,Int_t& nD0true){
380 Double_t D0,D0bar,xdummy,ydummy;
386 HLTError("No Vertex is set");
389 fVertex->GetXYZ(pvpos);
391 for(UInt_t ip=0;ip<fPos.size();ip++){
392 AliExternalTrackParam *tP=fPos[ip];
393 for(UInt_t in=0;in<fNeg.size();in++){
394 AliExternalTrackParam *tN=fNeg[in];
396 tP->PropagateToDCA(fVertex,fField,kVeryBig); //do I need this??????
397 tN->PropagateToDCA(fVertex,fField,kVeryBig);
399 Double_t dcatPtN = tP->GetDCA(tN,fField,xdummy,ydummy);
400 if(dcatPtN>fdca) { continue; }
402 ftwoTrackArray->AddAt(tP,0);
403 ftwoTrackArray->AddAt(tN,1);
404 AliAODVertex *vertexp1n1 = fd0calc->ReconstructSecondaryVertex(ftwoTrackArray,fField,fVertex,fuseKF);
406 ftwoTrackArray->Clear();
410 vertexp1n1->GetXYZ(svpos);
412 tP->PropagateToDCA(vertexp1n1,fField,kVeryBig);
413 tN->PropagateToDCA(vertexp1n1,fField,kVeryBig);
416 Double_t px[2],py[2],pz[2];
417 Double_t momentum[3];
418 tP->GetPxPyPz(momentum);
419 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
420 tN->GetPxPyPz(momentum);
421 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
423 Short_t dummycharge=0;
424 Double_t *dummyd0 = new Double_t[2];
427 for(Int_t ipr=0;ipr<nprongs;ipr++) dummyd0[ipr]=0.;
428 AliAODRecoDecay *rd = new AliAODRecoDecay(0x0,nprongs,dummycharge,px,py,pz,dummyd0);
429 delete [] dummyd0; dummyd0=NULL;
431 UInt_t pdg2[2],pdg2bar[2];
432 Double_t mPDG,minv,minvbar;
434 pdg2[0]=211; pdg2[1]=321; pdg2bar[0]=321; pdg2bar[1]=211;
435 minv = rd->InvMass(nprongs,pdg2);
436 minvbar = rd->InvMass(nprongs,pdg2bar);
437 if(TMath::Abs(minv-mD0PDG)>finvMass && TMath::Abs(minv-mD0PDG)>finvMass) {continue; delete vertexp1n1; delete rd;}
439 if((TMath::Abs(fd0calc->InvMass(tN,tP)-mD0PDG)) > finvMass && TMath::Abs((fd0calc->InvMass(tP,tN))-mD0PDG) > finvMass){continue;}
440 fd0calc->cosThetaStar(tN,tP,D0,D0bar);
441 if(TMath::Abs(D0) > fcosThetaStar && TMath::Abs(D0bar) > fcosThetaStar){continue;}
442 d0[0] = tP->GetD(pvpos[0],pvpos[1],fField);
443 d0[1] = tN->GetD(pvpos[0],pvpos[1],fField);
444 if((d0[0]*d0[1]) > fd0d0){continue;}
445 if(fd0calc->pointingAngle(tN,tP,pvpos,svpos) < fcosPoint){continue;}
448 //fD0mass->Fill(minv);
449 //fD0mass->Fill(minvbar);
450 fD0mass->Fill(fd0calc->InvMass(tN,tP));
451 fD0mass->Fill(fd0calc->InvMass(tP,tN));
452 fD0pt->Fill(fd0calc->Pt(tP,tN));
454 if((fd0calc->InvMass(tN,tP) - mD0PDG) > finvMass){
455 fD0mass->Fill(fd0calc->InvMass(tN,tP));
458 fD0mass->Fill(fd0calc->InvMass(tP,tN));
463 if(CheckTrackMC(tP,tN)==2){
466 if(CheckTrackMC(tP,tN)==1){
476 Int_t AliHLTD0Trigger::RecV0(const TObject* iter){
483 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
484 event->GetStdContent();
485 Int_t nV0 = event->GetNumberOfV0s();
486 Double_t field = event->GetMagneticField();
487 const AliESDVertex* pv = event->GetPrimaryVertexTracks();
490 for (Int_t iv=0; iv<nV0; iv++) {
492 AliESDtrack *tN=event->GetTrack( event->GetV0(iv)->GetNindex());
493 AliESDtrack *tP=event->GetTrack( event->GetV0(iv)->GetPindex());
495 if(tN->Pt()<fPtMin && tP->Pt()<fPtMin){continue;} //||????
497 d0[0] = tP->GetD(pvpos[0],pvpos[1],field);
498 d0[1] = tN->GetD(pvpos[0],pvpos[1],field);
500 if(d0[0]>fd0 && d0[0]>fd0){continue;} // make sure < or>
502 event->GetV0(iv)->GetXYZ(svpos[0],svpos[1],svpos[2]);
504 if(!tN->PropagateTo(svpos[0],field) && !tP->PropagateTo(svpos[0],field)){
505 HLTInfo("Tracks could not be propagated to secondary vertex");
510 if(tN->GetDCA(tP,field,tmp1,tmp2) > fdca){continue;}
512 if((fd0calc->InvMass(tN,tP) - mD0PDG) > finvMass && (fd0calc->InvMass(tP,tN) - mD0PDG) > finvMass){continue;}
513 fd0calc->cosThetaStar(tN,tP,D0,D0bar);
514 if(D0 > fcosThetaStar && D0bar > fcosThetaStar){continue;}
515 if((d0[0]*d0[1]) > fd0d0){continue;}
516 if(fd0calc->pointingAngle(tN,tP,pvpos,svpos) < fcosPoint){continue;}
519 if((fd0calc->InvMass(tN,tP) - mD0PDG) > finvMass){
520 fD0mass->Fill(fd0calc->InvMass(tN,tP));
523 fD0mass->Fill(fd0calc->InvMass(tP,tN));
529 int AliHLTD0Trigger::CheckTrackMC(AliExternalTrackParam* pt, AliExternalTrackParam* pn){
531 if(!fEvent){return 0;}
533 int lP = pt->GetLabel();
534 int lN = pn->GetLabel();
538 int imP = (fEvent->Particle(lP))->GetFirstMother();
539 int imN = (fEvent->Particle(lN))->GetFirstMother();
541 if(imP>=0 && imN>=0){
542 TParticle * mP = fEvent->Particle(imP);
543 TParticle * mN = fEvent->Particle(imN);
544 if(fabs(mP->GetPdgCode())==421 && fabs(mN->GetPdgCode())==421 && imP == imN){
547 if(fabs(mP->GetPdgCode())==421 || fabs(mN->GetPdgCode())==421 && imP == imN){
554 void AliHLTD0Trigger::GetOCDBObjectDescription( TMap* const targetMap)
556 // Get a list of OCDB object description.
557 if (!targetMap) return;
558 targetMap->Add(new TObjString("HLT/ConfigHLT/D0Trigger"),new TObjString("Object with default cuts for D0 reconstruction" ));