void MakeLHCClockPhaseEntry(const char *cdbStorage = "local://$ILC_ROOT/OCDB")
{
  // Example macro to put in OCDB the default (=0) LHC-clock phase
  // It is valid fro runs from 0 to inf
  // The timestamp range is also inf (we store the first and last value for
  // each beam)
  IlcCDBManager *man = IlcCDBManager::Instance();
  man->SetDefaultStorage(cdbStorage);

  IlcLHCClockPhase phaseObj;

  phaseObj.AddPhaseB1DP(0,0.);
  phaseObj.AddPhaseB2DP(0,0.);

  phaseObj.AddPhaseB1DP(2147483647,0.);
  phaseObj.AddPhaseB2DP(2147483647,0.);

  IlcCDBMetaData* metadata = new IlcCDBMetaData();
  metadata->SetResponsible("Cvetan Cheshkov");
  metadata->SetComment("Default LHC-clock phase object");
  IlcCDBId id("GRP/Calib/LHCClockPhase",0,IlcCDBRunRange::Infinity());

  man->Put(&phaseObj,id,metadata);

  return;
}
Example #2
0
void CreateMeanVertex(Double_t xmed=0., Double_t ymed=0., Double_t sigx=0.005,Double_t sigy=0.005, Double_t sigz=5.3){
  Double_t resolx=35./10000.;
  Double_t resoly=35./10000.;
  Double_t sigma[3],position[3];
  position[0]=xmed;
  position[1]=ymed;
  position[2]=0.;
  sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
  sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
  sigma[2]=sigz;
  IlcESDVertex *vave=new IlcESDVertex(position,sigma,"vtxmean");
  vave->PrintStatus();

  IlcCDBManager* man = IlcCDBManager::Instance();
  man->SetDefaultStorage("local://$ILC_ROOT/OCDB");
  
  IlcCDBId id("GRP/Calib/MeanVertex", 0, IlcCDBRunRange::Infinity());
  IlcCDBMetaData md;
  
  md.SetResponsible("*****@*****.**");
  md.SetComment("Default mean vertex position");
  md.SetIlcRootVersion("Default mean vertex position");
  
  man->Put(vave, id, &md);
  
  man->Destroy();

//  TFile *outf=new TFile("IlcESDMeanVertex.root","recreate");
// outf->cd();
//  vave->Write();
//  outf->Close();
}
void MakeSTRUCTZeroMisAlignment(){
  // Create TClonesArray of zero misalignment objects for all STRUCTures
  // (presently this includes only FRAME)
  // 
  const char* macroname = "MakeSTRUCTZeroMisAlignment.C";

  TClonesArray *array = new TClonesArray("IlcAlignObjParams",20);

  Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
  IlcGeomManager::ELayerID iLayer = IlcGeomManager::kInvalidLayer;
  UShort_t dvoluid = IlcGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id

  const char* basepath ="ILCM_1/B077_1/BSEGMO";
  TString segmpath;

  for(Int_t sm=0; sm<18; sm++){
    segmpath=basepath;
    segmpath+=sm;
    segmpath+="_1";
    cout<<segmpath.Data()<<endl;
    new((*array)[sm]) IlcAlignObjParams(segmpath.Data(),dvoluid,0.,0.,0.,0.,0.,0.,kTRUE);
  }

  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
    // save on file
    const char* filename = "STRUCTzeroMisalignment.root";
    TFile f(filename,"RECREATE");
    if(!f){
      Error(macroname,"cannot open file for output\n");
      return;
    }
    Info(macroname,"Saving alignment objects in %s", filename);
    f.cd();
    f.WriteObject(array,"STRUCTAlignObjs","kSingleKey");
    f.Close();
  }else{
    // save in CDB storage
    TString Storage = gSystem->Getenv("STORAGE");
    if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
      Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
      return;
    }
    Info(macroname,"Saving alignment objects in CDB storage %s",Storage.Data());
    IlcCDBManager* cdb = IlcCDBManager::Instance();
    IlcCDBStorage* storage = cdb->GetStorage(Storage.Data());
    if(!storage){
      Error(macroname,"Unable to open storage %s\n",Storage.Data());
      return;
    }
    IlcCDBMetaData* md = new IlcCDBMetaData();
    md->SetResponsible("Grosso Raffaele");
    md->SetComment("Zero misalignment for STRUCT: presently includes objects for FRAME");
    md->SetIlcRootVersion(gSystem->Getenv("ARVERSION"));
    IlcCDBId id("GRP/Align/Data",0,IlcCDBRunRange::Infinity());
    storage->Put(array,id,md);
  }

  array->Delete();

}
void UpdateCDBVertexDiamond(const char* objName, Double_t xmed, Double_t ymed, Double_t zmed, Double_t sigx, Double_t sigy, Double_t sigz) {
  // produce the mean vertex with the current IlcRoot and store it in the
  // CDB
  // [email protected]
  
  IlcCDBManager* man = IlcCDBManager::Instance();
  if(!gSystem->Getenv("STORAGE")){
      man->SetDefaultStorage("local://$ILC_ROOT/OCDB");
  }else{
      man->SetDefaultStorage(gSystem->Getenv("STORAGE"));
  }

  Int_t firstRun=0;
  if(gSystem->Getenv("FIRSTRUN")) firstRun=TString(gSystem->Getenv("FIRSTRUN")).Atoi();
  Int_t lastRun=IlcCDBRunRange::Infinity();
  if(gSystem->Getenv("LASTRUN")) lastRun=TString(gSystem->Getenv("LASTRUN")).Atoi();
  TString objFullName="GRP/Calib/";

  if(objName=="MeanVertex" || objName=="MeanVertexSPD" || objName=="MeanVertexTPC"){
      objFullName += objName;
  }else{
     Printf("\"%s\" is not a valid calibration object. Exiting!",objName);
     return;
  }
  IlcCDBId id(objFullName.Data(),firstRun,lastRun);
  IlcCDBMetaData *metadata= new IlcCDBMetaData();

  // Get root and IlcRoot versions
  const char* rootv = gROOT->GetVersion();
  TString av(ILCROOT_SVN_BRANCH);
  Int_t revnum = ILCROOT_SVN_REVISION;

  metadata->SetResponsible("*****@*****.**");
  metadata->SetComment("Default mean vertex position");
  metadata->SetIlcRootVersion(av.Data());
  metadata->SetComment(Form("Default mean vertex produced with root version %s and IlcRoot %s, revision number %d",rootv,av.Data(),revnum));
  

  Printf(Form("Storing in CDB the default mean vertex produced with root version %s and"
			  "IlcRoot version %s, revision number %d", rootv, av.Data(), revnum));

  Double_t sigma[3],position[3];
  position[0]=xmed;
  position[1]=ymed;
  position[2]=zmed;
  sigma[0]=sigx;
  sigma[1]=sigy;
  sigma[2]=sigz;

  IlcESDVertex *vertex = new IlcESDVertex(position,sigma,"vtxmean");
  vertex->PrintStatus();

  man->Put(vertex,id,metadata);

}
Example #5
0
void sim(Int_t embrun) 
{
  IlcSimulation sim;
  if (embrun == 4) {
    IlcCDBManager *cdbm = IlcCDBManager::Instance();
    cdbm->SetRun(atoi(gSystem->Getenv("DC_RUN")));
    cdbm->SetDefaultStorage("local://$ILC_ROOT/OCDB");     
    cdbm->SetSpecificStorage("GRP/GRP/Data",Form("local://%s",gSystem->pwd()));
    sim.SetMakeSDigits("ITS TPC TRD TOF VZERO");  

    sim.ConvertRaw2SDigits("raw.root","IlcESDs.root");
    return;
  }
  
  if (embrun == 2) {
    sim.SetRunGeneration(kFALSE);
    sim.SetMakeSDigits("");
    sim.SetMakeDigitsFromHits("");
  }
  else {
    sim.SetRunGeneration(kTRUE);
    sim.SetMakeSDigits("ITS TPC TRD TOF VZERO");
  }
  sim.SetRunSimulation(kTRUE);
  sim.SetMakeDigits("ITS TPC TRD TOF VZERO");
  sim.SetWriteRawData("ITS TPC TRD TOF VZERO","raw.root",kTRUE);
  if (embrun == 1)
    sim.MergeWith("../BackgroundSDigits/gilc.root",1);

  sim.SetDefaultStorage("local://$ILC_ROOT/OCDB");
  sim.SetSpecificStorage("GRP/GRP/Data",
			       Form("local://%s",gSystem->pwd()));
  sim.SetRunQA(":") ; 
  IlcQA::SetQARefStorage("local://$ILC_ROOT/OCDB") ;
  
  for (Int_t det = 0 ; det < IlcQA::kNDET ; det++) {
    sim.SetQACycles(det, 1) ;
  }

//   sim.SetDefaultStorage("alien://Folder=/ilc/simulation/2008/v4-15-Release/Full/");
//   sim.SetRunHLT("");
//   sim.SetQA(kFALSE);

  sim.Run(1);
}
Example #6
0
void simqa()
{
	const char * kYear = "08" ; 
	gEnv->SetValue("Root.Stacktrace","no");
	gEnv->SetValue("Root.Stacktrace","no");
	IlcCDBManager * man = IlcCDBManager::Instance();
	//man->SetDefaultStorage("alien://Folder=/ilc/data/2008/LHC08d/OCDB/");
	man->SetDefaultStorage("local://$ILC_ROOT/OCDB");
	TString detectors("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD PMD ZDC T0 VZERO"); 
	
	//IlcQA::SetQARefStorage(Form("%s%s/", IlcQA::GetQARefDefaultStorage(), kYear)) ;
	IlcQA::SetQARefStorage("local://$ILC_ROOT/QAref") ;
  

	IlcQAManager *  qas = IlcQAManager::QAManager("sim") ; 
	qas->SetDefaultStorage("local://$ILC_ROOT/QAref");
        qas->SetEventSpecie(IlcRecoParam::kLowMult); 
	qas->Run(detectors.Data(), IlcQA::kHITS);
	qas->Run(detectors.Data(), IlcQA::kSDIGITS);
	qas->Run(detectors.Data(), IlcQA::kDIGITS);
}
Example #7
0
void rec(const char *filename="raw.root",Int_t nevents=-1)
{
  // Load some system libs for Grid and monitoring
  // Set the CDB storage location
  IlcCDBManager * man = IlcCDBManager::Instance();
  man->SetDefaultStorage("raw://");
 
  // Reconstruction settings
  IlcReconstruction rec;

  // Set protection against too many events in a chunk (should not happen)
  if (nevents>0) rec.SetEventRange(0,nevents);

  // Switch off HLT until the problem with schema evolution resolved
  //rec.SetRunReconstruction("ALL-HLT");
  //
  // QA options
  //
  IlcQAManager *qam = IlcQAManager::QAManager(IlcQAv1::kRECMODE) ;
  rec.SetRunQA(":");
  rec.SetRunGlobalQA(kFALSE);

  // IlcReconstruction settings
  rec.SetWriteESDfriend(kTRUE);
  rec.SetWriteAlignmentData();
  rec.SetInput(filename);
  rec.SetUseTrackingErrorsForAlignment("ITS");
  rec.SetRunReconstruction("ITS TPC TRD TOF");
  rec.SetFillESD("ITS TPC TRD TOF");

  // switch off cleanESD
  rec.SetCleanESD(kFALSE);

  IlcLog::Flush();
  rec.Run();

}
void UpdateCDBCTPConfig(const char *CTPcfg, const char* cdbUri, const char* cfgFile){
  // Produces a trigger configuration starting from a 'cfg' file in the
  // GRP/CTP folder (CTPcfg argument). Stores the configuration in the specified CDB.
  // The third argument allows to specify the config file against which
  // the trigger confiuration is checked.

  IlcCDBManager* cdb = IlcCDBManager::Instance();
  // we set the default storage to the repository because some dets require
  // already at the time of geometry creation to find calibration objects in the cdb
  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ILC_ROOT/OCDB");
  IlcCDBStorage* storage = cdb->GetStorage(cdbUri);
  cdb->SetRun(0);
  IlcCDBId id("GRP/CTP/Config",0,IlcCDBRunRange::Infinity());
  IlcCDBMetaData *md= new IlcCDBMetaData();

  // Get root and IlcRoot versions
  const char* rootv = gROOT->GetVersion();
  gROOT->ProcessLine(".L $ILC_ROOT/macros/GetARversion.C");
  TString av(GetARversion());

  md->SetIlcRootVersion(av.Data());
  md->SetComment(Form("Default CTP configuration for p-p mode produced with root version %s and IlcRoot version %s",rootv,av.Data()));
  
  // construct the CTP configuration starting from GRP/CTP/<CTPcfg>.cfg file
  IlcTriggerConfiguration *trconfig = IlcTriggerConfiguration::LoadConfiguration(CTPcfg);
  if (!trconfig) {
    Printf("Invalid cfg file! Exiting...");
    return;
  }
  if (!trconfig->CheckConfiguration(cfgFile)) {
    Printf("CTP configuration is incompatible with the specified Config.C and IlcRoot version! Exiting...");
    return;
  }
  
  Printf("Storing in CDB geometry produced with root version %s and IlcRoot version %s",rootv,av.Data());
  storage->Put(trconfig,id,md);
  // This is to allow macros lauched after this one in the same session to find the
  // newly produced geometry.
  storage->QueryCDB(cdb->GetRun());

}
Example #9
0
void MergeSetsOfIlcgnObjs(const char* filename1, const char* filename2, const char* det="ITS")
{
  // example macro: building an array by merging the non-SSD entries
  // from one file (or OCDB entry) with the remaining SSD entries taken
  // from another file (or OCDB entry); the first two arguments can be local filenames
  // or URLs of the OCDB folders 
  //  
  const char* macroname = "MergeSetsOfIlcgnObjs";
  
  TClonesArray* array1 = 0;
  TClonesArray* array2 = 0;

  TString arName(det);
  arName+="AlignObjs";
  TString path(det);
  path+="/Align/Data";
  
  TString f1(filename1);
  TString f2(filename2);
  
  IlcCDBStorage* stor1 = 0;
  IlcCDBStorage* stor2 = 0;
  
  Bool_t fromOcdb1=kFALSE;
  Bool_t fromOcdb2=kFALSE;

  if(f1.Contains("alien://folder=") || f1.Contains("local://")) fromOcdb1=kTRUE;
  if(f2.Contains("alien://folder=") || f2.Contains("local://")) fromOcdb2=kTRUE;

  
  IlcCDBManager* cdb = IlcCDBManager::Instance();
  cdb->SetDefaultStorage("local://$ILC_ROOT/OCDB");
  cdb->SetRun(0);
  
  if(fromOcdb1){
    stor1 = cdb->GetStorage(f1.Data());
    IlcCDBEntry* entry = stor1->Get(path.Data(),0);
    array1 = (TClonesArray*) entry->GetObject();
  }else{
    TFile* filein1 = TFile::Open(f1.Data(),"READ");
    if(!filein1)
    {
      Info(macroname,Form("Unable to open file %s! Exiting ...", f1.Data()));
      return;
    }
    array1 = (TClonesArray*) filein1->Get(arName.Data());
  }
  if(array1){
    Info(macroname,Form("First array has %d entries", array1->GetEntriesFast()));
  }else{
    Info(macroname,"Unable to get first array! Exiting ...");
    return;
  }

  if(fromOcdb2){
    stor2 = cdb->GetStorage(f2.Data());
    IlcCDBEntry* entry = stor2->Get(path.Data(),0);
    array2 = (TClonesArray*) entry->GetObject();
  }else{
    TFile* filein2 = TFile::Open(f2.Data(),"READ");
    if(!filein2)
    {
      Info(macroname,Form("Unable to open file %s! Exiting ...", f2.Data()));
      return;
    }
    array2 = (TClonesArray*) filein2->Get(arName.Data());
  }
  if(array2){
    Info(macroname,Form("Second array has %d entries", array2->GetEntriesFast()));
  }else{
    Info(macroname,"Unable to get second array! Exiting ...");
    return;
  }


  TClonesArray *mergedArr = new TClonesArray("IlcAlignObjParams",3000);

  Info(macroname,"Merging objects for SPD and SDD from the first array ...");
  // SSD starts from 500
  for(Int_t i=0; i<500; i++)
  {
    (*mergedArr)[i] = (IlcAlignObjParams*) array1->UncheckedAt(i);
  }
  
  Info(macroname,"Merging objects for SSD from the second array ...");
  for(Int_t i=500; i<array2->GetEntriesFast(); i++)
  {
    (*mergedArr)[i] = (IlcAlignObjParams*) array2->UncheckedAt(i);
  }
  
  TString foutName("merged");
  foutName+=det;
  foutName+="Alignment.root";
  Info(macroname,Form("... in a single array into the file %s", foutName.Data()));
  TFile* fileout = TFile::Open(foutName.Data(),"RECREATE");
  fileout->cd();
  fileout->WriteObject(mergedArr,arName.Data(),"kSingleKey");
  fileout->Close();
  
  mergedArr->Delete();
  
}
void IlcTRDCreateDummyCDB()
{
  cout << endl << "TRD :: Creating dummy CDB with event number " << gkDummyRun << endl;
  
  IlcCDBManager *man = IlcCDBManager::Instance();
  gStorLoc = man->GetStorage("local://$ILC_ROOT");
  if (!gStorLoc)
    return;

  TObject* obj = 0;
  IlcCDBMetaData* metaData = 0;
  
  metaData = CreateMetaObject("IlcTRDCalPad");
  
  obj = CreatePadObject("LocalVdrift","TRD drift velocities (local variations)", 1);
  StoreObject("TRD/Calib/LocalVdrift", obj, metaData);
  
  obj = CreatePadObject("LocalT0","T0 (local variations)", 1);
  StoreObject("TRD/Calib/LocalT0", obj, metaData);

  obj = CreatePadObject("GainFactor","GainFactor (local variations)", 1);
  StoreObject("TRD/Calib/LocalGainFactor", obj, metaData);

  obj = CreatePRFWidthObject();
  StoreObject("TRD/Calib/PRFWidth", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalDet");
  
  obj = CreateDetObject("ChamberVdrift","TRD drift velocities (detector value)", 1.5);
  StoreObject("TRD/Calib/ChamberVdrift", obj, metaData);
  
  obj = CreateDetObject("ChamberT0","T0 (detector value)", 0);
  StoreObject("TRD/Calib/ChamberT0", obj, metaData);
  
  obj = CreateDetObject("ChamberGainFactor","GainFactor (detector value)", 1);
  StoreObject("TRD/Calib/ChamberGainFactor", obj, metaData);
  
  metaData = CreateMetaObject("IlcTRDCalGlobals");
  obj = CreateGlobalsObject();
  StoreObject("TRD/Calib/Globals", obj, metaData);
  
  metaData = CreateMetaObject("IlcTRDCalChamberPos");
  obj = CreateChamberObject();
  StoreObject("TRD/Calib/ChamberPos", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalStackPos");
  obj = CreateStackObject();
  StoreObject("TRD/Calib/StackPos", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalSuperModulePos");
  obj = CreateSuperModuleObject();
  StoreObject("TRD/Calib/SuperModulePos", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalSuperModuleStatus");
  obj = CreateSuperModuleStatusObject();
  StoreObject("TRD/Calib/SuperModuleStatus", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalChamberStatus");
  obj = CreateChamberStatusObject();
  StoreObject("TRD/Calib/ChamberStatus", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalMCMStatus");
  obj = CreateMCMStatusObject();
  StoreObject("TRD/Calib/MCMStatus", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalPadStatus");
  obj = CreatePadStatusObject();
  StoreObject("TRD/Calib/PadStatus", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalPIDLQ");
  obj = CreatePIDLQObject();
  StoreObject("TRD/Calib/PIDLQ", obj, metaData);

  metaData = CreateMetaObject("IlcTRDCalMonitoring");
  obj = CreateMonitoringObject();
  StoreObject("TRD/Calib/MonitoringData", obj, metaData);
}
void UpdateCDBVertexDiamondOld(Double_t xmed = 0., Double_t ymed = 0., Double_t sigx = 0.0060, Double_t sigy = 0.0060, Double_t sigz = 3.8) {
  // produce the mean vertex with the current IlcRoot and store it in the
  // CDB
  
  IlcCDBManager* man = IlcCDBManager::Instance();
  man->SetDefaultStorage("local://$ILC_ROOT/OCDB");
  man->SetRun(0);
  IlcCDBId id("GRP/Calib/MeanVertex",0,IlcCDBRunRange::Infinity());
  IlcCDBId idTPC("GRP/Calib/MeanVertexTPC",0,IlcCDBRunRange::Infinity());
  IlcCDBId idSPD("GRP/Calib/MeanVertexSPD",0,IlcCDBRunRange::Infinity());
  IlcCDBMetaData *metadata= new IlcCDBMetaData();

  // Get root and IlcRoot versions
  const char* rootv = gROOT->GetVersion();
  TString av(ILCROOT_SVN_BRANCH);
  Int_t revnum = ILCROOT_SVN_REVISION;

  metadata->SetResponsible("*****@*****.**");
  metadata->SetComment("Default mean vertex position");
  metadata->SetIlcRootVersion(av.Data());
  metadata->SetComment(Form("Default mean vertex produced with root version %s and IlcRoot %s, revision number %d",rootv,av.Data(),revnum));
  

  Printf(Form("Storing in CDB the default mean vertex produced with root version %s and"
			  "IlcRoot version %s, revision number %d", rootv, av.Data(), revnum));

  Double_t resolx=5./10000.; // this is error on the weighted mean (5 micron) 
  Double_t resoly=5./10000.; // this is error on the weighted mean (5 micron)
  Double_t sigma[3],position[3];
  position[0]=xmed;
  position[1]=ymed;
  position[2]=0.;
  sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
  sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
  sigma[2]=sigz;

  IlcESDVertex *vertex = new IlcESDVertex(position,sigma,"vtxmean");
  vertex->PrintStatus();

  man->Put(vertex,id,metadata);

  position[0]=xmed;
  position[1]=ymed;
  position[2]=0.;
  sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
  sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
  sigma[2]=sigz;

  IlcESDVertex *vertexTPC = new IlcESDVertex(position,sigma,"vtxmean");
  vertexTPC->PrintStatus();

  man->Put(vertexTPC,idTPC,metadata);

  position[0]=xmed;
  position[1]=ymed;
  position[2]=0.;
  sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
  sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
  sigma[2]=sigz;

  IlcESDVertex *vertexSPD = new IlcESDVertex(position,sigma,"vtxmean");
  vertexSPD->PrintStatus();

  man->Put(vertexSPD,idSPD,metadata);



}
Example #12
0
void mkOCDB(const Bool_t toGRID=kFALSE, const Bool_t debug=kFALSE)
{
  // This script reads PVBAR-EMC calibration object from OCDB raw://,
  // then reads corrections to gains O(1) from local://OCDB_corr
  // and create the new OCDB object with the new gains as a product of old gains
  // and gain corrections.
  // The new calibration object is written either to local://OCDB_new
  // --
  // Gain corrections were found by equalizing the mean cell energy
  // from the reconstructed data LHC10h by B.Polishchuk
  // --
  // Yuri Kharlov. 7-Feb-2011

  TH1F *hGainOrigM1 = new TH1F("hGainOrigM1","hGainM1OrigM1",1000,0.,0.01);
  TH1F *hGainOrigM2 = new TH1F("hGainOrigM2","hGainM1OrigM2",1000,0.,0.01);
  TH1F *hGainOrigM3 = new TH1F("hGainOrigM3","hGainM1OrigM3",1000,0.,0.01);
  TH1F *hGainOrigM4 = new TH1F("hGainOrigM4","hGainM1OrigM4",1000,0.,0.01);
  TH1F *hGainOrigM5 = new TH1F("hGainOrigM5","hGainM1OrigM5",1000,0.,0.01);

  TH2F *hOrigNewM1 = new TH2F("hOrigNewM1","hOrigNewM1",100,0.,0.01,100,0.,0.01);
  TH2F *hOrigNewM2 = new TH2F("hOrigNewM2","hOrigNewM2",100,0.,0.01,100,0.,0.01);
  TH2F *hOrigNewM3 = new TH2F("hOrigNewM3","hOrigNewM3",100,0.,0.01,100,0.,0.01);
  TH2F *hOrigNewM4 = new TH2F("hOrigNewM4","hOrigNewM4",100,0.,0.01,100,0.,0.01);
  TH2F *hOrigNewM5 = new TH2F("hOrigNewM5","hOrigNewM5",100,0.,0.01,100,0.,0.01);

  TH1F *hGainNewM1 = new TH1F("hGainNewM1","hGainM1NewM1",1000,0.,0.01);
  TH1F *hGainNewM2 = new TH1F("hGainNewM2","hGainM1NewM2",1000,0.,0.01);
  TH1F *hGainNewM3 = new TH1F("hGainNewM3","hGainM1NewM3",1000,0.,0.01);
  TH1F *hGainNewM4 = new TH1F("hGainNewM4","hGainM1NewM4",1000,0.,0.01);
  TH1F *hGainNewM5 = new TH1F("hGainNewM5","hGainM1NewM5",1000,0.,0.01);

  IlcCDBManager::Instance()->SetDefaultStorage("raw://");

  IlcCDBManager::Instance()->SetRun(114783);
  IlcPVBARCalibData db1(114783);

  IlcCDBManager::Instance()->SetDefaultStorage("local://OCDB_corr");
  IlcCDBManager::Instance()->SetSpecificStorage("PVBAR/Calib/EmcGainPedestals",
						"local://OCDB_corr");
  IlcCDBManager::Instance()->SetRun(114783);
  IlcPVBARCalibData db2(114783);  

  for(Int_t module=0; module<5; module++) {
    for(Int_t ix=0; ix<64; ix++) {
      for(Int_t iz=0; iz<56; iz++) {

	Float_t cc_i = db1.GetADCchannelEmc(module+1,iz+1,ix+1);
	Float_t corr = db2.GetADCchannelEmc(module+1,iz+1,ix+1);
        if (module <= 2)
          corr *= 0.135/0.1223;

	if      (module == 0) {
	  hGainOrigM1->Fill(cc_i);
	  hGainNewM1 ->Fill(cc_i*corr);
	  hOrigNewM1 ->Fill(cc_i,cc_i*corr);
	}
	else if (module == 1) {
	  hGainOrigM2->Fill(cc_i);
	  hGainNewM2 ->Fill(cc_i*corr);
	  hOrigNewM2 ->Fill(cc_i,cc_i*corr);
	}
	else if (module == 2) {
	  hGainOrigM3->Fill(cc_i);
	  hGainNewM3 ->Fill(cc_i*corr);
	  hOrigNewM3 ->Fill(cc_i,cc_i*corr);
	}
	else if (module == 3) {
	  hGainOrigM4->Fill(cc_i);
	  hGainNewM4 ->Fill(cc_i*corr);
	  hOrigNewM4 ->Fill(cc_i,cc_i*corr);
	}
	else if (module == 4) {
	  hGainOrigM5->Fill(cc_i);
	  hGainNewM5 ->Fill(cc_i*corr);
	  hOrigNewM5 ->Fill(cc_i,cc_i*corr);
	}

	db1.SetADCchannelEmc(module+1,iz+1,ix+1,cc_i*corr);
	if (debug) {
	  if (TMath::Abs(corr-1.)>0.01)
	    printf("CC for mod%d x%d z%d set to %f (orig %f, corr %f)\n",
		   module+1,ix+1,iz+1,
		   db1.GetADCchannelEmc(module+1,iz+1,ix+1),
		   cc_i,corr);
	}

      }
    }
  }
  
  //Writing new calibration coefficients (CCs) to OCDB

  IlcCDBManager* cdb = IlcCDBManager::Instance();
  if (toGRID)
    cdb->SetDefaultStorage("alien://Folder=/ilc/cern.ch/user/k/kharlov/RAW/2010/OCDB");
  else
    cdb->SetDefaultStorage("local://OCDB_new");

  IlcCDBMetaData *md= new IlcCDBMetaData();
  md->SetResponsible("Yuri Kharlov / Boris Polishchuk");
  md->SetComment("PVBAR gains calculated from mean cell energy equalization. All scaled to shift pi0 to 135 MeV. HL/LG ratio is calculated from LED runs offline. The pi0 width is 5-7 MeV");
  IlcCDBId id("PVBAR/Calib/EmcGainPedestals",114783,IlcCDBRunRange::Infinity());
//   cdb->Put(&db1,id, md);
  db1.WriteEmc(136833,IlcCDBRunRange::Infinity(),md);

  TFile *gainHisto = new TFile("gainHisto.root","recreate");
  hGainOrigM1->Write();
  hGainOrigM2->Write();
  hGainOrigM3->Write();
  hGainOrigM4->Write();
  hGainOrigM5->Write();
  hGainNewM1->Write();
  hGainNewM2->Write();
  hGainNewM3->Write();
  hGainNewM4->Write();
  hGainNewM5->Write();
  hOrigNewM1->Write();
  hOrigNewM2->Write();
  hOrigNewM3->Write();
  hOrigNewM4->Write();
  hOrigNewM5->Write();
  gainHisto->Close();
}
Example #13
0
void AddAnalysisTasks(const char *suffix)
{
  TString ss(suffix);
  ss.ToLower();
  Bool_t ibarrel = (ss.Contains("barrel"))?kTRUE:kFALSE;
  IlcAnalysisManager *mgr = IlcAnalysisManager::GetAnalysisManager();
  mgr->SetCommonFileName(Form("QAresults%s.root",suffix));
  // Statistics task
  mgr->AddStatisticsTask(kTriggerMask);
  //
  // CDB connection
  //
  if (doCDBconnect) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C");
    IlcTaskCDBconnect *taskCDB = AddTaskCDBconnect();
    if (!taskCDB) return;
    IlcCDBManager *cdb = IlcCDBManager::Instance();
    cdb->SetDefaultStorage("raw://");
    taskCDB->SetRunNumber(run_number);
  }    
  
  //
  // Event Statistics (Jan Fiete)
  //
  if (doEventStat) {
      gROOT->LoadMacro("$ILC_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
      IlcPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE /*MC*/);
      IlcAnalysisDataContainer *cstatsout = (IlcAnalysisDataContainer*)mgr->GetOutputs()->FindObject("cstatsout");
      cstatsout->SetFileName(Form("EventStat_temp%s.root", suffix));
  }
  
  //
  // Centrality (A. Toia)
  //
  if (doCentrality) {
     if (!iCollisionType) {
        printf("Disabling centrality task for p-p\n");
        doCentrality = kFALSE;
     } else {           
        gROOT->LoadMacro("$ILC_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
        IlcCentralitySelectionTask *taskCentrality = AddTaskCentrality();
     }   
  }   
  
  // Vertexing (A. Dainese)
  // 
  if (doVertex) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskVertexESD.C");
    IlcAnalysisTaskVertexESD* taskvertexesd =  AddTaskVertexESD(kFALSE, kTriggerMask);
    taskvertexesd->SelectCollisionCandidates(kTriggerMask);
  }  

  // TPC QA (E. Sicking)
  //
  if (doQAsym) {
  // offline trigger in AddTask
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddTaskQAsym.C");
    IlcAnalysisTaskSE * taskqasim = AddTaskQAsym(0, kTriggerMask, kTriggerHM, kTriggerEMC, kTriggerMuonBarell);
  }  
  //
  // VZERO QA  (C. Cheshkov)
  //
  if (doVZERO && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddTaskVZEROQA.C");
    IlcAnalysisTaskSE * taskv0qa = AddTaskVZEROQA(0);
//  taskv0qa->SelectCollisionCandidates();
  }
  if (doVZEROPbPb && iCollisionType==1) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/VZERO/AddTaskVZEROPbPb.C");
    IlcAnaVZEROPbPb* taskV0PbPb = (IlcAnaVZEROPbPb*)AddTaskVZEROPbPb(0);
//    taskV0PbPb->SetClassesNames("CTRUE-,C0HWU-,CPBI2WU_B1-,CPBI2_B1-,CPBI1WU-,CPBI1-,CVHNWU-,CVHN-,CVLNWU-,CVLN-");
//    taskV0PbPb->SetClassesNames("CTRUE-,C0HWU-,CPBI2WU,CPBI2,CPBI1WU-,CPBI1-,CVHNWU,CVHN,CVLNWU,CVLN");
//    taskV0PbPb->SetClassesNames("CTRUE-,C0HWU-,CPBI2WU-,CPBI2-,CPBI2WU_B1-,CPBI2_B1-,CPBI1WU-,CPBI1-,CVHNWU-,CVHN-,CVHN_R2-,CVHNWU_R2-,CVLNWU-,CVLN-,CVLN_B2-,CVLNWU_B2-");
//    taskV0PbPb->SetClassesNames("CTRUE-,C0HWU-,CPBI2WU-,CPBI2-,CPBI2WU_B1-,CPBI2_B1-,CPBI1WU-,CPBI1-,CVHNWU-,CVHN-,CVHN_R2-,CVHNWU_R2-,CVLNWU-,CVLN-,CVLN_R1-,CVLN_B2-,CVLNWU_R1-,CVLNWU_B2-");
    taskV0PbPb->SetClassesNames("CTRUE-,C0HWU-,CPBI2WU-,CPBI2-,CPBI2WU_B1-,CPBI2_B1-,CPBI1WU-,CPBI1-,CVHNWU-,CVHN-,CVHN_R2-,CVHNWU_R2-,CVLNWU-,CVLN-,CVLN_R1-,CVLN_B2-,CVLNWU_R1-,CVLNWU_B2-,CSEMI_R1-,CSEMIWU_R1-,CCENT_R2-,CCENTWU_R2-");
  }
  //
  // TPC (Jacek Otwinowski & Michael Knichel)
  //
  //
  // Optionally MC information can be used by setting the 1st argument to true
  // Optionally friends information can be switched off by setting the 2st argument 
  // to false
  // Optionally highMult axis can be used by setting the 3st argument to true (for PbPb)
  if (doTPC && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/TPC/macros/AddTaskPerformanceTPCdEdxQA.C");
    IlcPerformanceTask *tpcQA = 0;
    if (iCollisionType) {
       // High multiplicity Pb-Pb
       tpcQA = AddTaskPerformanceTPCdEdxQA(kFALSE, kTRUE, kTRUE);
    } else {
      // Low multiplicity (pp)
       tpcQA = AddTaskPerformanceTPCdEdxQA(kFALSE, kTRUE, kFALSE);
    }
    tpcQA->SelectCollisionCandidates(kTriggerMask);
  }  

  // HLT (Alberica Toia)
  if (doHLT && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/TPC/macros/AddTaskPerformanceTPCdEdxQA.C");
    IlcPerformanceTask *hltQA = AddTaskPerformanceTPCdEdxQA(kFALSE, kTRUE, kFALSE,0,kTRUE);
    hltQA->SelectCollisionCandidates(kTriggerMask);
  }  
  //
  // SPD (A. Mastroserio)
  //
  if (doSPD) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddTaskSPDQA.C");
    IlcAnalysisTaskSPD* taskspdqa = (IlcAnalysisTaskSPD*)AddTaskSPDQA();
    // Request from Annalisa
    if (iCollisionType) taskspdqa->SetHeavyIonMode();
    taskspdqa->SelectCollisionCandidates(kTriggerMask);
    taskspdqa->SetOCDBInfo(run_number, "raw://");
  }  
  //
  // SDD (F. Prino)
  //
  if (doSDD) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddSDDPoints.C");
    IlcAnalysisTaskSE* tasksdd = AddSDDPoints();
    tasksdd->SelectCollisionCandidates(kTriggerMask);
  }
  //
  // SSD dEdx (Marek Chojnacki)
  //
  if (doSSDdEdx) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddTaskdEdxSSDQA.C");
    IlcAnalysisTaskSE* taskssddedx = AddTaskdEdxSSDQA();
    taskssddedx->SelectCollisionCandidates(kTriggerMask);
  }

  //
  // ITS
  //
  if (doITS) {
  // hardcoded non-zero trigger mask
      gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskPerformanceITS.C");
      IlcAnalysisTaskITSTrackingCheck *itsQA = 0;
      IlcAnalysisTaskITSTrackingCheck *itsQACent0010 = 0;
      IlcAnalysisTaskITSTrackingCheck *itsQACent3050 = 0;
      IlcAnalysisTaskITSTrackingCheck *itsQACent6080 = 0;
      if(iCollisionType==0) {
        itsQA = AddTaskPerformanceITS(kFALSE);
      } else {
        itsQA = AddTaskPerformanceITS(kFALSE);
        itsQACent0010 = AddTaskPerformanceITS(kFALSE,kFALSE,kFALSE,3500,10000);
        itsQACent3050 = AddTaskPerformanceITS(kFALSE,kFALSE,kFALSE,590,1570);
        itsQACent6080 = AddTaskPerformanceITS(kFALSE,kFALSE,kFALSE,70,310);
      }
  }
  //
  // ITS saTracks, align (F.Prino)
  //
  if (doITSsaTracks) {
  // offline trigger in AddTask
     gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskITSsaTracks.C");
     IlcAnalysisTaskITSsaTracks *itssaTracks = AddTaskITSsaTracks(kFALSE,kFALSE);
     itssaTracks->SelectCollisionCandidates(kTriggerMask);
  }   
  if (doITSalign) {
  // no offline trigger selection
     gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskITSAlign.C");
     IlcAnalysisTaskITSAlignQA *itsAlign = AddTaskITSAlign(0,2011);
  }   
  //
  // TRD (Alex Bercuci, M. Fasel) 
  //
  if(doTRD && ibarrel) {
  // no offline trigger selection
      gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTrainPerformanceTRD.C");
      // steer individual TRD tasks
      Bool_t 
      doCheckESD(kTRUE),  // IlcTRDcheckESD
      doCheckDET(kTRUE),  // IlcTRDcheckDET
      doEffic(kTRUE),     // IlcTRDefficiency
      doResolution(kTRUE),// IlcTRDresolution
      doCheckPID(kTRUE),  // IlcTRDcheckPID
      doV0Monitor(kFALSE);// IlcTRDv0Monitor
      AddTrainPerformanceTRD(Translate(doCheckESD, doCheckDET, doEffic, doResolution, doCheckPID, doV0Monitor));
  }

  //
  // ZDC (Chiara Oppedisano) 
  //
  if(doZDC && ibarrel) {
  // hardcoded kMB trigger mask
     gROOT->LoadMacro("$ILC_ROOT/PWGPP/ZDC/AddTaskZDCQA.C");
     IlcAnalysisTaskSE *taskZDC = AddTaskZDCQA();
     taskZDC->SelectCollisionCandidates(kTriggerMask);
  }   
  //
  // Calorimetry (Gustavo Conesa)
  //

  if(doCALO) {
      gROOT->LoadMacro("$ILC_ROOT/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
      IlcAnalysisTaskCaloTrackCorrelation *taskCaloQA = AddTaskCalorimeterQA("ESD", 2011, kFALSE, kFALSE);
      taskCaloQA->SetDebugLevel(0);
      // offline mask set in AddTask to kMB
      taskCaloQA->SelectCollisionCandidates(kTriggerMask);
      // Add a new calo task with EMC1 trigger only
      taskCaloQA = AddTaskCalorimeterQA("ESD", 2011, kFALSE, kFALSE, "", "EMC7");
      taskCaloQA->SetDebugLevel(0);
      taskCaloQA->SelectCollisionCandidates(kTriggerEMC);
  }

  //
  // Muon Trigger
  //
  
  if(doMUONTrig) {
  // no offline trigger selection
      gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskMTRchamberEfficiency.C");
      IlcAnalysisTaskTrigChEff *taskMuonTrig = AddTaskMTRchamberEfficiency();
  }

  //
  // Impact parameter resolution ([email protected], [email protected])
  //
  if (doImpParRes && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskImpParRes.C");
    IlcAnalysisTaskSE* taskimpparres=0;
    if(iCollisionType==0) {
       taskimpparres= AddTaskImpParRes();
    } else {
       taskimpparres= AddTaskImpParRes(kFALSE,-1,kFALSE,kFALSE);
    }
    taskimpparres->SelectCollisionCandidates(kTriggerMask);
  }  
  //
  // MUON QA (Philippe Pillot)
  //
  if (doMUON) {
  // trigger analysis internal
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/PilotTrain/AddTaskMuonQA.C");
    IlcAnalysisTaskSE* taskmuonqa= AddTaskMuonQA();
  }  
  //
  // TOF (Francesca Bellini)
  //
  if (doTOF && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/TOF/AddTaskTOFQA.C");
    IlcAnalysisTaskTOFqa *tofQA = AddTaskTOFQA();
    tofQA->SelectCollisionCandidates(kTriggerMask);
  } 
   //
  // PIDResponse(JENS)
  //
  if (doPIDResponse && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); 
    IlcAnalysisTaskPIDResponse *PIDResponse = AddTaskPIDResponse();
    PIDResponse->SelectCollisionCandidates(kTriggerMask);
  }  

  //
  // PIDqa(JENS)
  //
  if (doPIDqa && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
    IlcAnalysisTaskPIDqa *PIDQA = AddTaskPIDqa();
    PIDQA->SelectCollisionCandidates(kTriggerMask);
  }  
 
  //
  // HMPID QA (Giacomo Volpe)
  //
  if (doHMPID && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/HMPID/AddTaskHmpidQA.C");
    IlcAnalysisTaskSE* taskhmpidqa= AddTaskHmpidQA(kFALSE);
      // offline mask set in AddTask to kMB
    taskhmpidqa->SelectCollisionCandidates(kTriggerMask);
  }      
  
  
  // T0 QA (Alla Mayevskaya)
  if (doT0 && ibarrel) {
  // no offline trigger selection
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/T0/AddTaskT0QA.C");
    IlcT0AnalysisTaskQA* taskt0qa= AddTaskT0QA();
    taskt0qa->SelectCollisionCandidates(kTriggerMask);
  }      
  // FMD QA (Christian Holm Christiansen)
  if (doFMD && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGLF/FORWARD/analysis2/AddTaskForwardQA.C");
    // Parameters: usemc, usecentrality
    IlcAnalysisTaskSE *forwardQA = (IlcAnalysisTaskSE *)AddTaskForwardQA(kFALSE, kFALSE);
    // No offline trigger config. needed (see #84077)
  }
   //     
  // PHOS QA (Boris Polishchuk)
  //
  if (doPHOS) {
    gROOT->LoadMacro("$ILC_ROOT/PWGGA/PHOSTasks/CaloCellQA/macros/AddTaskCaloCellsQA.C");
    IlcAnalysisTaskCaloCellsQA *taskPHOSCellQA1 = AddTaskCaloCellsQA(4, 1, NULL,"PHOSCellsQA_AnyInt"); 
    taskPHOSCellQA1->SelectCollisionCandidates(kTriggerMask);
    taskPHOSCellQA1->GetCaloCellsQA()->SetClusterEnergyCuts(0.3,0.3,1.0);
    IlcAnalysisTaskCaloCellsQA *taskPHOSCellQA2 = AddTaskCaloCellsQA(4, 1, NULL,"PHOSCellsQA_PHI7"); 
    taskPHOSCellQA2->SelectCollisionCandidates(IlcVEvent::kPHI7);
    taskPHOSCellQA2->GetCaloCellsQA()->SetClusterEnergyCuts(0.3,0.3,1.0);
    // Pi0 QA fo PbPb
    if (iCollisionType) {
      gROOT->LoadMacro("$ILC_ROOT/PWGGA/PHOSTasks/PHOS_PbPbQA/macros/AddTaskPHOSPbPb.C");
      IlcAnalysisTaskPHOSPbPbQA* phosPbPb = AddTaskPHOSPbPbQA(0);
    }
  }    
  if (doPHOSTrig) {
     gROOT->LoadMacro("$ILC_ROOT/PWGGA/PHOSTasks/PHOS_TriggerQA/macros/AddTaskPHOSTriggerQA.C");
     IlcAnalysisTaskPHOSTriggerQA *taskPHOSTrig = AddTaskPHOSTriggerQA(NULL);
  }
  //
  // EMCAL QA (Gustavo Conesa)
  //
  if (doEMCAL) {
     gROOT->LoadMacro("$ILC_ROOT/PWGGA/EMCALTasks/macros/AddTaskEMCALTriggerQA.C");
     IlcAnalysisTaskEMCALTriggerQA *emctrig = AddTaskEMCALTriggerQA();
  }   
  //     
  // FLOW and BF QA (C.Perez && A.Rodriguez)
  //
  if (doFBFqa && ibarrel) {
    gROOT->LoadMacro("$ILC_ROOT/PWGPP/macros/AddTaskFBFqa.C");
    IlcAnalysisTaskSE *qaFBFMB = (IlcAnalysisTaskSE*) AddTaskFBFqa("qaFBFmb",kFALSE);
    qaFBFMB->SelectCollisionCandidates(IlcVEvent::kMB);
    IlcAnalysisTaskSE *qaFBFSC = (IlcAnalysisTaskSE*) AddTaskFBFqa("qaFBFsc",kFALSE);
    qaFBFSC->SelectCollisionCandidates(IlcVEvent::kSemiCentral);
    IlcAnalysisTaskSE *qaFBFCE = (IlcAnalysisTaskSE*) AddTaskFBFqa("qaFBFce",kFALSE);
    qaFBFCE->SelectCollisionCandidates(IlcVEvent::kCentral);
  }
}