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"
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTD0Trigger)
51 AliHLTD0Trigger::AliHLTD0Trigger()
62 , mD0PDG(TDatabasePDG::Instance()->GetParticle(421)->Mass())
68 , ftwoTrackArray(NULL)
76 // see header file for class documentation
78 // refer to README to build package
80 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
84 const char* AliHLTD0Trigger::fgkOCDBEntry="HLT/ConfigHLT/D0Trigger";
86 AliHLTD0Trigger::~AliHLTD0Trigger()
88 //if(fd0calc){delete fd0calc;}
89 //if(fD0mass){delete fD0mass;}
90 //if(ftwoTrackArray){delete ftwoTrackArray;}
91 // see header file for class documentation
94 const char* AliHLTD0Trigger::GetTriggerName() const
96 // see header file for class documentation
100 AliHLTComponent* AliHLTD0Trigger::Spawn()
102 // see header file for class documentation
103 return new AliHLTD0Trigger;
106 int AliHLTD0Trigger::DoTrigger()
108 // -- Iterator over Data Blocks --
109 //const AliHLTComponentBlockData* iter = NULL;
111 if (!IsDataEvent()) return 0;
117 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT); iter != NULL; iter = GetNextInputObject() ) {
118 fEvent = dynamic_cast<AliHLTMCEvent*>(const_cast<TObject*>( iter ) );
120 HLTError( "No MC Event present!" );
125 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
130 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
131 event->GetStdContent();
132 fField = event->GetMagneticField();
133 const AliESDVertex* pv = event->GetPrimaryVertexTracks();
134 fVertex = new AliESDVertex(*pv);
135 if(fVertex->GetNContributors()<2){
136 HLTWarning("Contributors in ESD vertex to low or not been set");
139 for(Int_t it=0;it<event->GetNumberOfTracks();it++){
140 SingleTrackSelect(event->GetTrack(it));
147 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut);
148 iter != NULL; iter = GetNextInputObject() ) {
149 fVertex = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ));
151 HLTError("Vertex object is corrupted");
156 for ( const AliHLTComponentBlockData* iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
157 iter != NULL; iter = GetNextInputBlock() ) {
158 vector<AliHLTGlobalBarrelTrack> tracksVector;
159 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
162 for(UInt_t i=0;i<tracksVector.size();i++){
163 SingleTrackSelect(&tracksVector[i]);
169 fTotalD0true += nD0true;
171 ftwoTrackArray->Clear();
175 HLTDebug("Number of D0 found: %d",nD0);
176 HLTDebug("Number of True D0 found: %d",nD0true);
177 HLTDebug("Total Number of D0 found: %d",fTotalD0);
178 HLTDebug("Total Number of True D0 found: %d",fTotalD0true);
181 PushBack( (TObject*) fD0mass, kAliHLTDataTypeHistogram,0);
182 PushBack( (TObject*) fD0pt, kAliHLTDataTypeHistogram,0);
189 description.Form("Event contains %d D0(s)", nD0);
190 SetDescription(description.Data());
191 // Enable the central detectors for readout.
192 GetReadoutList().Enable(
193 AliHLTReadoutList::kITSSPD |
194 AliHLTReadoutList::kITSSDD |
195 AliHLTReadoutList::kITSSSD |
196 AliHLTReadoutList::kTPC |
197 AliHLTReadoutList::kTRD |
198 AliHLTReadoutList::kTOF |
199 AliHLTReadoutList::kHMPID |
200 AliHLTReadoutList::kPHOS
202 // Add the available HLT information for readout too.
203 GetTriggerDomain().Add("CLUSTERS", "TPC ");
207 description.Form("No D0");
209 description.Form("No input blocks found");
211 SetDescription(description.Data());
217 int AliHLTD0Trigger::DoInit(int argc, const char** argv)
220 fd0calc = new AliHLTD0toKpi();
221 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);
237 int AliHLTD0Trigger::DoDeinit()
239 // see header file for class documentation
240 if(fd0calc){delete fd0calc;}
241 if(fD0mass){delete fD0mass;}
242 if(ftwoTrackArray){delete ftwoTrackArray;}
243 if(fVertex){delete fVertex;}
247 int AliHLTD0Trigger::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
249 // see header file for class documentation
251 // configure from the specified antry or the default one
252 const char* entry=cdbEntry;
253 if (!entry || entry[0]==0) {
257 return ConfigureFromCDBTObjString(entry);
260 int AliHLTD0Trigger::ScanConfigurationArgument(int argc, const char** argv)
262 // see header file for class documentation
263 if (argc<=0) return 0;
265 TString argument=argv[i];
267 if (argument.CompareTo("-pt")==0) {
268 if (++i>=argc) return -EPROTO;
270 fPtMin=argument.Atof();
273 // minimum dca for decay tracks
274 if (argument.CompareTo("-dca")==0) {
275 if (++i>=argc) return -EPROTO;
277 fdca=argument.Atof();
280 // inv. mass half width.
281 if (argument.CompareTo("-invmass")==0) {
282 if (++i>=argc) return -EPROTO;
284 finvMass=argument.Atof();
288 // cos theta for decay angle
289 if (argument.CompareTo("-costhetastar")==0) {
290 if (++i>=argc) return -EPROTO;
292 fcosThetaStar=argument.Atof();
296 // impact parameter for decay
297 if (argument.CompareTo("-d0")==0) {
298 if (++i>=argc) return -EPROTO;
303 // product of impact parameter
304 if (argument.CompareTo("-d0d0")==0) {
305 if (++i>=argc) return -EPROTO;
307 fd0d0=argument.Atof();
310 // product of impact parameter
311 if (argument.CompareTo("-cospoint")==0) {
312 if (++i>=argc) return -EPROTO;
314 fcosPoint=argument.Atof();
317 if (argument.CompareTo("-plothistogram")==0) {
321 if (argument.CompareTo("-usev0")==0) {
330 void AliHLTD0Trigger::SingleTrackSelect(AliExternalTrackParam* t){
331 // Offline har || på disse kuttene på de to henfallsproduktene
335 if(t->Pt()<fPtMin){return;}
336 if(TMath::Abs(t->GetD(pv[0],pv[1],fField)) > fd0){return;}
346 void AliHLTD0Trigger::RecD0(Int_t& nD0, Int_t& nD0true){
348 Double_t D0,D0bar,xdummy,ydummy;
354 HLTError("No Vertex is set");
357 fVertex->GetXYZ(pvpos);
359 for(UInt_t ip=0;ip<fPos.size();ip++){
360 AliExternalTrackParam *tP=fPos[ip];
361 for(UInt_t in=0;in<fNeg.size();in++){
362 AliExternalTrackParam *tN=fNeg[in];
364 tP->PropagateToDCA(fVertex,fField,kVeryBig); //do I need this??????
365 tN->PropagateToDCA(fVertex,fField,kVeryBig);
367 Double_t dcatPtN = tP->GetDCA(tN,fField,xdummy,ydummy);
368 if(dcatPtN>fdca) { continue; }
370 ftwoTrackArray->AddAt(tP,0);
371 ftwoTrackArray->AddAt(tN,1);
372 AliAODVertex *vertexp1n1 = fd0calc->ReconstructSecondaryVertex(ftwoTrackArray,fField,fVertex);
374 ftwoTrackArray->Clear();
378 vertexp1n1->GetXYZ(svpos);
380 tP->PropagateToDCA(vertexp1n1,fField,kVeryBig);
381 tN->PropagateToDCA(vertexp1n1,fField,kVeryBig);
384 Double_t px[2],py[2],pz[2];
385 Double_t momentum[3];
386 tP->GetPxPyPz(momentum);
387 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
388 tN->GetPxPyPz(momentum);
389 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
391 Short_t dummycharge=0;
392 Double_t *dummyd0 = new Double_t[2];
395 for(Int_t ipr=0;ipr<nprongs;ipr++) dummyd0[ipr]=0.;
396 AliAODRecoDecay *rd = new AliAODRecoDecay(0x0,nprongs,dummycharge,px,py,pz,dummyd0);
397 delete [] dummyd0; dummyd0=NULL;
399 UInt_t pdg2[2],pdg2bar[2];
400 Double_t mPDG,minv,minvbar;
402 pdg2[0]=211; pdg2[1]=321; pdg2bar[0]=321; pdg2bar[1]=211;
403 minv = rd->InvMass(nprongs,pdg2);
404 minvbar = rd->InvMass(nprongs,pdg2bar);
405 if(TMath::Abs(minv-mD0PDG)>finvMass && TMath::Abs(minv-mD0PDG)>finvMass) {continue; delete vertexp1n1; delete rd;}
407 if((TMath::Abs(fd0calc->InvMass(tN,tP)-mD0PDG)) > finvMass && TMath::Abs((fd0calc->InvMass(tP,tN))-mD0PDG) > finvMass){continue;}
408 fd0calc->cosThetaStar(tN,tP,D0,D0bar);
409 if(TMath::Abs(D0) > fcosThetaStar && TMath::Abs(D0bar) > fcosThetaStar){continue;}
410 d0[0] = tP->GetD(pvpos[0],pvpos[1],fField);
411 d0[1] = tN->GetD(pvpos[0],pvpos[1],fField);
412 if((d0[0]*d0[1]) > fd0d0){continue;}
413 if(fd0calc->pointingAngle(tN,tP,pvpos,svpos) < fcosPoint){continue;}
416 //fD0mass->Fill(minv);
417 //fD0mass->Fill(minvbar);
418 fD0mass->Fill(fd0calc->InvMass(tN,tP));
419 fD0mass->Fill(fd0calc->InvMass(tP,tN));
420 fD0pt->Fill(fd0calc->Pt(tP,tN));
422 if((fd0calc->InvMass(tN,tP) - mD0PDG) > finvMass){
423 fD0mass->Fill(fd0calc->InvMass(tN,tP));
426 fD0mass->Fill(fd0calc->InvMass(tP,tN));
431 if(CheckTrackMC(tP,tN)){
441 Int_t AliHLTD0Trigger::RecV0(const TObject* iter){
448 AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
449 event->GetStdContent();
450 Int_t nV0 = event->GetNumberOfV0s();
451 Double_t field = event->GetMagneticField();
452 const AliESDVertex* pv = event->GetPrimaryVertexTracks();
455 for (Int_t iv=0; iv<nV0; iv++) {
457 AliESDtrack *tN=event->GetTrack( event->GetV0(iv)->GetNindex());
458 AliESDtrack *tP=event->GetTrack( event->GetV0(iv)->GetPindex());
460 if(tN->Pt()<fPtMin && tP->Pt()<fPtMin){continue;} //||????
462 d0[0] = tP->GetD(pvpos[0],pvpos[1],field);
463 d0[1] = tN->GetD(pvpos[0],pvpos[1],field);
465 if(d0[0]>fd0 && d0[0]>fd0){continue;} // make sure < or>
467 event->GetV0(iv)->GetXYZ(svpos[0],svpos[1],svpos[2]);
469 if(!tN->PropagateTo(svpos[0],field) && !tP->PropagateTo(svpos[0],field)){
470 HLTInfo("Tracks could not be propagated to secondary vertex");
475 if(tN->GetDCA(tP,field,tmp1,tmp2) > fdca){continue;}
477 if((fd0calc->InvMass(tN,tP) - mD0PDG) > finvMass && (fd0calc->InvMass(tP,tN) - mD0PDG) > finvMass){continue;}
478 fd0calc->cosThetaStar(tN,tP,D0,D0bar);
479 if(D0 > fcosThetaStar && D0bar > fcosThetaStar){continue;}
480 if((d0[0]*d0[1]) > fd0d0){continue;}
481 if(fd0calc->pointingAngle(tN,tP,pvpos,svpos) < fcosPoint){continue;}
484 if((fd0calc->InvMass(tN,tP) - mD0PDG) > finvMass){
485 fD0mass->Fill(fd0calc->InvMass(tN,tP));
488 fD0mass->Fill(fd0calc->InvMass(tP,tN));
494 bool AliHLTD0Trigger::CheckTrackMC(AliExternalTrackParam* pt, AliExternalTrackParam* pn){
496 if(!fEvent){return false;}
498 int lP = pt->GetLabel();
499 int lN = pn->GetLabel();
503 int imP = (fEvent->Particle(lP))->GetFirstMother();
504 int imN = (fEvent->Particle(lN))->GetFirstMother();
506 if(imP>=0 && imN>=0){
507 TParticle * mP = fEvent->Particle(imP);
508 TParticle * mN = fEvent->Particle(imN);
509 if(fabs(mP->GetPdgCode())==421 && fabs(mN->GetPdgCode())==421 && imP == imN){