1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include "AliCDBManager.h"
3 #include "AliCDBStorage.h"
4 #include "AliCDBEntry.h"
5 #include "AliAlignObjParams.h"
7 #include <TClonesArray.h>
13 void MergeSetsOfAlignObjs(const char* filename1, const char* filename2, const char* det="ITS")
15 // example macro: building an array by merging the non-SSD entries
16 // from one file (or OCDB entry) with the remaining SSD entries taken
17 // from another file (or OCDB entry); the first two arguments can be local filenames
18 // or URLs of the OCDB folders
20 const char* macroname = "MergeSetsOfAlignObjs";
22 TClonesArray* array1 = 0;
23 TClonesArray* array2 = 0;
30 TString f1(filename1);
31 TString f2(filename2);
33 AliCDBStorage* stor1 = 0;
34 AliCDBStorage* stor2 = 0;
36 Bool_t fromOcdb1=kFALSE;
37 Bool_t fromOcdb2=kFALSE;
39 if(f1.Contains("alien://folder=") || f1.Contains("local://")) fromOcdb1=kTRUE;
40 if(f2.Contains("alien://folder=") || f2.Contains("local://")) fromOcdb2=kTRUE;
43 AliCDBManager* cdb = AliCDBManager::Instance();
44 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
48 stor1 = cdb->GetStorage(f1.Data());
49 AliCDBEntry* entry = stor1->Get(path.Data(),0);
50 array1 = (TClonesArray*) entry->GetObject();
52 TFile* filein1 = TFile::Open(f1.Data(),"READ");
55 Info(macroname,Form("Unable to open file %s! Exiting ...", f1.Data()));
58 array1 = (TClonesArray*) filein1->Get(arName.Data());
61 Info(macroname,Form("First array has %d entries", array1->GetEntriesFast()));
63 Info(macroname,"Unable to get first array! Exiting ...");
68 stor2 = cdb->GetStorage(f2.Data());
69 AliCDBEntry* entry = stor2->Get(path.Data(),0);
70 array2 = (TClonesArray*) entry->GetObject();
72 TFile* filein2 = TFile::Open(f2.Data(),"READ");
75 Info(macroname,Form("Unable to open file %s! Exiting ...", f2.Data()));
78 array2 = (TClonesArray*) filein2->Get(arName.Data());
81 Info(macroname,Form("Second array has %d entries", array2->GetEntriesFast()));
83 Info(macroname,"Unable to get second array! Exiting ...");
88 TClonesArray *mergedArr = new TClonesArray("AliAlignObjParams",3000);
90 Info(macroname,"Merging objects for SPD and SDD from the first array ...");
91 // SSD starts from 500
92 for(Int_t i=0; i<500; i++)
94 (*mergedArr)[i] = (AliAlignObjParams*) array1->UncheckedAt(i);
97 Info(macroname,"Merging objects for SSD from the second array ...");
98 for(Int_t i=500; i<array2->GetEntriesFast(); i++)
100 (*mergedArr)[i] = (AliAlignObjParams*) array2->UncheckedAt(i);
103 TString foutName("merged");
105 foutName+="Alignment.root";
106 Info(macroname,Form("... in a single array into the file %s", foutName.Data()));
107 TFile* fileout = TFile::Open(foutName.Data(),"RECREATE");
109 fileout->WriteObject(mergedArr,arName.Data(),"kSingleKey");