]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/CompareTrackRefsAndHits.C
Introducing the FMD trackreferences in the stepmanager as well as a strip address...
[u/mrichter/AliRoot.git] / FMD / scripts / CompareTrackRefsAndHits.C
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
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   
23 public:
24   
25   
26   
27   ReadHits(){
28     AddLoad(kKinematics);
29     AddLoad(kHits);
30     nHits = 0;
31   }
32
33   Bool_t ProcessHit(AliFMDHit* hit, TParticle* p) 
34   {
35     nHits++;
36     std::cout<<hit->Px()<<"   "<<hit->Py()<<"   "<<hit->Pz()<<std::endl;
37     std::cout<<hit->Detector()<<"   "<<hit->Ring()<<"    "<<hit->Sector()<<"    "<<hit->Strip()<<std::endl;
38     return kTRUE;
39   }
40   Bool_t Finish()
41   {
42     Int_t nTracks = 0;
43     TFile* f=TFile::Open("TrackRefs.root");
44     TTree* tree = (TTree*)f->Get("Event0/TreeTR");
45     
46     
47     TClonesArray* array=new TClonesArray("AliTrackReference");
48     
49     tree->SetBranchAddress("TrackReferences",&array);
50     
51     UShort_t det,sec,strip;
52     Char_t ring;
53     for (int i=0; i<tree->GetEntries(); i++) {
54       tree->GetEvent(i);
55     for(Int_t j = 0; j <array->GetEntriesFast();j++) {
56       
57       AliTrackReference* track = static_cast<AliTrackReference*>(array->At(j));
58       
59       if(track->DetectorId()==AliTrackReference::kFMD) {
60         nTracks++;
61         AliFMDStripIndex::Unpack(track->UserId(),det,ring,sec,strip);
62         std::cout<<track->Px()<<"   "<<track->Py()<<"   "<<track->Pz()<<"   "<<track->UserId()<<endl;
63         std::cout<<det<<"   "<<ring<<"    "<<sec<<"    "<<strip<<std::endl;
64       }
65       
66     }
67     
68     }
69     std::cout<<nTracks<<"     "<<nHits<<std::endl;
70     return kTRUE;
71   }
72   
73 };