]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Various fixes
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Jan 2009 00:24:30 +0000 (00:24 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Jan 2009 00:24:30 +0000 (00:24 +0000)
19 files changed:
FMD/AliFMD.cxx
FMD/AliFMD.h
FMD/AliFMD2.cxx
FMD/AliFMDBaseDigitizer.cxx
FMD/AliFMDBaseDigitizer.h
FMD/AliFMDDetector.cxx
FMD/AliFMDDigitizer.cxx
FMD/AliFMDEdepHitPair.h
FMD/AliFMDEdepMap.cxx
FMD/AliFMDGeometryBuilder.cxx
FMD/AliFMDHitDigitizer.cxx
FMD/AliFMDHitDigitizer.h
FMD/AliFMDSDigit.cxx
FMD/AliFMDSDigit.h
FMD/AliFMDSurveyToAlignObjs.cxx [new file with mode: 0644]
FMD/AliFMDSurveyToAlignObjs.h [new file with mode: 0644]
FMD/FMDbaseLinkDef.h
FMD/libFMDbase.pkg
FMD/scripts/TestSurveyToAlignObjs.C [new file with mode: 0644]

index 728962ef6911d71aaeb61fe6335e909ec1bb5c3b..0f404539c22b25408ab6f8ccc42b93dd6167cbb9 100644 (file)
@@ -652,6 +652,7 @@ AliFMD::AddHitByFields(Int_t    track,
   hit = new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, 
                                  strip, x, y, z, px, py, pz, edep, pdg, t, 
                                  l, stop);
+  // gMC->AddTrackReference(track, 12);
   fNhits++;
   
   //Reference track
@@ -754,22 +755,22 @@ AliFMD::AddSDigit(Int_t* digits)
                    Short_t(digits[8]),    // ADC Count4
                    UShort_t(digits[9]),   // N particles
                    UShort_t(digits[10])); // N primaries
-   
 }
 
 //____________________________________________________________________
 void 
-AliFMD::AddSDigitByFields(UShort_t detector, 
-                         Char_t   ring, 
-                         UShort_t sector, 
-                         UShort_t strip, 
-                         Float_t  edep,
-                         UShort_t count1, 
-                         Short_t  count2,
-                         Short_t  count3, 
-                         Short_t  count4, 
-                         UShort_t ntot, 
-                         UShort_t nprim)
+AliFMD::AddSDigitByFields(UShort_t       detector, 
+                         Char_t         ring, 
+                         UShort_t       sector, 
+                         UShort_t       strip, 
+                         Float_t        edep,
+                         UShort_t       count1, 
+                         Short_t        count2,
+                         Short_t        count3, 
+                         Short_t        count4, 
+                         UShort_t       ntot, 
+                         UShort_t       nprim,
+                         const TArrayI& refs)
 {
   // add a summable digit
   // 
@@ -789,7 +790,7 @@ AliFMD::AddSDigitByFields(UShort_t detector,
   
   new (a[fNsdigits++]) 
     AliFMDSDigit(detector, ring, sector, strip, edep, 
-                count1, count2, count3, count4, ntot, nprim);
+                count1, count2, count3, count4, ntot, nprim, refs);
 }
 
 //____________________________________________________________________
index 889b2c64d58e9f9cf6f06150326f336c40ec263c..b1c16407adb49a1e3365f6634241c34d21ac2be3 100644 (file)
 #ifndef ALIDETECTOR_H  
 # include <AliDetector.h>
 #endif
+#ifndef ROOT_TArrayI
+# include <TArrayI.h>
+#endif
 class TBranch;
 class TClonesArray;
 class TBrowser;
 class TMarker3DBox;
+class TArrayI;
 class AliDigitizer;
 class AliFMDHit;
 
@@ -461,17 +465,18 @@ public:
       @param count1    ADC count (a 10-bit word)
       @param count2    ADC count (a 10-bit word), or -1 if not used 
       @param count3    ADC count (a 10-bit word), or -1 if not used */
-  virtual        void   AddSDigitByFields(UShort_t detector=0, 
-                                         Char_t   ring='\0', 
-                                         UShort_t sector=0, 
-                                         UShort_t strip=0, 
-                                         Float_t  edep=0,
-                                         UShort_t count1=0, 
-                                         Short_t  count2=-1, 
-                                         Short_t  count3=-1,
-                                         Short_t  count4=-1, 
-                                         UShort_t ntot=0, 
-                                         UShort_t nprim=0);
+  virtual        void   AddSDigitByFields(UShort_t       detector=0, 
+                                         Char_t         ring='\0', 
+                                         UShort_t       sector=0, 
+                                         UShort_t       strip=0, 
+                                         Float_t        edep=0,
+                                         UShort_t       count1=0, 
+                                         Short_t        count2=-1, 
+                                         Short_t        count3=-1,
+                                         Short_t        count4=-1, 
+                                         UShort_t       ntot=0, 
+                                         UShort_t       nprim=0,
+                                         const TArrayI& refs=TArrayI());
   /** @}*/
 
   /** @{ */
index ba0a6decb9f5068311360931a06bf768b6285c82..1354cc40115b0fdadf918dd6226b83ae2449f558 100644 (file)
@@ -45,7 +45,9 @@ AliFMD2::AliFMD2(AliFMDRing* inner, AliFMDRing* outer)
   // Constructor 
   // SetInnerZ(83.4);
   // SetOuterZ(75.2);
-  Double_t off = 0.414256-0.1963; // 2.35
+  // Double_t off = 0.414256-0.1963; // 2.35
+  Double_t off = 0.414256-0.1963+.27; // 2.35
+  if (off < 0) off = 0;
   if (off != 0) 
     AliWarning(Form("Z position of FMD2 rings may be wrong by %fcm!", off));
   SetInnerZ(83.4+off);
index c063bb378a877242017ce700b35bc0861659ab95..780b27c3f1d48d4f0a0e4caa80c5d0c58b72ae0b 100644 (file)
@@ -230,7 +230,8 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer()
          AliFMDMap::kMaxRings, 
          AliFMDMap::kMaxSectors, 
          AliFMDMap::kMaxStrips),
-    fShapingTime(6)
+    fShapingTime(6),
+    fStoreTrackRefs(kFALSE)
 {
   AliFMDDebug(1, ("Constructed"));
   // Default ctor - don't use it
@@ -245,7 +246,8 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer(AliRunDigitizer* manager)
          AliFMDMap::kMaxRings, 
          AliFMDMap::kMaxSectors, 
          AliFMDMap::kMaxStrips), 
-    fShapingTime(6)
+    fShapingTime(6),
+    fStoreTrackRefs(kFALSE)
 {
   // Normal CTOR
   AliFMDDebug(1, ("Constructed"));
@@ -262,7 +264,8 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer(const Char_t* name,
          AliFMDMap::kMaxRings, 
          AliFMDMap::kMaxSectors, 
          AliFMDMap::kMaxStrips),
-    fShapingTime(6)
+    fShapingTime(6),
+    fStoreTrackRefs(kFALSE)
 {
   // Normal CTOR
   AliFMDDebug(1, (" Constructed"));
@@ -310,7 +313,8 @@ AliFMDBaseDigitizer::AddContribution(UShort_t detector,
                                     UShort_t sector, 
                                     UShort_t strip, 
                                     Float_t  edep, 
-                                    Bool_t   isPrimary)
+                                    Bool_t   isPrimary,
+                                    Int_t    trackno)
 {
   // Add edep contribution from (detector,ring,sector,strip) to cache
   AliFMDParameters* param = AliFMDParameters::Instance();
@@ -328,19 +332,24 @@ AliFMDBaseDigitizer::AddContribution(UShort_t detector,
   //   continue;
   // }
   
+  AliFMDEdepHitPair& entry = fEdep(detector, ring, sector, strip);
+
   // Give warning in case of double sdigit 
-  if (fEdep(detector, ring, sector, strip).fEdep != 0)
-    AliFMDDebug(5, ("Double digit in %d%c(%d,%d)", 
+  if (entry.fEdep != 0)
+    AliFMDDebug(5, ("Double digit in FMD%d%c[%2d,%3d]", 
                    detector, ring, sector, strip));
       
   // Sum energy deposition
-  fEdep(detector, ring, sector, strip).fEdep    += edep;
-  fEdep(detector, ring, sector, strip).fN       += 1;
-  if (isPrimary)
-    fEdep(detector, ring, sector, strip).fNPrim += 1;
+  entry.fEdep += edep;
+  entry.fN    += 1;
+  if (isPrimary) entry.fNPrim += 1;
+  if (fStoreTrackRefs) { 
+    entry.fLabels.Set(entry.fN);
+    entry.fLabels[entry.fN-1] = trackno;
+  }
   AliFMDDebug(15, ("Adding contribution %f to FMD%d%c[%2d,%3d] (%f)", 
-                 edep, detector, ring, sector, strip,
-                 fEdep(detector, ring, sector, strip).fEdep));
+                  edep, detector, ring, sector, strip,
+                  entry.fEdep));
   
 }
 
@@ -385,9 +394,11 @@ AliFMDBaseDigitizer::DigitizeHits() const
          // VA1_ALICE channel. 
          if (strip % 128 == 0) last = 0;
          
-         Float_t  edep  = fEdep(detector, ring, sector, strip).fEdep;
-         UShort_t ntot  = fEdep(detector, ring, sector, strip).fN;
-         UShort_t nprim = fEdep(detector, ring, sector, strip).fNPrim;
+         const AliFMDEdepHitPair& entry  = fEdep(detector,ring,sector,strip);
+         Float_t                  edep   = entry.fEdep;
+         UShort_t                 ntot   = entry.fN;
+         UShort_t                 nprim  = entry.fNPrim;
+         const TArrayI&           labels = entry.fLabels;
          if (edep > 0)
            AliFMDDebug(15, ("Edep = %f for FMD%d%c[%2d,%3d]", 
                             edep, detector, ring, sector, strip));
@@ -415,7 +426,7 @@ AliFMDBaseDigitizer::DigitizeHits() const
          AddDigit(detector, ring, sector, strip, edep, 
                   UShort_t(counts[0]), Short_t(counts[1]), 
                   Short_t(counts[2]), Short_t(counts[3]), 
-                  ntot, nprim);
+                  ntot, nprim, labels);
          AliFMDDebug(15, ("   Adding digit in FMD%d%c[%2d,%3d]=%d", 
                          detector,ring,sector,strip,counts[0]));
 #if 0
@@ -528,17 +539,18 @@ AliFMDBaseDigitizer::ConvertToCount(Float_t   edep,
 
 //____________________________________________________________________
 void
-AliFMDBaseDigitizer::AddDigit(UShort_t  detector, 
-                             Char_t    ring,
-                             UShort_t  sector, 
-                             UShort_t  strip, 
-                             Float_t   /* edep */, 
-                             UShort_t  count1, 
-                             Short_t   count2, 
-                             Short_t   count3,
-                             Short_t   count4,
-                             UShort_t  /* ntot */, 
-                             UShort_t  /* nprim */) const
+AliFMDBaseDigitizer::AddDigit(UShort_t        detector, 
+                             Char_t          ring,
+                             UShort_t        sector, 
+                             UShort_t        strip, 
+                             Float_t         /* edep */, 
+                             UShort_t        count1, 
+                             Short_t         count2, 
+                             Short_t         count3,
+                             Short_t         count4,
+                             UShort_t        /* ntot */, 
+                             UShort_t        /* nprim */,
+                             const TArrayI&  /* refs */) const
 {
   // Add a digit or summable digit
   
index 636038f4effe9e7e031da2f583eaf4f12e9fc52f..b5d77f8d9adfdb1147f34e013f8899dc8fe0eefc 100644 (file)
@@ -184,6 +184,10 @@ public:
   void     SetShapingTime(Float_t B=10) { fShapingTime = B;  }  
   /** @return Get the shaping time */
   Float_t  GetShapingTime()      const { return fShapingTime; }
+  
+  void SetStoreTrackRefs(Bool_t store=kTRUE) { fStoreTrackRefs = store; }
+  Bool_t IsStoreTrackRefs() const { return fStoreTrackRefs; }
+    
 protected:
   /** For the stored energy contributions in the cache, convert the
       energy signal to ADC counts, and store the created digit in  
@@ -225,19 +229,21 @@ protected:
                               UShort_t sector, 
                               UShort_t strip, 
                               Float_t  edep, 
-                              Bool_t   isPrimary);
+                              Bool_t   isPrimary,
+                              Int_t    trackno);
   /** Add a digit to output */
-  virtual void     AddDigit(UShort_t detector, 
-                           Char_t   ring,
-                           UShort_t sector, 
-                           UShort_t strip, 
-                           Float_t  edep, 
-                           UShort_t count1, 
-                           Short_t  count2, 
-                           Short_t  count3,
-                           Short_t  count4, 
-                           UShort_t ntot, 
-                           UShort_t nprim) const;
+  virtual void     AddDigit(UShort_t       detector, 
+                           Char_t         ring,
+                           UShort_t       sector, 
+                           UShort_t       strip, 
+                           Float_t        edep, 
+                           UShort_t       count1, 
+                           Short_t        count2, 
+                           Short_t        count3,
+                           Short_t        count4, 
+                           UShort_t       ntot, 
+                           UShort_t       nprim,
+                           const TArrayI& refs) const;
   /** Make the output tree using the passed loader 
       @param loader 
       @return The generated tree. */
@@ -246,10 +252,11 @@ protected:
       @param loader The loader */
   virtual void StoreDigits(AliLoader* loader);
 
-  AliFMD*       fFMD;
-  AliRunLoader* fRunLoader;       //! Run loader
-  AliFMDEdepMap fEdep;             // Cache of Energy from hits 
-  Float_t       fShapingTime;      // Shaping profile parameter
+  AliFMD*         fFMD;              // Detector object 
+  AliRunLoader*   fRunLoader;       //! Run loader
+  AliFMDEdepMap   fEdep;             // Cache of Energy from hits 
+  Float_t         fShapingTime;      // Shaping profile parameter
+  Bool_t          fStoreTrackRefs;   // Wether to store track references
   
   /** Copy CTOR 
       @param o object to copy from  */
@@ -258,16 +265,18 @@ protected:
       fFMD(o.fFMD),
       fRunLoader(0),
       fEdep(o.fEdep),
-      fShapingTime(o.fShapingTime)
+      fShapingTime(o.fShapingTime),
+      fStoreTrackRefs(o.fStoreTrackRefs)
   {}
   /** Assignment operator
       @return Reference to this object */
   AliFMDBaseDigitizer& operator=(const AliFMDBaseDigitizer& o) 
   { 
     AliDigitizer::operator=(o);
-    fRunLoader   = o.fRunLoader;
-    fEdep        = o.fEdep;
-    fShapingTime = o.fShapingTime;
+    fRunLoader      = o.fRunLoader;
+    fEdep           = o.fEdep;
+    fShapingTime    = o.fShapingTime;
+    fStoreTrackRefs = o.fStoreTrackRefs;
     return *this; 
   }
   ClassDef(AliFMDBaseDigitizer,2) // Base class for FMD digitizers
index 4851e2469bb84049566cd1bde0ac94630d1a2b8c..020b077c4bc79c55e5322b39edcec830bc12267e 100644 (file)
@@ -188,6 +188,27 @@ AliFMDDetector::InitTransformations()
   if (fOuter && !fOuterTransforms) 
     fOuterTransforms = new TObjArray(fOuter->GetNModules());
   
+  // Loop over bottom/top 
+  for (size_t ihalf = 0; ihalf < 2; ihalf++) {
+    char  half = (ihalf == 0 ? 'T' : 'B');
+    TString path(Form(HALF_FORMAT, fId, half));
+    TGeoPNEntry* entry = gGeoManager->GetAlignableEntry(path.Data());
+    if (!entry) {
+      AliError(Form("Alignable entry for half-detector \"%s\" not found!", 
+                   path.Data()));
+      continue;
+    }
+    TGeoPhysicalNode* pn = entry->GetPhysicalNode();
+    if (!pn) {
+      AliWarning(Form("Making physical volume for \"%s\"", path.Data()));
+      pn = gGeoManager->MakeAlignablePN(entry);
+      if (!pn) {
+       AliError(Form("No physical node for \"%s\"", path.Data()));
+       continue;
+      }
+    }
+  }
+  
   // Loop over rings 
   for (size_t iring = 0; iring < 2; iring++) {
     char ring = (iring == 0 ? 'I' : 'O');
index aa68a17a6aade953fa04828f64917fa68a5d322e..91e4ff8270ab638db8b2fbf527546ad237ce1e91 100644 (file)
@@ -405,7 +405,8 @@ AliFMDDigitizer::SumContributions(TBranch* sdigitsBranch)
                      fmdSDigit->Sector(),
                      fmdSDigit->Strip(),
                      fmdSDigit->Edep(), 
-                     kTRUE);
+                     kTRUE,
+                     -1);
     }  // sdigit loop
   } // event loop
 
index 56e889e87ac60f54311999eb4b5f23e2061feaaf..6c6b41cef84bf3d388d524bb0178356cb1c52570 100644 (file)
 #ifndef ROOT_Rtypes
 # include <Rtypes.h>
 #endif 
+#ifndef ROOT_TArrayI
+# include <TArrayI.h>
+#endif
+
 //____________________________________________________________________
 /** @brief Cache of Energy deposited, hit information per strip.
     Contains a pair of energy deposited @c fEdep and 
 class AliFMDEdepHitPair 
 {
 public:
-  Float_t  fEdep;  // summed energy deposition
-  UShort_t fN;     // Number of hits
-  UShort_t fNPrim; // Number of primaries;
+  Float_t  fEdep;   // summed energy deposition
+  UShort_t fN;      // Number of hits
+  UShort_t fNPrim;  // Number of primaries;
+  TArrayI  fLabels; // Track labels.
   
   /** CTOR  */
-  AliFMDEdepHitPair() : fEdep(0), fN(0), fNPrim(0) {}
+  AliFMDEdepHitPair() : fEdep(0), fN(0), fNPrim(0), fLabels(0) {}
   /** DTOR */
   virtual ~AliFMDEdepHitPair() {}
   /** Assignment operator 
@@ -45,17 +50,18 @@ public:
       @return Reference to this object */
   AliFMDEdepHitPair& operator=(const AliFMDEdepHitPair& o) 
   { 
-    fEdep  = o.fEdep; 
-    fN     = o.fN; 
-    fNPrim = o.fNPrim;
+    fEdep   = o.fEdep; 
+    fN      = o.fN; 
+    fNPrim  = o.fNPrim;
+    fLabels = o.fLabels;
     return *this; 
   }
   /** Copy CTOR 
       @param o Object to copy from */
   AliFMDEdepHitPair(const AliFMDEdepHitPair& o) 
-    : fEdep(o.fEdep), fN(o.fN), fNPrim(o.fNPrim)
+    : fEdep(o.fEdep), fN(o.fN), fNPrim(o.fNPrim), fLabels(o.fLabels)
   {}
-  ClassDef(AliFMDEdepHitPair, 2)
+  ClassDef(AliFMDEdepHitPair, 3)
 };
 
 #endif 
index 84d869976465d9cf456360555df681b2058935a0..cc1e8c6d7a5adf2aa6a3c8c3df6f792654e13244 100644 (file)
@@ -108,6 +108,7 @@ AliFMDEdepMap::Reset(const AliFMDEdepHitPair& val)
     fData[i].fEdep  = val.fEdep; 
     fData[i].fN     = val.fN; 
     fData[i].fNPrim = val.fNPrim;
+    fData[i].fLabels.Set(0);
   };
 }
 
index e383291d80cdd0253753dba9dfae6255b45122ed..ecb994f64f5ff9a6d34ed6a59dd7cd5d8825960c 100644 (file)
@@ -755,7 +755,8 @@ AliFMDGeometryBuilder::FMD2Geometry(AliFMD2* fmd2,
   Double_t    framelr       = 32.01;  // fmd2->GetOuterHoneyHighR()+0.5;
   Double_t    framehr       = 33.611; // fmd2->GetOuterHoneyHighR()+1.8;
   Double_t    framel        = 14.8; // framehz - framelz;
-  Double_t    backth        = 0.3;
+  // Double_t    backth        = 0.3;
+  Double_t    backth        = 0.03;
   Double_t    framelz       = -(2.38 
                                - r->GetModuleDepth() 
                                - r->GetModuleSpacing() / 2);
index 4087677ec19fcc2b703d0cf6fe73104f298bbc2a..20714d60f4fc715291604f5f1b950b4e1edb5ecf 100644 (file)
@@ -215,6 +215,7 @@ AliFMDHitDigitizer::AliFMDHitDigitizer(AliFMD* fmd, Output_t  output)
                                "FMD Hit->Digit digitizer" :
                                "FMD Hit->SDigit digitizer")),
     fOutput(output), 
+    fHoldTime(2e-6),
     fStack(0)
 {
   fFMD = fmd;
@@ -384,11 +385,16 @@ AliFMDHitDigitizer::SumContributions(TBranch* hitsBranch)
       // Get the hit number `hit'
       AliFMDHit* fmdHit = 
        static_cast<AliFMDHit*>(fmdHits->UncheckedAt(hit));
+
+      // Ignore hits that arrive too late
+      if (fmdHit->Time() > fHoldTime) continue;
       
+
       // Check if this is a primary particle
       Bool_t isPrimary = kTRUE;
+      Int_t  trackno   = -1;
       if (fStack) {
-       Int_t      trackno = fmdHit->Track();
+       trackno = fmdHit->Track();
        AliFMDDebug(10, ("Will get track # %d/%d from entry # %d", 
                        trackno, fStack->GetNtrack(), track));
        if (fStack->GetNtrack() < trackno) {
@@ -396,7 +402,9 @@ AliFMDHitDigitizer::SumContributions(TBranch* hitsBranch)
                        trackno, fStack->GetNtrack()));
          continue;
        }
-       
+#if 1
+       isPrimary = fStack->IsPhysicalPrimary(trackno);
+#else // This is our hand-crafted code.  We use the ALICE definition
        TParticle* part    = fStack->Particle(trackno);
        isPrimary          = part->IsPrimary();
        if (!isPrimary) { 
@@ -412,6 +420,7 @@ AliFMDHitDigitizer::SumContributions(TBranch* hitsBranch)
                       (mother ? mother->GetStatusCode() : -1),
                       (isPrimary ? "primary" : "secondary")));
        }
+#endif
       }
     
       // Extract parameters 
@@ -420,7 +429,8 @@ AliFMDHitDigitizer::SumContributions(TBranch* hitsBranch)
                      fmdHit->Sector(),
                      fmdHit->Strip(),
                      fmdHit->Edep(), 
-                     isPrimary);
+                     isPrimary, 
+                     trackno);
     }  // hit loop
   } // track loop
   AliFMDDebug(5, ("Size of cache: %d bytes, read %d bytes", 
@@ -444,22 +454,23 @@ AliFMDHitDigitizer::MakePedestal(UShort_t  detector,
 
 //____________________________________________________________________
 void
-AliFMDHitDigitizer::AddDigit(UShort_t  detector, 
-                            Char_t    ring,
-                            UShort_t  sector, 
-                            UShort_t  strip, 
-                            Float_t   edep, 
-                            UShort_t  count1, 
-                            Short_t   count2, 
-                            Short_t   count3,
-                            Short_t   count4, 
-                            UShort_t  ntotal,
-                            UShort_t  nprim) const
+AliFMDHitDigitizer::AddDigit(UShort_t        detector, 
+                            Char_t          ring,
+                            UShort_t        sector, 
+                            UShort_t        strip, 
+                            Float_t         edep, 
+                            UShort_t        count1, 
+                            Short_t         count2, 
+                            Short_t         count3,
+                            Short_t         count4, 
+                            UShort_t        ntotal,
+                            UShort_t        nprim, 
+                            const TArrayI&  refs) const
 {
   // Add a digit or summable digit
   if (fOutput == kDigits) { 
     AliFMDBaseDigitizer::AddDigit(detector, ring, sector, strip, 0,
-                                 count1, count2, count3, count4, 0, 0);
+                                 count1, count2, count3, count4, 0, 0, refs);
     return;
   }
   if (edep <= 0) { 
@@ -478,7 +489,7 @@ AliFMDHitDigitizer::AddDigit(UShort_t  detector,
                   count1, count2, count3, count4, nprim, ntotal));
   fFMD->AddSDigitByFields(detector, ring, sector, strip, edep,
                          count1, count2, count3, count4, 
-                         ntotal, nprim);
+                         ntotal, nprim, refs);
 }
 
 //____________________________________________________________________
index 656f94eba35c8abe69578a8d5bbaa69f198c9c25..4c120852a75d2b9c9821f16838ec5d3c83573050 100644 (file)
@@ -52,6 +52,7 @@ public:
   AliFMDHitDigitizer() 
     : AliFMDBaseDigitizer(), 
       fOutput(kDigits), 
+      fHoldTime(2e-6),
       fStack(0)
   {}
   /** CTOR 
@@ -61,12 +62,21 @@ public:
   virtual ~AliFMDHitDigitizer() {}
   /** Run over the input events (retrieved via run loader) */
   void Exec(Option_t* option="");
+  /** 
+   * Set the end of integration
+   * 
+   * @param holdT Time when integration ends (nominally @f$
+   *        2\mu{}s@f$) 
+   */
+  void SetHoldTime(Double_t holdT=2e-6) { fHoldTime = holdT; }
+  Double_t GetHoldTime() const { return fHoldTime; }
 protected:
   /** Copy constructor 
       @param o Object to copy from */
   AliFMDHitDigitizer(const AliFMDHitDigitizer& o) 
     : AliFMDBaseDigitizer(o),
       fOutput(o.fOutput), 
+      fHoldTime(2e-6),
       fStack(o.fStack)
   {}
   /** Assignment operator
@@ -75,7 +85,9 @@ protected:
   AliFMDHitDigitizer& operator=(const AliFMDHitDigitizer& o) 
   {
     AliFMDBaseDigitizer::operator=(o);
+    fHoldTime    = o.fHoldTime;
     fOutput      = o.fOutput;
+    fStack       = o.fStack;
     return *this;
   }
   /** Make the output tree using the passed loader 
@@ -106,17 +118,18 @@ protected:
       @param count2   ADC count 2 (-1 if not used)
       @param count3   ADC count 3 (-1 if not used) 
       @param count4   ADC count 4 (-1 if not used) */
-  void AddDigit(UShort_t  detector, 
-               Char_t    ring,
-               UShort_t  sector, 
-               UShort_t  strip, 
-               Float_t   edep, 
-               UShort_t  count1, 
-               Short_t   count2, 
-               Short_t   count3,
-               Short_t   count4, 
-               UShort_t  ntot, 
-               UShort_t  nprim) const;
+  void AddDigit(UShort_t       detector, 
+               Char_t         ring,
+               UShort_t       sector, 
+               UShort_t       strip, 
+               Float_t        edep, 
+               UShort_t       count1, 
+               Short_t        count2, 
+               Short_t        count3,
+               Short_t        count4, 
+               UShort_t       ntot, 
+               UShort_t       nprim,
+               const TArrayI& trackrefs) const;
   /** Check that digit data is consistent
       @param digit   Digit
       @param nhits   Number of hits
@@ -130,6 +143,7 @@ protected:
   
 
   Output_t      fOutput;           // Output mode
+  Double_t      fHoldTime;         // Stop of integration
   AliStack*     fStack;            // Kinematics
 
   ClassDef(AliFMDHitDigitizer,1) // Make Digits from Hits
index ae98a01adaf19d1e09f7911793ed3fc2024593d1..9077fc5cec7ab90366cb13545be1f8178046a236 100644 (file)
@@ -78,23 +78,25 @@ AliFMDSDigit::AliFMDSDigit()
     fCount1(0),
     fCount2(-1),
     fCount3(-1), 
-    fCount4(-1)
+    fCount4(-1), 
+    fLabels(0)
 {
   // cTOR 
 }
 
 //____________________________________________________________________
-AliFMDSDigit::AliFMDSDigit(UShort_t detector, 
-                          Char_t   ring, 
-                          UShort_t sector, 
-                          UShort_t strip, 
-                          Float_t  edep,
-                          UShort_t count1,
-                          Short_t  count2, 
-                          Short_t  count3, 
-                          Short_t  count4,
-                          UShort_t npart,
-                          UShort_t nprim)
+AliFMDSDigit::AliFMDSDigit(UShort_t       detector, 
+                          Char_t         ring, 
+                          UShort_t       sector, 
+                          UShort_t       strip, 
+                          Float_t        edep,
+                          UShort_t       count1,
+                          Short_t        count2, 
+                          Short_t        count3, 
+                          Short_t        count4,
+                          UShort_t       npart,
+                          UShort_t       nprim,
+                          const TArrayI& refs)
   : AliFMDBaseDigit(detector, ring, sector, strip), 
     fEdep(edep),
     fCount1(count1),
@@ -102,7 +104,8 @@ AliFMDSDigit::AliFMDSDigit(UShort_t detector,
     fCount3(count3),
     fCount4(count4),
     fNParticles(npart), 
-    fNPrimaries(nprim)
+    fNPrimaries(nprim), 
+    fLabels(refs)
 {
   //
   // Creates a real data digit object
@@ -121,13 +124,23 @@ AliFMDSDigit::AliFMDSDigit(UShort_t detector,
 
 //____________________________________________________________________
 void
-AliFMDSDigit::Print(Option_t* /* option*/) const 
+AliFMDSDigit::Print(Option_t* option) const 
 {
   // Print digit to standard out 
   AliFMDBaseDigit::Print();
-  cout << "\t" << fEdep << " -> "
-       << fCount1 << " (" << fCount2 << "," << fCount3 << "," 
-       << fCount4 << ") = " << Counts() << endl;
+  std::cout << "\t" << fEdep << " -> "
+           << fCount1 << " (" << fCount2 << "," << fCount3 << "," 
+           << fCount4 << ") = " << Counts() << std::flush;
+  TString opt(option);
+  if (opt.Contains("p", TString::kIgnoreCase)) 
+    std::cout << " [" << fNPrimaries << "/" << fNParticles << "]"
+             << std::flush;
+  if (opt.Contains("l", TString::kIgnoreCase)) {
+    std::cout << " ";
+    for (Int_t i = 0; i < fLabels.fN; i++) 
+      std::cout << (i == 0 ? "" : ",") << fLabels.fArray[i];
+  }
+  std::cout << std::endl;
 }
 
 //____________________________________________________________________
index 6e6b1387ac34b6a8739b4994d67ec6d44630c882..18598eeeddf9f73b9785142b2f6ad6596a6067bb 100644 (file)
 #ifndef ALIFMDBASEDIGIT_H
 # include <AliFMDBaseDigit.h>
 #endif
+#ifndef ROOT_TArrayI
+# include <TArrayI.h>
+#endif
+
 //____________________________________________________________________
 /** @class AliFMDSDigit AliFMDDigit.h <FMD/AliFMDDigit.h>
     @brief class for summable digits 
@@ -34,17 +38,18 @@ public:
       @param count    ADC (first sample)
       @param count2   ADC (second sample, or -1 if not used)
       @param count3   ADC (third sample, or -1 if not used) */
-  AliFMDSDigit(UShort_t detector, 
-              Char_t   ring='\0', 
-              UShort_t sector=0, 
-              UShort_t strip=0, 
-              Float_t  edep=0,
-              UShort_t count=0, 
-              Short_t  count2=-1, 
-              Short_t  count3=-1,
-              Short_t  count4=-1,
-              UShort_t npart=0,
-              UShort_t nprim=0);
+  AliFMDSDigit(UShort_t       detector, 
+              Char_t         ring='\0', 
+              UShort_t       sector=0, 
+              UShort_t       strip=0, 
+              Float_t        edep=0,
+              UShort_t       count=0, 
+              Short_t        count2=-1, 
+              Short_t        count3=-1,
+              Short_t        count4=-1,
+              UShort_t       npart=0,
+              UShort_t       nprim=0, 
+              const TArrayI& refs=TArrayI());
   /** DTOR */
   virtual ~AliFMDSDigit() {}
   /** @return ADC count (first sample) */
@@ -63,7 +68,8 @@ public:
   UShort_t NParticles() const { return fNParticles; }
   /** @return Number of primary particles that hit this strip */
   UShort_t NPrimaries() const { return fNPrimaries; }
-     
+  /** @return the track labels */
+  const TArrayI& TrackLabels() const { return fLabels; }
   /** Print info 
       @param opt Not used */
   void     Print(Option_t* opt="") const;
@@ -75,7 +81,8 @@ protected:
   Short_t  fCount4;     // Digital signal (-1 if not used)
   UShort_t fNParticles; // Total number of particles that hit this strip
   UShort_t fNPrimaries; // Number of primary particles that his this strip
-  ClassDef(AliFMDSDigit,3)     // Summable FMD digit
+  TArrayI  fLabels;     // MC-truth track labels
+  ClassDef(AliFMDSDigit,4)     // Summable FMD digit
 };
   
 inline UShort_t 
diff --git a/FMD/AliFMDSurveyToAlignObjs.cxx b/FMD/AliFMDSurveyToAlignObjs.cxx
new file mode 100644 (file)
index 0000000..bac9fd7
--- /dev/null
@@ -0,0 +1,224 @@
+#include "AliFMDSurveyToAlignObjs.h"
+#include "AliSurveyPoint.h"
+#include <TGraph2DErrors.h>
+#include <TF2.h>
+#include <TVector3.h>
+#include <iostream>
+#include <iomanip>
+#include <TMath.h>
+#include <TRotation.h>
+#include <TGeoMatrix.h>
+#include <TGeoManager.h>
+#include <TGeoPhysicalNode.h>
+#include "AliFMDGeometry.h"
+
+//____________________________________________________________________
+Bool_t
+AliFMDSurveyToAlignObjs::GetFMD2Plane(Double_t* rot, 
+                                     Double_t* trans)
+{
+
+  // The possile survey points 
+  const char*  names[] = { "FMD2_ITOP",  "FMD2_OTOP", 
+                          "FMD2_IBOTM", "FMD2_OBOTM", 
+                          "FMD2_IBOT",  "FMD2_OBOT", 
+                          0 };
+  const char** name    = names;
+  Int_t    i = 0;
+  TGraph2DErrors g;
+  
+  Double_t unit = 1.;
+  TString units(fSurveyObj->GetUnits());
+  if      (units.CompareTo("mm", TString::kIgnoreCase) == 0) unit = .1;
+  else if (units.CompareTo("cm", TString::kIgnoreCase) == 0) unit = 1.;
+  else if (units.CompareTo("m",  TString::kIgnoreCase) == 0) unit = 100.;
+  
+  // Loop and fill graph 
+  while (*name) {
+    TObject* obj = fSurveyPoints->FindObject(*name);
+    name++;
+    if (!obj) continue;
+    
+    AliSurveyPoint* p = static_cast<AliSurveyPoint*>(obj);
+    Double_t x  = unit * p->GetX();
+    Double_t y  = unit * p->GetY();
+    Double_t z  = unit * p->GetZ();
+    Double_t ex = unit * p->GetPrecisionX();
+    Double_t ey = unit * p->GetPrecisionY();
+    Double_t ez = unit * p->GetPrecisionZ();
+    
+    g.SetPoint(i, x, y, z);
+    g.SetPointError(i, ex, ey, ez);
+    i++;
+  }
+  
+  // Check that we have enough points
+  if (g.GetN() < 4) { 
+    Error("GetFMD2Plane", "Only got %d survey points - no good for FMD2 plane",
+         g.GetN());
+    return kFALSE;
+  }
+
+  // Next, declare fitting function and fit to graph. 
+  // Fit to the plane equation: 
+  // 
+  //   ax + by + cz + d = 0
+  //
+  // or 
+  // 
+  //   z = - ax/c - by/c - d/c
+  //
+  TF2 f("fmd2Plane", "-[0]*x-[1]*y-[2]", 
+       g.GetXmin(), g.GetXmax(), g.GetYmin(), g.GetYmax());
+  g.Fit(&f, "Q");
+
+  // Now, extract the normal and offset
+  TVector3 nv(f.GetParameter(0), f.GetParameter(1), 1);
+  TVector3 n(nv.Unit());
+  Double_t p = -f.GetParameter(2);
+
+  // Create two vectors spanning the plane 
+  TVector3 a(1, 0, f.Eval(1, 0)-p);
+  TVector3 b(0, -1, f.Eval(0, -1)-p);
+  TVector3 ua(a.Unit());
+  TVector3 ub(b.Unit());
+  Double_t angAb = ua.Angle(ub);
+  PrintVector("ua: ", ua);
+  PrintVector("ub: ", ub);
+  std::cout << "Angle: " << angAb * 180 / TMath::Pi() << std::endl;
+  
+  for (size_t i = 0; i < 3; i++) { 
+    rot[i * 3 + 0] = ua[i];
+    rot[i * 3 + 1] = ub[i];
+    rot[i * 3 + 2] = n[i];
+  }
+  
+  // The intersection of the plane is given by (0, 0, -d/c)
+  trans[0] = 0;
+  trans[1] = 0;
+  trans[2] = p;
+
+  return kTRUE;
+}
+
+#define M(I,J) rot[(J-1) * 3 + (I-1)]
+//____________________________________________________________________
+Bool_t
+AliFMDSurveyToAlignObjs::DoFMD2()
+{
+  Double_t rot[9], trans[3];
+  if (!GetFMD2Plane(rot, trans)) return kFALSE;
+  
+  PrintRotation("Rotation: ", rot);
+  PrintVector("Translation: ", trans);
+
+#if 0
+  Double_t theta = TMath::ATan2(M(3,1), M(3,2));
+  Double_t phi   = TMath::ACos(M(3,3));
+  Double_t psi   = -TMath::ATan2(M(1,3), M(2,3));
+  
+  std::cout << " Theta=" << theta * 180 / TMath::Pi() 
+           << " Phi="   << phi   * 180 / TMath::Pi() 
+           << " Psi="   << psi   * 180 / TMath::Pi() 
+           << std::endl;
+
+  TRotation r;
+  r.SetXEulerAngles(theta, phi, psi);
+  r.Print();
+  
+  TGeoRotation*   geoR = new TGeoRotation("FMD2_survey_rotation", 
+                                         r.GetYTheta(),
+                                         r.GetYPhi(),
+                                         r.GetYPsi());
+  TGeoCombiTrans* geoM = new TGeoCombiTrans(trans[0], trans[1], trans[2], geoR);
+#else
+  TGeoHMatrix* geoM = new TGeoHMatrix;
+  geoM->SetRotation(rot);
+  geoM->SetTranslation(trans);
+#endif
+  geoM->Print();
+
+  const char* path = "/ALIC_1/F2MT_2/FMD2_support_0/FMD2_back_cover_2";
+  gGeoManager->cd(path);
+  TGeoMatrix* globalBack = gGeoManager->GetCurrentMatrix();
+  globalBack->Print();
+  PrintRotation("Back rotation:",    globalBack->GetRotationMatrix());
+  PrintVector("Back translation:",   globalBack->GetTranslation());
+  
+  // TObjArray* pns = gGeoManager->GetListOfPhysicalNodes();
+  // TObject*   oT  = pns->FindObject("/ALIC_1/F2MT_2");
+  // TObject*   oB  = pns->FindObject("/ALIC_1/F2MB_2");
+  // if (!oT) { 
+  //   Warning("DoFMD2", Form("Physical node /ALIC_1/F2MT_2 not found"));
+  //   return kFALSE;
+  // }
+  // if (!oB) { 
+  //   Warning("DoFMD2", Form("Physical node /ALIC_1/F2MB_2 not found"));
+  //   return kFALSE;
+  // }
+  // TGeoPhysicalNode* top = static_cast<TGeoPhysicalNode*>(oT);
+  // TGeoPhysicalNode* bot = static_cast<TGeoPhysicalNode*>(oB);
+  TGeoHMatrix tDelta(globalBack->Inverse());
+  TGeoHMatrix bDelta(globalBack->Inverse());
+  PrintRotation("Back^-1 rotation:",    tDelta.GetRotationMatrix());
+  PrintVector("Back^-1 translation:",   tDelta.GetTranslation());
+
+  std::cout << "tDelta = 1? " << tDelta.IsIdentity() << std::endl;
+  
+  tDelta.MultiplyLeft(geoM);
+  bDelta.MultiplyLeft(geoM);
+  
+  PrintRotation("tDelta rotation:",  tDelta.GetRotationMatrix());
+  PrintVector("tDelta translation:", tDelta.GetTranslation());
+  PrintRotation("bDelta rotation:",  bDelta.GetRotationMatrix());
+  PrintVector("bDelta translation:", bDelta.GetTranslation());
+  
+  return kTRUE;
+}
+
+//____________________________________________________________________
+void
+AliFMDSurveyToAlignObjs::Run()
+{
+  AliFMDGeometry* geom = AliFMDGeometry::Instance();
+  geom->Init();
+  geom->InitTransformations();
+  
+  DoFMD2();
+}
+
+//____________________________________________________________________
+void 
+AliFMDSurveyToAlignObjs::PrintVector(const char* text, const TVector3& v)
+{
+  Double_t va[] = { v.X(), v.Y(), v.Z() };
+  PrintVector(text, va);
+}
+//____________________________________________________________________
+void 
+AliFMDSurveyToAlignObjs::PrintVector(const char* text, const Double_t* v)
+{
+  std::cout << text 
+           << std::setw(15) << v[0] 
+           << std::setw(15) << v[1]
+           << std::setw(15) << v[2]
+           << std::endl;
+}
+
+
+//____________________________________________________________________
+void 
+AliFMDSurveyToAlignObjs::PrintRotation(const char* text, const Double_t* rot)
+{
+  std::cout << text << std::endl;
+  for (size_t i = 0; i < 3; i++) { 
+    for (size_t j = 0; j < 3; j++) 
+      std::cout << std::setw(15) << rot[i * 3 + j];
+    std::cout << std::endl;
+  }
+}
+
+//____________________________________________________________________
+//
+// EOF
+//
diff --git a/FMD/AliFMDSurveyToAlignObjs.h b/FMD/AliFMDSurveyToAlignObjs.h
new file mode 100644 (file)
index 0000000..e510dbd
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef ALIFMDSURVEYTOALIGNOBJS_H
+#define ALIFMDSURVEYTOALIGNOBJS_H
+#include <AliSurveyToAlignObjs.h>
+
+// Forward decl
+class TVector3;
+
+
+class AliFMDSurveyToAlignObjs : public AliSurveyToAlignObjs
+{
+public:
+  AliFMDSurveyToAlignObjs() : AliSurveyToAlignObjs() {}
+  void Run();
+  Bool_t CreateAlignObjs() { return kTRUE; }
+protected:
+  Bool_t DoFMD2();
+  Bool_t GetFMD2Plane(Double_t* rot, Double_t* trans);
+
+  static void PrintVector(const char* text, const Double_t* v);
+  static void PrintVector(const char* text, const TVector3& v);
+  static void PrintRotation(const char* text, const Double_t* rot);
+
+  
+  ClassDef(AliFMDSurveyToAlignObjs,0) // Convert FMD survey to alignments
+};
+
+
+#endif
+//____________________________________________________________________
+//
+// Local Variables:
+//  mode: C++
+// End:
+//
+
index 5a6602b9bd9279fb5b66a5d218372fa2b955649a..6f23101e87b1811e4b863756a02df3c3985b6788 100644 (file)
@@ -35,6 +35,7 @@
 #pragma link C++ class  AliFMDPreprocessor+;
 #pragma link C++ class  AliFMDQAChecker+;
 #pragma link C++ class  AliFMDGeometryBuilder+;
+#pragma link C++ class  AliFMDSurveyToAlignObjs+;
 
 // #pragma link C++ class  AliFMDAltroIO+;
 // #pragma link C++ class  AliFMDAltroReader+;
index ba4fffac8d4bbdd3bdb502c0955a3d1574783d1e..9c7063a260b008b8536f2b718da88c2eaafa1a96 100644 (file)
@@ -22,12 +22,12 @@ SRCS                =  AliFMDIndex.cxx              \
                   AliFMD3.cxx                  \
                   AliFMDPreprocessor.cxx       \
                   AliFMDQAChecker.cxx          \
-                  AliFMDGeometryBuilder.cxx  
+                  AliFMDGeometryBuilder.cxx    \
+                  AliFMDSurveyToAlignObjs.cxx  
 
 #                 AliFMDAltroIO.cxx            
 
-HDRS           =  $(SRCS:.cxx=.h)  \
-                  AliFMDStripIndex.h
+HDRS           =  $(SRCS:.cxx=.h) 
 DHDR           := FMDbaseLinkDef.h
 
 EINCLUDE        :=  RAW
diff --git a/FMD/scripts/TestSurveyToAlignObjs.C b/FMD/scripts/TestSurveyToAlignObjs.C
new file mode 100644 (file)
index 0000000..e473560
--- /dev/null
@@ -0,0 +1,10 @@
+void
+TestSurveyToAlignObjs()
+{
+  AliGeomManager::LoadGeometry("geometry.root");
+
+  AliFMDSurveyToAlignObjs convert;
+  convert.LoadSurveyFromLocalFile("$ALICE_ROOT/FMD/Survey_XXX_FMD.txt");
+  convert.Run();
+}
+