X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FMakeTOFFullMisAlignment.C;h=7fbeafaeca40fdde26103fb977401233248db468;hb=e9f92e043d889c1fb4579af209d407afb2b4e5ac;hp=02bddee17e59e2295e69112261c2f821009933d2;hpb=3b2d5e3b77f9d3dc84ff8842e5222dcf71faa16e;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/MakeTOFFullMisAlignment.C b/TOF/MakeTOFFullMisAlignment.C index 02bddee17e5..7fbeafaeca4 100644 --- a/TOF/MakeTOFFullMisAlignment.C +++ b/TOF/MakeTOFFullMisAlignment.C @@ -1,179 +1,177 @@ -void MakeTOFFullMisAlignment(){ +void MakeTOFFullMisAlignment() { + // // Create TClonesArray of full misalignment objects for TOF + // Expects to read objects for FRAME // - TClonesArray *array = new TClonesArray("AliAlignObjAngles",2000); - TClonesArray &alobj = *array; - - if(!gGeoManager) TGeoManager::Import("/home/rgrosso/Prove/AliRoot/geometry.root"); - - AliAlignObjAngles a; - Double_t sfdpsi=0.,sfdtheta=0.,sfdphi=0.; - Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT - AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer; - UShort_t dvoluid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy vol id - - // FRAME part !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - const char* basepath ="ALIC_1/B077_1/BSEGMO"; - TString segmpath; - - // for dead weight !!!! carefull: in mm - ifstream dw_file("/home/rgrosso/MacroAllineamento010207/disp_deadweight.txt", ios::in); - if(!dw_file) {cerr<<"cannot open dead weight file for input\n"; return;} - TArrayD dwdx(36); - TArrayD dwdy(36); - TArrayD dwdz(36); - TArrayD dwdrot(36); - // for additional load - ifstream orig_file("/home/rgrosso/MacroAllineamento010207/disp_full.txt", ios::in); -// ifstream orig_file("disp_full_nohmpid.txt", ios::in); - if(!orig_file) {cerr<<"cannot open file for input\n"; return;} - TArrayD adx(36); - TArrayD ady(36); - TArrayD adz(36); - TArrayD adrot(36); - // avarage displacements - Double_t mean_dx[18]; - Double_t mean_dy[18]; - Double_t idx[18]; - Double_t idy[18]; - Double_t newx[18]; - Double_t newy[18]; - - string buffer; - Int_t point; - Double_t dx,dy,dz,drot; - - // fill in from file the array for dead weight deformations - dw_file>>point>>dx>>dy>>dz>>drot; - dwdx.AddAt(dx,point-1);dwdy.AddAt(dy,point-1);dwdz.AddAt(dz,point-1);dwdrot.AddAt(drot,point-1); - while(getline(dw_file,buffer)) - { - dw_file>>point>>dx>>dy>>dz>>drot; - dwdx.AddAt(dx,point-1);dwdy.AddAt(dy,point-1);dwdz.AddAt(dz,point-1);dwdrot.AddAt(drot,point-1); - } - // fill in from file the array for remaining load deformations - orig_file>>point>>dx>>dy>>dz>>drot; - adx.AddAt(dx,point-1);ady.AddAt(dy,point-1);adz.AddAt(dz,point-1);adrot.AddAt(drot,point-1); - while(getline(orig_file,buffer)) - { - orig_file>>point>>dx>>dy>>dz>>drot; - adx.AddAt(dx,point-1);ady.AddAt(dy,point-1);adz.AddAt(dz,point-1);adrot.AddAt(drot,point-1); - } + const char* macroname = "MakeTOFFullMisAlignment.C"; - //calculate the displacement of the center of the sm neglecting rotations, - //thus as average of the four surrounding point for dw + other load - // Prepare also to plot with respect to ideal circle. - Double_t cx=0.5; //just for plotting - Double_t cy=0.5; - Double_t rr=0.3; - Double_t kk = TMath::Pi()*20./180.; - Double_t scale = 100./4000.; - TPolyMarker* iddu = new TPolyMarker(18,newx,newy); - TPolyMarker* disp = new TPolyMarker(18,newx,newy); - - Int_t sm,outc,outclw; //outer number counterclock and clockwise - for(sm=0; sm<18; sm++){ - outc=5-sm; - if(outc<1) outc+=18; - outclw=outc-1; - if(outclw<1) outclw+=18; - mean_dx[sm]=0.125*(adx[outc-1]+adx[outclw-1]+adx[outc+18-1]+adx[outclw+18-1]+dwdx[outc-1]+dwdx[outclw-1]+dwdx[outc+18-1]+dwdx[outclw+18-1]); - mean_dy[sm]=0.125*(ady[outc-1]+ady[outclw-1]+ady[outc+18-1]+ady[outclw+18-1]+dwdy[outc-1]+dwdy[outclw-1]+dwdy[outc+18-1]+dwdy[outclw+18-1]); - idx[sm]=cx+rr*TMath::Sin(sm*kk); - idy[sm]=cy+rr*TMath::Cos(sm*kk); - newx[sm]=idx[sm]+scale*mean_dx[sm]; - newy[sm]=idy[sm]+scale*mean_dy[sm]; - iddu->SetPoint(sm,idx[sm],idy[sm]); - disp->SetPoint(sm,newx[sm],newy[sm]); - - segmpath=basepath; - segmpath+=sm; - segmpath+="_1"; - cout<UncheckedAt(k); - if(!smobj->ApplyToGeometry()){ - cout<<"application of object "<IsDefaultStorageSet()) + cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + cdb->SetRun(0); + + AliCDBStorage* storage; + TString 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; } + 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(); //load geom from default CDB storage + + // load FRAME full misalignment objects (if needed, the macro + // for FRAME has to be run in advance) and apply them to geometry + AliCDBPath fpath("GRP","Align","Data"); + if ( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ) { + Info(macroname,"Loading FRAME alignment objects from CDB storage %s", + Storage.Data()); + AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun()); + } else + AliCDBEntry *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; jUncheckedAt(j); + if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE; } - gGeoManager->Export("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO.root"); - gGeoManager=0x0; - TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO.root"); + if (!flag) + Fatal(macroname,"Error in the application of FRAME alignment objects"); + + //Produce objects for TOF supermodules + Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT + AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; + UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id - // TOF part !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Int_t nSMTOF = 18; - Int_t i; - Int_t j=18; - Double_t tofdx, tofdy, tofdz, dpsi, dtheta, dphi; + Int_t j=0; + Double_t smdx, smdy, smdz=0., dpsi=0., dtheta, dphi=0.; TRandom *rnd = new TRandom(2345); Double_t sigmatr = 0.4; // max shift in cm w.r.t. local ideal RS Double_t sigmarot = 0.06; // max rot in deg w.r.t. local ideal RS (~ 1 mrad) - for(i=0; i<18; i++) { - TString symname(Form("TOF/sm%02d",i)); - tofdx = rnd->Gaus(0.,sigmatr); - tofdy = rnd->Gaus(0.,sigmatr); - tofdz =0; - dpsi = 0.; + for (Int_t isect=0; isectGaus(0.,sigmatr); + smdy = rnd->Gaus(0.,sigmatr); dtheta = rnd->Gaus(0.,sigmarot); - dphi = 0.; - new(alobj[j++]) AliAlignObjAngles(symname.Data(), dvoluid, tofdx, tofdy, tofdz, dpsi, dtheta, dphi, kFALSE); + new((*array)[j++]) AliAlignObjParams(symname.Data(), + dvoluid, + smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE); } - for(Int_t k=18; k<36; k++){ - AliAlignObjAngles* smobj = (AliAlignObjAngles*)array->UncheckedAt(k); - if(!smobj->ApplyToGeometry()){ - cout<<"application of object "<Export("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_tofSM.root"); + // Apply objects for TOF supermodules + Int_t smCounter=0; + for (Int_t isect=0; isectUncheckedAt(smCounter++); + //Info(macroname,Form("Applying object for sector %d ",isect)); + if ( !smobj->ApplyToGeometry() ) + Fatal(macroname,Form("application of full misalignment object for sector %d failed!",isect)); + } - gGeoManager=0x0; - TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_tofSM.root"); - // tof strips as in residual - AliAlignObj::ELayerID idTOF = AliAlignObj::kTOF; + //Produce objects for TOF strips (same sigmas as for residual misalignment) + AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF; + Int_t strId=-1; - Double_t sdx=0.; - Double_t sdy=0.; - Double_t sdz=0.; - Double_t sdpsi, sdtheta, sdphi; - TRandom *rnds = new TRandom(4357); + Double_t sdx=0., sdy=0., sdz=0., sdpsi=0., sdtheta=0., sdphi=0.; + //TRandom *rnds = new TRandom(4357); sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS - for(i=0; iGaus(0.,sigmatr); - sdz = rnds->Gaus(0.,sigmatr); - sdpsi = 0.; - sdtheta = 0.; - sdphi = 0.; - new(alobj[j++]) AliAlignObjAngles(AliAlignObj::SymName(idTOF,i), AliAlignObj::LayerToVolUID(idTOF,i), sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE); + Int_t nstrA=15; + Int_t nstrB=19; + Int_t nstrC=19; + Int_t nSectors=18; + Int_t nStrips=nstrA+2*nstrB+2*nstrC; + Double_t cuty=0., cutz=0., cut=3*sigmatr; + + for (Int_t isect = 0; isect < nSectors; isect++) { + for (Int_t istr = 1; istr <= nStrips; istr++) { + switch (istr) { + case 25: + case 29: + case 63: + case 67: + cuty = sigmatr*0.6; + sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty); + sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut); + strId++; + break; + /* + case 38: + cuty = sigmatr*2.5; + cutz = sigmatr*2.5; + sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty); + sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut, cutz); + strId++; + break; + case 54: + cuty = sigmatr*2.5; + cutz = sigmatr*2.5; + sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty); + sdz = AliMathBase::TruncatedGaus(0., sigmatr, cutz, cut); + strId++; + break; + */ + default: + sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut); + sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut); + strId++; + break; + } + + if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; + new((*array)[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId), + AliGeomManager::LayerToVolUID(idTOF,strId), + sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE); + } } - if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){ - // save on file - TFile f("TOFfullMisalignment.root","RECREATE"); - if(!f) cerr<<"cannot open file for output\n"; + if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) { + // save in file + const char* filename = "TOFfullMisalignment.root"; + TFile f(filename,"RECREATE"); + if(!f){ + Error(macroname,"cannot open file for output\n"); + return; + } + Info(macroname,"Saving alignment objects in file %s", filename); f.cd(); f.WriteObject(array,"TOFAlignObjs","kSingleKey"); f.Close(); - }else{ + } else { // save in CDB storage - const char* Storage = gSystem->Getenv("STORAGE"); - AliCDBManager* cdb = AliCDBManager::Instance(); - AliCDBStorage* storage = cdb->GetStorage(Storage); + Info(macroname,"Saving alignment objects in CDB storage %s", + Storage.Data()); AliCDBMetaData* md = new AliCDBMetaData(); md->SetResponsible("Silvia Arcelli"); - md->SetComment("Full misalignment for TOF and FRAME"); + md->SetComment("Full misalignment for TOF"); md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); - AliCDBId id("TOF/Align/Data",0,9999999); + AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity()); storage->Put(array,id,md); } @@ -181,4 +179,15 @@ void MakeTOFFullMisAlignment(){ } - +/* +Double_t LocalTruncatedGaus(Double_t mean, Double_t sigma, Double_t cutatL, Double_t cutatR) +{ + // return number generated according to a gaussian distribution N(mean,sigma) truncated at cutat + // + Double_t value; + do{ + value=gRandom->Gaus(mean,sigma); + }while(value-mean<-cutatL || value-mean>cutatR); + return value; +} +*/