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 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());

}
Beispiel #3
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);
}