ROOT logo
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TRandom3.h>
#include "AliCDBManager.h"
#include "AliCDBMetaData.h"
#include "AliCDBStorage.h"
#include "AliCDBRunRange.h"
#include "AliCDBId.h"
#include "AliITSPlaneEffSPD.h"
#endif

void MakeITSPlaneEfficiencySPD(Int_t firstRun=0, Int_t lastRun=AliCDBRunRange::Infinity(), 
 Double_t eff=0.99, Int_t nTried=1000){
  
  if(eff<0 || eff > 1) {
   printf("Efficiency must be in the range [0,1]: nothing done");
  }
  if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  }
  
  AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object
  md1->SetObjectClassName("AliITSPlaneEff");
  md1->SetResponsible("Giuseppe Bruno");
  md1->SetBeamPeriod(0);
  md1->SetAliRootVersion("head 16/02/08"); //root version

  AliCDBId idplaneeffSPD("ITS/PlaneEff/PlaneEffSPD",firstRun, lastRun);
  
  AliITSPlaneEffSPD* planeeffSPD = new AliITSPlaneEffSPD();
  TRandom3 *gran = new TRandom3();

//  planeeffSPD->SetOwner(kFALSE);
  
//  Int_t nTried=1000;
  Double_t limit=nTried;
  limit*=(1-eff);
  printf("limit = %f",limit);
  // loop over SPD chip
  Bool_t BFound=kFALSE;
  for(UInt_t key=0;key<planeeffSPD->Nblock();key++){
  //for(UInt_t mod=0;mod<240;mod++){
  //for(UInt_t chip=0;chip<5;chip++){
  // suppose to have 1000 tracks in each chip and an average efficiency of 99%
    for(Int_t j=0; j<nTried; j++) {
      BFound=kFALSE;
      //if (gRandom->Uniform(0,1000)>10) BFound=kTRUE;
      if (nTried*gran->Uniform()>limit) BFound=kTRUE;
      //planeeffSPD->UpDatePlaneEff(BFound,mod,chip);
      planeeffSPD->UpDatePlaneEff(BFound,key);
    }
  //}}
  }
  if(AliCDBManager::Instance()->GetDefaultStorage()->Put(planeeffSPD, idplaneeffSPD, md1))
  printf("Local CDB file with random SPD plane efficiencies written \n");
 delete gran;
 delete planeeffSPD;
 delete md1;
}
 MakeITSPlaneEfficiencySPD.C:1
 MakeITSPlaneEfficiencySPD.C:2
 MakeITSPlaneEfficiencySPD.C:3
 MakeITSPlaneEfficiencySPD.C:4
 MakeITSPlaneEfficiencySPD.C:5
 MakeITSPlaneEfficiencySPD.C:6
 MakeITSPlaneEfficiencySPD.C:7
 MakeITSPlaneEfficiencySPD.C:8
 MakeITSPlaneEfficiencySPD.C:9
 MakeITSPlaneEfficiencySPD.C:10
 MakeITSPlaneEfficiencySPD.C:11
 MakeITSPlaneEfficiencySPD.C:12
 MakeITSPlaneEfficiencySPD.C:13
 MakeITSPlaneEfficiencySPD.C:14
 MakeITSPlaneEfficiencySPD.C:15
 MakeITSPlaneEfficiencySPD.C:16
 MakeITSPlaneEfficiencySPD.C:17
 MakeITSPlaneEfficiencySPD.C:18
 MakeITSPlaneEfficiencySPD.C:19
 MakeITSPlaneEfficiencySPD.C:20
 MakeITSPlaneEfficiencySPD.C:21
 MakeITSPlaneEfficiencySPD.C:22
 MakeITSPlaneEfficiencySPD.C:23
 MakeITSPlaneEfficiencySPD.C:24
 MakeITSPlaneEfficiencySPD.C:25
 MakeITSPlaneEfficiencySPD.C:26
 MakeITSPlaneEfficiencySPD.C:27
 MakeITSPlaneEfficiencySPD.C:28
 MakeITSPlaneEfficiencySPD.C:29
 MakeITSPlaneEfficiencySPD.C:30
 MakeITSPlaneEfficiencySPD.C:31
 MakeITSPlaneEfficiencySPD.C:32
 MakeITSPlaneEfficiencySPD.C:33
 MakeITSPlaneEfficiencySPD.C:34
 MakeITSPlaneEfficiencySPD.C:35
 MakeITSPlaneEfficiencySPD.C:36
 MakeITSPlaneEfficiencySPD.C:37
 MakeITSPlaneEfficiencySPD.C:38
 MakeITSPlaneEfficiencySPD.C:39
 MakeITSPlaneEfficiencySPD.C:40
 MakeITSPlaneEfficiencySPD.C:41
 MakeITSPlaneEfficiencySPD.C:42
 MakeITSPlaneEfficiencySPD.C:43
 MakeITSPlaneEfficiencySPD.C:44
 MakeITSPlaneEfficiencySPD.C:45
 MakeITSPlaneEfficiencySPD.C:46
 MakeITSPlaneEfficiencySPD.C:47
 MakeITSPlaneEfficiencySPD.C:48
 MakeITSPlaneEfficiencySPD.C:49
 MakeITSPlaneEfficiencySPD.C:50
 MakeITSPlaneEfficiencySPD.C:51
 MakeITSPlaneEfficiencySPD.C:52
 MakeITSPlaneEfficiencySPD.C:53
 MakeITSPlaneEfficiencySPD.C:54
 MakeITSPlaneEfficiencySPD.C:55
 MakeITSPlaneEfficiencySPD.C:56
 MakeITSPlaneEfficiencySPD.C:57
 MakeITSPlaneEfficiencySPD.C:58
 MakeITSPlaneEfficiencySPD.C:59