Add macro to create OCDB entry for ion tail
authormivanov <mivanov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 1 Nov 2012 13:26:57 +0000 (13:26 +0000)
committermivanov <mivanov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 1 Nov 2012 13:26:57 +0000 (13:26 +0000)
TPC/CalibMacros/CreateIonTailObject.C [new file with mode: 0755]

diff --git a/TPC/CalibMacros/CreateIonTailObject.C b/TPC/CalibMacros/CreateIonTailObject.C
new file mode 100755 (executable)
index 0000000..abb9477
--- /dev/null
@@ -0,0 +1,49 @@
+/* CreateIonTailObject
+ * Generic script in order to create a IonTail object
+ *
+ * Usage : aliroot -b -q CreateIonTailObject.C
+ *
+ *
+ *   Read object :
+ *
+ *   TFile* f = TFile::Open("/tmp/ocdb/TPC/Calib/IonTail/Run0_999999999_v0_s0.root")
+ *   AliCDBEntry* entry = static_cast<AliCDBEntry*>(f.Get("AliCDBEntry"))
+ *   TObjArray * arr = entry->GetObject();
+ *   arr->ls()
+ *
+ */
+void CreateIonTailObject( const Char_t* objectPath = "/u/marsland/MAF/OCDBimp/AllResponseFunctions.root",
+                         const Int_t minRun = 0, 
+                         const Int_t maxRun = AliCDBRunRange::Infinity(),
+                         const Char_t* newStoragePath = "local:///tmp/ocdb", 
+                         const Char_t* author = "Mesut Arslandok", 
+                         const Char_t *comment = "Create new IonTail object",
+                         const Char_t* alirootVersion = "05-02-Rev-35") {
+  
+  // -- Get Input 
+  // -------------------------------------------------------------------
+  TFile* inFile = TFile::Open(objectPath);
+  if (!inFile) {
+    printf("File %s could not be found!\n", objectPath);
+    return -1;
+  }
+
+  TObjArray* arr = static_cast<TObjArray*>(inFile->Get("arrResponse"));
+
+
+  // -- Write out
+  // -------------------------------------------------------------------
+  
+  AliCDBMetaData *metaData= new AliCDBMetaData();
+  metaData->SetObjectClassName("TObjArray");
+  metaData->SetResponsible(author);
+  metaData->SetBeamPeriod(1);
+  metaData->SetAliRootVersion(alirootVersion); 
+  metaData->SetComment(comment);
+
+  AliCDBId id("TPC/Calib/IonTail", minRun, maxRun);
+  AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(newStoragePath);
+  gStorage->Put(arr, id, metaData);    
+
+  return;
+}