]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/MakeTRDFullMisAlignment.C
running local for SP and LYZEP and new histograms for QC
[u/mrichter/AliRoot.git] / TRD / MakeTRDFullMisAlignment.C
index d60f2928926db7ecccac2180b129745ca28649e5..dd8ed5a6827e363f60f28d908423965cc3ee6e17 100644 (file)
@@ -11,9 +11,10 @@ void MakeTRDFullMisAlignment(){
   cdb->SetRun(0);
   
   AliCDBStorage* storage;
+  TString Storage;
   
-  if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
-    TString Storage = gSystem->Getenv("STORAGE");
+  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
+    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;
@@ -35,107 +36,106 @@ void MakeTRDFullMisAlignment(){
                  
   // load FRAME full misalignment objects (if needed, the macro
   // for FRAME has to be ran in advance) and apply them to geometry
-  Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
-      Storage.Data());
   AliCDBPath fpath("GRP","Align","Data");
-  if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
-    AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun());
-    if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
-    TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
-    arFrame->Sort();
-    Int_t nvols = arFrame->GetEntriesFast();
-    Bool_t flag = kTRUE;
-    for(Int_t j=0; j<nvols; j++)
-      {
-       AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
-       if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
-      }
-    if(!flag)
-      Fatal(macroname,"Error in the application of FRAME objects");
+  AliCDBEntry *eFrame;
+  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
+    Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
+      Storage.Data());
+    eFrame = storage->Get(fpath.GetPath(),cdb->GetRun());
   }else{
-    AliCDBEntry *eFrame = cdb->Get(fpath.GetPath());
-    if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
-    TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
-    arFrame->Sort();
-    Int_t nvols = arFrame->GetEntriesFast();
-    Bool_t flag = kTRUE;
-    for(Int_t j=0; j<nvols; j++)
-      {
-       AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
-       if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
-      }
-    if(!flag)
-      Fatal(macroname,"Error in the application of FRAME objects");
+    eFrame = cdb->Get(fpath.GetPath());
   }
+  if(!eFrame) Fatal(macroname,"Could not get the specified CDB entry!");
+  TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
+  arFrame->Sort();
+  Int_t nvols = arFrame->GetEntriesFast();
+  Bool_t flag = kTRUE;
+  for(Int_t j=0; j<nvols; j++)
+  {
+    AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
+    if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
+  }
+  if(!flag) Fatal(macroname,"Error in the application of FRAME objects");
 
-   
-  // sigmas for the supermodules
-  Double_t smdx=0.3; // 3 mm
-  Double_t smdy=0.3; // 3 mm
-  Double_t smdz=0.3; // 3 mm
-  Double_t smrx=0.4/1000/TMath::Pi()*180; // 0.4 mrad
-  Double_t smry=2.0/1000/TMath::Pi()*180; // 2 mrad
-  Double_t smrz=0.4/1000/TMath::Pi()*180; // 0.4 mrad
-
+  // Sigmas for the chambers
+  Double_t smdx    = 0.3; // 3 mm
+  Double_t smdy    = 0.3; // 3 mm
+  Double_t smdz    = 0.3; // 3 mm
+  Double_t smrx    = 0.4 / 1000.0 / TMath::Pi()*180; // 0.4 mrad
+  Double_t smry    = 2.0 / 1000.0 / TMath::Pi()*180; // 2.0 mrad
+  Double_t smrz    = 0.4 / 1000.0 / TMath::Pi()*180; // 0.4 mrad
+  // Truncation for the chambers
+  Double_t cutSmdx = 3.0 * smdx;
+  Double_t cutSmdy = 3.0 * smdy;
+  Double_t cutSmdz = 3.0 * smdz;
 
-  // sigmas for the chambers
-  Double_t chdx=0.1; // 1 mm
-  Double_t chdy=0.1; // 1 mm
-  Double_t chdz=0.1; // 1 mm
-  Double_t chrx=1.0/1000/TMath::Pi()*180; // 1 mrad
-  Double_t chry=1.0/1000/TMath::Pi()*180; // 1 mrad
-  Double_t chrz=0.7/1000/TMath::Pi()*180; // 0.7 mrad
+  // Sigmas for the chambers
+  Double_t chdx    = 0.05;  // 0.5 mm
+  Double_t chdy    = 0.1;   // 1.0 mm
+  Double_t chdz    = 0.007; // 70  microns
+  Double_t chrx    = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad
+  Double_t chry    = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad
+  Double_t chrz    = 0.3    / 1000.0 / TMath::Pi()*180; // 0.3 mrad
+  // Truncation for the chambers
+  Double_t cutChdx = 1.0  * chdx;
+  Double_t cutChdy = 1.0  * chdy;
+  Double_t cutChdz = 0.14 * chdz;
 
+  Int_t sActive[18]={1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1};
   Double_t dx,dy,dz,rx,ry,rz;
 
   Int_t j=0;
-  TRandom *ran = new TRandom(4357);
   UShort_t volid;
   const char *symname;
 
   // create the supermodules' alignment objects
-  for (int i; i<18; i++) {
-    TString sm_symname(Form("TRD/sm%02d",i));
-    ran->Rannor(dx,rx);
-    ran->Rannor(dy,ry);
-    ran->Rannor(dz,rz);
-    dx*=smdx;
-    dy*=smdy;
-    dz*=smdz;
-    rx*=smrx;
-    ry*=smry;
-    rz*=smrz;
+  for (int iSect; iSect<18; iSect++) {
+    TString sm_symname(Form("TRD/sm%02d",iSect));
+    dx = AliMathBase::TruncatedGaus(0.0,smdx,cutSmdx); 
+    dy = AliMathBase::TruncatedGaus(0.0,smdy,cutSmdy); 
+    dz = AliMathBase::TruncatedGaus(0.0,smdz,cutSmdz); 
+    rx = gRandom->Rndm() * 2.0*smrx - smrx;
+    ry = gRandom->Rndm() * 2.0*smry - smry;
+    rz = gRandom->Rndm() * 2.0*smrz - smrz;
+    if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue;
     new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
   }
-
-  for(Int_t k=0; k<18; k++){
-    AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(k);
+  // apply supermodules' alignment objects
+  Int_t smCounter=0;
+  for(Int_t iSect=0; iSect<18; iSect++){
+    if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue;
+    AliAlignObjParams* smobj =
+      (AliAlignObjParams*)array->UncheckedAt(smCounter++);
     if(!smobj->ApplyToGeometry()){
-      cout<<"application of object "<<k<<" failed!"<<endl;
+      Fatal(macroname,Form("application of full misalignment object for sector %d failed!",iSect));
       return;
     }
   }
 
   // create the chambers' alignment objects
   ran = new TRandom(4357);
+  Int_t chId;
   for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
-    for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
-      ran->Rannor(dx,rx);
-      ran->Rannor(dy,ry);
-      ran->Rannor(dz,rz);
-      dx*=chdx;
-      dy*=chdy;
-      dz*=chdz;
-      rx*=chrx;
-      ry*=chry;
-      rz*=chrz;
-      volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
-      symname = AliGeomManager::SymName(volid);
-      new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
+    chId=-1;
+    for (Int_t iSect = 0; iSect < 18; iSect++){
+      for (Int_t iCh = 0; iCh < 5; iCh++) {
+        dx = AliMathBase::TruncatedGaus(0.0,chdx,cutChdx); 
+        dy = AliMathBase::TruncatedGaus(0.0,chdy,cutChdy); 
+        dz = AliMathBase::TruncatedGaus(0.0,chdz,cutChdz); 
+        rx = gRandom->Rndm() * 2.0*chrx - chrx;
+        ry = gRandom->Rndm() * 2.0*chry - chry;
+        rz = gRandom->Rndm() * 2.0*chrz - chrz;
+        chId++;
+        if ((iSect==13 || iSect==14 || iSect==15) && iCh==2) continue;
+        volid = AliGeomManager::LayerToVolUID(iLayer,chId);
+        if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue;
+        symname = AliGeomManager::SymName(volid);
+        new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
+      }
     }
   }
 
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
     const char* filename = "TRDfullMisalignment.root";
     TFile f(filename,"RECREATE");
@@ -162,4 +162,3 @@ void MakeTRDFullMisAlignment(){
   array->Delete();
 }
 
-