Introducing the FMD trackreferences in the stepmanager as well as a strip address...
authorhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Jan 2009 10:19:44 +0000 (10:19 +0000)
committerhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Jan 2009 10:19:44 +0000 (10:19 +0000)
FMD/AliFMD.cxx
FMD/AliFMDStripIndex.h [new file with mode: 0644]
FMD/libFMDbase.pkg
FMD/scripts/CompareTrackRefsAndHits.C [new file with mode: 0644]

index aec1986..8fe3744 100644 (file)
 //#endif
 // #include "AliFMDGeometryBuilder.h"
 #include "AliFMDRawWriter.h"   // ALIFMDRAWWRITER_H
+#include "AliTrackReference.h" 
+#include "AliFMDStripIndex.h"
 
 //____________________________________________________________________
 ClassImp(AliFMD)
@@ -651,6 +653,17 @@ AliFMD::AddHitByFields(Int_t    track,
                                  strip, x, y, z, px, py, pz, edep, pdg, t, 
                                  l, stop);
   fNhits++;
+  
+  //Reference track
+
+  AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+  
+  AliTrackReference* trackRef = AddTrackReference(mcApplication->GetCurrentTrackNumber(), 12); // should be AliTrackReference::kFMD
+  UInt_t stripId = AliFMDStripIndex::Pack(detector,ring,sector,strip);
+  trackRef->SetUserId(stripId);
+  
+  
+  
   return hit;
 }
 
diff --git a/FMD/AliFMDStripIndex.h b/FMD/AliFMDStripIndex.h
new file mode 100644 (file)
index 0000000..cf9a379
--- /dev/null
@@ -0,0 +1,45 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//Struct to encode a strip address into one integer
+//developed by Christian Holm Christensen (cholm@nbi.dk).
+// The functions are static
+// to ensure applicability from anywhere. This is needed to smoothly store
+//strip addresses in track references.
+// Added by Hans H. Dalsgaard (hans.dalsgaard@cern.ch) 
+
+
+struct AliFMDStripIndex
+{
+  static UInt_t Pack(UShort_t det, Char_t rng, UShort_t sec, UShort_t str) 
+  {
+    UInt_t irg  = (rng == 'I' || rng == 'i' ? 0 : 1);
+    UInt_t id   = (((str & 0x1FF) <<  0) | 
+                  ((sec & 0x03F) <<  9) | 
+                  ((irg & 0x001) << 16) | 
+                  ((det & 0x003) << 17));
+    return id;
+  }
+  static void Unpack(UInt_t id, 
+             UShort_t& det, Char_t& rng, UShort_t& sec, UShort_t& str)
+  {
+    str = ((id >>  0) & 0x1FF);
+    sec = ((id >>  9) & 0x03F);
+    rng = ((id >> 16) & 0x001) ? 'O' : 'I';
+    det = ((id >> 17) & 0x003);
+  }
+
+  ClassDef(AliFMDStripIndex,0)
+};
index 6b39eb6..ba4fffa 100644 (file)
@@ -22,11 +22,12 @@ SRCS                =  AliFMDIndex.cxx              \
                   AliFMD3.cxx                  \
                   AliFMDPreprocessor.cxx       \
                   AliFMDQAChecker.cxx          \
-                  AliFMDGeometryBuilder.cxx
+                  AliFMDGeometryBuilder.cxx  
 
 #                 AliFMDAltroIO.cxx            
 
-HDRS           =  $(SRCS:.cxx=.h) 
+HDRS           =  $(SRCS:.cxx=.h)  \
+                  AliFMDStripIndex.h
 DHDR           := FMDbaseLinkDef.h
 
 EINCLUDE        :=  RAW
diff --git a/FMD/scripts/CompareTrackRefsAndHits.C b/FMD/scripts/CompareTrackRefsAndHits.C
new file mode 100644 (file)
index 0000000..0b3e499
--- /dev/null
@@ -0,0 +1,73 @@
+#include "iostream"
+#include "AliFMDInput.h"
+#include "AliFMDHit.h"
+#include "TFile.h"
+#include "TTree.h"
+#include "TClonesArray.h"
+#include "AliTrackReference.h"
+#include "AliFMDStripIndex.h"
+
+//Script to compare the hits and the FMD track references for one event.
+//To run:
+//>gSystem->Load("libFMDutil")
+//>.L CompareTrackRefsAndHits.C++
+//>ReadHits t
+//>t.Run()
+//Note that the order of hits and trackrefs is different.
+
+class ReadHits : public AliFMDInput{
+
+private:
+  Int_t nHits;
+  
+public:
+  
+  
+  
+  ReadHits(){
+    AddLoad(kKinematics);
+    AddLoad(kHits);
+    nHits = 0;
+  }
+
+  Bool_t ProcessHit(AliFMDHit* hit, TParticle* p) 
+  {
+    nHits++;
+    std::cout<<hit->Px()<<"   "<<hit->Py()<<"   "<<hit->Pz()<<std::endl;
+    std::cout<<hit->Detector()<<"   "<<hit->Ring()<<"    "<<hit->Sector()<<"    "<<hit->Strip()<<std::endl;
+    return kTRUE;
+  }
+  Bool_t Finish()
+  {
+    Int_t nTracks = 0;
+    TFile* f=TFile::Open("TrackRefs.root");
+    TTree* tree = (TTree*)f->Get("Event0/TreeTR");
+    
+    
+    TClonesArray* array=new TClonesArray("AliTrackReference");
+    
+    tree->SetBranchAddress("TrackReferences",&array);
+    
+    UShort_t det,sec,strip;
+    Char_t ring;
+    for (int i=0; i<tree->GetEntries(); i++) {
+      tree->GetEvent(i);
+    for(Int_t j = 0; j <array->GetEntriesFast();j++) {
+      
+      AliTrackReference* track = static_cast<AliTrackReference*>(array->At(j));
+      
+      if(track->DetectorId()==AliTrackReference::kFMD) {
+       nTracks++;
+       AliFMDStripIndex::Unpack(track->UserId(),det,ring,sec,strip);
+       std::cout<<track->Px()<<"   "<<track->Py()<<"   "<<track->Pz()<<"   "<<track->UserId()<<endl;
+       std::cout<<det<<"   "<<ring<<"    "<<sec<<"    "<<strip<<std::endl;
+      }
+      
+    }
+    
+    }
+    std::cout<<nTracks<<"     "<<nHits<<std::endl;
+    return kTRUE;
+  }
+  
+};