AliRoot Core  edcc906 (edcc906)
CompareTrackRefsAndHits.C
Go to the documentation of this file.
1 #include "iostream"
2 #include "AliFMDInput.h"
3 #include "AliFMDHit.h"
4 #include "TFile.h"
5 #include "TTree.h"
6 #include "TClonesArray.h"
7 #include "AliTrackReference.h"
8 #include "AliFMDStripIndex.h"
9 #include "TParticle.h"
10 //Script to compare the hits and the FMD track references for one event.
11 //To run:
12 //>gSystem->Load("libFMDutil")
13 //>.L CompareTrackRefsAndHits.C++
14 //>ReadHits t
15 //>t.Run()
16 //Note that the order of hits and trackrefs is different.
17 
18 class ReadHits : public AliFMDInput{
19 
20 private:
21  Int_t nHits;
22  Int_t nTracks;
23 public:
24 
25 
26 
29  AddLoad(kTracks);
31  AddLoad(kHits);
32  nHits = 0;
33  nTracks = 0;
34  fGAliceFile.Form("galice.root");
35  }
36 
37  Bool_t ProcessHit(AliFMDHit* hit, TParticle* p)
38  {
39  nHits++;
40  // std::cout<<hit->Px()<<" "<<hit->Py()<<" "<<hit->Pz()<<std::endl;
41  //std::cout<<hit->Detector()<<" "<<hit->Ring()<<" "<<hit->Sector()<<" "<<hit->Strip()<<std::endl;
42  return kTRUE;
43  }
44  Bool_t ProcessTrackRef(AliTrackReference* trackRef, TParticle* p)
45  {
46  UShort_t det,sec,strip;
47  Char_t ring;
48  if(trackRef->DetectorId() == AliTrackReference::kFMD) {
49  nTracks++;
50  AliFMDStripIndex::Unpack(trackRef->UserId(),det,ring,sec,strip);
51  //std::cout<<p->Px()<<" "<<p->Py()<<" "<<p->Pz()<<std::endl;
52  //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<strip<<std::endl;
53  }
54 
55  return kTRUE;
56  }
57 
58 
59  Bool_t Finish()
60  {
61  // Int_t nTracks = 0;
62  /* TFile* f=TFile::Open("TrackRefs.root");
63  TTree* tree = (TTree*)f->Get("Event0/TreeTR");
64 
65 
66  TClonesArray* array=new TClonesArray("AliTrackReference");
67 
68  tree->SetBranchAddress("TrackReferences",&array);
69 
70  UShort_t det,sec,strip;
71  Char_t ring;
72  for (int i=0; i<tree->GetEntries(); i++) {
73  tree->GetEvent(i);
74  for(Int_t j = 0; j <array->GetEntriesFast();j++) {
75 
76  AliTrackReference* track = static_cast<AliTrackReference*>(array->At(j));
77 
78  if(track->DetectorId()==AliTrackReference::kFMD) {
79  nTracks++;
80  AliFMDStripIndex::Unpack(track->UserId(),det,ring,sec,strip);
81  std::cout<<track->Px()<<" "<<track->Py()<<" "<<track->Pz()<<" "<<track->UserId()<<endl;
82  std::cout<<det<<" "<<ring<<" "<<sec<<" "<<strip<<std::endl;
83  }
84 
85  }
86 
87  }
88  */
89  std::cout<<nTracks<<" "<<nHits<<std::endl;
90  return kTRUE;
91  }
92 
93 };
Hit in the FMD.
FMD utility classes for reading FMD data.
Bool_t ProcessTrackRef(AliTrackReference *trackRef, TParticle *p)
Float_t p[]
Definition: kNNTest.C:133
virtual void AddLoad(ETrees tree)
Definition: AliFMDInput.h:134
TString fGAliceFile
Definition: AliFMDInput.h:413
Base class for reading in various FMD data. The class loops over all found events. For each event the specified data is read in. The class then loops over all elements of the read data, and process these with user defined code.
Definition: AliFMDInput.h:106
AliFMDhit is the hit class for the FMD. Hits are the information that comes from a Monte Carlo at eac...
Definition: AliFMDHit.h:30
virtual Int_t UserId() const
Bool_t ProcessHit(AliFMDHit *hit, TParticle *p)
static void Unpack(UInt_t id, UShort_t &det, Char_t &rng, UShort_t &sec, UShort_t &str)
virtual Int_t DetectorId() const