]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPedestalEventGenerator.cxx
Eff C++ warning removal
[u/mrichter/AliRoot.git] / MUON / AliMUONPedestalEventGenerator.cxx
index 7f0953bd7e60907cb131a20df33454d8f73e538f..fabf0891a348e1cc14520904b55fa93bd9467a06 100644 (file)
 
 #include "AliMUONPedestalEventGenerator.h"
 
+#include "AliCodeTimer.h"
+#include "AliDAQ.h"
 #include "AliHeader.h"
 #include "AliLog.h"
 #include "AliMUONCalibrationData.h"
-#include "AliMUONDigitStoreV1.h"
 #include "AliMUONRawWriter.h"
-#include "AliMUONStopwatchGroup.h"
-#include "AliMUONStopwatchGroupElement.h"
 #include "AliMUONVCalibParam.h"
 #include "AliMUONVDigit.h"
+#include "AliMUONVDigitStore.h"
 #include "AliMUONVStore.h"
 #include "AliMpCathodType.h"
 #include "AliMpConstants.h"
@@ -33,6 +33,7 @@
 #include "AliMpDetElement.h"
 #include "AliMpIntPair.h"
 #include "AliMpPlaneType.h"
+#include "AliRawDataHeaderSim.h"
 #include "AliRunLoader.h"
 #include <TClonesArray.h>
 #include <TMath.h>
@@ -40,9 +41,8 @@
 #include <TRandom.h>
 #include <TStopwatch.h>
 #include <TSystem.h>
-#include "AliDAQ.h"
 
-///
+//-----------------------------------------------------------------------------
 /// \class AliMUONPedestalEventGenerator
 ///
 /// Generate simulated pedestal events for MUON TRK, to be able to e.g. test
@@ -57,7 +57,7 @@
 /// + raw (date files, one per LDC), depending of ctor and MakeDDL() method.
 ///
 /// \author L. Aphecetche
-///
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMUONPedestalEventGenerator)
@@ -86,7 +86,6 @@ fGAliceFileName("galice.root"),
 fMakeDDL(kTRUE),
 fLoader(0x0),
 fPedestals(fCalibrationData->Pedestals()),
-fTimers(new AliMUONStopwatchGroup),
 fDigitStore(0x0),
 fRawWriter(0x0)
 {
@@ -136,9 +135,6 @@ AliMUONPedestalEventGenerator::~AliMUONPedestalEventGenerator()
 {
   /// dtor
   delete fCalibrationData;
-  AliInfo("Timers:");
-  fTimers->Print();
-  delete fTimers;
   AliInfo(Form("make a digit counter %d",fgCounter));
   delete fDigitStore;
   delete fRawWriter;
@@ -151,7 +147,7 @@ AliMUONPedestalEventGenerator::ConvertRawFilesToDate()
   /// convert raw data DDL files to DATE files with the program "dateStream".
   /// we make one file per LDC
   
-  AliMUONStopwatchGroupElement timer(fTimers,"MUON","AliMUONPedestalEventGenerator::ConvertRawFilesToDate");
+  AliCodeTimerAuto("")
   
   AliInfo("Converting raw to date");
   
@@ -222,6 +218,13 @@ AliMUONPedestalEventGenerator::ConvertRawFilesToDate()
     result += gSystem->ClosePipe(pipe[iFile]);
   }
   
+  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); ++iEvent) 
+  {
+    char command[256];
+    sprintf(command, "rm -r raw%d", iEvent);
+    gSystem->Exec(command);
+  }
+  
   delete [] pipe;
   delete runLoader;
   fLoader=0x0;
@@ -234,7 +237,7 @@ AliMUONPedestalEventGenerator::DigitStore()
 {
 /// Return digt container; create it if it does not exist
 
-  if (!fDigitStore) fDigitStore = new AliMUONDigitStoreV1;
+  if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
   return fDigitStore;
 }
 
@@ -244,7 +247,7 @@ AliMUONPedestalEventGenerator::Exec(Option_t*)
 {  
   /// Main steering method
   
-  AliMUONStopwatchGroupElement timer(fTimers,"MUON","AliMUONPedestalEventGenerator::Exec");
+  AliCodeTimerAuto("")
   
   if (!fPedestals)
   {
@@ -280,18 +283,17 @@ AliMUONPedestalEventGenerator::Exec(Option_t*)
     // tree (=TreeD) in different branches, this WriteDigits in fact writes all of 
     // the 3 branches.
 
-    fTimers->Start("MUON","AliMUONPedestalEventGenerator::Exec WriteDigits");
+    AliCodeTimerStart("WriteDigits")
     fLoader->WriteDigits("OVERWRITE");
-    fTimers->Stop("MUON","AliMUONPedestalEventGenerator::Exec WriteDigits");
+    AliCodeTimerStop("WriteDigits")
     
     fLoader->UnloadDigits();
     
     if ( fMakeDDL )
     {
+      AliCodeTimerAuto("Digits2Raw");
       Digits2Raw(i);
     }
-    
-//    gROOT->ProcessLine(Form("gObjectTable->Print(); > generate.txt.%d",i));
   }
     
   runLoader->WriteRunLoader("OVERWRITE");
@@ -301,6 +303,7 @@ AliMUONPedestalEventGenerator::Exec(Option_t*)
   // Finally, if instructed to do so, convert DDL files to DATE file(s)
   if ( fMakeDDL && fDateFileName.Length() > 0 ) 
   {
+    AliCodeTimerAuto("ConvertRawFilesToDate")
     Bool_t dateOutput = ConvertRawFilesToDate();
     if (!dateOutput) 
     {
@@ -316,9 +319,14 @@ AliMUONPedestalEventGenerator::Digits2Raw(Int_t event)
 {
   /// Converts digits (from MUON.Digits.root file) to Raw DDL ascii files.
   
-  AliMUONStopwatchGroupElement timer(fTimers,"MUON","AliMUONPedestalEventGenerator::Digits2Raw");
+  AliCodeTimerAuto("")
   
-  if (!fRawWriter) fRawWriter = new AliMUONRawWriter;
+  if (!fRawWriter) 
+  {
+      AliRawDataHeaderSim header;
+      fRawWriter = new AliMUONRawWriter;
+      fRawWriter->SetHeader(header);
+  }
   
   // Generate RAW data from the digits
   // Be carefull to create&change to the correct directory first...
@@ -346,7 +354,7 @@ AliMUONPedestalEventGenerator::GenerateDigits(AliMUONVDigitStore& digitStore)
   /// Generate digits (where ADC is set to pedestal value) for all MUON TRK
   /// and for 1 event.
   
-  AliMUONStopwatchGroupElement timer(fTimers,"MUON","AliMUONPedestalEventGenerator::GenerateDigits(AliMUONVDigitStore&)");
+  AliCodeTimerAuto("")
 
   digitStore.Clear();
   
@@ -380,16 +388,34 @@ AliMUONPedestalEventGenerator::GenerateDigits(AliMUONVDigitStore& digitStore)
         // using AliMpVSegmentation::PadByLocation(AliMpIntPair(manuId,manuChannel))
         continue;
       }
+      else if ( mean < 1 || mean >  4095 ) 
+      {
+        AliFatal(Form("Got an invalid mean pedestal value for DE %d Manu %d"
+                      " channel %d : mean = %e",detElemId,manuId,manuChannel,
+                      mean));
+      }
       else
       {
         Float_t sigma = pedestals->ValueAsFloat(manuChannel,1);
         
-
+        if ( sigma < 0 ) 
+        {
+          AliWarning(Form("Got a negative sigma pedestal value for DE %d Manu %d"
+                          " channel %d : sigma = %e, will use Abs()=%e",
+                          detElemId,manuId,manuChannel,
+                          sigma,-sigma));
+          sigma = -sigma;
+        }
+        
         AliMUONVDigit* d = digitStore.Add(detElemId,manuId,manuChannel,
                                           cathode,
                                           AliMUONVDigitStore::kIgnore);
         
-        Float_t ped = gRandom->Gaus(mean,sigma);
+        Float_t ped = -1;
+        while ( ped <= 0 ) 
+        {
+          ped = gRandom->Gaus(mean,sigma);
+        }
         Int_t pedADC = TMath::FloorNint(ped);
 
         d->SetADC(pedADC);