1 #if !defined( __CINT__) || defined(__MAKECINT__)
14 #include "AliCDBManager.h"
16 #include "AliCDBStorage.h"
17 #include "AliCDBMetaData.h"
18 #include "AliTRDCalibra.h"
19 #include "AliTRDCalDet.h"
22 const Int_t firstrun = 0;
23 const Int_t lastrun = 0;
24 AliCDBStorage* gStorLoc = 0;
25 AliCDBMetaData* CreateMetaObject(const char* objectClassName);
26 void StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData);
27 Bool_t WriteIntoDataBase(TTree *tree, Int_t i);
30 AliCDBMetaData* CreateMetaObject(const char* objectClassName)
32 AliCDBMetaData *md1= new AliCDBMetaData();
33 md1->SetObjectClassName(objectClassName);
34 md1->SetResponsible("Raphaelle Bailhache");
35 md1->SetBeamPeriod(1);
36 md1->SetAliRootVersion("05-06-00"); //root version
37 md1->SetComment("The dummy values in this calibration file are for testing only");
42 void StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
44 AliCDBId id1(cdbPath, firstrun, lastrun);
46 gStorLoc->Put(object, id1, metaData);
50 Bool_t AliTRDWriteIntoDataBase(TTree *tree, Int_t i){
52 // To use this macro, you have first to write the coefficients in a file
53 // To take the resulted tree from the file and to give it to this macro
54 // The macro will write the coefficient into a local database
55 // in the directory where you run it
59 AliTRDCalDet* obj1 = 0;
61 AliCDBMetaData *metadata = 0;
65 //Single instance of AliCDBManager and AliTRDCalibra
66 AliCDBManager *man = AliCDBManager::Instance();
68 printf("Could not get CDB Manager");
71 gStorLoc = man->GetDefaultStorage();
73 printf("Could not get default Storage");
76 AliTRDCalibra *calibra = AliTRDCalibra::Instance();
80 // Create the new database object Det
82 obj1 = calibra->CreateDetObjectTree(tree, i);
83 obj2 = calibra->CreatePadObjectTree(tree, i, obj1);
85 if(i == 2) obj2 = calibra->CreatePadObjectTree(tree);
88 //Store the info for the detector
90 metadata = CreateMetaObject("AliTRDCalDet");
91 if(i == 0) StoreObject("TRD/Calib/ChamberGainFactor",(TObject *) obj1, metadata);
92 if(i == 1) StoreObject("TRD/Calib/ChamberVdrift",(TObject *) obj1, metadata);
93 if(i == 3) StoreObject("TRD/Calib/ChamberT0",(TObject *) obj1, metadata);
98 //Store the info for the pad
99 metadata = CreateMetaObject("AliTRDCalPad");
100 if(i == 0) StoreObject("TRD/Calib/LocalGainFactor",(TObject *) obj2, metadata);
101 if(i == 1) StoreObject("TRD/Calib/LocalVdrift",(TObject *) obj2, metadata);
102 if(i == 3) StoreObject("TRD/Calib/LocalT0",(TObject *) obj2, metadata);
103 if(i == 2) StoreObject("TRD/Calib/PRFWidth",(TObject *) obj2, metadata);