]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONOfflineShift.C
Coding convention (data member comments after the data member definition)
[u/mrichter/AliRoot.git] / MUON / MUONOfflineShift.C
index f4b168cae6d1a6ee44e4c96515c6b49b6f6728f6..ac52aeed74c549306cccc9cefd26363e1a8abed0 100644 (file)
@@ -19,6 +19,8 @@
 /// \file MUONOfflineShift.C
 /// \brief Macro to be used to check raw data during MUON offline shifts.
 ///  
+/// You NEED an access to the Grid to run this macro.
+///
 /// Basic usage is : 
 ///
 /// MUONOfflineShift("path_to_raw_file","basename of output file"); > log
 ///
 /// - basename.log, containing (for the moment) the occupancy numbers of the various detection elements
 ///
+/// Unless you really know what you're doing, please use this macro together with 
+/// the grid OCDB (i.e. don't set it to a local OCDB). There are now a lot of things
+/// that are grabbed from the OCDB that are run dependent...
+///
 /// \author Laurent Aphecetche
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
 #include "AliCDBManager.h"
 #include "AliCodeTimer.h"
-#include "AliMUONPainterRegistry.h"
-#include "AliMUONTrackerCalibratedDataMaker.h"
-#include "AliMUONTrackerRawDataMaker.h"
+#include "AliMUONCDB.h"
+#include "AliMUONPainterDataRegistry.h"
+#include "AliMUONRecoParam.h"
+#include "AliMUONTrackerDataMaker.h"
 #include "AliMUONVTrackerData.h"
 #include "AliMpCDB.h"
 #include "AliMpConstants.h"
 #include "AliMpDEIterator.h"
 #include "AliRawReader.h"
-#include "AliRawReaderDate.h"
-#include "AliRawReaderRoot.h"
 #include <Riostream.h>
 #include <TFile.h>
 #include <TGrid.h>
@@ -78,32 +83,25 @@ Int_t DataMakerReading(const char* input,
   
   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
-  }
+  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
   
   if (!rawReader) return 0;
   
   AliMUONVTrackerDataMaker* dm(0x0);
   
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return 0;
+  
   if ( strlen(cdbPath) > 0 ) 
   {
-    dm = new AliMUONTrackerCalibratedDataMaker(rawReader,cdbPath,calibMode,histogram,xmin,xmax);
+    dm = new AliMUONTrackerDataMaker(recoParam,rawReader,cdbPath,calibMode,histogram,xmin,xmax);
   }
   else  
   {
-    dm = new AliMUONTrackerRawDataMaker(rawReader,kTRUE);
+    dm = new AliMUONTrackerDataMaker(rawReader,histogram);
   }
   
-  AliMUONPainterRegistry::Instance()->Register(dm);
+  AliMUONPainterDataRegistry::Instance()->Register(dm);
 
   timer.Start(kTRUE);
   Int_t n(0);
@@ -146,7 +144,7 @@ void Occupancy(ostream& outfile)
   
   const Int_t occIndex = 2;
   
-  AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
+  AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
 
   Int_t nofDataSources = reg->NumberOfDataSources();
 
@@ -209,47 +207,52 @@ void Occupancy(ostream& outfile)
 }
 
 //______________________________________________________________________________
-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")
+void MUONOfflineShift(const char* input="alien:///alice/data/2009/LHC09a/000067495/raw/09000067495031.10.root", 
+                      const char* outputBase="67495031.10",
+                      const char* ocdbPath="alien://folder=/alice/data/2009/OCDB")
 {
   /// Entry point of the macro. 
-  /// Example of syntax for an input file (from alien)
-  ///
-  /// alien::///alice/data/2007/LHC07w/000014493/raw/07000014493001.10.root
-  /// 
-  /// and for an OCDB path : 
-  ///
-  /// alien://folder=/alice/data/2007/LHC07w/OCDB
-  ///
 
+  AliCodeTimer::Instance()->Reset();
+  
   TGrid::Connect("alien://");
   
-  AliCodeTimer::Instance()->Reset();
+  AliRawReader* rawReader = AliRawReader::Create(input);
+  
+  rawReader->NextEvent();
   
-  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-  AliCDBManager::Instance()->SetRun(0);
-  AliMpCDB::LoadDDLStore();
+  Int_t runNumber = rawReader->GetRunNumber();
+    
+  delete rawReader;
+  
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(runNumber);
+
+  if (!AliMUONCDB::LoadMapping()) return;
   
   TStopwatch timer1;
   TStopwatch timer2;
   TStopwatch timer3;
   TStopwatch timer4;
+  TStopwatch timer5;
   
-  Int_t n1 = DataMakerReading(input,timer1);
-  
-  Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN",kTRUE);
+  Int_t n1 = DataMakerReading(input,timer1,"","",kTRUE,0,0);
+
+  Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN");
 
-  Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA",kTRUE);
+  Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA");
 
-  Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN",kTRUE);
+  Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN");
+
+  Int_t n5 = DataMakerReading(input,timer5,ocdbPath,"INJECTIONGAIN");
 
   Print("DataMakerReading(HRAW)",timer1,n1);  
   Print("DataMakerReading(HCALZ)",timer2,n2);
   Print("DataMakerReading(HCALG)",timer3,n3);
   Print("DataMakerReading(HCALC)",timer4,n4);
+  Print("DataMakerReading(HCALE)",timer5,n5);
   
-  AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
+  AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
   
   TFile f(gSystem->ExpandPathName(Form("%s.root",outputBase)),"RECREATE");
   ofstream out(gSystem->ExpandPathName(Form("%s.log",outputBase)));
@@ -264,4 +267,6 @@ void MUONOfflineShift(const char* input="alien:///alice/data/2008/LHC08a/0000219
   
   f.Close();
   
+  AliCodeTimer::Instance()->Print();
+
 }