]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDReconstructor.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / FMD / AliFMDReconstructor.cxx
index a230b0c6a15b47b5d037142fe2964ac83a977de0..7b295f2e1de69517024350ec6f2e18c57fa5df15 100644 (file)
@@ -118,7 +118,7 @@ AliFMDReconstructor::Init()
 
   // Initialize the parameters
   AliFMDParameters* param = AliFMDParameters::Instance();
-  if (param->Init() != 0) {
+  if (param->Init(true) != 0) {
     AliError("Failed to initialize parameters, making zombie");
     fZombie = true;
   }
@@ -188,7 +188,8 @@ AliFMDReconstructor::ConvertDigits(AliRawReader* reader,
     AliError("No digits tree passed");
     return;
   }
-  static TClonesArray* array = new TClonesArray("AliFMDDigit");
+  static TClonesArray* array = 0;
+  if (!array) array = new TClonesArray("AliFMDDigit");
   digitsTree->Branch("FMD", &array);
   array->Clear();
   
@@ -198,14 +199,15 @@ AliFMDReconstructor::ConvertDigits(AliRawReader* reader,
   rawRead.ReadAdcs(array);
 
   Int_t nWrite = digitsTree->Fill();
-  AliFMDDebug(1, ("Got a grand total of %d digits, wrote %d bytes to tree", 
-                  array->GetEntriesFast(), nWrite));
+  AliDebugF(1, "Got a grand total of %d digits, wrote %d bytes to tree", 
+           array->GetEntriesFast(), nWrite);
 
   
   AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
-  for (size_t i = 1; i <= 3; i++) { 
+  for (UShort_t i = 1; i <= 3; i++) { 
     fZS[i-1]       = rawRead.IsZeroSuppressed(map->Detector2DDL(i));
     fZSFactor[i-1] = rawRead.NoiseFactor(map->Detector2DDL(i));
+    AliDebugF(2, "Noise factor for FMD%hu: %d", i, fZSFactor[i-1]);
   }
 }
 
@@ -320,19 +322,23 @@ AliFMDReconstructor::MarkDeadChannels(AliESDFMD* esd) const
          // Hence, a dead strip will always be marked kInvalid here, 
          // while a non-dead bad-read strip will be filled with 0. 
          if (fBad(d, r, s, t)) { 
-           AliDebug(5, Form("Marking FMD%d%c[%2d,%3d] as bad", d, r, s, t));
+           AliDebugF(5, "Marking FMD%d%c[%2d,%3d] as bad", d, r, s, t);
            esd->SetMultiplicity(d, r, s, t, AliESDFMD::kInvalidMult);
          }         
          if (param->IsDead(d, r, s, t)) { 
-           AliDebug(5, Form("Marking FMD%d%c[%2d,%3d] as dead", d, r, s, t));
+           AliDebugF(5, "Marking FMD%d%c[%2d,%3d] as dead", d, r, s, t);
            esd->SetMultiplicity(d, r, s, t, AliESDFMD::kInvalidMult);
            // esd->SetEta(d, r, s, t, AliESDFMD::kInvalidEta);
          }
          else if (esd->Multiplicity(d, r, s, t) == AliESDFMD::kInvalidMult) {
-           AliDebug(10, Form("Setting null signal in FMD%d%c[%2d,%3d]", 
-                             d, r, s, t));
+           AliDebugF(20, "Setting null signal in FMD%d%c[%2d,%3d]", 
+                     d, r, s, t);
            esd->SetMultiplicity(d, r, s, t, 0);
          }
+         else {
+           AliDebugF(10, "Setting FMD%d%c[%2d,%3d]=%f",d,r,s,t,
+                     esd->Multiplicity(d, r, s, t));
+         }
        }
       }
     }
@@ -500,10 +506,10 @@ AliFMDReconstructor::Reconstruct(TTree* digitsTree,
   fTreeR = clusterTree;
   fTreeR->Branch("FMD", &fMult);
   
-  AliFMDDebug(5, ("Getting entry 0 from digit branch"));
+  AliDebug(5, "Getting entry 0 from digit branch");
   digitBranch->GetEntry(0);
   
-  AliFMDDebug(5, ("Processing digits"));
+  AliDebugF(5, "Processing %d digits", digits->GetEntriesFast());
   UseRecoParam(kTRUE);
   ProcessDigits(digits);
   UseRecoParam(kFALSE);
@@ -579,7 +585,7 @@ AliFMDReconstructor::ProcessDigit(AliFMDDigit* digit) const
   UShort_t sec = digit->Sector();
   UShort_t str = digit->Strip();
   Short_t  adc = digit->Counts();
+  // if (AliLog::GetDebugLevel("FMD","")>3) digit->Print();
   ProcessSignal(det, rng, sec, str, adc);
 }
 
@@ -600,8 +606,13 @@ AliFMDReconstructor::ProcessSignal(UShort_t det,
   //    rng    Strip ID
   //    adc     ADC counts
   // 
+  Int_t  dbg = AliLog::GetDebugLevel("FMD","");
+  Bool_t dhr = dbg > 3 && dbg < 10;
+  if (dhr) printf("FMD%d%c[%2d,%3d] adc=%4d ", det, rng, sec, str, adc);
+  
   if (adc >= AliFMDRawReader::kBadSignal) { 
-    AliFMDDebug(3, ("FMD%d%c[%2d,%3d] is marked bad", det, rng, sec, str));
+    AliFMDDebug(10, ("FMD%d%c[%2d,%3d] is marked bad", det, rng, sec, str));
+    if (dhr) Printf("bad");
     fBad(det,rng,sec,str) = true;
     return;
   }
@@ -609,7 +620,8 @@ AliFMDReconstructor::ProcessSignal(UShort_t det,
   // Check that the strip is not marked as dead 
   AliFMDParameters* param  = AliFMDParameters::Instance();
   if (param->IsDead(det, rng, sec, str)) {
-    AliFMDDebug(3, ("FMD%d%c[%2d,%3d] is dead", det, rng, sec, str));
+    AliFMDDebug(10, ("FMD%d%c[%2d,%3d] is dead", det, rng, sec, str));
+    if (dhr) Printf("dead");
     fBad(det,rng,sec,str) = true;
     return;
   }
@@ -620,12 +632,20 @@ AliFMDReconstructor::ProcessSignal(UShort_t det,
     
   // Substract pedestal. 
   UShort_t counts   = SubtractPedestal(det, rng, sec, str, adc);
-  if(counts == USHRT_MAX) return;
+  if(counts == USHRT_MAX)  { 
+    if (dhr) Printf("invalid");
+    return;
+  }
+  if (dhr) printf("counts=%4d ", counts);
   
     // Gain match digits. 
   Double_t edep     = Adc2Energy(det, rng, sec, str, eta, counts);
   // Get rid of nonsense energy
-  if(edep < 0)  return;
+  if(edep < 0)  { 
+    if (dhr) Printf("zero");
+    return;
+  }
+  if (dhr) printf("edep=%f ", edep);
   
   // Make rough multiplicity 
   Double_t mult     = Energy2Multiplicity(det, rng, sec, str, edep);
@@ -635,7 +655,12 @@ AliFMDReconstructor::ProcessSignal(UShort_t det,
   //               "(ADC: %d, Energy: %f)", det, rng, sec, str, mult, 
   //               counts, edep));
   // }
-  if (mult < 0)  return; 
+  if (mult < 0)  {
+    if (dhr) Printf("not hit");
+    return; 
+  }
+
+  if (dhr) Printf("mult=%f ", mult);
   AliFMDDebug(10, ("FMD%d%c[%2d,%3d]: "
                    "ADC: %d, Counts: %d, Energy: %f, Mult: %f",
                  det, rng, sec, str, adc, counts, edep, mult));
@@ -735,13 +760,13 @@ AliFMDReconstructor::SubtractPedestal(UShort_t det,
   Float_t           ped    = (zsEnabled ? 0 : 
                              param->GetPedestal(det, rng, sec, str));
   Float_t           noise  = param->GetPedestalWidth(det, rng, sec, str);
-  if(ped < 0 || noise < 0) { 
+  if (ped < 0 || noise < 0) { 
     AliWarningClass(Form("Invalid pedestal (%f) or noise (%f) "
                         "for FMD%d%c[%02d,%03d]", 
                    ped, noise, det, rng, sec, str));
     return USHRT_MAX;
   }
-  AliDebugClass(15, Form("Subtracting pedestal for FMD%d%c[%2d,%3d]=%4d "
+  AliDebugClass(10, Form("Subtracting pedestal for FMD%d%c[%2d,%3d]=%4d "
                         "(%s w/factor %d, noise factor %f, "
                         "pedestal %8.2f+/-%8.2f)",
                         det, rng, sec, str, adc, 
@@ -765,8 +790,8 @@ AliFMDReconstructor::SubtractPedestal(UShort_t det,
   //
   // In this way, we make sure that we do not suppress away too much
   // data, and that the read-factor is the most stringent cut. 
-  Float_t nf = TMath::Max(0.F, noiseFactor - (zsEnabled ? zsNoiseFactor : 0));
-  if (counts < noise * nf) counts = 0;
+  Float_t nf = zsNoiseFactor; // TMath::Max(0.F, noiseFactor - (zsEnabled ? zsNoiseFactor : 0));
+  if (counts <= noise * nf) counts = 0;
   if (counts > 0) AliDebugClass(15, "Got a hit strip");
 
   UShort_t ret = counts < 0 ? 0 : counts;
@@ -849,12 +874,12 @@ AliFMDReconstructor::Adc2Energy(UShort_t det,
   Float_t           gain  = param->GetPulseGain(det, rng, sec, str);
   // 'Tagging' bad gains as bad energy
   if (gain < 0) { 
-    AliWarning(Form("Invalid gain (%f) for FMD%d%c[%02d,%03d]", 
-                   gain, det, rng, sec, str));
+    AliDebugF(10, "Invalid gain (%f) for FMD%d%c[%02d,%03d]", 
+               gain, det, rng, sec, str);
     return -1;
   }
-  AliFMDDebug(5, ("Converting counts %d to energy (factor=%f, DAC2MIP=%f)", 
-                 count, gain,param->GetDACPerMIP()));
+  AliDebugF(10, "Converting counts %d to energy (factor=%f, DAC2MIP=%f)", 
+           count, gain,param->GetDACPerMIP());
 
   Double_t edep  = ((count * param->GetEdepMip()) 
                    / (gain * param->GetDACPerMIP()));
@@ -913,8 +938,8 @@ AliFMDReconstructor::Adc2Energy(UShort_t det,
     Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
     Double_t corr  = TMath::Abs(TMath::Cos(theta));
     Double_t cedep = corr * edep;
-    AliFMDDebug(10, ("correcting for path %f * %f = %f (eta=%f, theta=%f)",
-                     edep, corr, cedep, eta, theta));
+    AliDebugF(10, "correcting for path %f * %f = %f (eta=%f, theta=%f)",
+             edep, corr, cedep, eta, theta);
     if (fDiagStep3) fDiagStep3->Fill(edep, cedep);  
     edep = cedep;
   }