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"
45 #include "AliHLTD0Candidate.h"
47 #include "TClonesArray.h"
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTD0Trigger)
52 AliHLTD0Trigger::AliHLTD0Trigger()
63 , fD0PDG(TDatabasePDG::Instance()->GetParticle(421)->Mass())
69 , ftwoTrackArray(NULL)
72 , fSendCandidate(false)
73 , fCandidateTree(NULL)
74 , fCandidateArray(NULL)
78 // see header file for class documentation
80 // refer to README to build package
82 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
86 const char* AliHLTD0Trigger::fgkOCDBEntry="HLT/ConfigHLT/D0Trigger";
88 AliHLTD0Trigger::~AliHLTD0Trigger()
93 const char* AliHLTD0Trigger::GetTriggerName() const
95 // see header file for class documentation
99 AliHLTComponent* AliHLTD0Trigger::Spawn()
101 // see header file for class documentation
102 return new AliHLTD0Trigger;
105 int AliHLTD0Trigger::DoTrigger()
107 // -- Iterator over Data Blocks --
108 //const AliHLTComponentBlockData* iter = NULL;
110 if (!IsDataEvent()) return 0;
112 HLTDebug("Used Cuts: pT: %f , DCA: %f , InvMass: %f , CosThetaStar: %f , d0: %f , d0xd0: %f , CosPointingAngle: %f",fPtMin,fdca,finvMass,fcosThetaStar,fd0,fd0d0,fcosPoint);
117 const AliESDVertex *Vertex=NULL;
118 if(fCandidateArray){fCandidateArray->Clear();}
120 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
125 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
126 event->GetStdContent();
127 Double_t field = event->GetMagneticField();
128 Vertex = event->GetPrimaryVertexTracks();
129 if(!Vertex || Vertex->GetNContributors()<2){
130 HLTDebug("Contributors in ESD vertex to low or not been set");
133 for(Int_t it=0;it<event->GetNumberOfTracks();it++){
134 SingleTrackSelect(event->GetTrack(it),Vertex,field);
136 RecD0(nD0,Vertex,field);
140 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut);
141 iter != NULL; iter = GetNextInputObject() ) {
142 Vertex = dynamic_cast<const AliESDVertex*>(iter);
144 HLTError("Vertex object is corrupted");
149 for ( const AliHLTComponentBlockData* iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
150 iter != NULL; iter = GetNextInputBlock() ) {
151 vector<AliHLTGlobalBarrelTrack> tracksVector;
152 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
154 Double_t field = GetBz();
156 for(UInt_t i=0;i<tracksVector.size();i++){
157 SingleTrackSelect(&tracksVector[i],Vertex,field);
159 RecD0(nD0,Vertex,field);
165 ftwoTrackArray->Clear();
169 HLTDebug("Number of D0 found: %d",nD0);
170 HLTDebug("Total Number of D0 found: %d",fTotalD0);
173 PushBack( (TObject*) fD0mass, kAliHLTDataTypeHistogram,0);
174 PushBack( (TObject*) fD0pt, kAliHLTDataTypeHistogram,0);
177 PushBack( (TObject*) fCandidateArray, kAliHLTDataTypeTObjArray,0);
179 if(fWriteFile && fCandidateTree!=NULL){
180 fCandidateTree->Fill();
183 fCandidateArray->Clear();
190 description.Form("Event contains %d D0(s)", nD0);
191 SetDescription(description.Data());
192 // Enable the central detectors for readout.
193 GetReadoutList().Enable(
194 AliHLTReadoutList::kITSSPD |
195 AliHLTReadoutList::kITSSDD |
196 AliHLTReadoutList::kITSSSD |
197 AliHLTReadoutList::kTPC |
198 AliHLTReadoutList::kTRD |
199 AliHLTReadoutList::kTOF |
200 AliHLTReadoutList::kHMPID |
201 AliHLTReadoutList::kPHOS
203 // Add the available HLT information for readout too.
204 GetTriggerDomain().Add("CLUSTERS", "TPC ");
208 description.Form("No D0");
210 description.Form("No input blocks found");
212 SetDescription(description.Data());
218 int AliHLTD0Trigger::DoInit(int argc, const char** argv)
220 // component initialization
222 fd0calc = new AliHLTD0toKpi();
223 ftwoTrackArray = new TObjArray(2);
224 // see header file for class documentation
225 fD0mass = new TH1F("hMass","D^{0} mass plot",100,1.7,2);
226 fD0pt = new TH1F("hPt","D^{0} Pt plot",20,0,20);
227 // first configure the default
229 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
231 // configure from the command line parameters if specified
232 if (iResult>=0 && argc>0)
233 iResult=ConfigureFromArgumentString(argc, argv);
235 if (iResult<0) return iResult;
237 if(fSendCandidate || fWriteFile){
238 fCandidateArray = new TClonesArray("AliHLTD0Candidate",1000);
241 fCandidateTree = new TTree("D0Candidates","Tree with D0 Candidates");
242 fCandidateTree->Branch("Candidates","TClonesArray",&fCandidateArray,32000,99);
248 int AliHLTD0Trigger::DoDeinit()
250 // see header file for class documentation
251 if(fd0calc){delete fd0calc; fd0calc = NULL;}
252 if(fD0mass){delete fD0mass; fD0mass = NULL;}
253 if(fD0pt){delete fD0pt; fD0pt=NULL;}
254 if(ftwoTrackArray){delete ftwoTrackArray; ftwoTrackArray=NULL;}
256 TFile *mcFile = new TFile("D0_Candidates.root","RECREATE");
257 fCandidateTree->Write();
260 if(fCandidateTree){delete fCandidateTree; fCandidateTree=NULL;}
261 if(fCandidateArray){delete fCandidateArray; fCandidateArray=NULL;}
265 int AliHLTD0Trigger::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
267 // see header file for class documentation
269 // configure from the specified antry or the default one
270 const char* entry=cdbEntry;
271 if (!entry || entry[0]==0) {
275 return ConfigureFromCDBTObjString(entry);
278 int AliHLTD0Trigger::ScanConfigurationArgument(int argc, const char** argv)
280 // see header file for class documentation
281 if (argc<=0) return 0;
283 TString argument=argv[i];
285 if (argument.CompareTo("-pt")==0) {
286 if (++i>=argc) return -EPROTO;
288 fPtMin=argument.Atof();
291 // minimum dca for decay tracks
292 if (argument.CompareTo("-dca")==0) {
293 if (++i>=argc) return -EPROTO;
295 fdca=argument.Atof();
298 // inv. mass half width.
299 if (argument.CompareTo("-invmass")==0) {
300 if (++i>=argc) return -EPROTO;
302 finvMass=argument.Atof();
306 // cos theta for decay angle
307 if (argument.CompareTo("-costhetastar")==0) {
308 if (++i>=argc) return -EPROTO;
310 fcosThetaStar=argument.Atof();
314 // impact parameter for decay
315 if (argument.CompareTo("-d0")==0) {
316 if (++i>=argc) return -EPROTO;
321 // product of impact parameter
322 if (argument.CompareTo("-d0d0")==0) {
323 if (++i>=argc) return -EPROTO;
325 fd0d0=argument.Atof();
328 // product of impact parameter
329 if (argument.CompareTo("-cospoint")==0) {
330 if (++i>=argc) return -EPROTO;
332 fcosPoint=argument.Atof();
335 if (argument.CompareTo("-plothistogram")==0) {
339 if (argument.CompareTo("-usev0")==0) {
343 if (argument.CompareTo("-useKF")==0) {
347 if (argument.CompareTo("-send-candidates")==0) {
351 if (argument.CompareTo("-write-file")==0) {
360 void AliHLTD0Trigger::SingleTrackSelect(AliExternalTrackParam* t, const AliESDVertex* pv, Double_t field){
361 // Offline uses || on the cuts of decay products
367 if(t->Pt()<fPtMin){return;}
368 if(TMath::Abs(t->GetD(pvpos[0],pvpos[1],field)) > fd0){return;}
378 void AliHLTD0Trigger::RecD0(Int_t& nD0,const AliESDVertex* pv, Double_t field){
379 // Default way of reconstructing D0's. Both from ESD and Barreltracks
380 Double_t D0,D0bar,xdummy,ydummy;
386 HLTError("No Vertex is set");
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(pv,field,kVeryBig); //do I need this??????
397 tN->PropagateToDCA(pv,field,kVeryBig);
399 Double_t dcatPtN = tP->GetDCA(tN,field,xdummy,ydummy);
400 if(dcatPtN>fdca) { continue; }
402 ftwoTrackArray->AddAt(tP,0);
403 ftwoTrackArray->AddAt(tN,1);
404 AliAODVertex *vertexp1n1 = fd0calc->ReconstructSecondaryVertex(ftwoTrackArray,field,pv,fuseKF);
406 ftwoTrackArray->Clear();
410 vertexp1n1->GetXYZ(svpos);
412 tP->PropagateToDCA(vertexp1n1,field,kVeryBig);
413 tN->PropagateToDCA(vertexp1n1,field,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-fD0PDG)>finvMass && TMath::Abs(minv-fD0PDG)>finvMass) {continue; delete vertexp1n1; delete rd;}
439 if((TMath::Abs(fd0calc->InvMass(tN,tP)-fD0PDG)) > finvMass && TMath::Abs((fd0calc->InvMass(tP,tN))-fD0PDG) > finvMass){
440 vertexp1n1->RemoveCovMatrix();
442 ftwoTrackArray->Clear();
446 fd0calc->cosThetaStar(tN,tP,D0,D0bar);
447 if(TMath::Abs(D0) > fcosThetaStar && TMath::Abs(D0bar) > fcosThetaStar){
448 vertexp1n1->RemoveCovMatrix();
450 ftwoTrackArray->Clear();
454 d0[0] = tP->GetD(pvpos[0],pvpos[1],field);
455 d0[1] = tN->GetD(pvpos[0],pvpos[1],field);
456 if((d0[0]*d0[1]) > fd0d0){
457 vertexp1n1->RemoveCovMatrix();
459 ftwoTrackArray->Clear();
463 if(fd0calc->pointingAngle(tN,tP,pvpos,svpos) < fcosPoint){
464 vertexp1n1->RemoveCovMatrix();
466 ftwoTrackArray->Clear();
471 //fD0mass->Fill(minv);
472 //fD0mass->Fill(minvbar);
473 fD0mass->Fill(fd0calc->InvMass(tN,tP));
474 fD0mass->Fill(fd0calc->InvMass(tP,tN));
475 fD0pt->Fill(fd0calc->Pt(tP,tN));
477 if((fd0calc->InvMass(tN,tP) - fD0PDG) > finvMass){
478 fD0mass->Fill(fd0calc->InvMass(tN,tP));
481 fD0mass->Fill(fd0calc->InvMass(tP,tN));
486 if(fSendCandidate && fCandidateArray){
487 new(fCandidateArray->AddrAt(nD0)) AliHLTD0Candidate(fd0calc->InvMass(tN,tP),fd0calc->InvMass(tP,tN),fd0calc->Pt(tP,tN),tP->GetLabel(),tN->GetLabel(),tP->Pt(),tN->Pt());
491 vertexp1n1->RemoveCovMatrix();
493 ftwoTrackArray->Clear();
496 ftwoTrackArray->Clear();
499 Int_t AliHLTD0Trigger::RecV0(const TObject* iter){
500 // Reconstruction D0's from the V0 found by the V0 finder
507 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
508 event->GetStdContent();
509 Int_t nV0 = event->GetNumberOfV0s();
510 Double_t field = event->GetMagneticField();
511 const AliESDVertex* pv = event->GetPrimaryVertexTracks();
514 for (Int_t iv=0; iv<nV0; iv++) {
516 AliESDtrack *tN=event->GetTrack( event->GetV0(iv)->GetNindex());
517 AliESDtrack *tP=event->GetTrack( event->GetV0(iv)->GetPindex());
519 if(tN->Pt()<fPtMin && tP->Pt()<fPtMin){continue;} //||????
521 d0[0] = tP->GetD(pvpos[0],pvpos[1],field);
522 d0[1] = tN->GetD(pvpos[0],pvpos[1],field);
524 if(d0[0]>fd0 && d0[0]>fd0){continue;} // make sure < or>
526 event->GetV0(iv)->GetXYZ(svpos[0],svpos[1],svpos[2]);
528 if(!tN->PropagateTo(svpos[0],field) && !tP->PropagateTo(svpos[0],field)){
529 HLTInfo("Tracks could not be propagated to secondary vertex");
534 if(tN->GetDCA(tP,field,tmp1,tmp2) > fdca){continue;}
536 if((fd0calc->InvMass(tN,tP) - fD0PDG) > finvMass && (fd0calc->InvMass(tP,tN) - fD0PDG) > finvMass){continue;}
537 fd0calc->cosThetaStar(tN,tP,D0,D0bar);
538 if(D0 > fcosThetaStar && D0bar > fcosThetaStar){continue;}
539 if((d0[0]*d0[1]) > fd0d0){continue;}
540 if(fd0calc->pointingAngle(tN,tP,pvpos,svpos) < fcosPoint){continue;}
543 if((fd0calc->InvMass(tN,tP) - fD0PDG) > finvMass){
544 fD0mass->Fill(fd0calc->InvMass(tN,tP));
547 fD0mass->Fill(fd0calc->InvMass(tP,tN));
553 void AliHLTD0Trigger::GetOCDBObjectDescription( TMap* const targetMap)
555 // Get a list of OCDB object description.
556 if (!targetMap) return;
557 targetMap->Add(new TObjString("HLT/ConfigHLT/D0Trigger"),new TObjString("Object with default cuts for D0 reconstruction" ));