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: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
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 AliHLTTriggerCosmics.cxx
19 /// @author Kalliopi Kanaki
21 /// @brief HLT trigger component for tagging cosmics tracks in the TPC
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 "AliHLTTriggerCosmics.h"
30 #include "AliESDtrack.h"
31 #include "AliESDEvent.h"
32 #include "AliHLTTriggerDecision.h"
33 #include "AliHLTDomainEntry.h"
34 #include "AliHLTGlobalBarrelTrack.h"
35 #include "AliHLTErrorGuard.h"
36 #include "AliTPCcalibTime.h"
37 #include "AliTracker.h"
39 #include "TObjArray.h"
40 #include "TObjString.h"
41 #include "TDatabasePDG.h"
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTTriggerCosmics)
46 AliHLTTriggerCosmics::AliHLTTriggerCosmics()
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 const char* AliHLTTriggerCosmics::fgkDefaultOCDBEntry="HLT/ConfigHLT/CosmicsTrigger";
60 AliHLTTriggerCosmics::~AliHLTTriggerCosmics(){
61 // see header file for class documentation
64 const char* AliHLTTriggerCosmics::GetTriggerName() const{
65 // see header file for class documentation
70 return "CosmicsTrigger";
73 AliHLTComponent* AliHLTTriggerCosmics::Spawn(){
74 // see header file for class documentation
75 return new AliHLTTriggerCosmics;
78 int AliHLTTriggerCosmics::DoTrigger(){
79 // see header file for class documentation
82 IgnoreEvent(); // dont generate any trigger decision.
86 int numberOfCosmics=-1;
88 const TObject *obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
89 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
91 printf("Empty ESD\n");
96 Int_t startTime = esd->GetTimeStamp()-60*60*1; //Start time one hour before first event, will make precise cuts later.
97 Int_t endTime = esd->GetTimeStamp()+60*60*23; //End time 23 hours after first event.
98 fTrackSelection = new AliTPCcalibTime("calibTime","time dependent Vdrift calibration", startTime, endTime, 20*60);
100 fTrackSelection->UpdateEventInfo(esd); // needed for getting the run number and time stamp information correct on the offline side
102 //TArrayI clusterSideA(esd->GetNumberOfTracks());
103 //TArrayI clusterSideC(esd->GetNumberOfTracks());
104 Float_t bz = AliTracker::GetBz();
105 Double_t vtxx[3]={0,0,0};
106 Double_t svtxx[3]={0.000001,0.000001,100.};
107 AliESDVertex vtx(vtxx,svtxx);
109 for(Int_t i=0; i<esd->GetNumberOfTracks(); ++i){
111 AliESDtrack *track0 = esd->GetTrack(i); // track 0 upper part
112 if(!track0) continue;
113 if(!track0->GetOuterParam()) continue;
114 if(track0->GetOuterParam()->GetAlpha()<0) continue;
116 track0->GetDirection(d1);
118 for(Int_t j=0; j<esd->GetNumberOfTracks(); ++j){
121 AliESDtrack *track1 = esd->GetTrack(j); //track 1 lower part
122 if(!track1) continue;
123 if(!track1->GetOuterParam()) continue;
124 if( track0->GetTPCNcls() + track1->GetTPCNcls()< 80 /*kMinClusters*/) continue;
126 //Int_t nAC = TMath::Max( TMath::Min(clusterSideA[i], clusterSideC[j]), TMath::Min(clusterSideC[i], clusterSideA[j]));
127 //if(nAC<30/*kMinClustersCross*/) continue;
128 //Int_t nA0 = clusterSideA[i];
129 //Int_t nC0 = clusterSideC[i];
130 //Int_t nA1 = clusterSideA[j];
131 //Int_t nC1 = clusterSideC[j];
132 // if (track1->GetOuterParam()->GetAlpha()>0) continue;
135 track1->GetDirection(d2);
137 // AliTPCseed * seed0 = (AliTPCseed*) tpcSeeds.At(i);
138 // AliTPCseed * seed1 = (AliTPCseed*) tpcSeeds.At(j);
139 // if (! seed0) continue;
140 // if (! seed1) continue;
141 Float_t dir = (d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2]);
142 Float_t dist0 = track0->GetLinearD(0,0);
143 Float_t dist1 = track1->GetLinearD(0,0);
145 // conservative cuts - convergence to be guarantied
146 // applying before track propagation
147 if (TMath::Abs(TMath::Abs(dist0)-TMath::Abs(dist1))>3 /*fCutMaxD*/) continue; // distance to the 0,0
148 if (TMath::Abs(dir)<TMath::Abs(-0.99/*fCutMinDir*/)) continue; // direction vector product
150 Float_t dvertex0[2]; //distance to 0,0
151 Float_t dvertex1[2]; //distance to 0,0
152 track0->GetDZ(0,0,0,bz,dvertex0);
153 track1->GetDZ(0,0,0,bz,dvertex1);
154 if (TMath::Abs(dvertex0[1])>250) continue;
155 if (TMath::Abs(dvertex1[1])>250) continue;
157 Float_t dmax = TMath::Max(TMath::Abs(dist0),TMath::Abs(dist1));
158 AliExternalTrackParam param0(*track0);
159 AliExternalTrackParam param1(*track1);
161 // Propagate using Magnetic field and correct for material budget
164 AliTracker::PropagateTrackTo(¶m0,dmax+1,TDatabasePDG::Instance()->GetParticle("e-")->Mass(),3,kTRUE);
165 AliTracker::PropagateTrackTo(¶m1,dmax+1,TDatabasePDG::Instance()->GetParticle("e-")->Mass(),3,kTRUE);
167 // Propagate rest to the 0,0 DCA - z should be ignored
169 param0.PropagateToDCA(&vtx,bz,1000);
170 param1.PropagateToDCA(&vtx,bz,1000);
171 param0.GetDZ(0,0,0,bz,dvertex0);
172 param1.GetDZ(0,0,0,bz,dvertex1);
178 Bool_t isPair = fTrackSelection->IsPair(¶m0,¶m1);
179 Bool_t isCross = fTrackSelection->IsCross(track0, track1);
180 Bool_t isSame = fTrackSelection->IsSame(track0, track1);
182 if((isSame) || (isCross && isPair)){
183 if( track0->GetTPCNcls() + track1->GetTPCNcls()> 80 ){
187 } // end 2nd order loop
188 } // end 1st order loop
190 bool condition = false;
193 if(numberOfCosmics>0){
194 description.Form("Event contains %d cosmics", numberOfCosmics);
199 description.Form("No input blocks found");
201 description.Form("No DataEvent found");
205 SetDescription(description.Data());
207 // add a specific trigger decision object with initialized name
208 // the readout list however is fixed
209 AliHLTTriggerDecision decision(
215 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
220 int AliHLTTriggerCosmics::DoInit(int argc, const char** argv){
221 // see header file for class documentation
225 // check if the -triggername argument is used
226 // the name of the trigger determines the following initialization
227 vector<const char*> remainingArgs;
228 for (int i=0; i<argc; i++) {
229 if (strcmp(argv[i], "-triggername")==0) {
230 if (++i<argc) fName=argv[i];
232 HLTError("invalid parameter for argument '-triggername', string expected");
237 remainingArgs.push_back(argv[i]);
240 // get path from triggername, use default object otherwise
242 if (!fName.IsNull()) {
243 cdbPath="HLT/ConfigHLT/";
246 cdbPath=fgkDefaultOCDBEntry;
249 iResult = ConfigureFromCDBObject(cdbPath);
251 // -- Configure from the command line parameters if specified
252 if (iResult>=0 && argc>0) iResult = ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0]));
257 int AliHLTTriggerCosmics::DoDeinit(){
258 // see header file for class documentation
260 if(fTrackSelection) delete fTrackSelection; fTrackSelection = NULL;
264 int AliHLTTriggerCosmics::Reconfigure(const char* cdbEntry, const char* /*chainId*/){
265 // see header file for class documentation
267 // configure from the specified antry or the default one
269 if (!cdbEntry || cdbEntry[0]==0) {
270 if (!fName.IsNull()) {
271 cdbPath="HLT/ConfigHLT/";
274 cdbPath=fgkDefaultOCDBEntry;
280 return ConfigureFromCDBObject(cdbPath);
283 int AliHLTTriggerCosmics::ReadPreprocessorValues(const char* /*modules*/){
284 // see header file for class documentation
288 Int_t AliHLTTriggerCosmics::ConfigureFromCDBObject(TString cdbPath){
289 // see header file for class documentation
294 // -- check for "-" and replace by "_._" in the path name
295 cdbPath.ReplaceAll("-",1,"_._",3);
297 TObject *pCDBObject = LoadAndExtractOCDBObject(cdbPath);
299 // AliHLTESDTrackCuts *pCuts = dynamic_cast<AliHLTESDTrackCuts*>(pCDBObject);
301 // HLTInfo("Received AliHLTESDTrackCuts configuration object : \'%s\'", pCuts->GetTitle());
302 // if (fHLTESDTrackCuts)
303 // delete fHLTESDTrackCuts;
304 // fHLTESDTrackCuts = pCuts;
307 // TObjString *pString = dynamic_cast<TObjString*>(pCDBObject);
309 // HLTInfo("Received configuration object string: \'%s\'", pString->GetString().Data());
310 // arguments+=pString->GetString().Data();
313 // HLTError("Configuration object \"%s\" has wrong type, required AliHLTESDTrackCuts or TObjString", cdbPath.Data());
319 HLTError("Cannot fetch object \"%s\" from CDB", cdbPath.Data());
323 if( iResult>=0 && !arguments.IsNull() ){
324 const Char_t* array = arguments.Data();
325 iResult = ConfigureFromArgumentString(1, &array);
331 //int AliHLTTriggerCosmics::ScanConfigurationArgument(int argc, const char** argv){
332 // see header file for class documentation
334 // if (argc<=0) return 0;
336 // TString argument=argv[i];
338 // if (!fHLTESDTrackCuts)
339 // fHLTESDTrackCuts = new AliHLTESDTrackCuts("AliHLTESDTrackCuts","No track cuts");
342 // if (argument.CompareTo("-maxpt")==0) {
343 // if (++i>=argc) return -EPROTO;
346 // Float_t minPt, maxPt;
347 // fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
348 // maxPt = argument.Atof();
349 // fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
351 // TString title = fHLTESDTrackCuts->GetTitle();
352 // if (!title.CompareTo("No track cuts")) title = "";
353 // else title += " && ";
354 // title += Form("p_t < %f", maxPt);
355 // fHLTESDTrackCuts->SetTitle(title);
360 // if (argument.CompareTo("-minpt")==0) {
361 // if (++i>=argc) return -EPROTO;
364 // Float_t minPt, maxPt;
365 // fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
366 // minPt = argument.Atof();
367 // fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
369 // TString title = fHLTESDTrackCuts->GetTitle();
370 // if (!title.CompareTo("No track cuts")) title = "";
371 // else title += " && ";
372 // title += Form("p_t > %f", minPt);
373 // fHLTESDTrackCuts->SetTitle(title);
378 // if (argument.CompareTo("-mintracks")==0) {
379 // if (++i>=argc) return -EPROTO;
381 // fMinTracks=argument.Atoi();
386 // // minimum longitudinal dca to vertex
387 // if (argument.CompareTo("-min-ldca")==0) {
388 // if (++i>=argc) return -EPROTO;
391 // fHLTESDTrackCuts->SetMinDCAToVertexZ(argument.Atof());
392 // TString title = fHLTESDTrackCuts->GetTitle();
393 // if (!title.CompareTo("No track cuts")) title = "";
394 // else title += " && ";
395 // title += Form("DCAz > %f", argument.Atof());
396 // fHLTESDTrackCuts->SetTitle(title);
401 // // maximum longitudinal dca to vertex
402 // if (argument.CompareTo("-max-ldca")==0) {
403 // if (++i>=argc) return -EPROTO;
406 // fHLTESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof());
407 // TString title = fHLTESDTrackCuts->GetTitle();
408 // if (!title.CompareTo("No track cuts")) title = "";
409 // else title += " && ";
410 // title += Form("DCAz < %f", argument.Atof());
411 // fHLTESDTrackCuts->SetTitle(title);
416 // // minimum transverse dca to vertex
417 // if (argument.CompareTo("-min-tdca")==0) {
418 // if (++i>=argc) return -EPROTO;
421 // fHLTESDTrackCuts->SetMinDCAToVertexXY(argument.Atof());
422 // TString title = fHLTESDTrackCuts->GetTitle();
423 // if (!title.CompareTo("No track cuts")) title = "";
424 // else title += " && ";
425 // title += Form("DCAr > %f", argument.Atof());
426 // fHLTESDTrackCuts->SetTitle(title);
431 // // maximum transverse dca to vertex
432 // if (argument.CompareTo("-max-tdca")==0) {
433 // if (++i>=argc) return -EPROTO;
436 // fHLTESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof());
437 // TString title = fHLTESDTrackCuts->GetTitle();
438 // if (!title.CompareTo("No track cuts")) title = "";
439 // else title += " && ";
440 // title += Form("DCAr < %f", argument.Atof());
441 // fHLTESDTrackCuts->SetTitle(title);
448 // // reference point for the transverse and longitudinal dca cut
449 // if (argument.CompareTo("-dca-reference")==0) {
450 // if (++i>=argc) return -EPROTO;
451 // HLTWarning("argument -dca-reference deprecated, ESDTrackCuts only allow for DCA to vertex");
456 // if (argument.CompareTo("-solenoidBz")==0) {
457 // if (++i>=argc) return -EPROTO;
458 // HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
462 // // unknown argument