AliMUONDigitCalibrator.cxx
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Feb 2008 18:25:06 +0000 (18:25 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Feb 2008 18:25:06 +0000 (18:25 +0000)
       Two bug fixes : a major one that lead to a crash in reconstruction when there is missing gain values for some manus, and a minor one that inhibited the usage of the "GAIN" option.

MUONOfflineShift.C

        Update of the macro which is now running 4 times on the same raw data to test the various reco options (no zero suppression, zero suppression alone, zero suppression + gain correction w/ constant capacitance, and finally the full blown calibration with zero suppression, gain correction w/ channel dependent capacitance)

MUON/AliMUONDigitCalibrator.cxx
MUON/MUONOfflineShift.C

index c7fd8888df791aabc2b92e2d273ff70827a2ad92..fb6f83d5530d5cac3e96d237053dafcc4380f525 100644 (file)
@@ -62,7 +62,7 @@ const Int_t AliMUONDigitCalibrator::fgkGain(2);
 AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib,
                                                const char* calibMode)
 : TObject(),
 AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib,
                                                const char* calibMode)
 : TObject(),
-fLogger(new AliMUONLogger(1000)),
+fLogger(new AliMUONLogger(20000)),
 fStatusMaker(0x0),
 fStatusMapMaker(0x0),
 fPedestals(0x0),
 fStatusMaker(0x0),
 fStatusMapMaker(0x0),
 fPedestals(0x0),
@@ -80,7 +80,7 @@ fCapacitances(0x0)
     fApplyGains = fgkNoGain;
     AliInfo("Will NOT apply gain correction");
   }
     fApplyGains = fgkNoGain;
     AliInfo("Will NOT apply gain correction");
   }
-  else if ( cMode = "GAINCONSTANTCAPA" ) 
+  else if ( cMode == "GAINCONSTANTCAPA" ) 
   {
     fApplyGains = fgkGainConstantCapa;
     AliInfo("Will apply gain correction, but with constant capacitance");
   {
     fApplyGains = fgkGainConstantCapa;
     AliInfo("Will apply gain correction, but with constant capacitance");
@@ -190,23 +190,34 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
 
     AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
     (fPedestals->FindObject(digit.DetElemId(),digit.ManuId()));
 
     AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
     (fPedestals->FindObject(digit.DetElemId(),digit.ManuId()));
-    
+
     if (!pedestal)
     {
     if (!pedestal)
     {
-      AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
-                    digit.DetElemId(),digit.ManuId()));
+      // no pedestal -> no charge
+      digit.SetCharge(0);
       
       
+      fLogger->Log(Form("Got a null pedestal object for DE,manu=%d,%d",
+                        digit.DetElemId(),digit.ManuId()));        
+      return;
     }
     }
-
+    
+    
     AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
         (fGains->FindObject(digit.DetElemId(),digit.ManuId()));
 
     if (!gain)
     {
     AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
         (fGains->FindObject(digit.DetElemId(),digit.ManuId()));
 
     if (!gain)
     {
-      AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
-                    digit.DetElemId(),digit.ManuId()));        
+      if ( fApplyGains != fgkNoGain )
+      {
+        // no gain -> no charge
+        digit.SetCharge(0);
+
+        fLogger->Log(Form("Got a null gain object for DE,manu=%d,%d",
+                          digit.DetElemId(),digit.ManuId())); 
+        return;
+      }
     }
     }
-    
+
     Int_t manuChannel = digit.ManuChannel();
     Float_t adc = digit.ADC();
     Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
     Int_t manuChannel = digit.ManuChannel();
     Float_t adc = digit.ADC();
     Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
@@ -225,7 +236,15 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
 
       AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fCapacitances->FindObject(serialNumber));
       
 
       AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fCapacitances->FindObject(serialNumber));
       
-      capa = param->ValueAsFloat(digit.ManuChannel());
+      if ( param )
+      {
+        capa = param->ValueAsFloat(digit.ManuChannel());
+      }
+      else
+      {
+        fLogger->Log(Form("No capa found for serialNumber=%d",serialNumber));
+        capa = 0.0;
+      }
     }
     
     if ( padc > 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
     }
     
     if ( padc > 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
@@ -249,9 +268,17 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
         charge = padc;
       }
     }
         charge = padc;
       }
     }
+    
     charge *= capa;
     digit.SetCharge(charge);
     charge *= capa;
     digit.SetCharge(charge);
-    Int_t saturation = gain->ValueAsInt(manuChannel,4);
+    
+    Int_t saturation(3000);
+    
+    if ( gain )
+    {
+      saturation = gain->ValueAsInt(manuChannel,4);
+    }
+    
     if ( padc >= saturation )
     {
       digit.Saturated(kTRUE);
     if ( padc >= saturation )
     {
       digit.Saturated(kTRUE);
index 7a4029aafe529ad3dabe93e2a7ac3ce61c9f6825..1538aeee84894f08cb12c09ba0691ad5c352c05d 100644 (file)
 ///  
 /// Basic usage is : 
 ///
 ///  
 /// Basic usage is : 
 ///
-/// MUONOfflineShift("path_to_raw_file","basename of output file")
+/// MUONOfflineShift("path_to_raw_file","basename of output file"); > log
+///
+/// (the redirection to an output log file is recommended as the output from
+/// this macro might be quite long...)
 ///
 /// This will read the raw data and process it several times, varying what's done :
 /// only decoding, decoding + zero-suppression, etc... (TBE)
 ///
 /// This will read the raw data and process it several times, varying what's done :
 /// only decoding, decoding + zero-suppression, etc... (TBE)
@@ -59,7 +62,7 @@
 #endif
 
 //______________________________________________________________________________
 #endif
 
 //______________________________________________________________________________
-Int_t DataMakerReading(AliRawReader* rawReader, 
+Int_t DataMakerReading(const char* input,
                        TStopwatch& timer,
                        const char* cdbPath="",
                        const char* calibMode="",
                        TStopwatch& timer,
                        const char* cdbPath="",
                        const char* calibMode="",
@@ -73,7 +76,21 @@ Int_t DataMakerReading(AliRawReader* rawReader,
   /// - GAINCONSTANTCAPA : zero-suppression + gain, but with a single capa value for all channels
   /// - GAIN             : zero-suppression + gain w/ individual capacitance per channel.
   
   /// - GAINCONSTANTCAPA : zero-suppression + gain, but with a single capa value for all channels
   /// - GAIN             : zero-suppression + gain w/ individual capacitance per channel.
   
-  rawReader->RewindEvents();
+  TString fileName(gSystem->ExpandPathName(input));
+  
+  AliRawReader* rawReader(0x0);
+  
+  // check extention to choose the rawdata file format
+  if (fileName.EndsWith(".root")) 
+  {
+    rawReader = new AliRawReaderRoot(fileName);
+  }
+  else if (!fileName.IsNull()) 
+  {
+    rawReader = new AliRawReaderDate(fileName); // DATE file
+  }
+  
+  if (!rawReader) return 0;
   
   AliMUONVTrackerDataMaker* dm(0x0);
   
   
   AliMUONVTrackerDataMaker* dm(0x0);
   
@@ -194,7 +211,8 @@ void Occupancy(ostream& outfile)
 }
 
 //______________________________________________________________________________
 }
 
 //______________________________________________________________________________
-void MUONOfflineShift(const char* input, const char* outputBase,
+void MUONOfflineShift(const char* input="alien:///alice/data/2008/LHC08a/000021931/raw/08000021931001.50.root", 
+                      const char* outputBase="21931.001.50",
                       const char* ocdbPath="alien://folder=/alice/data/2008/LHC08a/OCDB")
 {
   /// Entry point of the macro. 
                       const char* ocdbPath="alien://folder=/alice/data/2008/LHC08a/OCDB")
 {
   /// Entry point of the macro. 
@@ -215,32 +233,23 @@ void MUONOfflineShift(const char* input, const char* outputBase,
   AliCDBManager::Instance()->SetRun(0);
   AliMpCDB::LoadDDLStore();
   
   AliCDBManager::Instance()->SetRun(0);
   AliMpCDB::LoadDDLStore();
   
-  TString fileName(gSystem->ExpandPathName(input));
-  
-  AliRawReader* rawReader(0x0);
-  
-  // check extention to choose the rawdata file format
-  if (fileName.EndsWith(".root")) 
-  {
-    rawReader = new AliRawReaderRoot(fileName);
-  }
-  else if (!fileName.IsNull()) 
-  {
-    rawReader = new AliRawReaderDate(fileName); // DATE file
-  }
-  
-  if (!rawReader) return;
-  
+  TStopwatch timer1;
   TStopwatch timer2;
   TStopwatch timer3;
   TStopwatch timer2;
   TStopwatch timer3;
+  TStopwatch timer4;
   
   
-  Int_t n2 = DataMakerReading(rawReader,timer2);
-  
-  Int_t n3 = DataMakerReading(rawReader,timer3,ocdbPath);
+  Int_t n1 = DataMakerReading(input,timer1);
   
   
-  Print("DataMakerReading(RAW)",timer2,n2);
-  
-  Print("DataMakerReading(CAL)",timer3,n3);
+  Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN",kTRUE);
+
+  Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA",kTRUE);
+
+  Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN",kTRUE);
+
+  Print("DataMakerReading(HRAW)",timer1,n1);  
+  Print("DataMakerReading(HCALZ)",timer2,n2);
+  Print("DataMakerReading(HCALG)",timer3,n3);
+  Print("DataMakerReading(HCALC)",timer4,n4);
   
   AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
   
   
   AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();