]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Class AliMUONCDB:
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Oct 2009 22:46:12 +0000 (22:46 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Oct 2009 22:46:12 +0000 (22:46 +0000)
- Changed to namespace (remove constructor and destructor)
- Added new functions to ease the loading of Mapping, Magnetic Field and RecoParam from OCDB (OCDB path and run number must properly set before using any of these function)
- Moved from libMUONbase in libMUONrec

Class AliMUONESDInterface:
- Adding a flag in functions converting ESD track to MUON track to disable the refitting of track parameters at each cluster. That way, you do not need to load the proper RecoParam and magnetic field, but the drawback is that only the track parameters at first cluster, copied directly from ESD, is meaningful.

Macros:
- Remove the unnecessary access to geometry, mapping, magnetic field and/or recoParam
- Use the new functionalities of AliMUONCDB to load these informations from the OCDB when needed (except geometry for now)

Updated relevant READMEs

(Philippe P., Ivana)

30 files changed:
MUON/AliMUONCDB.cxx
MUON/AliMUONCDB.h
MUON/AliMUONCheck.cxx
MUON/AliMUONESDInterface.cxx
MUON/AliMUONESDInterface.h
MUON/AliMUONRecoCheck.cxx
MUON/AliMUONRecoCheck.h
MUON/AliMUONTrackerQADataMakerRec.cxx
MUON/DIMUONFakes.C
MUON/DecodeRecoCocktail.C
MUON/MUONAlignment.C
MUON/MUONClusterInfo.C
MUON/MUONFakes.C
MUON/MUONOfflineShift.C
MUON/MUONRecoCheck.C
MUON/MUONRefit.C
MUON/MUONTriggerChamberEfficiency.C
MUON/MUONbaseLinkDef.h
MUON/MUONefficiency.C
MUON/MUONmassPlot_ESD.C
MUON/MUONrecLinkDef.h
MUON/MakeMUONRecoParamArray.C
MUON/MakeMUONSingleRecoParam.C
MUON/READMEcalib.txt
MUON/READMErec.txt
MUON/READMEshuttle.txt
MUON/TestRecPoints.C
MUON/libMUONbase.pkg
MUON/libMUONrec.pkg
MUON/mapping/AliMpCDB.cxx

index 82962145d50394fcb041a800d7a99332fa9a4913..a4205b470250a26d9e02828be036ebf43bfacfc8 100644 (file)
 /* $Id$ */
 
 //-----------------------------------------------------------------------------
-/// \class AliMUONCDB
+/// \namespace AliMUONCDB
 ///
-/// Helper class to experience the OCDB
-/// It allows to generate dummy (but complete) containers for all the
+/// Helper functions to experience the OCDB
+///
+/// They allow to read magnetic field, mapping and recoParam from OCDB
+///
+/// And also to generate dummy (but complete) containers for all the
 /// calibration data types we have for tracker and trigger, and to write
 /// them into OCDB.
 ///
-/// For more information, please see READMECDB
+/// For more information, please see READMEcalib
 ///
 // \author Laurent Aphecetche
 //-----------------------------------------------------------------------------
 #include "AliMUONVCalibParam.h"
 #include "AliMUONGlobalCrateConfig.h"
 #include "AliMUONRegionalTriggerConfig.h"
+#include "AliMUONRecoParam.h"
 
 #include "AliMpCDB.h"
 #include "AliMpConstants.h"
+#include "AliMpDEStore.h"
 #include "AliMpDDLStore.h"
 #include "AliMpManuStore.h"
 #include "AliMpDEManager.h"
@@ -64,6 +69,7 @@
 #include "AliCodeTimer.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
+#include "AliGRPManager.h"
 #include "AliDCSValue.h"
 #include "AliLog.h"
 
 #include <TStopwatch.h>
 #include <TSystem.h>
 #include <TMath.h>
+#include <TGeoGlobalMagField.h>
 
 
-/// \cond CLASSIMP
-ClassImp(AliMUONCDB)
-/// \endcond
-
 namespace
 {
   //_____________________________________________________________________________
@@ -164,26 +167,142 @@ Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive)
 }
 
 //_____________________________________________________________________________
-AliMUONCDB::AliMUONCDB(const char* cdbpath)
-: TObject(),
-  fCDBPath(cdbpath),
-  fMaxNofChannelsToGenerate(-1)
+Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
 {
-  /// ctor
-    // Load mapping
-    if ( ! AliMpCDB::LoadDDLStore() ) {
-      AliFatal("Could not access mapping from OCDB !");
-    }
+  /// Check that OCDB path and run number are properly set
+  
+  AliCDBManager* man = AliCDBManager::Instance();
+  
+  // first OCDB path
+  if (!man->IsDefaultStorageSet()) {
+    AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set");
+    return kFALSE;
+  }
+  
+  // then run number if required
+  if (pathOnly) return kTRUE;
+  if (man->GetRun() < 0) {
+    AliErrorGeneral("AliMUONCDB", "Run number must be properly set");
+    return kFALSE;
+  }
+  
+  return kTRUE;
+  
+}
+
+//_____________________________________________________________________________
+Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly)
+{
+  /// Check that the mapping has been loaded
+  
+  // first the segmentation
+  if (!AliMpSegmentation::Instance(false)) {
+    AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first");
+    return kFALSE;
+  }
+  
+  // then the others if required
+  if (segmentationOnly) return kTRUE;
+  if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) {
+    AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first");
+    return kFALSE;
+  }
+  
+  return kTRUE;
+  
+}
+
+//_____________________________________________________________________________
+Bool_t AliMUONCDB::LoadField()
+{
+  /// Load magnetic field (existing field will be deleted).
+  /// OCDB path and run number are supposed to be set.
+  
+  AliInfoGeneral("AliMUONCDB","Loading field map from GRP...");
+  
+  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
+  
+  AliGRPManager grpMan;
+  
+  // make sure the old field is deleted even if it is locked
+  if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance();
+  
+  if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) {
+    AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB");
+    return kFALSE;
+  }
+  
+  return kTRUE;
+  
+}
 
-    if ( ! AliMpCDB::LoadManuStore() ) {
-      AliFatal("Could not access run-dependent mapping from OCDB !");
+//_____________________________________________________________________________
+Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly)
+{
+  /// Load mapping (existing mapping will be unloaded).
+  /// OCDB path and run number are supposed to be set.
+  
+  AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB...");
+  
+  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
+  
+  // in case it has already been set
+  AliMpCDB::UnloadAll();
+  
+  if (segmentationOnly) {
+    
+    if (!AliMpCDB::LoadMpSegmentation(kTRUE)){
+      AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB");
+      return kFALSE;
+    }
+    
+  } else {
+    
+    if (!AliMpCDB::LoadAll(kTRUE)) {
+      AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB");
+      return kFALSE;
     }
+    
+  }
+  
+  return kTRUE;
+  
 }
 
 //_____________________________________________________________________________
-AliMUONCDB::~AliMUONCDB()
+AliMUONRecoParam* AliMUONCDB::LoadRecoParam()
 {
-  /// dtor
+  /// Load and return reconstruction parameters.
+  /// OCDB path is supposed to be set.
+  
+  AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB...");
+  
+  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
+  
+  AliMUONRecoParam* recoParam = 0x0;
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
+  
+  if(entry) {
+    
+    // load recoParam according OCDB content (single or array)
+    if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) {
+      
+      TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
+      
+      for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
+       recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
+       if (recoParam->IsDefault()) break;
+       recoParam = 0x0;
+      }
+      
+    }
+    
+  }
+  
+  if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB");
+  
+  return recoParam;
+  
 }
 
 //_____________________________________________________________________________
@@ -203,7 +322,7 @@ AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2,
   
   if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
   {
-    AliErrorClass(Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
+    AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
     return 0x0;
   }
   
@@ -263,6 +382,8 @@ AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
   /// contained inside store.
   /// It produces histograms named name_0, name_1, etc...
   
+  if (!AliMUONCDB::CheckMapping(kTRUE)) return;
+  
   TIter next(store.CreateIterator());
   AliMUONVCalibParam* param;
   Int_t n(0);
@@ -286,7 +407,7 @@ AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
       {
         h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
                             nbins,xmin[i],xmax[i]);
-        AliInfo(Form("Created histogram %s",h[i]->GetName()));
+        AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
       }
     }
     
@@ -314,10 +435,10 @@ AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
   
   for ( Int_t i = 0; i < kNStations; ++i )
   {
-    AliInfo(Form("Station %d %d ",(i+1),nPerStation[i]));
+    AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i]));
   }
 
-  AliInfo(Form("Number of channels = %d",n));
+  AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
   
   delete[] nPerStation;
 }
@@ -328,6 +449,8 @@ AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
 {
   /// Create a HV store
   
+  if (!AliMUONCDB::CheckMapping()) return 0;
+  
   AliMpDCSNamer hvNamer("TRACKER");
   
   TObjArray* aliases = hvNamer.GenerateAliases();
@@ -379,7 +502,7 @@ AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
   
   delete aliases;
   
-  AliInfo(Form("%d HV channels and %d switches",nChannels,nSwitch));
+  AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch));
   
   return nChannels+nSwitch;
 }
@@ -390,6 +513,8 @@ AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues)
 {
   /// Create a Trigger HV and Currents store
   
+  if (!AliMUONCDB::CheckMapping()) return 0;
+  
   AliMpDCSNamer triggerDCSNamer("TRIGGER");
   
   TObjArray* aliases = triggerDCSNamer.GenerateAliases();
@@ -427,7 +552,7 @@ AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues)
   
   delete aliases;
   
-  AliInfo(Form("Trigger channels I -> %i   HV -> %i",nChannels[0], nChannels[1]));
+  AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i   HV -> %i",nChannels[0], nChannels[1]));
   
   return nChannels[0] + nChannels[1];
 }
@@ -440,7 +565,9 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues
   /// otherwise mean and sigma are from a gaussian (with parameters
   /// defined below by the kPedestal* constants)
 
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
+  
+  if (!AliMUONCDB::CheckMapping()) return 0;
   
   Int_t nchannels(0);
   Int_t nmanus(0);
@@ -524,12 +651,11 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues
     Bool_t ok = pedestalStore.Add(ped);
     if (!ok)
     {
-      AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
+      AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
     }
-    if ( fMaxNofChannelsToGenerate > 0 && nchannels >= fMaxNofChannelsToGenerate ) break;
   }
   
-  AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels));
+  AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
   return nchannels;
 }
 
@@ -539,7 +665,7 @@ AliMUONCDB::MakeRejectListStore(Bool_t defaultValues)
 {
   /// Create a reject list
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
 
   AliMUONRejectList* rl = new AliMUONRejectList;
   
@@ -559,7 +685,9 @@ AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defau
 {
   /// Create an occupancy map.
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
+  
+  if (!AliMUONCDB::CheckMapping()) return 0;
   
   Int_t nmanus(0);
   
@@ -582,7 +710,7 @@ AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defau
     
     Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId);
     
-    if (!defaultValues) occ = gRandom->Rndm(1.0);
+    if (!defaultValues) occ = gRandom->Rndm(1);
 
     Double_t sumn = occ*nevents;
     
@@ -595,7 +723,7 @@ AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defau
     Bool_t ok = occupancyMapStore.Add(occupancy);
     if (!ok)
     {
-      AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
+      AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
     }
   }
   
@@ -608,6 +736,8 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file)
 {
   /// Read the capacitance values from file and append them to the capaStore
   
+  if (!AliMUONCDB::CheckMapping()) return 0;
+  
   return AliMUONTrackerIO::ReadCapacitances(file,capaStore);
 }
 
@@ -619,7 +749,9 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
   /// otherwise they are from a gaussian with parameters defined in the
   /// kCapa* constants below.
 
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
+  
+  if (!AliMUONCDB::CheckMapping()) return 0;
   
   Int_t nchannels(0);
   Int_t nmanus(0);
@@ -654,7 +786,7 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
       Bool_t ok = capaStore.Add(capa);
       if (!ok)
       {
-        AliError(Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId));
+        AliErrorGeneral("AliMUONCDB", Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId));
       }      
     }
     
@@ -684,12 +816,12 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
   
   Float_t percent = 0;
   if ( nmanus ) percent = 100*nmanusOK/nmanus;
-  AliInfo(Form("%5d manus with serial number (out of %5d manus = %3.0f%%)",
+  AliInfoGeneral("AliMUONCDB", Form("%5d manus with serial number (out of %5d manus = %3.0f%%)",
                nmanusOK,nmanus,percent));
-  AliInfo(Form("%5d channels",nchannels));
+  AliInfoGeneral("AliMUONCDB", Form("%5d channels",nchannels));
   if ( percent < 100 ) 
   {
-    AliWarning("Did not get all serial numbers. capaStore is incomplete !!!!");
+    AliWarningGeneral("AliMUONCDB", "Did not get all serial numbers. capaStore is incomplete !!!!");
   }
   return nchannels;
   
@@ -705,7 +837,9 @@ AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues)
   /// otherwise parameters are taken from gaussians with parameters 
   /// defined in the k* constants below.
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
+  
+  if (!AliMUONCDB::CheckMapping()) return 0;
   
   Int_t nchannels(0);
   Int_t nmanus(0);
@@ -765,22 +899,21 @@ AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues)
     Bool_t ok = gainStore.Add(gain);
     if (!ok)
     {
-      AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
+      AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
     }
-    if ( fMaxNofChannelsToGenerate > 0 && nchannels >= fMaxNofChannelsToGenerate ) break;
   }
   
-  AliInfo(Form("%d Manus and %d channels.",nmanus,nchannels));
+  AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
   return nchannels;
 }
 
 //_____________________________________________________________________________
 Int_t
-AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const
+AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks)
 {
   /// Generate local trigger masks store. All masks are set to FFFF
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
   
   Int_t ngenerated(0);
   // Generate fake mask values for all localboards and put that into
@@ -804,14 +937,14 @@ AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) const
 
 //_____________________________________________________________________________
 Int_t
-AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) const
+AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm)
 {
   /// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.)
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
   
   if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) {
-    AliErrorStream() << "Error when reading from mapping file" << endl;
+    AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file");
     return 0;
   }
     
@@ -821,11 +954,11 @@ AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) co
 
 //_____________________________________________________________________________
 Int_t 
-AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) const
+AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm)
 {
   /// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.)
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
   
   return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping());
 }
@@ -833,11 +966,11 @@ AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) const
 
 //_____________________________________________________________________________
 AliMUONTriggerLut* 
-AliMUONCDB::MakeTriggerLUT(const char* file) const
+AliMUONCDB::MakeTriggerLUT(const char* file)
 {
   /// Make a triggerlut object, from a file.
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
   
   AliMUONTriggerLut* lut = new AliMUONTriggerLut;
   lut->ReadFromFile(file);
@@ -846,11 +979,11 @@ AliMUONCDB::MakeTriggerLUT(const char* file) const
 
 //_____________________________________________________________________________
 AliMUONTriggerEfficiencyCells*
-AliMUONCDB::MakeTriggerEfficiency(const char* file) const
+AliMUONCDB::MakeTriggerEfficiency(const char* file)
 {
   /// Make a trigger efficiency object from a file.
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
   
   return new AliMUONTriggerEfficiencyCells(file);
 }
@@ -889,14 +1022,14 @@ AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, I
 {
   /// Write a given object to OCDB
   
+  if (!AliMUONCDB::CheckOCDB(kTRUE)) return;
+  
   AliCDBId id(calibpath,startRun,endRun);
   AliCDBMetaData md;
   md.SetAliRootVersion(gROOT->GetVersion());
   md.SetComment(comment);
   md.SetResponsible(responsible);
-  AliCDBManager* man = AliCDBManager::Instance();
-  if (!man->IsDefaultStorageSet()) man->SetDefaultStorage(fCDBPath);
-  man->Put(object,id,&md);
+  AliCDBManager::Instance()->Put(object,id,&md);
 }
 
 //_____________________________________________________________________________
@@ -906,9 +1039,11 @@ AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore)
   /// Fill the neighbours store with, for each channel, a TObjArray of its
   /// neighbouring pads (including itself)
   
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAutoGeneral("",0);
+  
+  if (!AliMUONCDB::CheckMapping()) return 0;
   
-  AliInfo("Generating NeighbourStore. This will take a while. Please be patient.");
+  AliInfoGeneral("AliMUONCDB", "Generating NeighbourStore. This will take a while. Please be patient.");
   
   Int_t nchannels(0);
   
@@ -936,7 +1071,7 @@ AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore)
       Bool_t ok = neighbourStore.Add(calibParam);
       if (!ok)
       {
-        AliError(Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
+        AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
         return -1;
       }      
     }
@@ -973,15 +1108,6 @@ AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore)
   return nchannels;
 }
 
-//_____________________________________________________________________________
-void
-AliMUONCDB::SetMaxNofChannelsToGenerate(Int_t n)
-{
-  /// Set the maximum number of channels to generate (used for testing only)
-  /// n < 0 means no limit
-  fMaxNofChannelsToGenerate = n;
-}
-
 //_____________________________________________________________________________
 void
 AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
@@ -990,7 +1116,7 @@ AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
   
   AliMUONVStore* ltm = new AliMUON1DArray(AliMpConstants::TotalNofLocalBoards()+1);
   Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if (ngenerated>0)
   {
     WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true);
@@ -1006,7 +1132,7 @@ AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun)
   
   AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig();
   Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if (ngenerated>0)
   {
     WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
@@ -1024,7 +1150,7 @@ AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun)
   AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig();
 
   Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if (ngenerated>0)
   {
     WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
@@ -1069,7 +1195,7 @@ AliMUONCDB::WriteNeighbours(Int_t startRun, Int_t endRun)
   
   AliMUONVStore* neighbours = Create2DMap();
   Int_t ngenerated = MakeNeighbourStore(*neighbours);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if (ngenerated>0)
   {
     WriteToCDB("MUON/Calib/Neighbours",neighbours,startRun,endRun,true);
@@ -1089,7 +1215,7 @@ AliMUONCDB::WriteHV(Bool_t defaultValues,
   
   TMap* hvStore = new TMap;
   Int_t ngenerated = MakeHVStore(*hvStore,defaultValues);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if (ngenerated>0)
   {
     WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues);
@@ -1109,7 +1235,7 @@ AliMUONCDB::WriteTriggerDCS(Bool_t defaultValues,
   
   TMap* triggerDCSStore = new TMap;
   Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if (ngenerated>0)
   {
     WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues);
@@ -1129,7 +1255,7 @@ AliMUONCDB::WritePedestals(Bool_t defaultValues,
   
   AliMUONVStore* pedestalStore = Create2DMap();
   Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
   delete pedestalStore;
 }
@@ -1146,7 +1272,7 @@ AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues,
   
   AliMUONVStore* occupancyMapStore = Create2DMap();
   Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues);
   delete occupancyMapStore;
 }
@@ -1179,7 +1305,7 @@ AliMUONCDB::WriteGains(Bool_t defaultValues,
   
   AliMUONVStore* gainStore = Create2DMap();
   Int_t ngenerated = MakeGainStore(*gainStore,defaultValues);
-  AliInfo(Form("Ngenerated = %d",ngenerated));  
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));  
   WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues);
   delete gainStore;
 }
@@ -1195,7 +1321,7 @@ AliMUONCDB::WriteCapacitances(const char* filename,
   
   AliMUONVStore* capaStore = new AliMUON1DMap(16828);
   Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   if ( ngenerated > 0 ) 
   {
     WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
@@ -1215,7 +1341,7 @@ AliMUONCDB::WriteCapacitances(Bool_t defaultValues,
   
   AliMUONVStore* capaStore = new AliMUON1DMap(16828);
   Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues);
-  AliInfo(Form("Ngenerated = %d",ngenerated));
+  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
   WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues);
   delete capaStore;
 }
index 08d9bfb6d8709635916a2f1f07cdd3cce4315442..e395ea5aefae016c1f14c33a9cc8dc55754641c2 100644 (file)
@@ -5,13 +5,12 @@
 
 /* $Id$ */
 
-/// \ingroup base
-/// \class AliMUONCDB
-/// \brief Helper class to experience the OCDB
+/// \ingroup rec
+/// \namespace AliMUONCDB
+/// \brief Helper functions to experience the OCDB
 /// 
 //  Author Laurent Aphecetche
 
-#include <TObject.h>
 #include <TString.h>
 #include "AliCDBRunRange.h"
 
@@ -23,16 +22,16 @@ class AliMUONTriggerEfficiencyCells;
 class AliMUONRegionalTriggerConfig;
 class AliMUONGlobalCrateConfig;
 class AliMUONRejectList;
+class AliMUONRecoParam;
 
-class AliMUONCDB : public TObject
+namespace AliMUONCDB
 {
-public:
-  /// Ctor. change the path for testing the Shuttle preprocessor, to
-  /// "local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"
-  AliMUONCDB(const char* cdbpath = "local://$ALICE_ROOT/OCDB");
-  virtual ~AliMUONCDB();
+  Bool_t CheckOCDB(Bool_t pathOnly = kFALSE);
+  Bool_t CheckMapping(Bool_t segmentationOnly = kFALSE);
   
-  void SetMaxNofChannelsToGenerate(Int_t n);
+  Bool_t LoadField();
+  Bool_t LoadMapping(Bool_t segmentationOnly = kFALSE);
+  AliMUONRecoParam* LoadRecoParam();
   
   Int_t MakeNeighbourStore(AliMUONVStore& neighbourStore);
 
@@ -45,32 +44,29 @@ public:
   Int_t MakeOccupancyMapStore(AliMUONVStore& occupancyMap, Bool_t defaultValues);
   AliMUONRejectList* MakeRejectListStore(Bool_t defaultValues);
   
-  Int_t MakeLocalTriggerMaskStore(AliMUONVStore& ltm) const;  
-  Int_t MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) const;
-  Int_t MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) const;
+  Int_t MakeLocalTriggerMaskStore(AliMUONVStore& ltm);  
+  Int_t MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm);
+  Int_t MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm);
   
-  AliMUONTriggerLut* MakeTriggerLUT(const char* file="$(ALICE_ROOT)/MUON/data/lutAptLpt1Hpt1p7.root") const;
-  AliMUONTriggerEfficiencyCells* MakeTriggerEfficiency(const char* file="$ALICE_ROOT/MUON/data/efficiencyCells.dat") const;
+  AliMUONTriggerLut* MakeTriggerLUT(const char* file="$(ALICE_ROOT)/MUON/data/lutAptLpt1Hpt1p7.root");
+  AliMUONTriggerEfficiencyCells* MakeTriggerEfficiency(const char* file="$ALICE_ROOT/MUON/data/efficiencyCells.dat");
 
-  /// Compute the difference between two (compatible) stores
-  AliMUONVStore* Diff(AliMUONVStore& store1, AliMUONVStore& store2, 
-                        const char* opt="abs");
-    
+  AliMUONVStore* Diff(AliMUONVStore& store1, AliMUONVStore& store2, const char* opt="abs");
+  
   void Plot(const AliMUONVStore& store, const char* name, Int_t nbins=512);
 
-  void WriteToCDB(const char* calibpath, TObject* object, 
+  void WriteToCDB(const char* calibpath, TObject* object,
                   Int_t startRun, Int_t endRun, Bool_t defaultValues);
-  void WriteToCDB(const char* calibpath, TObject* object, 
+  void WriteToCDB(const char* calibpath, TObject* object,
                   Int_t startRun, Int_t endRun, const char* filename);
   void WriteToCDB(TObject* object, const char* calibpath, Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity(),
-                 const char* comment="", const char* responsible="AliMUONCDB tester class");
+                  const char* comment="", const char* responsible="AliMUONCDB tester class");
 
   void WriteTrigger(Bool_t defaultValues=kTRUE, Int_t startRun=0,Int_t endRun=AliCDBRunRange::Infinity());
   void WriteTracker(Bool_t defaultValues=kTRUE, Int_t startRun=0,Int_t endRun=AliCDBRunRange::Infinity());
   
   void WriteNeighbours(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity());
   void WriteHV(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity());
-  void WriteTriggerDCS(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity());
   void WritePedestals(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity());
   void WriteGains(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity());
   void WriteCapacitances(Bool_t defaultValues, Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity());
@@ -82,20 +78,9 @@ public:
   void WriteRegionalTriggerConfig(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity());
   void WriteGlobalTriggerConfig(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity());
   
+  void WriteTriggerDCS(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity());
   void WriteTriggerLut(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity());
   void WriteTriggerEfficiency(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity());
-  
-private:
-  /// Not implemented
-  AliMUONCDB(const AliMUONCDB& rhs);
-  /// Not implemented
-  AliMUONCDB& operator=(const AliMUONCDB& rhs);
-  
-private:
-  TString fCDBPath; //!< where to write stuff
-  Int_t fMaxNofChannelsToGenerate; //!< to limit the number of generated channels (debug)
-  
-  ClassDef(AliMUONCDB,0) // Helper class to experience OCDB
-};
+}
 
 #endif
index 6d985c39726e342cf15c79bd976d3846f5a260de..a398fa0dc2dfa8339f90b652601789a20d977209 100644 (file)
@@ -171,8 +171,7 @@ AliMUONCheck::CheckESD(Bool_t pdc06TriggerResponse)
   for (ievent = fFirstEvent; ievent < endOfLoop; ++ievent ) 
   {
     nev++;    
-    tree->GetEvent(ievent);
-    if (!fESD) 
+    if (tree->GetEvent(ievent) <= 0) 
     {
       Error("CheckESD", "no ESD object found for event %d", ievent);
       return ;
index f53ec73e0bd422b70d06c1406a3e2259cce0b58e..d98041caf5e80d97eb7a86f5d928b9b91fabe7be 100644 (file)
@@ -49,6 +49,8 @@
 #include <TMath.h>
 #include <TMatrixD.h>
 #include <Riostream.h>
+#include <TGeoGlobalMagField.h>
+#include <TVirtualMagField.h>
 
 //-----------------------------------------------------------------------------
 /// \class AliMUONESDInterface
@@ -141,7 +143,7 @@ void AliMUONESDInterface::Reset()
 }
 
 //_____________________________________________________________________________
-void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent)
+void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent, Bool_t refit)
 {
   /// Extract MUON data from the given ESD event
   
@@ -162,7 +164,7 @@ void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent)
     if (!esdTrack->ContainTrackerData()) continue;
     
     // add it to track store
-    AliMUONTrack* track = Add(*esdTrack, *fTracks);
+    AliMUONTrack* track = Add(*esdTrack, *fTracks, refit);
     
     // prepare cluster map
     AliMpExMap* cMap = new AliMpExMap;
@@ -435,7 +437,7 @@ AliMUONVCluster* AliMUONESDInterface::FindClusterInTrack(const AliMUONTrack& tra
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
 
 //_____________________________________________________________________________
-void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam)
+void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam, Bool_t info)
 {
   /// Reset the MUON tracker using "recoParam" if provided.
   /// If not provided, will use Kalman filter + Smoother
@@ -447,19 +449,28 @@ void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam)
     
     fgRecoParam = new AliMUONRecoParam(*recoParam);
     
+    if (info) cout<<"I-AliMUONESDInterface::ResetTracker: will refit tracks with provided RecoParam:"<<endl;
+    
   } else {
     
     fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
     
     cout<<"W-AliMUONESDInterface::ResetTracker: RecoParam not provided. Will use default LowFlux parametrization:"<<endl;
+    
+  }
+  
+  // print useful parameters for refitting
+  if (info) {
     cout<<"                                     --> Tracking mode = "<<fgRecoParam->GetTrackingMode()<<endl;
     if (fgRecoParam->UseSmoother()) cout<<"                                     --> Use Smoother"<<endl;
     else cout<<"                                     --> Do not use smoother"<<endl;
     cout<<"                                     --> Vertex dispersion in bending direction = "
-        <<fgRecoParam->GetBendingVertexDispersion()<<" cm"<<endl;
-    
+    <<fgRecoParam->GetBendingVertexDispersion()<<" cm"<<endl;
   }
   
+  if (!TGeoGlobalMagField::Instance()->GetField())
+    cout<<"W-AliMUONESDInterface::ResetTracker: Magnetic field has not been set --> assume field is OFF"<<endl;
+  
   fgTracker = AliMUONTracker::CreateTrackReconstructor(fgRecoParam,0x0);
   
 }
@@ -642,11 +653,12 @@ void AliMUONESDInterface::SetParamCov(const AliMUONTrackParam& trackParam, AliES
 }
 
 //_____________________________________________________________________________
-void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track)
+void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track, Bool_t refit)
 {
   /// Transfert data from ESDMuon track to MUON track.
-  /// The track parameters at each cluster are obtained by refitting the track
+  /// If refit = kTRUE, the track parameters at each cluster are obtained by refitting the track
   /// or by extrapolating the parameters at the first one if the refit failed.
+  /// If refit = kFALSE, only the track parameters at first cluster are valid.
   /// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
   ///       By default we use Kalman filter + Smoother
   
@@ -708,15 +720,20 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrac
       esdCluster = (AliESDMuonCluster*) esdTrack.GetClusters().After(esdCluster);
     }
     
-    // recompute parameters at first cluster in case of those stored
-    // in ESD are not related to the most upstream cluster
-    AliMUONTrackParam *firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
-    firstTrackParam->SetZ(esdTrack.GetZUncorrected()); // reset the z to the one stored in ESD
-    AliMUONTrackExtrap::ExtrapToZCov(firstTrackParam,firstTrackParam->GetClusterPtr()->GetZ());
-    
     // refit the track to get better parameters and covariances at each cluster (temporary disable track improvement)
-    if (!fgTracker) ResetTracker();
-    if (!fgTracker->RefitTrack(track, kFALSE) && track.GetGlobalChi2() < AliMUONTrack::MaxChi2()) track.UpdateCovTrackParamAtCluster();
+    if (refit) {
+      
+      AliMUONTrackParam *firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
+      AliMUONTrackParam paramSave(*firstTrackParam);
+      
+      if (!fgTracker) ResetTracker();
+      
+      if (!fgTracker->RefitTrack(track, kFALSE) && track.GetGlobalChi2() < AliMUONTrack::MaxChi2()) {
+       *firstTrackParam = paramSave;
+       track.UpdateCovTrackParamAtCluster();
+      }
+      
+    }
     
   } else {
     
@@ -799,6 +816,11 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit&
 {
   /// Transfert data from ESDMuon pad to MUON digit
   
+  if (!AliMpSegmentation::Instance(kFALSE)) {
+    cout<<"E-AliMUONESDInterface::ESDToMUON: need mapping segmentation to convert ESD pad to MUON digit"<<endl;
+    return;
+  }
+  
   const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(esdPad.GetDetElemId(), esdPad.GetManuId());  
   AliMpPad pad = seg->PadByLocation(esdPad.GetManuId(), esdPad.GetManuChannel(), kFALSE);
   
@@ -972,13 +994,14 @@ void AliMUONESDInterface::MUONToESD(const AliMUONVDigit& digit, AliESDMuonPad& e
 }
 
 //___________________________________________________________________________
-AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore)
+AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore, Bool_t refit)
 {
   /// Create MUON track from ESDMuon track and add it to the store
+  /// Track parameters at each clusters are recomputed or not depending on the flag "refit"
   /// return a pointer to the track into the store (0x0 if the track already exist)
   if(trackStore.FindObject(esdTrack.GetUniqueID())) return 0x0;
   AliMUONTrack* track = trackStore.Add(AliMUONTrack());
-  ESDToMUON(esdTrack, *track);
+  ESDToMUON(esdTrack, *track, refit);
   return track;
 }
 
index 180b0b7f1cc89e487e542ba5caf8c8e2dd896b13..2f7ba6c4f9c025bf9fd9b551e2ade93b17eae55f 100644 (file)
@@ -44,7 +44,7 @@ public: // methods to play with internal objects
   
   virtual void Clear(Option_t* = "");
   
-  void LoadEvent(AliESDEvent& esdEvent);
+  void LoadEvent(AliESDEvent& esdEvent,  Bool_t refit = kTRUE);
   
   /// Return internal track store
   AliMUONVTrackStore* GetTracks() const {return fTracks;}
@@ -83,8 +83,8 @@ public: // methods to play with internal objects
   
 public: // static methods
   
-  /// Reset the MUON tracker (using "recoParam" if provided)
-  static void ResetTracker(const AliMUONRecoParam* recoParam = 0x0);
+  // Reset the MUON tracker (using "recoParam" if provided)
+  static void ResetTracker(const AliMUONRecoParam* recoParam = 0x0, Bool_t info = kTRUE);
   
   /// Set the version of track store
   static void UseTrackStore(TString name) {fgTrackStoreName = name;}
@@ -114,7 +114,7 @@ public: // static methods
   static void SetParamCov(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
   
   // ESDMuon objects --> MUON objects conversion
-  static void ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track);
+  static void ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track, Bool_t refit = kTRUE);
   static void ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONLocalTrigger& locTrg);
   static void ESDToMUON(const AliESDMuonCluster& esdCluster, AliMUONVCluster& cluster);
   static void ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit& digit);
@@ -129,7 +129,7 @@ public: // static methods
   
   // Add ESD object into the corresponding MUON store
   // return a pointer to the corresponding MUON object into the store
-  static AliMUONTrack*    Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore);
+  static AliMUONTrack*    Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore, Bool_t refit = kTRUE);
   static void             Add(const AliESDMuonTrack& esdTrack, AliMUONVTriggerStore& triggerStore);
   static AliMUONVCluster* Add(const AliESDMuonCluster& esdCluster, AliMUONVClusterStore& clusterStore);
   static AliMUONVDigit*   Add(const AliESDMuonPad& esdPad, AliMUONVDigitStore& digitStore);
index 5a83d2e54e687711da3c90390206a1f5a89eba7b..0daff813097ecc89e1704f8b7f89e14f9ee97747 100644 (file)
@@ -139,6 +139,21 @@ void AliMUONRecoCheck::ResetStores()
   delete fRecoTrackStore;     fRecoTrackStore = 0x0;
 }
 
+//_____________________________________________________________________________
+Int_t AliMUONRecoCheck::GetRunNumber()
+{
+  /// Return the run number of the current ESD event
+  
+  if (fESDEventOwner && fRecoTrackStore == 0x0) {
+    if (!fESDTree || fESDTree->GetEvent(fCurrentEvent) <= 0) {
+      AliError(Form("fails to read ESD object for event %d: cannot get the run number",fCurrentEvent));
+      return -1;
+    }
+  }
+  
+  return fESDEvent->GetRunNumber();
+}
+
 //_____________________________________________________________________________
 Int_t AliMUONRecoCheck::NumberOfEvents() const
 {
@@ -148,13 +163,15 @@ Int_t AliMUONRecoCheck::NumberOfEvents() const
 }
 
 //_____________________________________________________________________________
-AliMUONVTrackStore* AliMUONRecoCheck::ReconstructedTracks(Int_t event)
+AliMUONVTrackStore* AliMUONRecoCheck::ReconstructedTracks(Int_t event, Bool_t refit)
 {
   /// Return a track store containing the reconstructed tracks (converted into 
-  /// MUONTrack objects) for a given event
+  /// MUONTrack objects) for a given event.
+  /// Track parameters at each clusters are computed or not depending on the flag "refit".
+  /// If not, only the track parameters at first cluster are valid.
   
   if (!fESDEventOwner) {
-    MakeReconstructedTracks();
+    if (fRecoTrackStore == 0x0) MakeReconstructedTracks(refit);
     return fRecoTrackStore;
   }
 
@@ -170,7 +187,7 @@ AliMUONVTrackStore* AliMUONRecoCheck::ReconstructedTracks(Int_t event)
       AliError(Form("fails to read ESD object for event %d", event));
       return 0x0;
     }
-    MakeReconstructedTracks();
+    MakeReconstructedTracks(refit);
     return fRecoTrackStore;
   }
 }
@@ -182,7 +199,7 @@ AliMUONVTrackStore* AliMUONRecoCheck::TrackRefs(Int_t event)
   /// MUONTrack objects) for a given event
   
   if (!fESDEventOwner) {
-    MakeTrackRefs();
+    if (fTrackRefStore == 0x0) MakeTrackRefs();
     return fTrackRefStore;
   }
 
@@ -208,8 +225,10 @@ AliMUONVTrackStore* AliMUONRecoCheck::ReconstructibleTracks(Int_t event)
   /// Return a track store containing the reconstructible tracks for a given event
 
   if (!fESDEventOwner) {
-    if (TrackRefs(event) == 0x0) return 0x0;
-    MakeReconstructibleTracks();
+    if (fRecoTrackRefStore == 0x0) {
+      if (TrackRefs(event) == 0x0) return 0x0;
+      MakeReconstructibleTracks();
+    }
     return fRecoTrackRefStore;
   }
 
@@ -227,7 +246,7 @@ AliMUONVTrackStore* AliMUONRecoCheck::ReconstructibleTracks(Int_t event)
 }
 
 //_____________________________________________________________________________
-void AliMUONRecoCheck::MakeReconstructedTracks()
+void AliMUONRecoCheck::MakeReconstructedTracks(Bool_t refit)
 {
   /// Make reconstructed tracks
   if (!(fRecoTrackStore = AliMUONESDInterface::NewTrackStore())) return;
@@ -236,7 +255,7 @@ void AliMUONRecoCheck::MakeReconstructedTracks()
   Int_t nTracks = (Int_t) fESDEvent->GetNumberOfMuonTracks();
   for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
     AliESDMuonTrack* esdTrack = fESDEvent->GetMuonTrack(iTrack);
-    if (esdTrack->ContainTrackerData()) AliMUONESDInterface::Add(*esdTrack, *fRecoTrackStore);
+    if (esdTrack->ContainTrackerData()) AliMUONESDInterface::Add(*esdTrack, *fRecoTrackStore, refit);
   }
   
 }
index 47485d82395181cdb97528daecaac608c5d86357..0897c1b28512a852ff34f418eb6f407c6912817c 100644 (file)
@@ -27,7 +27,7 @@ public:
   virtual ~AliMUONRecoCheck();
 
   /// Return the list of reconstructed tracks
-  AliMUONVTrackStore* ReconstructedTracks(Int_t event);
+  AliMUONVTrackStore* ReconstructedTracks(Int_t event, Bool_t refit = kTRUE);
   
   /// Return reference muon tracks
   AliMUONVTrackStore* TrackRefs(Int_t event);
@@ -35,6 +35,9 @@ public:
   /// Return reconstructible reference tracks
   AliMUONVTrackStore* ReconstructibleTracks(Int_t event);
   
+  /// Return the run number of the current ESD event
+  Int_t GetRunNumber();
+  
   /// Return the total number of events.
   Int_t NumberOfEvents() const;
   
@@ -52,7 +55,7 @@ private:
 
   void ResetStores();
   
-  void MakeReconstructedTracks();
+  void MakeReconstructedTracks(Bool_t refit);
   
   void MakeTrackRefs();
   
index 89ad415f9794bd896f3346682b4de40c3931f796..0b0411aca714b701155b08db8a777181f703d00f 100644 (file)
@@ -929,7 +929,7 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
   
   // load ESD event in the interface
   AliMUONESDInterface esdInterface;
-  if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam());
+  if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
   else AliError("Unable to get recoParam: use default ones for residual calculation");
   esdInterface.LoadEvent(*esd);
   
index 6f6da72886c74106721ade04045c4750ec925a56..95b7ace37e86c522c85fa0ff63fa26511ab8fff7 100644 (file)
@@ -1,31 +1,24 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 // ROOT includes
-#include <TTree.h>
 #include <TFile.h>
 #include <TH1.h>
 #include <TCanvas.h>
 #include <Riostream.h>
 #include <TROOT.h>
 #include <TClonesArray.h>
-#include <TGeoGlobalMagField.h>
 #include <TLorentzVector.h>
 
 // STEER includes
 #include "AliLog.h"
-#include "AliMagF.h"
 #include "AliESDEvent.h"
 #include "AliESDMuonTrack.h"
-#include "AliESDMuonCluster.h"
-#include "AliCDBPath.h"
-#include "AliCDBEntry.h"
 #include "AliCDBManager.h"
 
 // MUON includes
+#include "AliMUONCDB.h"
 #include "AliMUONTrack.h"
 #include "AliMUONVTrackStore.h"
 #include "AliMUONTrackParam.h"
-#include "AliMUONTrackExtrap.h"
-#include "AliMUONESDInterface.h"
 #include "AliMUONRecoCheck.h"
 #include "AliMUONVCluster.h"
 #include "AliMUONRecoParam.h"
 /// Results are saved in the root file DiFakes.root
 /// Results are relevent provided that you use the same recoParams as for the reconstruction
 
-void Prepare(AliMUONRecoParam *&recoParam, Double_t &sigmaCut);
-TTree* GetESDTree(TFile *esdFile);
 Bool_t TrackMatched(AliMUONTrack &track, AliMUONTrack &trackRef, Float_t &fractionOfMatchCluster, Double_t sigmaCut);
-AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
+AliMUONTrack* MatchWithTrackRef(AliMUONTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
                                Float_t &fractionOfMatchCluster, Bool_t useLabel, Double_t sigmaCut);
 
 //-----------------------------------------------------------------------
 void DIMUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent = -1,
-                const TString esdFileName = "AliESDs.root", const TString SimDir = "./generated/")
+                const TString esdFileName = "AliESDs.root", const TString SimDir = "./generated/",
+                const TString ocdbPath = "local://$ALICE_ROOT/OCDB")
 {
   
   //Reset ROOT and connect tree file
@@ -76,45 +68,42 @@ void DIMUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent
   TH1F *hPhiM = new TH1F("hPhiM"," matched track phi distribution",100,-1.,9.);
   TH1F *hPhiF = new TH1F("hPhiF"," fake track phi distribution",100,-1.,9.);
   
-  // prepare for analysis
-  AliMUONRecoParam *recoParam = 0x0;
-  Double_t sigmaCut = -1;
-  Prepare(recoParam, sigmaCut);
+  // link to reconstructed and simulated tracks
+  AliMUONRecoCheck rc(esdFileName, SimDir);
   
-  // link to reconstructed tracks
-  TFile* esdFile = TFile::Open(esdFileName);
-  TTree* esdTree = GetESDTree(esdFile);
-  AliESDEvent* esd = new AliESDEvent();
-  esd->ReadFromTree(esdTree);
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(rc.GetRunNumber());
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return;
   
-  // link to simulated tracks
-  AliMUONRecoCheck rc(esdFileName, SimDir);
+  // get sigma cut from recoParam to associate clusters with TrackRefs in case the label are not used
+  Double_t sigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking();
   
   TLorentzVector vMu1, vMu2, vDiMu;
   
   // Loop over ESD events
   FirstEvent = TMath::Max(0, FirstEvent);
-  LastEvent = (LastEvent>=0) ? TMath::Min((Int_t)esdTree->GetEntries() - 1, LastEvent) : (Int_t)esdTree->GetEntries() - 1;
+  LastEvent = (LastEvent>=0) ? TMath::Min(rc.NumberOfEvents() - 1, LastEvent) : rc.NumberOfEvents() - 1;
   for (Int_t iEvent = FirstEvent; iEvent <= LastEvent; iEvent++) {
     
-    // get the ESD of current event
-    esdTree->GetEvent(iEvent);
-    if (!esd) {
-      Error("CheckESD", "no ESD object found for event %d", iEvent);
-      return;
-    }
-    
-    // convert TrackRef to MUON tracks
+    // get reconstructed and simulated tracks
+    AliMUONVTrackStore* muonTrackStore = rc.ReconstructedTracks(iEvent, kFALSE);
     AliMUONVTrackStore* trackRefStore = rc.TrackRefs(iEvent);
+    if (!muonTrackStore || !trackRefStore) continue;
     
     // loop over ESD tracks and flag them
+    const AliESDEvent* esd = rc.GetESDEvent();
     Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ;
     for (Int_t iTrack = 0; iTrack <  nTracks;  iTrack++) {
       
-      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
+      AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
       
       // skip ghosts
-      if (!muonTrack->ContainTrackerData()) continue;
+      if (!esdTrack->ContainTrackerData()) continue;
+      
+      // find the corresponding MUON track
+      AliMUONTrack* muonTrack = (AliMUONTrack*) muonTrackStore->FindObject(esdTrack->GetUniqueID());
       
       // try to match the reconstructed track with a simulated one
       Float_t fractionOfMatchCluster = 0.;
@@ -124,7 +113,7 @@ void DIMUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent
       if (matchedTrackRef) {
        
        // flag matched tracks
-       muonTrack->SetLabel(matchedTrackRef->GetUniqueID());
+       esdTrack->SetLabel(matchedTrackRef->GetUniqueID());
        
        // remove already matched trackRefs
        trackRefStore->Remove(*matchedTrackRef);
@@ -132,7 +121,7 @@ void DIMUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent
       } else {
        
        // flag fake tracks
-       muonTrack->SetLabel(-1);
+       esdTrack->SetLabel(-1);
        
       }
       
@@ -279,74 +268,6 @@ void DIMUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent
   cDiFakesSummary.Write();
   histoFile->Close();
   
-  // clear memory
-  delete esd;
-  esdFile->Close();
-  delete recoParam;
-  
-}
-
-//-----------------------------------------------------------------------
-void Prepare(AliMUONRecoParam *&recoParam, Double_t &sigmaCut)
-{
-  /// Set the magnetic field and return recoParam and sigmaCut to associate cluster and trackRef
-  
-  // prepare OCDB access
-  AliCDBManager* man = AliCDBManager::Instance();
-  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  man->SetRun(0);
-  
-  // set  mag field 
-  // waiting for mag field in CDB 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
-  }
-  // set the magnetic field for track extrapolations
-  AliMUONTrackExtrap::SetField();
-  
-  // Load initial reconstruction parameters from OCDB
-  AliCDBPath path("MUON","Calib","RecoParam");
-  AliCDBEntry *entry=man->Get(path.GetPath());
-  if(entry) {
-    recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject());
-    entry->SetOwner(0);
-    AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
-  }
-  if (!recoParam) {
-    printf("Couldn't find RecoParam object in OCDB: create default one");
-    recoParam = AliMUONRecoParam::GetLowFluxParam();
-  }
-  
-  Info("MUONFakes", "\n recontruction parameters:");
-  recoParam->Print("FULL");
-  AliMUONESDInterface::ResetTracker(recoParam);
-  
-  // sigma cut to associate clusters with TrackRefs in case the label are not used
-  sigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking(); 
-  
-}
-
-//-----------------------------------------------------------------------
-TTree* GetESDTree(TFile *esdFile)
-{
-  /// Check that the file is properly open
-  /// Return pointer to the ESD Tree
-  
-  if (!esdFile || !esdFile->IsOpen()) {
-    Error("GetESDTree", "opening ESD file failed");
-    exit(-1);
-  }
-  
-  TTree* tree = (TTree*) esdFile->Get("esdTree");
-  if (!tree) {
-    Error("GetESDTree", "no ESD tree found");
-    exit(-1);
-  }
-  
-  return tree;
-  
 }
 
 //-----------------------------------------------------------------------
@@ -366,7 +287,7 @@ Bool_t TrackMatched(AliMUONTrack &track, AliMUONTrack &trackRef, Float_t &fracti
 }
 
 //-----------------------------------------------------------------------
-AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
+AliMUONTrack* MatchWithTrackRef(AliMUONTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
                                Float_t &fractionOfMatchCluster, Bool_t useLabel, Double_t sigmaCut)
 {
   /// Return if the trackRef matched with the reconstructed track and the fraction of matched clusters
@@ -377,28 +298,21 @@ AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &
   if (useLabel) { // by using the MC label
     
     // get the corresponding simulated track if any
-    Int_t label = muonTrack.GetLabel();
+    Int_t label = muonTrack.GetMCLabel();
     matchedTrackRef = (AliMUONTrack*) trackRefStore.FindObject(label);
     
     // get the fraction of matched clusters
     if (matchedTrackRef) {
       Int_t nMatchClusters = 0;
-      if (muonTrack.ClustersStored()) {
-       AliESDMuonCluster* cluster = (AliESDMuonCluster*) muonTrack.GetClusters().First();
-       while (cluster) {
-         if (cluster->GetLabel() == label) nMatchClusters++;
-         cluster = (AliESDMuonCluster*) muonTrack.GetClusters().After(cluster);
-       }
-      }
-      fractionOfMatchCluster = ((Float_t)nMatchClusters) / ((Float_t)muonTrack.GetNClusters());
+      Int_t nClusters = muonTrack.GetNClusters();
+      for (Int_t iCl = 0; iCl < nClusters; iCl++)
+       if (((AliMUONTrackParam*) muonTrack.GetTrackParamAtCluster()->UncheckedAt(iCl))->GetClusterPtr()->GetMCLabel() == label)
+         nMatchClusters++;
+      fractionOfMatchCluster = ((Float_t)nMatchClusters) / ((Float_t)nClusters);
     }
     
   } else { // by comparing cluster/TrackRef positions
     
-    // convert ESD track to MUON track
-    AliMUONTrack track;
-    AliMUONESDInterface::ESDToMUON(muonTrack,track);
-    
     // look for the corresponding simulated track if any
     TIter next(trackRefStore.CreateIterator());
     AliMUONTrack* trackRef;
@@ -406,7 +320,7 @@ AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &
       
       // check compatibility
       Float_t f = 0.;
-      if (TrackMatched(track, *trackRef, f, sigmaCut)) {
+      if (TrackMatched(muonTrack, *trackRef, f, sigmaCut)) {
        matchedTrackRef = trackRef;
        fractionOfMatchCluster = f;
        break;
index 0909f65e1acec53005ee965529dc9f89da96467c..6b2b7df8a818499d093b5f92e9145318a19b4df6 100644 (file)
 #include <TParticle.h>
 #include <TSystem.h>
 #include <TGeoManager.h>
-#include <TGeoGlobalMagField.h>
+#include "AliMUONCDB.h"
 #include "AliMUONRecoCheck.h"
 #include "AliMUONTrack.h"
-#include "AliMUONTrackParam.h"
 #include "AliMUONTrackLight.h"
 #include "AliMUONPairLight.h"
 #include "AliMUONVTrackStore.h"
 #include "AliESDVertex.h"
 #include "AliMCEventHandler.h"
 #include "AliMCEvent.h"
-#include "AliMagF.h"
-#include "AliGRPManager.h"
+#include "AliStack.h"
+#include "AliCDBManager.h"
 /*TODO: need to update this with changes made to ITS
 #include "AliITSVertexerPPZ.h"
 #include "AliITSLoader.h"
 */
-#include "AliTracker.h"
 #endif
 
 
@@ -103,15 +101,10 @@ void DecodeRecoCocktail(
     }
   }
   
-  // set  mag field 
-  // waiting for mag field in CDB 
-   if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliGRPManager *grpMan = new AliGRPManager();
-    grpMan->ReadGRPEntry();
-    grpMan->SetMagField();
-    delete grpMan;
-  }
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  AliCDBManager::Instance()->SetRun(0);
+  if (!AliMUONCDB::LoadField()) return;
   // set the magnetic field for track extrapolations
   AliMUONTrackExtrap::SetField();
 
@@ -145,7 +138,7 @@ void DecodeRecoCocktail(
     muonArray->Clear();     // clean muon and dimuon arrays 
     dimuonArray->Clear(); 
     
-    AliMUONVTrackStore* recoTracks = rc->ReconstructedTracks(ievent);  // Use tracks from actual reconstruction, but this does not work anymore.
+    AliMUONVTrackStore* recoTracks = rc->ReconstructedTracks(ievent, kFALSE);  // Use tracks from actual reconstruction.
     //AliMUONVTrackStore* trackRefs = rc->ReconstructibleTracks(ievent);  // Only use reconstructible reference tracks.
     AliMUONVTrackStore* trackRefs = rc->TrackRefs(ievent);
     AliStack* pstack = (const_cast<AliMCEventHandler*>(rc->GetMCEventHandler()))->MCEvent()->Stack();
index 242af5eafccc449c22898210bd883fa72d546f3b..862b4f7e5105d8c83623ec91506300ae86f892c5 100644 (file)
 
 #include "AliMUONAlignment.h"
 #include "AliMUONTrack.h"
-#include "AliMUONTrackExtrap.h"
+#include "AliMUONRecoParam.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONGeometryTransformer.h"
 #include "AliMUONESDInterface.h"
+#include "AliMUONCDB.h"
 
 #include "AliESDEvent.h"
 #include "AliESDMuonTrack.h"
-#include "AliMagF.h"
-#include "AliTracker.h"
-#include "AliGRPManager.h"
 #include "AliCDBManager.h"
 #include "AliCDBMetaData.h"
 #include "AliCDBId.h"
@@ -80,21 +78,16 @@ void MUONAlignment(Int_t nEvents = 100000, char* geoFilename = "geometry.root",
     }
   }
   
-  // CDB manager
+  // load necessary data from OCDB
   AliCDBManager* cdbManager = AliCDBManager::Instance();
   cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
   cdbManager->SetRun(0);
-
-  // set  mag field 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliGRPManager *grpMan = new AliGRPManager();
-    grpMan->ReadGRPEntry();
-    grpMan->SetMagField();
-    delete grpMan;
-  }
-  // set the magnetic field for track extrapolations
-  AliMUONTrackExtrap::SetField();
+  if (!AliMUONCDB::LoadField()) return;
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return;
+  
+  // reset tracker for restoring initial track parameters at cluster
+  AliMUONESDInterface::ResetTracker(recoParam);
 
   Double_t parameters[4*156];
   Double_t errors[4*156];
index 7109f67866b4e4150fe2af997cc90e4fd8d74d69..b668486b33fa4a0bcd5eb8eb2476bc8a44a72a0c 100644 (file)
 #include <TMath.h>
 
 // STEER includes
-#include "AliMagF.h"
-#include "AliTracker.h"
 #include "AliESDEvent.h"
 #include "AliRecoParam.h"
 #include "AliCDBManager.h"
 #include "AliRunLoader.h"
 #include "AliLoader.h"
+#include "AliHeader.h"
 
 // MUON includes
 #include "AliMpConstants.h"
-#include "AliMpCDB.h"
 #include "AliMpSegmentation.h"
 #include "AliMpVSegmentation.h"
 #include "AliMpPad.h"
+#include "AliMUONCDB.h"
 #include "AliMUONCalibrationData.h"
 #include "AliMUONVCalibParam.h"
 #include "AliMUONPadInfo.h"
 
 const Int_t printLevel = 1;
 
-void Prepare();
 TTree* GetESDTree(TFile *esdFile);
 UInt_t buildClusterMap(AliMUONTrack &track);
 
 //-----------------------------------------------------------------------
-void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root",
-                    const char* inFileName = "galice.root", const char* outFileName = "clusterInfo.root")
+void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root", const char* inFileName = "galice.root",
+                    const TString ocdbPath = "local://$ALICE_ROOT/OCDB", const char* outFileName = "clusterInfo.root")
 {
   /// 1) if (esdFileName != "")
   /// loop over ESD event and fill AliMUONClusterInfo object with cluster + corresponding track parameters;
@@ -97,18 +95,21 @@ void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root
   AliMUONVClusterStore* clusterStore = 0x0;
   AliMUONVDigitStore* digitStore = 0x0;
   
-  // prepare the refitting during ESD->MUON conversion
-  Prepare();
-  
   // open the ESD file and tree and connect the ESD event
   TFile* esdFile = 0x0;
   TTree* esdTree = 0x0;
   AliESDEvent* esd = 0x0;
+  Int_t runNumber = -1;
   if (useESD) {
     esdFile = TFile::Open(esdFileName);
     esdTree = GetESDTree(esdFile);
     esd = new AliESDEvent();
     esd->ReadFromTree(esdTree);
+    if (esdTree->GetEvent(0) <= 0) {
+      Error("MUONClusterInfo", "no ESD object found for event 0");
+      return;
+    }
+    runNumber = esd->GetRunNumber();
   }
   
   // get the cluster from RecPoints
@@ -119,8 +120,24 @@ void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root
     MUONLoader = rl->GetDetectorLoader("MUON");
     MUONLoader->LoadRecPoints("READ");   
     MUONLoader->LoadDigits("READ");
+    rl->LoadHeader();
+    if (runNumber < 0) runNumber = rl->GetHeader()->GetRun();
   }
   
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(runNumber);
+  if (!AliMUONCDB::LoadField()) return;
+  if (!AliMUONCDB::LoadMapping(kTRUE)) return;
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return;
+  
+  // reset tracker for track restoring initial track parameters at cluster
+  AliMUONESDInterface::ResetTracker(recoParam);
+  
+  // prepare access to calibration data
+  calibData = new AliMUONCalibrationData(runNumber);
+  
   // prepare the output tree
   gROOT->cd();
   TFile* clusterInfoFile = TFile::Open(outFileName, "RECREATE");
@@ -181,10 +198,6 @@ void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root
       }
     }
     
-    // prepare access to calibration data
-    if (useESD && !calibData) calibData = new AliMUONCalibrationData(esd->GetESDRun()->GetRunNumber());
-    else if (!calibData) calibData = new AliMUONCalibrationData(rl->GetRunNumber());
-    
     //----------------------------------------------//
     // ------------- fill cluster info ------------ //
     //----------------------------------------------//
@@ -372,6 +385,7 @@ void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root
   if (useRecPoints) {
     MUONLoader->UnloadDigits();
     MUONLoader->UnloadRecPoints();
+    rl->UnloadHeader();
     delete rl;
   }
   if (useESD) {
@@ -381,36 +395,6 @@ void MUONClusterInfo(Int_t nevents = -1, const char* esdFileName = "AliESDs.root
   cout<<endl<<"time to fill cluster/track info: R:"<<timer.RealTime()<<" C:"<<timer.CpuTime()<<endl<<endl;
 }
 
-//-----------------------------------------------------------------------
-void Prepare()
-{
-  /// Set the magnetic field, the mapping and the reconstruction parameters
-  
-  gRandom->SetSeed(0);
-  
-  // set mag field
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
-  }
-  
-  // Load mapping
-  AliCDBManager* man = AliCDBManager::Instance();
-  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  man->SetRun(0);
-  if ( ! AliMpCDB::LoadDDLStore() ) {
-    Error("Prepare","Could not access mapping from OCDB !");
-    exit(-1);
-  }
-  
-  // Reset the reconstruction parameters for track refitting if needed
-  // (by default will use Kalman filter + Smoother)
-  //  AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLowFluxParam();
-  //  AliMUONESDInterface::ResetTracker(muonRecoParam);
-  
-}
-
 //-----------------------------------------------------------------------
 TTree* GetESDTree(TFile *esdFile)
 {
index e53bb56f9d56e7aa5dcebb18706b84971e160921..60ff78f119b5d35cd820480eeda2860317d98ef7 100644 (file)
@@ -1,30 +1,24 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 // ROOT includes
-#include <TTree.h>
 #include <TFile.h>
 #include <TH1.h>
 #include <TCanvas.h>
 #include <Riostream.h>
 #include <TROOT.h>
 #include <TClonesArray.h>
-#include <TGeoGlobalMagField.h>
 #include <TArrayI.h>
 
 // STEER includes
 #include "AliLog.h"
-#include "AliMagF.h"
 #include "AliESDEvent.h"
 #include "AliESDMuonTrack.h"
-#include "AliESDMuonCluster.h"
-#include "AliCDBPath.h"
-#include "AliCDBEntry.h"
 #include "AliCDBManager.h"
   
 // MUON includes
+#include "AliMUONCDB.h"
 #include "AliMUONTrack.h"
 #include "AliMUONVTrackStore.h"
 #include "AliMUONTrackParam.h"
-#include "AliMUONTrackExtrap.h"
 #include "AliMUONESDInterface.h"
 #include "AliMUONRecoCheck.h"
 #include "AliMUONVCluster.h"
 /// Results are saved in the root file Fakes.root
 /// Results are relevent provided that you use the same recoParams as for the reconstruction
 
-void Prepare(AliMUONRecoParam *&recoParam, Double_t &sigmaCut);
-TTree* GetESDTree(TFile *esdFile);
 Bool_t TrackMatched(AliMUONTrack &track, AliMUONTrack &trackRef, Float_t &fractionOfMatchCluster, Double_t sigmaCut);
 Bool_t IsRecontructible(AliMUONTrack &track, AliMUONRecoParam &recoParam);
-AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
+AliMUONTrack* MatchWithTrackRef(AliMUONTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
                                Float_t &fractionOfMatchCluster, Bool_t useLabel, Double_t sigmaCut);
 Int_t RemoveConnectedFakes(AliMUONVTrackStore &fakeTrackStore, AliMUONVTrackStore &trackRefStore, AliMUONRecoParam &recoParam,
                           Bool_t useLabel, Double_t sigmaCut, TH1F &hFractionOfConnectedClusters);
 
 //-----------------------------------------------------------------------
 void MUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent = -1,
-              const TString esdFileName = "AliESDs.root", const TString SimDir = "./generated/")
+              const TString esdFileName = "AliESDs.root", const TString SimDir = "./generated/",
+              const TString ocdbPath = "local://$ALICE_ROOT/OCDB")
 {
   
   //Reset ROOT and connect tree file
@@ -86,19 +79,17 @@ void MUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent =
   TH1F *hPhiM = new TH1F("hPhiM"," matched track phi distribution",100,-1.,9.);
   TH1F *hPhiF = new TH1F("hPhiF"," fake track phi distribution",100,-1.,9.);
   
-  // prepare for analysis
-  AliMUONRecoParam *recoParam = 0x0;
-  Double_t sigmaCut = -1;
-  Prepare(recoParam, sigmaCut);
+  // link to reconstructed and simulated tracks
+  AliMUONRecoCheck rc(esdFileName, SimDir);
   
-  // link to reconstructed tracks
-  TFile* esdFile = TFile::Open(esdFileName);
-  TTree* esdTree = GetESDTree(esdFile);
-  AliESDEvent* esd = new AliESDEvent();
-  esd->ReadFromTree(esdTree);
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(rc.GetRunNumber());
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return;
   
-  // link to simulated tracks
-  AliMUONRecoCheck rc(esdFileName, SimDir);
+  // get sigma cut from recoParam to associate clusters with TrackRefs in case the label are not used
+  Double_t sigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking();
   
   // initialize global counters
   Int_t nReconstructibleTracks = 0;
@@ -118,18 +109,13 @@ void MUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent =
   
   // Loop over ESD events
   FirstEvent = TMath::Max(0, FirstEvent);
-  LastEvent = (LastEvent>=0) ? TMath::Min((Int_t)esdTree->GetEntries() - 1, LastEvent) : (Int_t)esdTree->GetEntries() - 1;
+  LastEvent = (LastEvent>=0) ? TMath::Min(rc.NumberOfEvents() - 1, LastEvent) : rc.NumberOfEvents() - 1;
   for (Int_t iEvent = FirstEvent; iEvent <= LastEvent; iEvent++) {
     
-    // get the ESD of current event
-    esdTree->GetEvent(iEvent);
-    if (!esd) {
-      Error("CheckESD", "no ESD object found for event %d", iEvent);
-      return;
-    }
-    
-    // convert TrackRef to MUON tracks
+    // get reconstructed and simulated tracks
+    AliMUONVTrackStore* muonTrackStore = rc.ReconstructedTracks(iEvent, kFALSE);
     AliMUONVTrackStore* trackRefStore = rc.TrackRefs(iEvent);
+    if (!muonTrackStore || !trackRefStore) continue;
     
     // count the number of reconstructible tracks
     TIter next(trackRefStore->CreateIterator());
@@ -142,22 +128,26 @@ void MUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent =
     Int_t nTrackerTracks = 0;
     trackReconstructedYet = kFALSE;
     AliMUONVTrackStore *fakeTrackStore = AliMUONESDInterface::NewTrackStore();
+    const AliESDEvent* esd = rc.GetESDEvent();
     Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ;
     for (Int_t iTrack = 0; iTrack <  nTracks;  iTrack++) {
       
-      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
+      AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
       
       // skip ghosts
-      if (!muonTrack->ContainTrackerData()) continue;
+      if (!esdTrack->ContainTrackerData()) continue;
       nTrackerTracks++;
       
+      // find the corresponding MUON track
+      AliMUONTrack* muonTrack = (AliMUONTrack*) muonTrackStore->FindObject(esdTrack->GetUniqueID());
+      
       // get track info
-      Int_t nClusters = muonTrack->GetNClusters();
-      Double_t normalizedChi2 = muonTrack->GetChi2() / (2. * muonTrack->GetNHit() - 5);
-      Double_t p = muonTrack->P();
-      Double_t pT = muonTrack->Pt();
-      Double_t eta = muonTrack->Eta();
-      Double_t phi = muonTrack->Phi();
+      Int_t nClusters = esdTrack->GetNClusters();
+      Double_t normalizedChi2 = esdTrack->GetChi2() / (2. * esdTrack->GetNHit() - 5);
+      Double_t p = esdTrack->P();
+      Double_t pT = esdTrack->Pt();
+      Double_t eta = esdTrack->Eta();
+      Double_t phi = esdTrack->Phi();
       
       // fill global histograms
       hNumberOfClusters->Fill(nClusters);
@@ -208,7 +198,7 @@ void MUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent =
        hPhiF->Fill(phi);
        
        // store fake tracks
-       AliMUONESDInterface::Add(*muonTrack, *fakeTrackStore);
+       fakeTrackStore->Add(*muonTrack);
        
       }
       
@@ -354,74 +344,6 @@ void MUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent =
   cout << "REMINDER: results are relevent provided that you use the same recoParams as for the reconstruction" << endl;
   cout << endl;
   
-  // clear memory
-  delete esd;
-  esdFile->Close();
-  delete recoParam;
-  
-}
-
-//-----------------------------------------------------------------------
-void Prepare(AliMUONRecoParam *&recoParam, Double_t &sigmaCut)
-{
-  /// Set the magnetic field and return recoParam and sigmaCut to associate cluster and trackRef
-  
-  // prepare OCDB access
-  AliCDBManager* man = AliCDBManager::Instance();
-  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  man->SetRun(0);
-  
-  // set  mag field 
-  // waiting for mag field in CDB 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1., AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
-  }
-  // set the magnetic field for track extrapolations
-  AliMUONTrackExtrap::SetField();
-  
-  // Load initial reconstruction parameters from OCDB
-  AliCDBPath path("MUON","Calib","RecoParam");
-  AliCDBEntry *entry=man->Get(path.GetPath());
-  if(entry) {
-    recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject());
-    entry->SetOwner(0);
-    AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
-  }
-  if (!recoParam) {
-    printf("Couldn't find RecoParam object in OCDB: create default one");
-    recoParam = AliMUONRecoParam::GetLowFluxParam();
-  }
-  
-  Info("MUONFakes", "\n recontruction parameters:");
-  recoParam->Print("FULL");
-  AliMUONESDInterface::ResetTracker(recoParam);
-  
-  // sigma cut to associate clusters with TrackRefs in case the label are not used
-  sigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking(); 
-  
-}
-
-//-----------------------------------------------------------------------
-TTree* GetESDTree(TFile *esdFile)
-{
-  /// Check that the file is properly open
-  /// Return pointer to the ESD Tree
-  
-  if (!esdFile || !esdFile->IsOpen()) {
-    Error("GetESDTree", "opening ESD file failed");
-    exit(-1);
-  }
-  
-  TTree* tree = (TTree*) esdFile->Get("esdTree");
-  if (!tree) {
-    Error("GetESDTree", "no ESD tree found");
-    exit(-1);
-  }
-  
-  return tree;
-  
 }
 
 //-----------------------------------------------------------------------
@@ -470,7 +392,7 @@ Bool_t IsRecontructible(AliMUONTrack &track, AliMUONRecoParam &recoParam)
 }
 
 //-----------------------------------------------------------------------
-AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
+AliMUONTrack* MatchWithTrackRef(AliMUONTrack &muonTrack, AliMUONVTrackStore &trackRefStore,
                                Float_t &fractionOfMatchCluster, Bool_t useLabel, Double_t sigmaCut)
 {
   /// Return if the trackRef matched with the reconstructed track and the fraction of matched clusters
@@ -481,28 +403,21 @@ AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &
   if (useLabel) { // by using the MC label
     
     // get the corresponding simulated track if any
-    Int_t label = muonTrack.GetLabel();
+    Int_t label = muonTrack.GetMCLabel();
     matchedTrackRef = (AliMUONTrack*) trackRefStore.FindObject(label);
     
     // get the fraction of matched clusters
     if (matchedTrackRef) {
       Int_t nMatchClusters = 0;
-      if (muonTrack.ClustersStored()) {
-       AliESDMuonCluster* cluster = (AliESDMuonCluster*) muonTrack.GetClusters().First();
-       while (cluster) {
-         if (cluster->GetLabel() == label) nMatchClusters++;
-         cluster = (AliESDMuonCluster*) muonTrack.GetClusters().After(cluster);
-       }
-      }
-      fractionOfMatchCluster = ((Float_t)nMatchClusters) / ((Float_t)muonTrack.GetNClusters());
+      Int_t nClusters = muonTrack.GetNClusters();
+      for (Int_t iCl = 0; iCl < nClusters; iCl++)
+       if (((AliMUONTrackParam*) muonTrack.GetTrackParamAtCluster()->UncheckedAt(iCl))->GetClusterPtr()->GetMCLabel() == label)
+         nMatchClusters++;
+      fractionOfMatchCluster = ((Float_t)nMatchClusters) / ((Float_t)nClusters);
     }
     
   } else { // by comparing cluster/TrackRef positions
     
-    // convert ESD track to MUON track
-    AliMUONTrack track;
-    AliMUONESDInterface::ESDToMUON(muonTrack,track);
-    
     // look for the corresponding simulated track if any
     TIter next(trackRefStore.CreateIterator());
     AliMUONTrack* trackRef;
@@ -510,7 +425,7 @@ AliMUONTrack* MatchWithTrackRef(AliESDMuonTrack &muonTrack, AliMUONVTrackStore &
       
       // check compatibility
       Float_t f = 0.;
-      if (TrackMatched(track, *trackRef, f, sigmaCut)) {
+      if (TrackMatched(muonTrack, *trackRef, f, sigmaCut)) {
        matchedTrackRef = trackRef;
        fractionOfMatchCluster = f;
        break;
@@ -547,7 +462,7 @@ Int_t RemoveConnectedFakes(AliMUONVTrackStore &fakeTrackStore, AliMUONVTrackStor
     
     // look for the most connected fake track
     AliMUONTrack *connectedFake = 0x0;
-    Float_t fractionOfConnectedClusters = 0.;
+    Double_t fractionOfConnectedClusters = 0.;
     TIter next2(fakeTrackStore.CreateIterator());
     AliMUONTrack* fakeTrack;
     while ( ( fakeTrack = static_cast<AliMUONTrack*>(next2()) ) ) {
@@ -567,7 +482,7 @@ Int_t RemoveConnectedFakes(AliMUONVTrackStore &fakeTrackStore, AliMUONVTrackStor
       if (nConnectedClusters == 0) continue;
       
       // check if it is the most connected fake track
-      Float_t f = ((Float_t)nConnectedClusters) / ((Float_t)fakeTrack->GetNClusters());
+      Double_t f = ((Double_t)nConnectedClusters) / ((Double_t)fakeTrack->GetNClusters());
       if (f > fractionOfConnectedClusters) {
        connectedFake = fakeTrack;
        fractionOfConnectedClusters = f;
index 22c35d06ee05510f4fcd5a3a231591a54a81b0aa..ac52aeed74c549306cccc9cefd26363e1a8abed0 100644 (file)
@@ -46,9 +46,9 @@
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
-#include "AliCDBEntry.h"
 #include "AliCDBManager.h"
 #include "AliCodeTimer.h"
+#include "AliMUONCDB.h"
 #include "AliMUONPainterDataRegistry.h"
 #include "AliMUONRecoParam.h"
 #include "AliMUONTrackerDataMaker.h"
@@ -89,10 +89,8 @@ Int_t DataMakerReading(const char* input,
   
   AliMUONVTrackerDataMaker* dm(0x0);
   
-  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
-  AliMUONRecoParam* recoParam(0x0);
-  
-  if ( entry ) recoParam = static_cast<AliMUONRecoParam*>(entry->GetObject());
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return 0;
   
   if ( strlen(cdbPath) > 0 ) 
   {
@@ -230,8 +228,7 @@ void MUONOfflineShift(const char* input="alien:///alice/data/2009/LHC09a/0000674
   AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
   AliCDBManager::Instance()->SetRun(runNumber);
 
-  AliMpCDB::LoadDDLStore();
-  AliMpCDB::LoadManuStore();
+  if (!AliMUONCDB::LoadMapping()) return;
   
   TStopwatch timer1;
   TStopwatch timer2;
index 0c1d278bcd9aca4b8538416e6f956ddb84f08bf2..cc62800fb17eabb29f1f49558d255a327d46a2e9 100644 (file)
 #include "TClonesArray.h"
 #include "TH1.h"
 #include "TFile.h"
-#include <TGeoManager.h>
 
 // STEER includes
-#include "AliRun.h"
-#include "AliHeader.h"
-#include "AliMC.h"
-#include "AliStack.h"
-#include "AliMagF.h"
-#include "AliTracker.h"
+#include "AliCDBManager.h"
 
 // MUON includes
+#include "AliMUONCDB.h"
 #include "AliMUONConstants.h"
 #include "AliMUONTrack.h"
 #include "AliMUONRecoCheck.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONTrackExtrap.h"
+#include "AliMUONRecoParam.h"
 #include "AliMUONVTrackStore.h"
 
 Int_t TrackCheck( Bool_t *compTrack);
 
-void MUONRecoCheck (Int_t nEvent = -1, char* geoFilename = "geometry.root", 
-                    char * pathSim="./generated/", char * esdFileName="AliESDs.root")
+void MUONRecoCheck (Int_t nEvent = -1, char * pathSim="./generated/", char * esdFileName="AliESDs.root",
+                    const char* ocdbPath = "local://$ALICE_ROOT/OCDB")
 {
   
   Bool_t compTrack[10];
@@ -60,7 +56,6 @@ void MUONRecoCheck (Int_t nEvent = -1, char* geoFilename = "geometry.root",
   Int_t iTrack = 0;
   AliMUONTrack* trackOK(0x0);
   Int_t trackID = 0;
-  Double_t sigmaCut = 4.;  // 4 sigmas cut
   Double_t maxChi2 = 999.;
   AliMUONTrackParam *trackParam;
   Double_t x1,y1,z1,pX1,pY1,pZ1,p1;
@@ -78,26 +73,20 @@ void MUONRecoCheck (Int_t nEvent = -1, char* geoFilename = "geometry.root",
   TH1F *hResMomVertex = new TH1F("hResMomVertex"," delta P vertex (GeV/c)",100,-10.,10);
   TH1F *hResMomFirstCluster = new TH1F("hResMomFirstCluster"," delta P first cluster (GeV/c)",100,-10.,10);
   
-  // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
-  if (!gGeoManager) {
-    TGeoManager::Import(geoFilename);
-    if (!gGeoManager) {
-      Error("MUONmass_ESD", "getting geometry from file %s failed", geoFilename);
-      return;
-    }
-  }
+  AliMUONRecoCheck rc(esdFileName, pathSim);
+  
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(rc.GetRunNumber());
+  AliMUONCDB::LoadField();
+  AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  if (!recoParam) return;
   
-  // set  mag field 
-  // waiting for mag field in CDB 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
-  }
   // set the magnetic field for track extrapolations
   AliMUONTrackExtrap::SetField();
 
-  AliMUONRecoCheck rc(esdFileName, pathSim);
+  // get sigma cut from recoParam to associate clusters with TrackRefs
+  Double_t sigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking();
   
   Int_t nevents = rc.NumberOfEvents();
   
@@ -112,7 +101,7 @@ void MUONRecoCheck (Int_t nEvent = -1, char* geoFilename = "geometry.root",
   {
     if (!(ievent%10)) printf(" **** event # %d  \n",ievent);
     
-    AliMUONVTrackStore* trackStore = rc.ReconstructedTracks(ievent);
+    AliMUONVTrackStore* trackStore = rc.ReconstructedTracks(ievent, kFALSE);
     AliMUONVTrackStore* trackRefStore = rc.ReconstructibleTracks(ievent);
     
     hReconstructible->Fill(trackRefStore->GetSize());
index 1bddca84a2c4347da1e4a206dcd781a1b179a274..69d299d5c7169e5e4123d6771cce7ce273c1a566 100644 (file)
 #include <TROOT.h>
 
 // STEER includes
-#include "AliMagF.h"
-#include "AliTracker.h"
 #include "AliESDEvent.h"
 #include "AliESDMuonTrack.h"
-#include "AliRecoParam.h"
 #include "AliCDBManager.h"
-#include "AliCDBEntry.h"
-#include "AliCDBPath.h"
 #include "AliGeomManager.h"
 
 // MUON includes
-#include "AliMpCDB.h"
+#include "AliMUONCDB.h"
 #include "AliMUONRecoParam.h"
 #include "AliMUONESDInterface.h"
 #include "AliMUONRefitter.h"
 #include "AliMUONTrack.h"
 #include "AliMUONVTrackStore.h"
 #include "AliMUONTrackParam.h"
-#include "AliMUONTrackExtrap.h"
 #endif
 
 const Int_t printLevel = 1;
 
-void Prepare();
 TTree* GetESDTree(TFile *esdFile);
 
 //-----------------------------------------------------------------------
-void MUONRefit(Int_t nevents = -1, const char* esdFileNameIn = "AliESDs.root", const char* esdFileNameOut = "AliESDs_New.root")
+void MUONRefit(Int_t nevents = -1, const char* esdFileNameIn = "AliESDs.root", const char* esdFileNameOut = "AliESDs_New.root",
+              const char* geoFilename = "geometry.root", const char* ocdbPath = "local://$ALICE_ROOT/OCDB")
 {
+  /// Example of muon refitting:
   /// refit ESD tracks from ESD pads (i.e. re-clusterized the attached ESD clusters);
   /// reset the charge of the digit using their raw charge before refitting;
   /// compare results with original ESD tracks; 
   /// write results in a new ESD file
   
-  // prepare the refitting
-  gRandom->SetSeed(1);
-  Prepare();
-  
-  // reconstruction parameters for the refitting
-  AliMUONRecoParam* recoParam = AliMUONRecoParam::GetLowFluxParam();
-  Info("MUONRefit", "\n Reconstruction parameters for refitting:");
-  recoParam->Print("FULL");
-  
-  AliMUONESDInterface esdInterface;
-  AliMUONRefitter refitter(recoParam);
-  refitter.Connect(&esdInterface);
-  
   // open the ESD file and tree
   TFile* esdFile = TFile::Open(esdFileNameIn);
   TTree* esdTree = GetESDTree(esdFile);
@@ -92,7 +74,39 @@ void MUONRefit(Int_t nevents = -1, const char* esdFileNameIn = "AliESDs.root", c
   // connect ESD event to the ESD tree
   AliESDEvent* esd = new AliESDEvent();
   esd->ReadFromTree(esdTree);
-
+  
+  // get run number
+  if (esdTree->GetEvent(0) <= 0) {
+    Error("MUONRefit", "no ESD object found for event 0");
+    return;
+  }
+  Int_t runNumber = esd->GetRunNumber();
+  
+  // Import TGeo geometry
+  if (!gGeoManager) {
+    AliGeomManager::LoadGeometry(geoFilename);
+    if (!gGeoManager) {
+      Error("MUONRefit", "getting geometry from file %s failed", "generated/galice.root");
+      exit(-1);
+    }
+  }
+  
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(runNumber);
+  if (!AliMUONCDB::LoadField()) return;
+  if (!AliMUONCDB::LoadMapping(kTRUE)) return;
+  
+  // reconstruction parameters for the refitting
+  AliMUONRecoParam* recoParam = AliMUONRecoParam::GetLowFluxParam();
+  Info("MUONRefit", "\n Reconstruction parameters for refitting:");
+  recoParam->Print("FULL");
+  
+  AliMUONESDInterface esdInterface;
+  AliMUONRefitter refitter(recoParam);
+  refitter.Connect(&esdInterface);
+  gRandom->SetSeed(1);
+  
   // timer start...
   TStopwatch timer;
   
@@ -115,7 +129,7 @@ void MUONRefit(Int_t nevents = -1, const char* esdFileNameIn = "AliESDs.root", c
     if (nTracks < 1) continue;
     
     // load the current event
-    esdInterface.LoadEvent(*esd);
+    esdInterface.LoadEvent(*esd, kFALSE);
     
     // loop over digit to modify their charge
     AliMUONVDigit *digit;
@@ -194,62 +208,11 @@ void MUONRefit(Int_t nevents = -1, const char* esdFileNameIn = "AliESDs.root", c
   // free memory
   esdFile->Close();
   delete esd;
+  delete recoParam;
   
   cout<<endl<<"time to refit: R:"<<timer.RealTime()<<" C:"<<timer.CpuTime()<<endl<<endl;
 }
 
-//-----------------------------------------------------------------------
-void Prepare()
-{
-  /// Set the geometry, the magnetic field, the mapping and the reconstruction parameters
-  
-  // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
-  if (!gGeoManager) {
-    AliGeomManager::LoadGeometry("geometry.root");
-    if (!gGeoManager) {
-      Error("MUONRefit", "getting geometry from file %s failed", "generated/galice.root");
-      return;
-    }
-  }
-  
-  // set  mag field 
-  // waiting for mag field in CDB 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
-  }
-  // set the magnetic field for track extrapolations
-  AliMUONTrackExtrap::SetField();
-  
-  // Load mapping
-  AliCDBManager* man = AliCDBManager::Instance();
-  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  man->SetRun(0);
-  if ( ! AliMpCDB::LoadDDLStore() ) {
-    Error("MUONRefit","Could not access mapping from OCDB !");
-    exit(-1);
-  }
-  
-  // Load initial reconstruction parameters from OCDB
-  AliMUONRecoParam* recoParam = 0x0;
-  AliCDBPath path("MUON","Calib","RecoParam");
-  AliCDBEntry *entry=man->Get(path.GetPath());
-  if(entry) {
-    recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject());
-    entry->SetOwner(0);
-    AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
-  }
-  if (!recoParam) {
-    printf("Couldn't find RecoParam object in OCDB: create default one");
-    recoParam = AliMUONRecoParam::GetLowFluxParam();
-  }
-  Info("MUONRefit", "\n initial recontruction parameters:");
-  recoParam->Print("FULL");
-  AliMUONESDInterface::ResetTracker(recoParam);
-  
-}
-
 //-----------------------------------------------------------------------
 TTree* GetESDTree(TFile *esdFile)
 {
index 325b17949024d7e7f1483e654ad1caa53eaab46d..cf0086a9bfa8d7a68be3af6fa6d6e7da92e7b7d2 100644 (file)
@@ -23,6 +23,7 @@
 // MUON includes
 #include "AliMUONCDB.h"
 #include "AliMUONTriggerEfficiencyCells.h"
+#include "AliCDBManager.h"
 #include "AliCDBRunRange.h"
 #include "Riostream.h"
 
@@ -72,6 +73,6 @@ void MUONTriggerChamberEfficiency(Bool_t addMapInSimulation=kFALSE,
 
     if(!addMapInSimulation) return;
 
-    AliMUONCDB muonCDB;
-  muonCDB.WriteToCDB("MUON/Calib/TriggerEfficiency",effMap,0,AliCDBRunRange::Infinity(),true);
+    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+    AliMUONCDB::WriteToCDB("MUON/Calib/TriggerEfficiency",effMap,0,AliCDBRunRange::Infinity(),true);
 }
index 3ca3ee4bcfdfcbaa6f2904ca7f57ff27084be77c..ab8378d67038f50aa3414283037db467c6ff9884 100644 (file)
@@ -41,9 +41,6 @@
 #pragma link C++ class AliMUONDigitMaker+;
 #pragma link C++ class AliMUONRawWriter+;
 
-// calibration access
-#pragma link C++ class AliMUONCDB+;
-
 #endif
 
 
index 094471accfe01b8d7f995c41cef1187994030265..e799880cd7cb14e8a88d603ecf95f856085d69fa 100644 (file)
@@ -33,6 +33,7 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
 // MUON includes
+#include "AliMUONCDB.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONTrackExtrap.h"
 #include "AliMUONESDInterface.h"
 #include "AliHeader.h"
 #include "AliLoader.h"
 #include "AliStack.h"
-#include "AliMagF.h"
 #include "AliESDEvent.h"
 #include "AliESDVertex.h"
-#include "AliTracker.h"
 #include "AliCDBManager.h"
 #include "AliESDMuonTrack.h"
 
 // ROOT includes
 #include "TTree.h"
 #include "TNtuple.h"
-#include "TBranch.h"
-#include "TClonesArray.h"
 #include "TLorentzVector.h"
 #include "TFile.h"
 #include "TH1.h"
 #include "TH2.h"
 #include "TParticle.h"
-#include "TTree.h"
 #include "TString.h"
 #include <Riostream.h>
 #include <TGeoManager.h>
 #include <TROOT.h>
 #include <TF1.h>
+#include <TMath.h>
 
 #endif
 
-Bool_t MUONefficiency( char* filename = "galice.root", char* geoFilename = "geometry.root", char* esdFileName = "AliESDs.root",
-                       Int_t ExtrapToVertex = -1, Int_t ResType = 553, Int_t FirstEvent = 0, Int_t LastEvent = 1000000 )
+Bool_t MUONefficiency(char* filename = "generated/galice.root", char* esdFileName = "AliESDs.root",
+                     char* geoFilename = "geometry.root", char* ocdbPath = "local://$ALICE_ROOT/OCDB",
+                     Int_t ExtrapToVertex = -1, Int_t ResType = 553, Int_t FirstEvent = 0, Int_t LastEvent = 1000000 )
 { 
 /// \param ExtrapToVertex (default -1) 
 ///  - <0: no extrapolation;
@@ -84,10 +82,6 @@ Bool_t MUONefficiency( char* filename = "galice.root", char* geoFilename = "geom
 
   // MUONefficiency starts
 
-  // Set default CDB storage
-  AliCDBManager* man = AliCDBManager::Instance();
-  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-
   Double_t MUON_MASS = 0.105658369;
   Double_t UPSILON_MASS = 9.4603 ;
   Double_t JPSI_MASS = 3.097;
@@ -198,22 +192,41 @@ Bool_t MUONefficiency( char* filename = "galice.root", char* geoFilename = "geom
   if (!gGeoManager) {
     TGeoManager::Import(geoFilename);
     if (!gGeoManager) {
-      Error("MUONmass_ESD", "getting geometry from file %s failed", filename);
+      Error("MUONefficiency", "getting geometry from file %s failed", geoFilename);
       return kFALSE;
     }
   }
   
-  // set  mag field 
-  // waiting for mag field in CDB 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
+  // open the ESD file
+  TFile* esdFile = TFile::Open(esdFileName);
+  if (!esdFile || !esdFile->IsOpen()) {
+    Error("MUONefficiency", "opening ESD file %s failed", esdFileName);
+    return kFALSE;
   }
+
+  AliESDEvent* esd = new AliESDEvent();
+  TTree* tree = (TTree*) esdFile->Get("esdTree");
+  if (!tree) {
+    Error("MUONefficiency", "no ESD tree found");
+    return kFALSE;
+  } 
+  esd->ReadFromTree(tree);
+
+  // get run number
+  if (tree->GetEvent(0) <= 0) {
+    Error("MUONefficiency", "no ESD object found for event 0");
+    return kFALSE;
+  }
+  Int_t runNumber = esd->GetRunNumber();
+
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(runNumber);
+  if (!AliMUONCDB::LoadField()) return kFALSE;
+
   // set the magnetic field for track extrapolations
   AliMUONTrackExtrap::SetField();
 
-
   // open run loader and load gAlice, kinematics and header
   AliRunLoader* runLoader = AliRunLoader::Open(filename);
   if (!runLoader) {
@@ -227,25 +240,12 @@ Bool_t MUONefficiency( char* filename = "galice.root", char* geoFilename = "geom
     Error("MUONefficiency", "no galice object found");
     return kFALSE;
   }
-  
-  // open the ESD file
-  TFile* esdFile = TFile::Open(esdFileName);
-  if (!esdFile || !esdFile->IsOpen()) {
-    Error("MUONefficiency", "opening ESD file %s failed", esdFileName);
-    return kFALSE;
-  }
-  
-  AliESDEvent* esd = new AliESDEvent();
-  TTree* tree = (TTree*) esdFile->Get("esdTree");
-  if (!tree) {
-    Error("CheckESD", "no ESD tree found");
-    return kFALSE;
-  } 
-  esd->ReadFromTree(tree);
 
   runLoader->LoadHeader();
-  Int_t runNumber = runLoader->GetHeader()->GetRun();
-  AliCDBManager::Instance()->SetRun(runNumber);
+  if (runNumber != runLoader->GetHeader()->GetRun()) {
+    Error("MUONefficiency", "mismatch between run number from ESD and from runLoader");
+    return kFALSE;
+  }
 
   nevents = runLoader->GetNumberOfEvents();
   AliMUONTrackParam trackParam;
@@ -326,8 +326,7 @@ Bool_t MUONefficiency( char* filename = "galice.root", char* geoFilename = "geom
 
     
     // get the event summary data
-    tree->GetEvent(iEvent);
-    if (!esd) {
+    if (tree->GetEvent(iEvent) <= 0) {
       Error("CheckESD", "no ESD object found for event %d", iEvent);
       return kFALSE;
     }
index 91c24ee698d16f360fda0d6f1b4c24e4384982a2..5b30efc9212965b12beb01ab0a18044aa840b8fd 100644 (file)
 
 // STEER includes
 #include "AliLog.h"
-#include "AliMagF.h"
+#include "AliCDBManager.h"
 #include "AliESDEvent.h"
 #include "AliESDVertex.h"
-#include "AliTracker.h"
 #include "AliESDMuonTrack.h"
 
 // MUON includes
+#include "AliMUONCDB.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONTrackExtrap.h"
 #include "AliMUONESDInterface.h"
@@ -29,7 +29,7 @@
 
 /// \ingroup macros
 /// \file MUONmassPlot_ESD.C
-/// \brief Macro MUONefficiency.C for ESD
+/// \brief Macro MUONmassPlot_ESD.C for ESD
 ///
 /// \author Ch. Finck, Subatech, April. 2004
 ///
 ///
 /// Add parameters and histograms for analysis 
 
-Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.root", 
-                 Int_t FirstEvent = 0, Int_t LastEvent = 10000, char* esdFileName = "AliESDs.root", Int_t ResType = 553, 
-                  Float_t Chi2Cut = 100., Float_t PtCutMin = 1., Float_t PtCutMax = 10000.,
-                  Float_t massMin = 9.17,Float_t massMax = 9.77)
+Bool_t MUONmassPlot(const char* esdFileName = "AliESDs.root", const char* geoFilename = "geometry.root",
+                   const char* ocdbPath = "local://$ALICE_ROOT/OCDB",
+                   Int_t FirstEvent = 0, Int_t LastEvent = 10000, Int_t ExtrapToVertex = -1,
+                   Int_t ResType = 553, Float_t Chi2Cut = 100., Float_t PtCutMin = 1.,
+                   Float_t PtCutMax = 10000., Float_t massMin = 9.17,Float_t massMax = 9.77)
 {
-/// \param ExtrapToVertex (default -1)
-///   -        <0: no extrapolation;
-///   -        =0: extrapolation to (0,0,0);
-///   -        >0: extrapolation to ESDVertex if available, else to (0,0,0)
-/// \param FirstEvent (default 0)
-/// \param LastEvent (default 0)
-/// \param ResType    553 for Upsilon, anything else for J/Psi (default 553)
-/// \param Chi2Cut    to keep only tracks with chi2 per d.o.f. < Chi2Cut (default 100)
-/// \param PtCutMin   to keep only tracks with transverse momentum > PtCutMin (default 1)
-/// \param PtCutMax   to keep only tracks with transverse momentum < PtCutMax (default 10000)
-/// \param massMin   (default 9.17 for Upsilon) 
-/// \param massMax   (default 9.77 for Upsilon);  
-///         to calculate the reconstruction efficiency for resonances with invariant mass
-///         massMin < mass < massMax.
+  /// \param FirstEvent (default 0)
+  /// \param LastEvent (default 10000)
+  /// \param ExtrapToVertex (default -1)
+  ///   -      <0: no extrapolation;
+  ///   -      =0: extrapolation to (0,0,0);
+  ///   -      >0: extrapolation to ESDVertex if available, else to (0,0,0)
+  /// \param ResType    553 for Upsilon, anything else for J/Psi (default 553)
+  /// \param Chi2Cut    to keep only tracks with chi2 per d.o.f. < Chi2Cut (default 100)
+  /// \param PtCutMin   to keep only tracks with transverse momentum > PtCutMin (default 1)
+  /// \param PtCutMax   to keep only tracks with transverse momentum < PtCutMax (default 10000)
+  /// \param massMin   (default 9.17 for Upsilon) 
+  /// \param massMax   (default 9.77 for Upsilon);  
+  ///         to calculate the reconstruction efficiency for resonances with invariant mass
+  ///         massMin < mass < massMax.
 
   cout << "MUONmassPlot " << endl;
   cout << "FirstEvent " << FirstEvent << endl;
@@ -118,7 +119,7 @@ Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.roo
   Double_t fPxRec1, fPyRec1, fPzRec1, fE1;
   Double_t fPxRec2, fPyRec2, fPzRec2, fE2;
 
-  Int_t ntrackhits, nevents;
+  Int_t ntrackhits;
   Double_t fitfmin;
   Double_t fZVertex=0;
   Double_t fYVertex=0;
@@ -127,7 +128,7 @@ Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.roo
   Double_t errYVtx=0;
  
   TLorentzVector fV1, fV2, fVtot;
-
+  
   // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
   if (!gGeoManager) {
     TGeoManager::Import(geoFilename);
@@ -137,47 +138,47 @@ Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.roo
     }
   }
   
-  // set mag field
-  // waiting for mag field in CDB 
-  if (!TGeoGlobalMagField::Instance()->GetField()) {
-    printf("Loading field map...\n");
-    AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG);
-    TGeoGlobalMagField::Instance()->SetField(field);
-  }
-  // set the magnetic field for track extrapolations
-  AliMUONTrackExtrap::SetField();
-
-
   // open the ESD file
   TFile* esdFile = TFile::Open(esdFileName);
   if (!esdFile || !esdFile->IsOpen()) {
     Error("MUONmass_ESD", "opening ESD file %s failed", esdFileName);
     return kFALSE;
   }
-  
   AliESDEvent* esd = new AliESDEvent();
   TTree* tree = (TTree*) esdFile->Get("esdTree");
   if (!tree) {
-    Error("CheckESD", "no ESD tree found");
+    Error("MUONmass_ESD", "no ESD tree found");
     return kFALSE;
   }
-//  tree->SetBranchAddress("ESD", &esd);
   esd->ReadFromTree(tree);
   
-  nevents = (Int_t)tree->GetEntries();
+  // get run number
+  if (tree->GetEvent(0) <= 0) {
+    Error("MUONmass_ESD", "no ESD object found for event 0");
+    return kFALSE;
+  }
+  Int_t runNumber = esd->GetRunNumber();
+  
+  // load necessary data from OCDB
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
+  AliCDBManager::Instance()->SetRun(runNumber);
+  if (!AliMUONCDB::LoadField()) return kFALSE;
+  
+  // set the magnetic field for track extrapolations
+  AliMUONTrackExtrap::SetField();
   
   AliMUONTrackParam trackParam;
 
   // Loop over events
+  Int_t nevents = (Int_t)tree->GetEntries();
   for (Int_t iEvent = FirstEvent; iEvent <= TMath::Min(LastEvent, nevents - 1); iEvent++) {
 
     // get the event summary data
-    tree->GetEvent(iEvent);
-    if (!esd) {
-      Error("CheckESD", "no ESD object found for event %d", iEvent);
+    if (tree->GetEvent(iEvent) <= 0) {
+      Error("MUONmass_ESD", "no ESD object found for event %d", iEvent);
       return kFALSE;
     }
-
+    
     // get the SPD reconstructed vertex (vertexer) and fill the histogram
     AliESDVertex* Vertex = (AliESDVertex*) esd->GetVertex();
     if (Vertex->GetNContributors()) {
@@ -236,7 +237,7 @@ Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.roo
 
       // condition for good track (Chi2Cut and PtCut)
 
-      if ((ch1 < Chi2Cut) && (pt1 > PtCutMin) && (pt1 < PtCutMax)) {
+//      if ((ch1 < Chi2Cut) && (pt1 > PtCutMin) && (pt1 < PtCutMax)) {
 
        // fill histos hPtMuon and hChi2PerDof
        hPtMuon->Fill(pt1);
@@ -283,7 +284,7 @@ Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.roo
          Float_t ch2 = fitfmin  / (2.0 * ntrackhits - 5);
 
          // condition for good track (Chi2Cut and PtCut)
-         if ((ch2 < Chi2Cut) && (pt2 > PtCutMin)  && (pt2 < PtCutMax)) {
+//       if ((ch2 < Chi2Cut) && (pt2 > PtCutMin)  && (pt2 < PtCutMax)) {
 
            // condition for opposite charges
            if ((fCharge1 * fCharge2) == -1) {
@@ -313,10 +314,10 @@ Bool_t MUONmassPlot(Int_t ExtrapToVertex = -1, char* geoFilename = "geometry.roo
              }
 
            } // if (fCharge1 * fCharge2) == -1)
-         } // if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax))
+//       } // if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax))
          delete muonTrack2;
        } //  for (Int_t iTrack2 = iTrack + 1; iTrack2 < iTrack; iTrack2++)
-      } // if (ch1 < Chi2Cut) && (pt1 > PtCutMin)&& (pt1 < PtCutMax) )
+//      } // if (ch1 < Chi2Cut) && (pt1 > PtCutMin)&& (pt1 < PtCutMax) )
       delete muonTrack;
     } // for (Int_t iTrack = 0; iTrack < nrectracks; iTrack++)
 
index 6ffbb798dfcc4e59301dd26980c33f02b439624e..70f8dd75e3dbc57e6c0345ff85f8fc3f23c60d61 100644 (file)
@@ -75,4 +75,7 @@
 
 #pragma link C++ class AliMUONQAMappingCheck+;
 
+// OCDB access
+#pragma link C++ class AliMUONCDB+;
+
 #endif
index 4190c9d6e2974f5128e1acc0437c8ce7006608f7..b8cfd70e04fd102f8b8434830bb01e9d3b9c3803 100644 (file)
@@ -99,8 +99,7 @@ void MakeMUONRecoParamArray(Int_t startRun = 0, Int_t endRun = AliCDBRunRange::I
   }
   
   // save RecoParam in CDB
-  AliMUONCDB cdb;
-  cdb.WriteToCDB(&recoParams, "MUON/Calib/RecoParam", startRun, endRun, "reconstruction parameters for MUON", "Philippe Pillot");
+  AliMUONCDB::WriteToCDB(&recoParams, "MUON/Calib/RecoParam", startRun, endRun, "reconstruction parameters for MUON", "Philippe Pillot");
   
 }
 
index cf3ea988a40f3858e030f2cce7b1f509989a85ff..474a15ef36229b104cc89fd3ac2c98b020fa77ca 100644 (file)
@@ -67,8 +67,7 @@ void MakeMUONSingleRecoParam(Int_t startRun = 0, Int_t endRun = AliCDBRunRange::
   param->Print("FULL");
   
   // save RecoParam in CDB
-  AliMUONCDB cdb;
-  cdb.WriteToCDB(param, "MUON/Calib/RecoParam", startRun, endRun, "reconstruction parameters for MUON", "Philippe Pillot");
+  AliMUONCDB::WriteToCDB(param, "MUON/Calib/RecoParam", startRun, endRun, "reconstruction parameters for MUON", "Philippe Pillot");
   
 }
 
index 8c2d46acc17b9351825d44c8e9c8970a07bbd5d6..980fa52b8c46eb5ddca0540bf0a14a5010a6141b 100644 (file)
@@ -92,7 +92,7 @@ When using alien, the path definition can be eg.
 AliMUONCDB class is used to populate the CDB with fake calibration objects for testing purposes.
 Real calibration data will normally be handled by the Shuttle (see READMEshuttle).
 
-The various WriteXXX() methods may be used to populate MUON tracker and trigger 
+The various WriteXXX() static methods may be used to populate MUON tracker and trigger 
 information.
 A full set of calibration data types can be created from scratch using, from
 the Root prompt (from within the $ALICE_ROOT/MUON directory to get the correct
@@ -100,11 +100,10 @@ list of libraries loaded by the loadlibs.C macro)
 
 <pre>
 root[0] AliMpCDB::LoadAll2(); 
-root[1] AliMUONCDB cdb;
-root[2] Int_t startRun = 0;
-root[3] Bool_t defaultValues = kTRUE;
-root[4] cdb.WriteTrigger(startRun);
-root[5] cdb.WriteTracker(defaultValues,startRun);
+root[1] Int_t startRun = 0;
+root[2] Bool_t defaultValues = kTRUE;
+root[3] AliMUONCDB::WriteTrigger(startRun);
+root[4] AliMUONCDB::WriteTracker(defaultValues,startRun);
 </pre>
 
 
@@ -119,11 +118,12 @@ AliMUONVStore* ped = AliMUONCalibrationData::CreatePedestals(67138);
 </pre>
 
 If you want to plot calibration data (not terribly usefull as it's a really global view),
- use the Plot() function of AliMUONCDB, e.g.  
+ use the Plot() function of AliMUONCDB (this require to load the segmentation), e.g.  
  
 <pre>
-AliMUONCDB cdb(cdbpath);
-cdb.Plot(*ped,"pedestal")
+AliCDBManager::Instance()->SetRun(0);
+AliMUONCDB::LoadMapping(kTRUE);
+AliMUONCDB::Plot(*ped,"pedestal");
 </pre>
 
 which will create 2 histograms : pedestal_0 (mean) and pedestal_1 (sigma).
index fcab523c4f6bf7160267ca05f32a008709a9a8ce..60686a505d7b7e888ac5c9f117fe9851562aa211 100644 (file)
@@ -192,6 +192,9 @@ Every option/parameter can be set one by one. Here is the complete list of avail
 - <code>SetDefaultBendingReso(Int_t iCh, Double_t val)</code>: Set the default bending resolution of chamber iCh
 - <code>SetMaxTriggerTracks(Int_t val)</code>: Set the maximum number of trigger tracks above which the tracking is cancelled
 - <code>SetMaxTrackCandidates(Int_t val)</code>: Set the maximum number of track candidates above which the tracking abort
+- <code>SetManuOccupancyLimits(float low, float high)</code>: Set the limits for the acceptable manu occupancy
+- <code>SetBuspatchOccupancyLimits(float low, float high)</code>: Set the limits for the acceptable bp occupancy
+- <code>SetDEOccupancyLimits(float low, float high)</code>: Set the limits for the acceptable DE occupancy
 
 We can use the method Print("FULL") to printout all the parameters and options set in the class AliMUONRecoParam.
 
@@ -244,7 +247,21 @@ The AliESDMuonPad objects contain:
 \section rec_s6 Conversion between MUON/ESD objects
 
 Every conversion between MUON objects (AliMUONVDigit/AliMUONVCluster/AliMUONTrack) and ESD objects
-(AliESDMuonPad/AliESDMuonCluster/AliESDMuonTrack) is done by the class AliMUONESDInterface. There are 2 ways of using this class:
+(AliESDMuonPad/AliESDMuonCluster/AliESDMuonTrack) is done by the class AliMUONESDInterface.
+
+WARNING: some of these conversions require input from outside, namely the magnetic field map, the geometry, the reconstruction parameters
+and/or the mapping segmentation. In particular:
+- The conversion of ESDPads to MUON digits requires the mapping segmentation.
+- The conversion of a MUON track to an ESD track requires the magnetic field and the geometry to extrapolate the track parameters at vertex
+and compute the correction of multiple scattering and energy loss in the front absorber.
+- While converting an ESD track to a MUON track, the track is refitted by using the cluster position stored in ESD in order to recover the
+track parameters at each cluster. This refitting needs both the magnetic field and the reconstruction parameters initially used to
+reconstruct the tracks to be correct. The reconstruction parameters can be passed to the interface by using the static method
+AliMUONESDTrack::ResetTracker(const AliMUONRecoParam* recoParam, Bool_t info). The refitting can however be disconnected by user (using flag
+in the fonction parameters). In that case, none of these external inputs is necessary anymore but only the track parameters at first cluster,
+which is then copied directly from the ESD, is meaningful.
+
+There are 2 ways of using this class:
 
 1) Using the static methods to convert the objects one by one (and possibly put them into the provided store):
 - Get track parameters at vertex, at DCA, ...:
@@ -272,20 +289,21 @@ Every conversion between MUON objects (AliMUONVDigit/AliMUONVCluster/AliMUONTrac
   AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, trackId, triggerTrack);
 \endverbatim
 
-- Convert an AliESDMuonTrack to an AliMUONTrack:
+- Convert an AliESDMuonTrack to an AliMUONTrack (the parameters at each clusters are recomputed or not according to the flag "refit".
+if not, only the parameters at first cluster are relevant):
 \verbatim
   ...
   AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
   AliMUONTrack track;
-  AliMUONESDInterface::ESDToMUON(*esdTrack, track);
+  AliMUONESDInterface::ESDToMUON(*esdTrack, track, refit);
 \endverbatim
   
-- Add an AliESDMuonTrack (converted into AliMUONTrack object) into an AliMUONVTrackStore:
+- Add an AliESDMuonTrack (converted into AliMUONTrack object) into an AliMUONVTrackStore (same remark as above about the flag "refit"):
 \verbatim
   ...
   AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
   AliMUONVTrackStore *trackStore = AliMUONESDInteface::NewTrackStore();
-  AliMUONTrack* trackInStore = AliMUONESDInterface::Add(*esdTrack, *trackStore);
+  AliMUONTrack* trackInStore = AliMUONESDInterface::Add(*esdTrack, *trackStore, refit);
 \endverbatim
 
 2) Loading an entire ESDEvent and using the finders and/or the iterators to access the corresponding MUON objects:
@@ -333,10 +351,11 @@ Note: You can change (via static method) the type of the store this class is usi
 \section rec_s7 ESD cluster/track refitting
 
 We can re-clusterize and re-track the clusters/tracks stored into the ESD by using the class AliMUONRefitter. This class gets the MUON objects
-to be refitted from an instance of AliMUONESDInterface (see section @ref rec_s6), then uses the reconstruction framework to refit the
-objects. The reconstruction parameters are still set via the class AliMUONRecoParam (see section @ref rec_s5). The initial data are not changed.
-Results are stored into new MUON objects. The aim of the refitting is to be able to study effects of changing the reconstruction parameter, the
-calibration parameters or the alignment without re-running the entire reconstruction.
+to be refitted from an instance of AliMUONESDInterface (see section @ref rec_s6), then uses the reconstruction framework to refit them. The new
+reconstruction parameters are still set via the class AliMUONRecoParam (see section @ref rec_s4) and passed to refitter through its constructor.
+The old reconstruction parameters, the mapping, the magnetic field and/or the geometry may also be needed to convert the ESD objects to MUON ones
+and/or to refit them. The initial data are not changed. Results are stored into new MUON objects. The aim of the refitting is to be able to
+study effects of changing the reconstruction parameter, the calibration parameters or the alignment without re-running the entire reconstruction.
 
 To use this class we first have to connect it to the ESD interface containing MUON objects:
 \verbatim
index 1a327da952e00c45d59e5e8243513be7baaa753b..8bd1b899daea9ad8fdda170badb80f4491df6449 100644 (file)
@@ -65,7 +65,7 @@ Two options here. You can either use a pre-done set of ASCII pedestals files (ge
  
 We've written an AliMUONPedestalEventGenerator which creates fake pedestal events. The pedestal values
 are taken from the Offline Condition DataBase (OCDB) (which is itself fakely filled
-using the WritePedestals() method of AliMUONCDB class
+using the static WritePedestals() method of AliMUONCDB class
 
 So first generate a valid pedestal CDB entry by using the AliMUONCDB class. There's one
  little trick : you should first point to the "default" OCDB (local://$ALICE_ROOT/OCDB) in
@@ -89,11 +89,11 @@ root[] AliCDBManager::Instance()->SetRun(0); // only if you've not put the mappi
 root[] AliMpCDB::LoadDDLStore(); // only if you've not put the mapping in test OCDB
 // below are lines to be executed whatever you did with the mapping...
 root[] const char* cdbpath="local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"; // where to put the CDB
-root[] AliMUONCDB cdb(cdbpath)
+root[] AliCDBManager::Instance()->SetDefaultStorage(cdbpath);
 root[] Bool_t defaultValues = kFALSE; // to generate random values instead of plain zeros...
 root[] Int_t startRun = 80;
 root[] Int_t endRun = 80;
-root[] cdb.WritePedestals(defaultValues, startRun, endRun);
+root[] AliMUONCDB::WritePedestals(defaultValues, startRun, endRun);
 </pre>
 
 Expected output is (don't worry about the warnings, they are harmless) :
@@ -165,12 +165,12 @@ entry by using the AliMUONCDB class, from the Root prompt:
 
 <pre>
 const char* cdbpath="local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"; // where to put the CDB
-AliMUONCDB cdb(cdbpath)
+root[] AliCDBManager::Instance()->SetDefaultStorage(cdbpath);
 Bool_t defaultValues = kFALSE; // to generate random values instead of plain zeros...
 Int_t gainRun = 80;
 Int_t pedRun = 81;
-cdb.WritePedestals(defaultValues, pedRun, pedRun);
-cdb.WriteGains(defaultValues, gainRun, gainRun);
+AliMUONCDB::WritePedestals(defaultValues, pedRun, pedRun);
+AliMUONCDB::WriteGains(defaultValues, gainRun, gainRun);
 </pre>
 
 Expected output is (don't worry about the warnings, they are harmless) :
index 365df6650654bc2409fa48c1fe4062def651f1fb..c9dedc8358d0fc12b1222584b073b0a358b74188 100644 (file)
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 #include "AliCDBManager.h"
-#include "AliCDBEntry.h"
-#include "AliCDBPath.h"
 
 // tracker
 #include "AliGeomManager.h"
 
 // MUON
-#include "AliMpCDB.h"
-#include "AliMpDDL.h"
-#include "AliMpDDLStore.h"
 #include "AliMpConstants.h"
 
 // trigger
@@ -66,6 +61,7 @@
 #include "AliMUONDigitStoreV2R.h"
 #include "AliMUONVCluster.h"
 #include "AliMUONRecoParam.h"
+#include "AliMUONCDB.h"
 
 #endif
 
@@ -174,11 +170,10 @@ void TestRecPoints(TString baseDir=".", TString outDir=".", Float_t adcCut = 10.
   AliMUONDigitStoreV2R digitStoreTrackCut;
   AliMUONVCluster* cluster = 0x0;
   
-  // Load segmentation
+  // Load mapping
   AliCDBManager::Instance()->SetDefaultStorage(cdbStorage.Data());
   AliCDBManager::Instance()->SetRun(runNumber);
-  
-  AliMpCDB::LoadDDLStore();
+  if (!AliMUONCDB::LoadMapping()) return;
   
   AliMUONGeometryTransformer* transformer = 0x0;
   
@@ -207,17 +202,8 @@ void TestRecPoints(TString baseDir=".", TString outDir=".", Float_t adcCut = 10.
     // Load geometry data
     transformer->LoadGeometryData();
     // Load reconstruction parameters
-    AliCDBPath path("MUON","Calib","RecoParam");
-    AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
-    if(entry) {
-      recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject());
-      entry->SetOwner(0);
-      AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
-    }
-    if (!recoParam) {
-      printf("Couldn't find RecoParam object in OCDB: create default one");
-      recoParam = AliMUONRecoParam::GetLowFluxParam();
-    }
+    recoParam = AliMUONCDB::LoadRecoParam();
+    if (!recoParam) return;
     recoParam->Print("FULL");
     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
     clusterServer = new AliMUONSimpleClusterServer(clusterFinder,*transformer);
index 3929357bd652e1e127e2c0fbc658e6c7d60b76c1..3d2d586de2c8e2b814bd33e97df0d67becc3152b 100644 (file)
@@ -10,7 +10,6 @@ SRCS:=  AliMUONConstants.cxx \
         AliMUONRawClusterV2.cxx \
         AliMUONDigitMaker.cxx \
         AliMUONRawWriter.cxx \
-        AliMUONCDB.cxx \
         AliMUONVDigitStore.cxx \
         AliMUONDigitStoreV1.cxx \
         AliMUONDigitStoreV1Iterator.cxx \
index 8b3e065dbb9585996f7cd42c650fbe11f2845dbe..d6ec11d768f2373fdbfea07b8c626c14ce2c79dd 100644 (file)
@@ -52,7 +52,8 @@ SRCS:= AliMUONReconstructor.cxx \
        AliMUONTriggerTrackToTrackerClusters.cxx \
        AliMUONVTrackerDataMaker.cxx \
        AliMUONTrackerDataMaker.cxx \
-       AliMUONQAMappingCheck.cxx
+       AliMUONQAMappingCheck.cxx \
+       AliMUONCDB.cxx
        
 HDRS:= $(SRCS:.cxx=.h)
 
index 223717aceebb603dae6ce76c2408785892470781..077198f2f38e901027f5266f08e5bae40622f04c 100644 (file)
@@ -510,5 +510,6 @@ void AliMpCDB::UnloadAll()
   delete AliMpDDLStore::Instance(false);
   delete AliMpSegmentation::Instance(false);
   delete AliMpDEStore::Instance(false);
+  delete AliMpManuStore::Instance(false);
 }