Update master to aliroot
[u/mrichter/AliRoot.git] / PHOS / macros / CalibrationDB / makeDecalibCDB.C
CommitLineData
d5b302a6 1void makeDecalibCDB(Int_t firstRun, Int_t lastRun, Float_t decalib = 0.065)
2{
3 //Generates a random decalibration factors O(1)
4 //to be applied in the anchor run simulations with raw:// .
5 //If decalib<0, no decalibration generated, all factors=1.
6
7 //Run range is [firstRun,lastRun] and gaussian sigma = decalib.
8 //Author: Boris Polishchuk.
9
10 AliCDBManager::Instance()->SetDefaultStorage("raw://");
11 AliCDBManager::Instance()->SetRun(firstRun);
12
13 TString emcPath("PHOS/Calib/EmcGainPedestals");
14 AliCDBEntry* entryEmc = AliCDBManager::Instance()->Get(emcPath.Data(),-1);
15
16 AliPHOSEmcCalibData* clb=0;
17
18 if(entryEmc) clb = (AliPHOSEmcCalibData*)entryEmc->GetObject();
19 else { printf("CDB entry not found. Exit.\n"); return; }
20
21 if(!clb) { printf("Calibration parameters for PHOS EMC not found.\n"); return; }
22
23 printf("\t\tEMC calibration object found: FirstRun=%d LastRun=%d Version=%d SubVersion=%d\n",
24 entryEmc->GetId().GetFirstRun(), entryEmc->GetId().GetLastRun(),
25 entryEmc->GetId().GetVersion(),entryEmc->GetId().GetSubVersion());
26
27
28 TRandom rn;
29 rn.SetSeed(0); //the seed is set to the current machine clock
30
31 Float_t adcChannelEmc;
32
33 for(Int_t module=1; module<6; module++) {
34 for(Int_t column=1; column<57; column++) {
35 for(Int_t row=1; row<65; row++) {
36
37 if(decalib<0.) adcChannelEmc = 1.;
38 else
39 adcChannelEmc =rn.Gaus(1.,decalib);
40
41 clb->SetADCchannelEmcDecalib(module,column,row,adcChannelEmc);
42 }
43 }
44 }
45
46 AliCDBManager::Instance()->SetDefaultStorage("local://./");
47 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
48
49 AliCDBMetaData *md = new AliCDBMetaData();
50 AliCDBId id(emcPath.Data(),firstRun,lastRun);
51 storage->Put(clb,id, md);
52
53}