]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/MakeITSResMisAlignment.C
Switch on QA, as it seems it is not run by default anymore
[u/mrichter/AliRoot.git] / ITS / MakeITSResMisAlignment.C
index e0c2532807b1de17f790852f9325d78d51e68f36..b0cf2da0eb46d27d1668ebd87ca1de4358519fa4 100644 (file)
-void MakeITSResMisAlignment(){
-  // Create TClonesArray of residual misalignment objects for ITS
-  //
-  TClonesArray *array = new TClonesArray("AliAlignObjParams",4000);
-  TClonesArray &alobj = *array;
-   
-  if(!AliGeomManager::GetGeometry()){
-    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-      AliCDBManager::Instance()->SetRun(0);
-    AliGeomManager::LoadGeometry();
-  }
-  // needed for the constructors with local coordinates not to fail
-
-  Double_t globalZ = 0.005; // in cm, = 50 microns
-  Double_t resFact = 0.7;
-  Double_t spdXY   = 0.0015*resFact;
-  Double_t sddXYZ  = 0.0030*resFact;
-  Double_t ssdXY   = 0.0020*resFact;
-  Double_t rot     = 0.018;
-  Double_t spdZ    = 0.002;
-  Double_t ssdZ    = 0.010;
-
-  TRandom *rnd   = new TRandom(65416087);
-  AliAlignObjParams a;
-
-  Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
-  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; 
-
-  Int_t j = 0;
-
-  new(alobj[j++]) AliAlignObjParams("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
-  AliAlignObjParams* its_alobj = (AliAlignObjParams*) array->UncheckedAt(0);
-  its_alobj->ApplyToGeometry();
-
-
-  for ( Int_t l = AliGeomManager::kSPD1; l <= AliGeomManager::kSSD2; l++) {
-    
-    printf("%i modules in layer %i\n", AliGeomManager::LayerSize(l), l);
-    for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(l); iModule++) {
-
-      dpsi   = rnd->Gaus(0., rot);
-      dtheta = rnd->Gaus(0., rot);
-      dphi   = rnd->Gaus(0., rot);
-
-      iLayer = AliGeomManager::kInvalidLayer; 
-
-      switch (l) {
-      case 1: {
-       iLayer = AliGeomManager::kSPD1;
-       dx = rnd->Gaus(0., spdXY);
-       dy = rnd->Gaus(0., spdXY);
-       dz = rnd->Gaus(0., spdZ);
-      }; break;
-      case 2: {
-       iLayer = AliGeomManager::kSPD2;
-       dx = rnd->Gaus(0., spdXY);
-       dy = rnd->Gaus(0., spdXY);
-       dz = rnd->Gaus(0., spdZ);
-      }; break;
-      case 3: {
-       iLayer = AliGeomManager::kSDD1;
-       dx = rnd->Gaus(0., sddXYZ);
-       dy = rnd->Gaus(0., sddXYZ);
-       dz = rnd->Gaus(0., sddXYZ);
-      }; break;
-      case 4: {
-       iLayer = AliGeomManager::kSDD2;
-       dx = rnd->Gaus(0., sddXYZ);
-       dy = rnd->Gaus(0., sddXYZ);
-       dz = rnd->Gaus(0., sddXYZ);
-      }; break;
-      case 5: {
-       iLayer = AliGeomManager::kSSD1;
-       dx = rnd->Gaus(0., ssdXY);
-       dy = rnd->Gaus(0., ssdXY);
-       dz = rnd->Gaus(0., ssdZ);
-      }; break;
-      case 6: {
-       iLayer = AliGeomManager::kSSD2;
-       dx = rnd->Gaus(0., ssdXY);
-       dy = rnd->Gaus(0., ssdXY);
-       dz = rnd->Gaus(0., ssdZ);
-      }; break;
-      default: Printf("Wrong layer index in ITS (%d) !",l);
-      };
-      UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
-      const char *symname = AliGeomManager::SymName(volid);
-
-      new(alobj[j]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
-      j++;
+void MakeITSResMisAlignment() {
+//========================================================================
+//
+// Steering macro for ITS residual (realistic) misalignment
+//
+// Main author: L. Gaudichet
+// Contact: andrea.dainese@lnl.infn.it
+//
+//========================================================================
 
-    }
-  }
 
   const char* macroname = "MakeITSResMisAlignment.C";
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+
+  // Activate CDB storage and load geometry from CDB
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+  cdb->SetRun(0);
+  
+  AliCDBStorage* storage = NULL;
+
+  if(TString(gSystem->Getenv("TOCDB")) == TString("kTRUE")){
+    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;
+    }
+    storage = cdb->GetStorage(Storage.Data());
+    if(!storage){
+      Error(macroname,"Unable to open storage %s\n",Storage.Data());
+      return;
+    }
+    AliCDBPath path("GRP","Geometry","Data");
+    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
+    if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
+    entry->SetOwner(0);
+    TGeoManager* geom = (TGeoManager*) entry->GetObject();
+    AliGeomManager::SetGeometry(geom);
+  }else{
+    AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage
+  }    
+
+  //   SETTINGS:
+  //   - tranformations are defined by the "maximum transformation" 
+  //     dx,dy,dz,dpsi,dtheta,dphi: then we take a Gaussian with sigma=dx/3
+  //     and we cut it at +- 3*sigma = dx 
+  //     (the option "unif" allows to sample from a uniform distr.)
+  //   - units are cm and deg
+  //   - transformations are defined in the local frame of the volume
+  //     being misaligned
+  //
+  const Float_t kRadToDeg = 180./TMath::Pi();
+
+
+  //=****************************************
+  // overall ITS misalignment :              source - 
+  //=****************************************
+  Float_t its_dx     = 0.0000;   // ?
+  Float_t its_dy     = 0.0000;    // ?
+  Float_t its_dz     = 0.0000;    // ?
+  Float_t its_dpsi   = 0.0000;   // ?
+  Float_t its_dtheta = 0.0000;  // ?
+  Float_t its_dphi   = 0.0000;   // ?
+
+  //=****************************************
+  // misalignment at the level of SPD sectors : source - A.Pepato
+  //=****************************************
+  Float_t spdsector_dx     = 0.0050/5.; //  50 micron (~tangetial, i.e. rphi) 
+  Float_t spdsector_dy     = 0.0100/5.; // 100 micron (~radial)
+  Float_t spdsector_dz     = 0.0100/5.; // 100 micron
+  Float_t spdsector_dpsi   = 0.0100/30.*kRadToDeg/5.; // so as to have 100 micron difference at the two extremes
+  Float_t spdsector_dtheta = 0.0100/30.*kRadToDeg/5.; // so as to have 100 micron difference at the two extremes
+  Float_t spdsector_dphi   = 0.0050/1.5*kRadToDeg/5.; // so as to have 50 micron difference at the two extremes
+  Bool_t unifspdsector=kFALSE;
+
+  //=****************************************
+  // misalignment at the level of SPD half-barrels : source - A.Pepato
+  //=****************************************
+  Float_t spdhalfbarrel_dx     = 0.000; // 200 micron  
+  Float_t spdhalfbarrel_dy     = 0.000; // 200 micron 
+  Float_t spdhalfbarrel_dz     = 0.000; // 200 micron
+  Float_t spdhalfbarrel_dpsi   = 0.000/30.*kRadToDeg; // so as to have 100 micron difference at the two extremes
+  Float_t spdhalfbarrel_dtheta = 0.000/30.*kRadToDeg; // so as to have 100 micron difference at the two extremes
+  Float_t spdhalfbarrel_dphi   = 0.000/7.*kRadToDeg; // so as to have 100 micron difference at the two extremes
+
+  //=****************************************
+  // misalignment at the level of SPD barrel : source - A.Pepato
+  //=****************************************
+  Float_t spdbarrel_dx     = 0.000; // 1 mm (very pessimistic)  
+  Float_t spdbarrel_dy     = 0.000; // 1 mm (very pessimistic)
+  Float_t spdbarrel_dz     = 0.000; // 1 mm (very pessimistic)
+  Float_t spdbarrel_dpsi   = 0.000/30.*kRadToDeg; // so as to have 500 micron difference at the two extremes
+  Float_t spdbarrel_dtheta = 0.000/30.*kRadToDeg; // so as to have 500 micron difference at the two extremes
+  Float_t spdbarrel_dphi   = 0.000/7.*kRadToDeg; // so as to have 500 micron difference at the two extremes
+  
+
+  //=****************************************
+  // misalignment at the level of SDD and SSD layers: source
+  //=****************************************
+  Float_t sddlayer_dx     = 0.0000; 
+  Float_t sddlayer_dy     = 0.0000; 
+  Float_t sddlayer_dz     = 0.0000; 
+  Float_t sddlayer_dpsi   = 0.0000;
+  Float_t sddlayer_dtheta = 0.0000; 
+  Float_t sddlayer_dphi   = 0.0000;
+
+  Float_t ssdlayer_dx     = 0.0000;
+  Float_t ssdlayer_dy     = 0.0000;
+  Float_t ssdlayer_dz     = 0.0000;
+  Float_t ssdlayer_dpsi   = 0.0000;
+  Float_t ssdlayer_dtheta = 0.0000;
+  Float_t ssdlayer_dphi   = 0.0000;
+  
+
+  //=****************************************
+  // misalignment at the level of half-staves (SPD) : source - S.Moretto
+  //                              ladders (SDD,SSD) : source -
+  //=****************************************
+  Float_t spdhalfstave_dx     = 0.0100/4.; // 100 micron  
+  Float_t spdhalfstave_dy     = 0.0020/4.; // 20 micron 
+  Float_t spdhalfstave_dz     = 0.0020/4.; // 20 micron
+  Float_t spdhalfstave_dpsi   = 0.0020/7.*kRadToDeg/4.; // so as to have 20 micron difference at the two extremes
+  Float_t spdhalfstave_dtheta = 0.0050/7.*kRadToDeg/4.; // so as to have 50 micron difference at the two extremes
+  Float_t spdhalfstave_dphi   = 0.0050/0.7*kRadToDeg/4.; // so as to have 50 micron difference at the two extremes
+  Bool_t unifspdhalfstave=kFALSE;
+
+  Float_t sddladder_dx     = 0.0005; // 5 micron  
+  Float_t sddladder_dy     = 0.0005; // 5 micron 
+  Float_t sddladder_dz     = 0.0005; // 5 micron
+  Float_t sddladder_dpsi   = 0.00; //  ?
+  Float_t sddladder_dtheta = 0.00; //  ?
+  Float_t sddladder_dphi   = 0.00; //  ?
+
+  Float_t ssdladder_dx     = 0.0005; // 5 micron  
+  Float_t ssdladder_dy     = 0.0005; // 5 micron 
+  Float_t ssdladder_dz     = 0.0005; // 5 micron
+  Float_t ssdladder_dpsi   = 0.00; //  ?
+  Float_t ssdladder_dtheta = 0.00; //  ?
+  Float_t ssdladder_dphi   = 0.00; //  ?
+
+
+  //=****************************************
+  // misalignment at the level of ladders (SPD) : source - R.Santoro
+  //                              modules (SDD) : source - L.Gaudichet
+  //                              modules (SSD) : source - 
+  //=****************************************
+  Float_t spdladder_dx     = 0.0010/5.; // 10 micron  
+  Float_t spdladder_dy     = 0.0050/5.; // 50 micron 
+  Float_t spdladder_dz     = 0.0010/5.; // 10 micron
+  Float_t spdladder_dpsi   = 0.0001*kRadToDeg/5.; // 0.1 mrad
+  Float_t spdladder_dtheta = 0.0001*kRadToDeg/5.; // 0.1 mrad
+  Float_t spdladder_dphi   = 0.0001*kRadToDeg/5.; // 0.1 mrad
+
+  Float_t sddmodule_dx     = 0.0045/5.; // 45 micron  
+  Float_t sddmodule_dy     = 0.0045/5.; // 45 micron 
+  Float_t sddmodule_dz     = 0.0105/5.; // 105 micron
+  Float_t sddmodule_dpsi   = 0.00; // ?
+  Float_t sddmodule_dtheta = 0.00; //  ?
+  Float_t sddmodule_dphi   = 0.00; //  ?
+
+  Float_t ssdmodule_dx     = 0.0050/5.; // 50 micron  
+  Float_t ssdmodule_dy     = 0.0050/5.; // 50 micron 
+  Float_t ssdmodule_dz     = 0.0050/5.; // 50 micron
+  Float_t ssdmodule_dpsi   = 0.00; // ?
+  Float_t ssdmodule_dtheta = 0.00; //  ?
+  Float_t ssdmodule_dphi   = 0.00; //  ?
+  //
+  // END SETTINGS
+
+
+  AliITSMisalignMaker alignMaker;
+
+  //=****************************************
+  // overall ITS misalignment :
+  //=****************************************
+
+  alignMaker.AddAlignObj("ITS",its_dx,its_dy,its_dz,its_dpsi,its_dtheta,its_dphi,kFALSE);
+
+
+  //=****************************************
+  // misalignment at the level of SPD barrel, half-barrels, and at the level
+  // of SPD sectors
+  //=****************************************
+
+  Double_t vx,vy,vz,vpsi,vtheta,vphi;
+  Double_t vxbarrel,vybarrel,vzbarrel,vpsibarrel,vthetabarrel,vphibarrel;
+
+  //   barrel
+  vxbarrel = alignMaker.GaussCut(0,spdbarrel_dx/3,spdbarrel_dx);
+  vybarrel = alignMaker.GaussCut(0,spdbarrel_dy/3,spdbarrel_dy);
+  vzbarrel = alignMaker.GaussCut(0,spdbarrel_dz/3,spdbarrel_dz);
+  vpsibarrel = alignMaker.GaussCut(0,spdbarrel_dpsi/3,spdbarrel_dpsi);
+  vthetabarrel = alignMaker.GaussCut(0,spdbarrel_dtheta/3,spdbarrel_dtheta);
+  vphibarrel = alignMaker.GaussCut(0,spdbarrel_dphi/3,spdbarrel_dphi);
+
+  //  top half-barrel
+  vx = alignMaker.GaussCut(0,spdhalfbarrel_dx/3,spdhalfbarrel_dx);
+  vy = alignMaker.GaussCut(0,spdhalfbarrel_dy/3,spdhalfbarrel_dy);
+  vz = alignMaker.GaussCut(0,spdhalfbarrel_dz/3,spdhalfbarrel_dz);
+  vpsi = alignMaker.GaussCut(0,spdhalfbarrel_dpsi/3,spdhalfbarrel_dpsi);
+  vtheta = alignMaker.GaussCut(0,spdhalfbarrel_dtheta/3,spdhalfbarrel_dtheta);
+  vphi = alignMaker.GaussCut(0,spdhalfbarrel_dphi/3,spdhalfbarrel_dphi);
+
+  vx += vxbarrel;
+  vy += vybarrel;
+  vz += vzbarrel;
+  vpsi += vpsibarrel;
+  vtheta += vthetabarrel;
+  vphi += vphibarrel;
+
+  alignMaker.AddSectorAlignObj(1,5,spdsector_dx,spdsector_dy,spdsector_dz,
+                              spdsector_dpsi,spdsector_dtheta,spdsector_dphi,
+                              vx,vy,vz,vpsi,vtheta,vphi,unifspdsector);
+
+  //  bottom half-barrel
+  vx = alignMaker.GaussCut(0,spdhalfbarrel_dx/3,spdhalfbarrel_dx);
+  vy = alignMaker.GaussCut(0,spdhalfbarrel_dy/3,spdhalfbarrel_dy);
+  vz = alignMaker.GaussCut(0,spdhalfbarrel_dz/3,spdhalfbarrel_dz);
+  vpsi = alignMaker.GaussCut(0,spdhalfbarrel_dpsi/3,spdhalfbarrel_dpsi);
+  vtheta = alignMaker.GaussCut(0,spdhalfbarrel_dtheta/3,spdhalfbarrel_dtheta);
+  vphi = alignMaker.GaussCut(0,spdhalfbarrel_dphi/3,spdhalfbarrel_dphi);
+
+  vx += vxbarrel;
+  vy += vybarrel;
+  vz += vzbarrel;
+  vpsi += vpsibarrel;
+  vtheta += vthetabarrel;
+  vphi += vphibarrel;
+
+  alignMaker.AddSectorAlignObj(6,10,spdsector_dx,spdsector_dy,spdsector_dz,
+                              spdsector_dpsi,spdsector_dtheta,spdsector_dphi,
+                              vx,vy,vz,vpsi,vtheta,vphi,unifspdsector);
+
+
+  //=****************************************
+  // misalignment at the level of half-staves (SPD)/ladders (SDD,SSD) :
+  //=****************************************
+
+  alignMaker.AddAlignObj(0,-1,spdhalfstave_dx,spdhalfstave_dy,spdhalfstave_dz,spdhalfstave_dpsi,spdhalfstave_dtheta,spdhalfstave_dphi,0,0,0,0,0,0,unifspdhalfstave); // all SPD1 half-staves
+  alignMaker.AddAlignObj(1,-1,spdhalfstave_dx,spdhalfstave_dy,spdhalfstave_dz,spdhalfstave_dpsi,spdhalfstave_dtheta,spdhalfstave_dphi,0,0,0,0,0,0,unifspdhalfstave); // all SPD2 half-staves
+
+  alignMaker.AddAlignObj(2,-1,sddladder_dx,sddladder_dy,sddladder_dz,sddladder_dpsi,sddladder_dtheta,sddladder_dphi,0,0,0,0,0,0,kFALSE); // all SDD1 ladders
+  alignMaker.AddAlignObj(3,-1,sddladder_dx,sddladder_dy,sddladder_dz,sddladder_dpsi,sddladder_dtheta,sddladder_dphi,0,0,0,0,0,0,kFALSE); // all SDD2 ladders
+
+  alignMaker.AddAlignObj(4,-1,ssdladder_dx,ssdladder_dy,ssdladder_dz,ssdladder_dpsi,ssdladder_dtheta,ssdladder_dphi,0,0,0,0,0,0,kFALSE); // all SSD1 ladders
+  alignMaker.AddAlignObj(5,-1,ssdladder_dx,ssdladder_dy,ssdladder_dz,ssdladder_dpsi,ssdladder_dtheta,ssdladder_dphi,0,0,0,0,0,0,kFALSE); // all SSD2 ladders
+
+  //=****************************************
+  // misalignment at the level of ladders (SPD)/modules (SDD,SSD) :
+  //=****************************************
+
+  alignMaker.AddAlignObj(0,spdladder_dx,spdladder_dy,spdladder_dz,spdladder_dpsi,spdladder_dtheta,spdladder_dphi,kFALSE); // all SPD1 ladders
+  alignMaker.AddAlignObj(1,spdladder_dx,spdladder_dy,spdladder_dz,spdladder_dpsi,spdladder_dtheta,spdladder_dphi,kFALSE); // all SPD2 ladders
+
+  alignMaker.AddAlignObj(2,sddmodule_dx,sddmodule_dy,sddmodule_dz,sddmodule_dpsi,sddmodule_dtheta,sddmodule_dphi,kFALSE); // all SDD1 modules
+  alignMaker.AddAlignObj(3,sddmodule_dx,sddmodule_dy,sddmodule_dz,sddmodule_dpsi,sddmodule_dtheta,sddmodule_dphi,kFALSE); // all SDD2 modules
+
+  alignMaker.AddAlignObj(4,ssdmodule_dx,ssdmodule_dy,ssdmodule_dz,ssdmodule_dpsi,ssdmodule_dtheta,ssdmodule_dphi,kFALSE); // all SSD1 modules
+  alignMaker.AddAlignObj(5,ssdmodule_dx,ssdmodule_dy,ssdmodule_dz,ssdmodule_dpsi,ssdmodule_dtheta,ssdmodule_dphi,kFALSE); // all SSD2 modules
+
+
+
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
     const char* filename = "ITSresidualMisalignment.root";
     TFile f(filename,"RECREATE");
-    if(!f){
+    if(!f.IsOpen()){
       Error(macroname,"cannot open file for output\n");
       return;
     }
-    Info(macroname,"Saving alignment objects to the file %s", filename);
+    Info(macroname,"Saving alignment objects to the file %s",filename);
     f.cd();
-    f.WriteObject(array,"ITSAlignObjs","kSingleKey");
+    f.WriteObject(alignMaker.GetArray(),"ITSAlignObjs","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());
-    AliCDBManager* cdb = AliCDBManager::Instance();
-    AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
-    if(!storage){
-      Error(macroname,"Unable to open storage %s\n",Storage.Data());
-      return;
-    }
     AliCDBMetaData *md= new AliCDBMetaData();
-    md->SetResponsible("Ludovic Gaudichet");
-    md->SetComment("Alignment objects with actual ITS misalignment");
+    md->SetResponsible("Andrea Dainese");
+    md->SetComment("Alignment objects with residual ITS misalignment");
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
     AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
-    storage->Put(array,id, md);
+    storage->Put(alignMaker.GetArray(),id,md);
   }
 
-  array->Delete();
 
+  return;
 }
-
-