]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Reworked emcal setup to load the geometry properly.
authorConstantin Loizides <cloizides@lbl.gov>
Wed, 8 Jan 2014 08:55:25 +0000 (09:55 +0100)
committerConstantin Loizides <cloizides@lbl.gov>
Wed, 8 Jan 2014 08:55:25 +0000 (09:55 +0100)
PWG/CMakelibPWGEMCAL.pkg
PWG/EMCAL/AliEmcalSetupTask.cxx
PWG/EMCAL/AliEmcalSetupTask.h
PWG/EMCAL/data/2010.dat [new file with mode: 0644]
PWG/EMCAL/data/2011.dat [new file with mode: 0644]
PWG/EMCAL/data/2012.dat [new file with mode: 0644]
PWG/EMCAL/data/2013.dat [new file with mode: 0644]
PWG/EMCAL/macros/AddTaskEmcalSetup.C

index b98069c4d4d23d00905c5b4177653e06d251c3b9..c5cf42d7ba71e45da24bfd06ab9a1931289142a1 100644 (file)
@@ -62,3 +62,7 @@ string ( REPLACE ".cxx" ".h" EXPORT "${SRCS}" )
 set ( DHDR  PWGEMCALLinkDef.h)
 
 set ( EINCLUDE PWG/Tools PWG/EMCAL EMCAL OADB STEER/ESD STEER/STEERBase ANALYSIS)
+
+install (DIRECTORY EMCAL/data
+        DESTINATION PWG/EMCAL
+        PATTERN ".svn" EXCLUDE)
index 5feb5eb1211fbc6e168175501762c683411cc55d..319132a06b697de8a74f6705d879a09ed0a01a58 100644 (file)
@@ -8,6 +8,7 @@
 #include <TClonesArray.h>
 #include <TGeoGlobalMagField.h>
 #include <TGeoManager.h>
+#include <TRandom.h>
 #include "AliAODEvent.h"
 #include "AliAnalysisManager.h"
 #include "AliCDBManager.h"
@@ -23,11 +24,12 @@ ClassImp(AliEmcalSetupTask)
 //________________________________________________________________________
 AliEmcalSetupTask::AliEmcalSetupTask() : 
   AliAnalysisTaskSE(),
-  fOcdbPath(),
+  fOcdbPath("uselocal"),
   fOadbPath("$ALICE_ROOT/OADB/EMCAL"),
   fGeoPath("$ALICE_ROOT/OADB/EMCAL"),
   fObjs("GRP ITS TPC TRD EMCAL"),
-  fIsInit(kFALSE)
+  fIsInit(kFALSE),
+  fLocalOcdb()
 {
   // Constructor.
 }
@@ -35,11 +37,12 @@ AliEmcalSetupTask::AliEmcalSetupTask() :
 //________________________________________________________________________
 AliEmcalSetupTask::AliEmcalSetupTask(const char *name) : 
   AliAnalysisTaskSE(name),
-  fOcdbPath(),
+  fOcdbPath("uselocal"),
   fOadbPath("$ALICE_ROOT/OADB/EMCAL"),
   fGeoPath("$ALICE_ROOT/OADB/EMCAL"),
   fObjs("GRP ITS TPC TRD EMCAL"),
-  fIsInit(kFALSE)
+  fIsInit(kFALSE),
+  fLocalOcdb()
 {
   // Constructor.
   fBranchNames = "ESD:AliESDHeader.,AliESDRun.";
@@ -64,9 +67,11 @@ void AliEmcalSetupTask::UserExec(Option_t *)
     AliError("Manager zero, returning");
     return;
   }
+
   am->LoadBranch("AliESDRun.");
   am->LoadBranch("AliESDHeader.");
 
+  // Setup AliEMCALGeometry corresponding to year
   Int_t runno = InputEvent()->GetRunNumber();
   TString geoname("EMCAL_COMPLETE12SMV1");
   Int_t year = 2013;
@@ -79,29 +84,65 @@ void AliEmcalSetupTask::UserExec(Option_t *)
   } else if ((runno>170593) && (runno<=193766)) {
     year = 2012;
   }
-
   AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(geoname);
   if (!geom) {
     AliFatal(Form("Can not create geometry: %s",geoname.Data()));
     return;
   }
 
+  // Setup CDB manager
   AliCDBManager *man = 0;
   man = AliCDBManager::Instance();
-  if (!man->IsDefaultStorageSet()) {
-    if (fOcdbPath.Length()>0) {
-      AliInfo(Form("Setting up OCDB"));
+  if (man->IsDefaultStorageSet()) {
+    AliInfo(Form("Default OCDB storage already set"));
+  } else {
+    if (fOcdbPath.Length()==0) {
+      man = 0; // do not use OCDB
+    } else if (fOcdbPath != "uselocal") {
+      AliInfo(Form("Setting up OCDB to point to %s",fOcdbPath.Data()));
       man->SetDefaultStorage(fOcdbPath);
-      man->SetRun(runno);
-    } else {
-      man = 0;
+    } else { // use local copy of OCDB
+      TString tmpdir=gSystem->WorkingDirectory();
+      tmpdir+="/";
+      tmpdir+=gSystem->GetUid();
+      tmpdir+="-";
+      TDatime t;
+      tmpdir+=t.Get();
+      tmpdir+="-";
+      fLocalOcdb = tmpdir;
+      fLocalOcdb+=gRandom->Integer(999999999);
+      gSystem->MakeDirectory(fLocalOcdb);
+      Int_t counter = 0;
+      while (gSystem->AccessPathName(fLocalOcdb)) {
+       fLocalOcdb = tmpdir;
+       fLocalOcdb+=gRandom->Integer(999999999);
+       gSystem->MakeDirectory(fLocalOcdb);
+       gSystem->Exec("ls");
+       counter++;
+       if (counter>100) {
+         AliFatal(Form("Could not create local directory for OCDB at %s",tmpdir.Data()));
+       }
+      }
+      TString filename(Form("$ALICE_ROOT/PWG/EMCAL/data/%d.dat",year));
+      TString cmd(Form("cd %s && tar -xf %s",fLocalOcdb.Data(),filename.Data()));
+      Int_t ret = gSystem->Exec(cmd);
+      if (ret==0) {
+       TString locdb("local://");
+       locdb+=fLocalOcdb;
+       locdb+="/";
+       locdb+=year;
+       AliInfo(Form("Setting up local OCDB at %s",locdb.Data()));
+       man->SetDefaultStorage(locdb);
+      } else {
+       AliFatal(Form("Could not set up local OCDB at %s",fLocalOcdb.Data()));
+      }
     }
-  } else {
-    if (man->GetRun()!=runno)
-      man->SetRun(runno);
   }
   
+  // Load geometry from OCDB 
   if (man) {
+    if (man->GetRun()!=runno)
+      man->SetRun(runno);
     AliInfo(Form("Loading grp data from OCDB"));
     AliGRPManager GRPManager;
     GRPManager.ReadGRPEntry();
@@ -112,24 +153,29 @@ void AliEmcalSetupTask::UserExec(Option_t *)
       AliGeomManager::ApplyAlignObjsFromCDB(fObjs);
   }
 
+  // Load geometry from file (does not use misalignment of ITS/TPC!)
   TGeoManager *geo = AliGeomManager::GetGeometry();
-  if (!geo) {
+  if (!geo && fGeoPath.Length()>0) {
     TString fname(gSystem->ExpandPathName(Form("%s/geometry_%d.root", fGeoPath.Data(), year)));
     if (gSystem->AccessPathName(fname)==0) {
-      AliInfo(Form("Loading geometry from %s", fname.Data()));
+      AliInfo(Form("Loading geometry from file %s (should be avoided!)", fname.Data()));
       AliGeomManager::LoadGeometry(fname);
       geo = AliGeomManager::GetGeometry();
     }
   }
+
+  // Lock geometry
   if (geo) {
     AliInfo(Form("Locking geometry"));
     geo->LockGeometry();
   }
 
-  if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
+  // Construct field map
+  if (!TGeoGlobalMagField::Instance()->GetField()) { 
     InputEvent()->InitMagneticField();
   }
 
+  // Apply mis-alignment matrices from OADB
   if (fOadbPath.Length()>0) {
     AliOADBContainer emcalgeoCont(Form("emcal"));
     emcalgeoCont.InitFromFile(Form("%s/EMCALlocal2master.root",fOadbPath.Data()),
@@ -145,3 +191,14 @@ void AliEmcalSetupTask::UserExec(Option_t *)
 
   fIsInit = kTRUE;
 }
+
+//________________________________________________________________________
+void AliEmcalSetupTask::Terminate(Option_t *) 
+{
+  // Called at the end.
+
+  if (fLocalOcdb.Length()>0) {
+    TString cmd(Form("rm -rf %s", fLocalOcdb.Data()));
+    gSystem->Exec(cmd);
+  }
+}
index 07c435479f53db199392125b4d42e5e8dbe75254..f220b25edbbbe365b438bbd6c54be20d554c3d5c 100644 (file)
@@ -21,19 +21,21 @@ class AliEmcalSetupTask : public AliAnalysisTaskSE {
   void SetOcdbPath(const char *n) { fOcdbPath = n; }
   void SetObjs(const char *n)     { fObjs     = n; }
   void UserExec(Option_t *option);
+  void Terminate(Option_t *option);
 
  protected:
-  TString            fOcdbPath;        // path to ocdb (def=none)
+  TString            fOcdbPath;        // path to ocdb (def=uselocal)
   TString            fOadbPath;        // path to oadb
   TString            fGeoPath;         // path to geometry
   TString            fObjs;            // string of objects for alignment to apply
   Bool_t             fIsInit;          //!=true then already initialized 
+  TString            fLocalOcdb;       //!path to local ocdb
 
  private:
   AliEmcalSetupTask(const AliEmcalSetupTask&);            // not implemented
   AliEmcalSetupTask &operator=(const AliEmcalSetupTask&); // not implemented
 
-  ClassDef(AliEmcalSetupTask, 3); // Class to setup geometry for EMCal
+  ClassDef(AliEmcalSetupTask, 4); // Class to setup geometry for EMCal
 };
 
 #endif
diff --git a/PWG/EMCAL/data/2010.dat b/PWG/EMCAL/data/2010.dat
new file mode 100644 (file)
index 0000000..7541b72
Binary files /dev/null and b/PWG/EMCAL/data/2010.dat differ
diff --git a/PWG/EMCAL/data/2011.dat b/PWG/EMCAL/data/2011.dat
new file mode 100644 (file)
index 0000000..b06cecc
Binary files /dev/null and b/PWG/EMCAL/data/2011.dat differ
diff --git a/PWG/EMCAL/data/2012.dat b/PWG/EMCAL/data/2012.dat
new file mode 100644 (file)
index 0000000..0880026
Binary files /dev/null and b/PWG/EMCAL/data/2012.dat differ
diff --git a/PWG/EMCAL/data/2013.dat b/PWG/EMCAL/data/2013.dat
new file mode 100644 (file)
index 0000000..ab8b7b9
Binary files /dev/null and b/PWG/EMCAL/data/2013.dat differ
index 0b2ffad84dc6eb9eefe3ac95654222ac9baf1c02..e5e8ed7ea18e27c3c8d522d76282e73d7cd49b75 100644 (file)
@@ -41,6 +41,6 @@ AliEmcalSetupTask* AddTaskEmcalSetup(
   
   // Create containers for input/output
   AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
-  mgr->ConnectInput  (eTask, 0,  cinput1 );
+  mgr->ConnectInput(eTask, 0,  cinput1 );
   return eTask;
 }