From ef24eb3bd644397bb588db97d293cd8dfa882f27 Mon Sep 17 00:00:00 2001 From: masera Date: Tue, 20 Apr 2010 22:09:28 +0000 Subject: [PATCH] Major updates for millipede2 and related classes (Ruben) --- ITS/AliITSAlignMille2.cxx | 1226 +++++++++++++++++++++----- ITS/AliITSAlignMille2.h | 79 +- ITS/AliITSAlignMille2ConstrArray.cxx | 28 +- ITS/AliITSAlignMille2ConstrArray.h | 2 +- ITS/AliITSAlignMille2Constraint.cxx | 10 +- ITS/AliITSAlignMille2Constraint.h | 7 +- ITS/AliITSAlignMille2Module.cxx | 21 +- ITS/AliITSAlignMille2Module.h | 17 +- ITS/AliITSTPArrayFit.cxx | 384 +++++++- ITS/AliITSTPArrayFit.h | 11 +- ITS/AliITSresponseSDD.cxx | 1 + ITS/AliITSresponseSDD.h | 4 +- 12 files changed, 1480 insertions(+), 310 deletions(-) diff --git a/ITS/AliITSAlignMille2.cxx b/ITS/AliITSAlignMille2.cxx index 15288db5355..419178b3fba 100644 --- a/ITS/AliITSAlignMille2.cxx +++ b/ITS/AliITSAlignMille2.cxx @@ -22,12 +22,13 @@ // ITS specific alignment class which interface to AliMillepede. // For each track ProcessTrack calculates the local and global derivatives // at each hit and fill the corresponding local equations. Provide methods for -// fixing or constraining detection elements for best results. +// fixing or constraning detection elements for best results. // // author M. Lunardon (thanks to J. Castillo), ruben.shahoyan@cern.ch //----------------------------------------------------------------------------- #include +#include #include #include #include @@ -36,6 +37,9 @@ #include #include #include +#include +#include +#include #include "AliITSAlignMille2.h" #include "AliITSgeomTGeo.h" #include "AliGeomManager.h" @@ -51,18 +55,23 @@ #include "AliCDBManager.h" #include "AliCDBStorage.h" #include "AliCDBEntry.h" - +#include "AliITSsegmentationSDD.h" +#include "AliITSDriftSpeedArraySDD.h" +#include "AliESDVertex.h" ClassImp(AliITSAlignMille2) const Char_t* AliITSAlignMille2::fgkRecKeys[] = { "OCDB_PATH", + "OCDB_SPECIFIC", "GEOMETRY_FILE", "SUPERMODULE_FILE", "CONSTRAINTS_REFERENCE_FILE", "PREALIGNMENT_FILE", "PRECALIBSDD_FILE", + "PREVDRIFTSDD_FILE", "INITCALBSDD_FILE", + "INITVDRIFTSDD_FILE", "INITDELTA_FILE", "SET_GLOBAL_DELTAS", "CONSTRAINT_LOCAL", @@ -76,6 +85,7 @@ const Char_t* AliITSAlignMille2::fgkRecKeys[] = { "SET_RESCUT_OTHER", "SET_LOCALSIGMAFACTOR", "SET_STARTFAC", + "SET_FINALFAC", "SET_B_FIELD", "SET_SPARSE_MATRIX", "REQUIRE_POINT", @@ -85,8 +95,11 @@ const Char_t* AliITSAlignMille2::fgkRecKeys[] = { "SET_EXTRA_CLUSTERS_MODE", "SET_USE_TPAFITTER", "SET_USE_LOCAL_YERROR", - "SET_MIN_POINTS_PER_MODULE" - + "SET_MIN_POINTS_PER_MODULE", + "SET_USE_SDDVDCORRMULT", + "SET_WEIGHT_PT", + "SET_USE_DIAMOND", + "SET_SAME_SDDT0" }; const Char_t AliITSAlignMille2::fgkXYZ[] = "XYZ"; @@ -101,6 +114,7 @@ AliITSAlignMille2::AliITSAlignMille2(const Char_t *configFilename,TList *userInf : TObject(), fMillepede(0), fStartFac(16.), + fFinalFac(1.), fResCutInitial(100.), fResCut(100.), fNGlobal(0), @@ -127,7 +141,7 @@ AliITSAlignMille2::AliITSAlignMille2(const Char_t *configFilename,TList *userInf fConstrCharge(0), // fMinNPtsPerTrack(3), - fInitTrackParamsMeth(1), + fIniTrackParamsMeth(1), fTotBadLocEqPoints(0), fRieman(0), // @@ -138,19 +152,25 @@ AliITSAlignMille2::AliITSAlignMille2(const Char_t *configFilename,TList *userInf fUseGlobalDelta(kFALSE), fTempExcludedModule(-1), // - fDefCDBpath("local://$ALICE_ROOT/OCDB"), - fInitDeltaPath(""), - fInitSDDRespPath(""), + fIniUserInfo(userInfo), + fIniDeltaPath(""), + fIniSDDRespPath(""), fPreCalSDDRespPath(""), - fGeometryPath("geometry.root"), + fIniSDDVDriftPath(""), + fPreSDDVDriftPath(""), + fGeometryPath(""), fPreDeltaPath(""), fConstrRefPath(""), + fDiamondPath(""), fGeoManager(0), fIsConfigured(kFALSE), fPreAlignQF(0), // - fCorrectSDD(0), - fInitialRecSDD(0), + fIniRespSDD(0), + fPreRespSDD(0), + fIniVDriftSDD(0), + fPreVDriftSDD(0), + fSegmentationSDD(0), fPrealignment(0), fConstrRef(0), fMilleModule(2), @@ -165,7 +185,15 @@ AliITSAlignMille2::AliITSAlignMille2(const Char_t *configFilename,TList *userInf fMinPntPerSens(0), fBug(0), fMilleVersion(2), - fExtraClustersMode(0) + fExtraClustersMode(0), + fTrackWeight(1), + fWeightPt(0.), + fIsSDDVDriftMult(kFALSE), + fDiamond(), + fDiamondI(), + fUseDiamond(kFALSE), + fDiamondPointID(-1), + fDiamondModID(-1) { /// main constructor that takes input from configuration file for (int i=3;i--;) fSigmaFactor[i] = 1.0; @@ -188,7 +216,15 @@ AliITSAlignMille2::AliITSAlignMille2(const Char_t *configFilename,TList *userInf } } // - if (ProcessUserInfo(userInfo)) exit(1); + // if (ProcessUserInfo(userInfo)) exit(1); + // + fDiamond.SetVolumeID(kVtxSensVID); + fDiamondI.SetVolumeID(kVtxSensVID); + float xyzd[3] = {0,0,0}; + float covd[6] = {1,0,0,1,0,1e4}; + fDiamond.SetXYZ(xyzd,covd); // dummy diamond + covd[5] = 1e-4; + fDiamondI.SetXYZ(xyzd,covd); // Int_t lc=LoadConfig(configFilename); if (lc) { @@ -211,8 +247,11 @@ AliITSAlignMille2::~AliITSAlignMille2() delete fRieman; delete fPrealignment; delete fConstrRef; - delete fCorrectSDD; - delete fInitialRecSDD; + delete fPreRespSDD; + delete fIniRespSDD; + delete fSegmentationSDD; + delete fIniVDriftSDD; + delete fPreVDriftSDD; delete fTPAFitter; fCacheMatrixOrig.Delete(); fCacheMatrixCurr.Delete(); @@ -232,6 +271,7 @@ TObjArray* AliITSAlignMille2::GetConfigRecord(FILE* stream, TString& recTitle, T TString record; static TObjArray* recElems = 0; if (recElems) {delete recElems; recElems = 0;} + recOpt = ""; // TString keyws = recTitle; if (!keyws.IsNull()) { @@ -297,6 +337,8 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) // return 0 if success // 1 if error in module index or voluid // + AliInfo(Form("Loading MillePede2 configuration from %s",cfile)); + AliCDBManager::Instance()->SetCacheFlag(kFALSE); FILE *pfc=fopen(cfile,"r"); if (!pfc) return -1; // @@ -313,26 +355,33 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) // // ============= 1: we read some important records in predefined order ================ // - recTitle = fgkRecKeys[kOCDBPath]; - if ( GetConfigRecord(pfc,recTitle,recOpt,1) && !(fDefCDBpath=recOpt).IsNull() ) { - AliInfo(Form("Configuration sets OCDB Def.Storage to %s",fDefCDBpath.Data())); - AliCDBManager::Instance()->SetDefaultStorage( fDefCDBpath.Data() ); + recTitle = fgkRecKeys[kOCDBDefaultPath]; + if ( GetConfigRecord(pfc,recTitle,recOpt,1) && !recOpt.IsNull() ) { + AliInfo(Form("Configuration sets OCDB default storage to %s",recOpt.Data())); + AliCDBManager::Instance()->SetDefaultStorage( gSystem->ExpandPathName(recOpt.Data()) ); + TObjString* objStr = (TObjString*)AliCDBManager::Instance()->GetStorageMap()->GetValue("default"); + if (!objStr) {stopped = kTRUE; break;} + objStr->SetUniqueID(1); // mark as user set } // + if (fIniUserInfo && ProcessUserInfo(fIniUserInfo)) { AliError("Failed to process intial User Info"); stopped = kTRUE; break;} // recTitle = fgkRecKeys[kGeomFile]; - if ( GetConfigRecord(pfc,recTitle,recOpt,1) ) fGeometryPath = recOpt; + if ( GetConfigRecord(pfc,recTitle,recOpt,1) ) fGeometryPath = gSystem->ExpandPathName(recOpt.Data()); if ( InitGeometry() ) { AliError("Failed to find/load Geometry"); stopped = kTRUE; break;} // + // Do we use new TrackPointArray fitter ? + recTitle = fgkRecKeys[kTPAFitter]; + if ( GetConfigRecord(pfc,recTitle,recOpt,1) ) fTPAFitter = new AliITSTPArrayFit(kNLocal); // recTitle = fgkRecKeys[kSuperModileFile]; if ( !GetConfigRecord(pfc,recTitle,recOpt,1) || recOpt.IsNull() || + gSystem->ExpandPathName(recOpt) || gSystem->AccessPathName(recOpt.Data()) || LoadSuperModuleFile(recOpt.Data())) { AliError("Failed to find/load SuperModules"); stopped = kTRUE; break;} // - // recTitle = fgkRecKeys[kConstrRefFile]; // LOCAL_CONSTRAINTS are defined wrt these deltas if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) ) { if (recOpt.IsNull() || recOpt=="IDEAL") SetConstraintWrtRef( "IDEAL" ); @@ -345,45 +394,93 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) // // recTitle = fgkRecKeys[kInitDeltaFile]; - if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull()) { + if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull() ) { for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string - fInitDeltaPath = recOpt; - AliInfo(Form("Configuration sets Production Deltas to %s",fInitDeltaPath.Data())); + fIniDeltaPath = recOpt; + gSystem->ExpandPathName(fIniDeltaPath); + AliInfo(Form("Configuration sets Production Deltas to %s",fIniDeltaPath.Data())); } // // if initial deltas were provided, load them, apply to geometry and store are "original" matrices if (CacheMatricesOrig()) {stopped = kTRUE; break;} // recTitle = fgkRecKeys[kPreDeltaFile]; - if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull()) { - for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string - fPreDeltaPath = recOpt; + if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) ) { + if (!recOpt.IsNull()) { + for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string + fPreDeltaPath = recOpt; + gSystem->ExpandPathName(fPreDeltaPath); + } + else if (!fIniDeltaPath.IsNull()) { + AliInfo("PreAlignment Deltas keyword is present but empty, will set to Init Deltas"); + fPreDeltaPath = fIniDeltaPath; + } AliInfo(Form("Configuration sets PreAlignment Deltas to %s",fPreDeltaPath.Data())); } if (LoadDeltas(fPreDeltaPath,fPrealignment)) {stopped = kTRUE; break;} if (fPrealignment && ApplyToGeometry()) {stopped = kTRUE; break;} // + recTitle = fgkRecKeys[ kInitCalSDDFile ]; + if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull()) { + for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string + fIniSDDRespPath = recOpt; + gSystem->ExpandPathName(fIniSDDRespPath); + AliInfo(Form("Configuration sets Production SDD Response to %s",fIniSDDRespPath.Data())); + } + if (LoadSDDResponse(fIniSDDRespPath, fIniRespSDD) ) {stopped = kTRUE; break;} // recTitle = fgkRecKeys[kPreCalSDDFile]; - if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull() ) { - for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string - fPreCalSDDRespPath = recOpt; + if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) ) { + if (!recOpt.IsNull()) { + for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string + fPreCalSDDRespPath = recOpt; + gSystem->ExpandPathName(fPreCalSDDRespPath); + } + else if (!fIniSDDRespPath.IsNull()) { + AliInfo("PreCalibration SDD response keyword is present but empty, will set to Init SDD repsonse"); + fPreCalSDDRespPath = fIniSDDRespPath; + } AliInfo(Form("Configuration sets PreCalibration SDD Response to %s",fPreCalSDDRespPath.Data())); } - if (LoadSDDResponse(fPreCalSDDRespPath, fCorrectSDD) ) {stopped = kTRUE; break;} // - recTitle = fgkRecKeys[ kInitCalSDDFile ]; + if (LoadSDDResponse(fPreCalSDDRespPath, fPreRespSDD) ) {stopped = kTRUE; break;} + // + // + recTitle = fgkRecKeys[ kInitVDriftSDDFile ]; if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull()) { for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string - fInitSDDRespPath = recOpt; - AliInfo(Form("Configuration sets Production SDD Response to %s",fInitSDDRespPath.Data())); + fIniSDDVDriftPath = recOpt; + gSystem->ExpandPathName(fIniSDDVDriftPath); + AliInfo(Form("Configuration sets Production SDD VDrift to %s",fIniSDDVDriftPath.Data())); } - if (LoadSDDResponse(fInitSDDRespPath, fInitialRecSDD) ) {stopped = kTRUE; break;} + if (LoadSDDVDrift(fIniSDDVDriftPath, fIniVDriftSDD) ) {stopped = kTRUE; break;} // + recTitle = fgkRecKeys[ kPreVDriftSDDFile ]; + if ( (recArr = GetConfigRecord(pfc,recTitle,recOpt,1)) && !recOpt.IsNull()) { + for (int i=2;i<=recArr->GetLast();i++) {recOpt += " "; recOpt += recArr->At(i)->GetName();} // in case of OCDB string + fPreSDDVDriftPath = recOpt; + gSystem->ExpandPathName(fPreSDDVDriftPath); + AliInfo(Form("Configuration sets PreCalibration SDD VDrift to %s",fPreSDDVDriftPath.Data())); + if (LoadSDDVDrift(fPreSDDVDriftPath, fPreVDriftSDD) ) {stopped = kTRUE; break;} + } // recTitle = fgkRecKeys[ kGlobalDeltas ]; if ( GetConfigRecord(pfc,recTitle,recOpt,1) ) SetUseGlobalDelta(kTRUE); // + recTitle = fgkRecKeys[ kUseDiamond ]; + if ( GetConfigRecord(pfc,recTitle,recOpt,1) ) { + if (!GetUseGlobalDelta()) { + AliError("Diamond constraint is supported only for Global Frame mode"); + stopped = kTRUE; + break; + } + fUseDiamond = kTRUE; + if (!recOpt.IsNull()) { + fDiamondPath = recOpt; + gSystem->ExpandPathName(fDiamondPath); + AliInfo(Form("Configuration sets Diamond constraint to %s",fDiamondPath.Data())); + } + } // =========== 2: see if there are local gaussian constraints defined ===================== // Note that they should be loaded before the modules declaration // @@ -432,6 +529,7 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) mod->SetUniqueID(fNModules++); mod->SetNotInConf(kTRUE); } + CreateVertexModule(); // while( (recArr=GetConfigRecord(pfc,recTitle="",recOpt,0)) ) { if (!(recTitle==fgkRecKeys[ kModVolID ] || recTitle==fgkRecKeys[ kModIndex ])) continue; @@ -505,14 +603,19 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) } mod->SetFreeDOF(AliITSAlignMille2Module::kDOFT0,vl); // - vl = 0; - if (nrecElems>12) { - recExt = recArr->At(12)->GetName(); - if (recExt.IsFloat()) vl = recExt.Atof(); - else {stopped = kTRUE; break;} - irec = 12; + Bool_t cstLR = kFALSE; + for (int lr=0;lr<2;lr++) { // left right side vdrift corrections + vl = 0; + if (nrecElems>12+lr) { + recExt = recArr->At(12+lr)->GetName(); + if (recExt.IsFloat()) vl = recExt.Atof(); + else {stopped = kTRUE; break;} + irec = 12+lr; + } + mod->SetFreeDOF(lr==0 ? AliITSAlignMille2Module::kDOFDVL : AliITSAlignMille2Module::kDOFDVR,vl); + if (lr==1 && vl>=10) cstLR = kTRUE; // the right side should be constrained to left one } - mod->SetFreeDOF(AliITSAlignMille2Module::kDOFDV,vl); + if (cstLR) mod->SetVDriftLRSame(); } // mod->EvaluateDOF(); @@ -585,6 +688,11 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) fStartFac = recOpt.Atof(); } // + else if (recTitle == fgkRecKeys[ kFinalFactor ]) { //------------------------- + if (recOpt.IsNull() || !recOpt.IsFloat() ) {stopped = kTRUE; break;} + fFinalFac = recOpt.Atof(); + } + // // pepo2708909 else if (recTitle == fgkRecKeys[ kExtraClustersMode ]) { //------------------------- if (recOpt.IsNull() || !recOpt.IsDigit() ) {stopped = kTRUE; break;} @@ -597,6 +705,19 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) SetBField( recOpt.Atof() ); } // + else if (recTitle == fgkRecKeys[ kSDDVDCorrMult ]) { //------------------------- + SetSDDVDCorrMult( recOpt.IsNull() || (recOpt.IsFloat() && (recOpt.Atof())>-0.5) ); + } + // + else if (recTitle == fgkRecKeys[ kWeightPt ]) { //------------------------- + double wgh = 1; + if (!recOpt.IsNull()) { + if (!recOpt.IsFloat()) {stopped = kTRUE; break;} + else wgh = recOpt.Atof(); + } + SetWeightPt(wgh); + } + // else if (recTitle == fgkRecKeys[ kSparseMatrix ]) { // matrix solver type // AliMillePede2::SetGlobalMatSparse(kTRUE); @@ -688,7 +809,7 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) } // else if (recTitle == fgkRecKeys[ kConstrSubunits ]) { //------------------------ - // expect ONSTRAINT_SUBUNITS MEAN/MEDIAN Value parID0 ... parID1 ... VolID1 ... VolIDn - VolIDm + // expect CONSTRAINT_SUBUNITS MEAN/MEDIAN Value parID0 ... parID1 ... VolID1 ... VolIDn - VolIDm if (nrecElems<5) {stopped = kTRUE; break;} recExt = recArr->At(2)->GetName(); if (!recExt.IsFloat()) {stopped = kTRUE; break;} @@ -778,11 +899,48 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) if (rangeStart>=0) stopped = kTRUE; // unfinished range if (stopped) break; } - // Do we use new TrackPointArray fitter ? - else if (recTitle == fgkRecKeys[ kTPAFitter ]) { - // expect SET_TPAFITTER - fTPAFitter = new AliITSTPArrayFit(kNLocal); + // + // request of the same T0 for group of SDD modules + else if (recTitle == fgkRecKeys[ kSameSDDT0 ]) { //------------------------ + // expect SET_SAME_SDDT0 [SensID1 ... SensIDn - SensIDm] + if (nrecElems<3) {stopped = kTRUE; break;} + // + // now read the list of modules to constrain + int curID = -1; + int rangeStart = -1; + AliITSAlignMille2ConstrArray *cstrT0 = new AliITSAlignMille2ConstrArray("SDDT0",0,0,0,0); + int naddM = 0; + cstrT0->SetPattern(BIT(AliITSAlignMille2Module::kDOFT0)); + for (irec=1;irecAt(irec)->GetName(); + if (recExt == "-") {rangeStart = curID; continue;} // range is requested + else if (!recExt.IsDigit()) {stopped = kTRUE; break;} + else curID = recExt.Atoi(); + // + if (curID=kSDDoffsID+kNSDDmod) {stopped = kTRUE; break;} + // + // this was a range start or single + int start; + if (rangeStart>=0) {start = rangeStart+1; rangeStart=-1;} // continue the range + else start = curID; // create constraint either for single module (or 1st in the range) + for (int id=start;id<=curID;id++) { + int vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(id); + if (vid<=1) {AliDebug(3,Form("Undefined module index %d requested in the SAME_SDDT0 constraint, skipping",id)); continue;} + AliITSAlignMille2Module *md = GetMilleModuleByVID(vid); + if (!md) {AliDebug(3,Form("Undefined module %d requested in the Local constraint, skipping",id)); continue;} + cstrT0->AddModule(md,kFALSE); + naddM++; + } + } + if (rangeStart>=0) stopped = kTRUE; // unfinished range + if (stopped) break; + if (naddM<2) delete cstrT0; + else { + cstrT0->SetConstraintID(GetNConstraints()); + fConstraints.Add(cstrT0); + } } + // // Do we use new local Y errors? else if (recTitle == fgkRecKeys[ kUseLocalYErr ]) { // expect SET_TPAFITTER @@ -794,6 +952,15 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) SetMinPointsPerSensor( recOpt.Atoi() ); } // + else if (recTitle == fgkRecKeys[ kOCDBSpecificPath ]) { //------------------------- + if (recOpt.IsNull() || nrecElems<3 ) {stopped = kTRUE; break;} + AliCDBManager::Instance()->SetSpecificStorage(recOpt.Data(), gSystem->ExpandPathName(recArr->At(2)->GetName())); + AliInfo(Form("Configuration sets OCDB specific storage %s to %s",recOpt.Data(),recArr->At(2)->GetName())); + TObjString *pths = (TObjString*)AliCDBManager::Instance()->GetStorageMap()->GetValue(recOpt.Data()); + if (!pths) { stopped = kTRUE; break; } + pths->SetUniqueID(1); // mark as set by user + } + // else continue; // already processed record // } // end of while loop 4 over the various params @@ -802,6 +969,7 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) } // end of while(1) loop // fclose(pfc); + if (!fDiamondPath.IsNull() && IsDiamondUsed() && LoadDiamond(fDiamondPath) ) stopped = kTRUE; if (stopped) { AliError(Form("Failed on record %s %s ...\n",recTitle.Data(),recOpt.Data())); return -1; @@ -809,6 +977,8 @@ Int_t AliITSAlignMille2::LoadConfig(const Char_t *cfile) // if (CacheMatricesCurr()) return -1; SetUseLocalYErrors(fUseLocalYErr); // YErr used only with TPAFitter + fSegmentationSDD = new AliITSsegmentationSDD(); + // fIsConfigured = kTRUE; return 0; } @@ -1193,6 +1363,7 @@ void AliITSAlignMille2::Init() // // Set iterations if (fStartFac>1) fMillepede->SetIterations(fStartFac); + if (fFinalFac>1) fMillepede->SetChi2CutRef(fFinalFac); // } @@ -1282,6 +1453,7 @@ AliTrackPointArray *AliITSAlignMille2::PrepareTrack(const AliTrackPointArray *at Int_t idx[20]; Short_t lrID[20]; Int_t npts=atp->GetNPoints(); + if (npts> RS @@ -1444,11 +1616,12 @@ AliTrackPointArray *AliITSAlignMille2::PrepareTrack(const AliTrackPointArray *at // build a new track with (sorted) (prealigned) good points // pepo200709 //fTrack = (AliTrackPointArray*)fTrackBuff[ngoodpts-fMinNPtsPerTrack]; - fTrack = (AliTrackPointArray*)fTrackBuff[ngoodpts]; + Int_t addVertex = IsTypeCollision()&&IsDiamondUsed() ? 1 : 0; + fTrack = (AliTrackPointArray*)fTrackBuff[ngoodpts + addVertex ]; if (!fTrack) { - fTrack = new AliTrackPointArray(ngoodpts); + fTrack = new AliTrackPointArray(ngoodpts + addVertex); // fTrackBuff.AddAtAndExpand(fTrack,ngoodpts-fMinNPtsPerTrack); - fTrackBuff.AddAtAndExpand(fTrack,ngoodpts); + fTrackBuff.AddAtAndExpand(fTrack,ngoodpts + addVertex); } // fTrack = new AliTrackPointArray(ngoodpts); // endpepo200709 @@ -1474,38 +1647,18 @@ AliTrackPointArray *AliITSAlignMille2::PrepareTrack(const AliTrackPointArray *at AliITSAlignMille2Module *mod = GetMilleModule(intidx[idx[i]]); TGeoHMatrix *svOrigMatrix = GetSensorOrigMatrixSID(sid); //mod->GetSensitiveVolumeOrigGlobalMatrix(p.GetVolumeID()); // get back real local coordinate - Double_t *pl = fClusLoc.GetArray() + npto*3; - Double_t *pg = fClusGlo.GetArray() + npto*3; - Double_t *sgl = fClusSigLoc.GetArray() + npto*3; - pg[0]=p.GetX(); - pg[1]=p.GetY(); - pg[2]=p.GetZ(); - AliDebug(3,Form("Global coordinates of measured point : X=%f Y=%f Z=%f \n",pg[0],pg[1],pg[2])); - svOrigMatrix->MasterToLocal(pg,pl); - AliDebug(3,Form("Local coordinates of measured point : X=%f Y=%f Z=%f \n",pl[0],pl[1],pl[2])); - // - // this is a temporary code to extract the drift speed used for given point - if (p.GetDriftTime()>0) { // RRR - // calculate the drift speed - fDriftTime0[npto] = fInitialRecSDD ? fInitialRecSDD->GetTimeZero(sid) : 0.; - double tdif = p.GetDriftTime() - fDriftTime0[npto]; - if (tdif<=0) tdif = 1; - double vdrift = (3.5085-TMath::Abs(pl[0]))/tdif; - if (vdrift<0) vdrift = 0; - // - // TEMPORARY CORRECTION (if provided) -------------->>> - if (fCorrectSDD) { - float t0Upd = fCorrectSDD->GetTimeZero(sid); - vdrift += fCorrectSDD->GetDeltaVDrift(sid); - tdif = p.GetDriftTime() - t0Upd; - // correct Xlocal - pl[0] = TMath::Sign(3.5085 - vdrift*tdif,pl[0]); - fDriftTime0[npto] = t0Upd; - } - // TEMPORARY CORRECTION (if provided) --------------<<< - fDriftSpeed[npto] = TMath::Sign(vdrift,pl[0]); - // - } + fMeasLoc = fClusLoc.GetArray() + npto*3; + fMeasGlo = fClusGlo.GetArray() + npto*3; + fSigmaLoc = fClusSigLoc.GetArray() + npto*3; + fMeasGlo[0]=p.GetX(); + fMeasGlo[1]=p.GetY(); + fMeasGlo[2]=p.GetZ(); + AliDebug(3,Form("Global coordinates of measured point : X=%+f Y=%+f Z=%+f \n",fMeasGlo[0],fMeasGlo[1],fMeasGlo[2])); + svOrigMatrix->MasterToLocal(fMeasGlo,fMeasLoc); + AliDebug(3,Form("Local coordinates of measured point : X=%+f Y=%+f Z=%+f \n",fMeasLoc[0],fMeasLoc[1],fMeasLoc[2])); + // + if (p.GetDriftTime()>0) ProcessSDDPointInfo(&p,sid, npto); // for SDD points extract vdrift + // // update covariance matrix Double_t hcovel[9]; hcovel[0]=double(p.GetCov()[0]); @@ -1540,7 +1693,7 @@ AliTrackPointArray *AliITSAlignMille2::PrepareTrack(const AliTrackPointArray *at if (ir==ic) { if ( IsZero(hcovscl[ir*3+ic],1e-8) ) hcovscl[ir*3+ic] = 1E-8; else hcovscl[ir*3+ic] *= mod->GetSigmaFactor(ir)*mod->GetSigmaFactor(ic); //RRR - sgl[ir] = TMath::Sqrt(hcovscl[ir*3+ic]); + fSigmaLoc[ir] = TMath::Sqrt(hcovscl[ir*3+ic]); } else hcovscl[ir*3+ic] = 0; } @@ -1562,7 +1715,7 @@ AliTrackPointArray *AliITSAlignMille2::PrepareTrack(const AliTrackPointArray *at /// get (evenctually prealigned) matrix of sens. vol. TGeoHMatrix *svMatrix = GetSensorCurrMatrixSID(sid); //mod->GetSensitiveVolumeMatrix(p.GetVolumeID()); // modify global coordinates according with pre-aligment - svMatrix->LocalToMaster(pl,pg); + svMatrix->LocalToMaster(fMeasLoc,fMeasGlo); // now rotate in local system hcov.Multiply(&svMatrix->Inverse()); hcov.MultiplyLeft(svMatrix); // hcov is back in GLOBAL RF @@ -1583,16 +1736,31 @@ AliTrackPointArray *AliITSAlignMille2::PrepareTrack(const AliTrackPointArray *at pcov[4]=hcovscl[5]; pcov[5]=hcovscl[8]; // - p.SetXYZ(pg[0],pg[1],pg[2],pcov); - // printf("New Gl coordinates of measured point : X=%f Y=%f Z=%f \n",pg[0],pg[1],pg[2]); - AliDebug(3,Form("New global coordinates of measured point : X=%f Y=%f Z=%f \n",pg[0],pg[1],pg[2])); + p.SetXYZ(fMeasGlo[0],fMeasGlo[1],fMeasGlo[2],pcov); + // printf("New Gl coordinates of measured point : X=%f Y=%f Z=%f \n",fMeasGlo[0],fMeasGlo[1],fMeasGlo[2]); + AliDebug(3,Form("New global coordinates of measured point : X=%+f Y=%+f Z=%+f \n",fMeasGlo[0],fMeasGlo[1],fMeasGlo[2])); fTrack->AddPoint(npto,&p); - AliDebug(2,Form("Adding point[%d] = ( %f , %f , %f ) volid = %d",npto,fTrack->GetX()[npto], + AliDebug(2,Form("Adding point[%d] = ( %+f , %+f , %+f ) volid = %d",npto,fTrack->GetX()[npto], fTrack->GetY()[npto],fTrack->GetZ()[npto],fTrack->GetVolumeID()[npto] )); // printf("Adding %d %d %f\n",npto, p.GetVolumeID(), p.GetY()); npto++; } // + fDiamondPointID = -1; + if (addVertex) { + fTrack->AddPoint(npto,&fDiamond); + fMeasLoc = fClusLoc.GetArray() + npto*3; + fMeasGlo = fClusGlo.GetArray() + npto*3; + fSigmaLoc = fClusSigLoc.GetArray() + npto*3; + fMeasLoc[0] = fMeasGlo[0] = fDiamond.GetX(); + fMeasLoc[1] = fMeasGlo[1] = fDiamond.GetY(); + fMeasLoc[2] = fMeasGlo[2] = fDiamond.GetZ(); + fSigmaLoc[0] = fDiamond.GetCov()[0]; + fSigmaLoc[1] = fDiamond.GetCov()[3]; + fSigmaLoc[2] = fDiamond.GetCov()[5]; + fDiamondPointID = npto++; + } + // return fTrack; } @@ -1611,7 +1779,7 @@ AliTrackPointArray *AliITSAlignMille2::SortTrack(const AliTrackPointArray *atp) for (int i=0; iGetPoint(p,idx[i]); atps->AddPoint(i,&p); - AliDebug(2,Form("Point[%d] = ( %f , %f , %f ) volid = %d",i,atps->GetX()[i],atps->GetY()[i],atps->GetZ()[i],atps->GetVolumeID()[i] )); + AliDebug(2,Form("Point[%d] = ( %+f , %+f , %+f ) volid = %d",i,atps->GetX()[i],atps->GetY()[i],atps->GetZ()[i],atps->GetVolumeID()[i] )); } return atps; } @@ -1651,12 +1819,20 @@ Int_t AliITSAlignMille2::InitModuleParams() UShort_t voluid=fCluster.GetVolumeID(); fCurrentSensID = AliITSAlignMille2Module::GetIndexFromVolumeID(voluid); // - // IT IS VERY IMPORTANT: start from the end of the list, where the childs are located !!! - Int_t k=fNModules-1; - fCurrentModule = 0; - // VERY IMPORTANT: if the sensors were explicitly provided, don't look in the supermodules - while (k>=0 && ! (fCurrentModule=GetMilleModule(k))->IsIn(voluid)) k--; - if (k<0) return -3; + if (fCurrentSensID==-1) { // this is a special "vertex" module + fCurrentModule = GetMilleModuleByVID(voluid); + fCurrentSensID = fCurrentModule->GetIndex(); + + } + else { + // + // IT IS VERY IMPORTANT: start from the end of the list, where the childs are located !!! + Int_t k=fNModules-1; + fCurrentModule = 0; + // VERY IMPORTANT: if the sensors were explicitly provided, don't look in the supermodules + while (k>=0 && ! (fCurrentModule=GetMilleModule(k))->IsIn(voluid)) k--; + if (k<0) return -3; + } // for (int i=AliITSAlignMille2Module::kMaxParTot;i--;) fModuleInitParam[i] = 0.0; // @@ -1701,7 +1877,7 @@ Int_t AliITSAlignMille2::InitModuleParams() if (fSigmaLoc[0]<0.0010) fSigmaLoc[0]=0.0010; if (fSigmaLoc[2]<0.0010) fSigmaLoc[2]=0.0010; // - AliDebug(2,Form("Local coordinates of measured point : X=%f Y=%f Z=%f \n",fMeasLoc[0] ,fMeasLoc[1] ,fMeasLoc[2] )); + AliDebug(2,Form("Local coordinates of measured point : X=%+f Y=%+f Z=%+f \n",fMeasLoc[0] ,fMeasLoc[1] ,fMeasLoc[2] )); AliDebug(2,Form("Setting StDev from CovMat : fSigmaLocX=%g fSigmaLocY=%g fSigmaLocZ=%g \n",fSigmaLoc[0] ,fSigmaLoc[1] ,fSigmaLoc[2] )); // return 0; @@ -1727,7 +1903,7 @@ void AliITSAlignMille2::Print(Option_t*) const // // if (fBOn) - printf(" B Field set to %f T - using helices\n",fBField); + printf(" B Field set to %+f T - using helices\n",fBField); else printf(" B Field OFF - using straight lines \n"); // @@ -1751,9 +1927,12 @@ void AliITSAlignMille2::Print(Option_t*) const if (fNReqDet[itp][i]>0) printf(" Detector %d : %d points \n",i+1,fNReqDet[itp][i]); } } + printf(" SDD VDrift correction : %s",fIsSDDVDriftMult ? "Mult":"Add"); + printf(" Weight acc. to pT in power : %f",fWeightPt); // printf("\n Millepede configuration parameters:\n"); - printf(" init value for chi2 cut : %.4f\n",fStartFac); + printf(" init factor for chi2 cut : %.4f\n",fStartFac); + printf(" final factor for chi2 cut : %.4f\n",fFinalFac); printf(" first iteration cut value : %.4f\n",fResCutInitial); printf(" other iterations cut value : %.4f\n",fResCut); printf(" number of stddev for chi2 cut : %d\n",fNStdDev); @@ -1949,7 +2128,7 @@ void AliITSAlignMille2::InitTrackParams(int meth) fLocalInitParam[4] = 0.0; // endpepo200709 - AliDebug(2,Form("X = p0gx + ugx*Y : p0gx = %f ugx = %f\n",fLocalInitParam[0],fLocalInitParam[2])); + AliDebug(2,Form("X = p0gx + ugx*Y : p0gx = %+f ugx = %+f\n",fLocalInitParam[0],fLocalInitParam[2])); // if (meth==1) return; // @@ -2066,12 +2245,12 @@ Int_t AliITSAlignMille2::CheckCurrentTrack() } //________________________________________________________________________________________________________ -Int_t AliITSAlignMille2::ProcessTrack(const AliTrackPointArray *track) +Int_t AliITSAlignMille2::ProcessTrack(const AliTrackPointArray *track, Double_t wgh) { /// Process track; Loop over hits and set local equations /// here 'track' is a AliTrackPointArray /// return 0 if success; - + // if (!fIsMilleInit) Init(); // Int_t npts = track->GetNPoints(); @@ -2079,7 +2258,7 @@ Int_t AliITSAlignMille2::ProcessTrack(const AliTrackPointArray *track) // preprocessing of the input track: keep only points in defined volumes, // move points if prealignment is set, sort by Yglo if required - + fTrackWeight = wgh; fTrack=PrepareTrack(track); if (!fTrack) { RemoveHelixFitConstraint(); @@ -2091,31 +2270,110 @@ Int_t AliITSAlignMille2::ProcessTrack(const AliTrackPointArray *track) } AliDebug(2,Form("*** Processing prepared track with %d points ***",npts)); // + npts = FitTrack(); + if (npts<0) return npts; + // + // printf("Params: "); for (int i=0;iGetPoint(fCluster,ipt); + fCluster.SetUniqueID(ipt+1); + AliDebug(2,Form("\n--- processing point %d --- \n",ipt)); + + // set geometry parameters for the the current module + if (InitModuleParams()) continue; + AliDebug(2,Form(" VolID=%d Index=%d InternalIdx=%d symname=%s\n", + track->GetVolumeID()[ipt], fCurrentModule->GetIndex(), + fCurrentModule->GetUniqueID(), AliGeomManager::SymName(track->GetVolumeID()[ipt]) )); + AliDebug(2,Form(" Preprocessed Point = ( %+f , %+f , %+f ) \n",fCluster.GetX(),fCluster.GetY(),fCluster.GetZ())); + int res = fTPAFitter ? AddLocalEquationTPA(md[nloceq]) : AddLocalEquation(md[nloceq]); + if (res<0) {fTotBadLocEqPoints++; nloceq = 0; break;} + else if (res==0) nloceq++; + else {nloceq++; ngloeq++;} + } // end loop over points + // + fTrack=NULL; + // not enough good points? + if (nloceqSaveRecordData(); // RRR + // + return 0; +} + +//________________________________________________________________________________________________________ +Int_t AliITSAlignMille2::FitTrack() +{ + // Fit the track with selected constraints + // + const Double_t kfDiamondTolerance = 0.1; //diamond tolerance on top of the MS error + if (!fTrack) return -1; + int npts = fTrack->GetNPoints(); + // if (fTPAFitter) { // use dediacted fitter // - fTPAFitter->AttachPoints(fTrack); + // if the diamond point is attached, for the moment don't include it in the fit + fTPAFitter->AttachPoints(fTrack,0, fDiamondPointID>0 ? fDiamondPointID-1 : npts-1); fTPAFitter->SetBz(fBField); fTPAFitter->SetTypeCosmics(IsTypeCosmics()); - if (fInitTrackParamsMeth==1) fTPAFitter->SetIgnoreCov(); - double chi2 = fTPAFitter->Fit(fConstrCharge,fConstrPT,fConstrPTErr); + if (fIniTrackParamsMeth==1) fTPAFitter->SetIgnoreCov(); // - // suppress eventual constraints to not affect fit of the next track - RemoveHelixFitConstraint(); + double chi2; + double chi2f = 0; + double dca2err; + double dca2 = 0.; + Bool_t fitIsDone = kFALSE; + if (fDiamondPointID>0) { // vertex constraint was added, check if the track looks like prompt + chi2f = fTPAFitter->Fit(fConstrCharge,fConstrPT,fConstrPTErr); + if ( chi2f<0 || (chi2f>fNStdDev*fStartFac && fTPAFitter->GetNIterations()>=fTPAFitter->GetMaxIterations()) ) { //RRR + AliInfo(Form("Track fit failed on checking if it is prompt! skipping this track... Chi2:%+e",chi2f)); + fTPAFitter->Reset(); + // fTrack = NULL; + return -5; + } + double xyzRes[3]; + fTPAFitter->GetResiduals(xyzRes,&fDiamondI,kTRUE); + dca2 = xyzRes[0]*xyzRes[0] + xyzRes[1]*xyzRes[1]; + double pT = IsFieldON() ? fTPAFitter->GetPt() : 0.45; + if (pT<0.1) pT = 0.1; + dca2err = kfDiamondTolerance + 0.02/pT; + if (dca2>dca2err*dca2err) { // this is secondary + int* clst = (int*) fTrack->GetClusterType(); + clst[fDiamondPointID] = -1;; + fDiamondPointID = -1; + fitIsDone = kTRUE; + npts--; + } + else fTPAFitter->SetFirstLast(0,fDiamondPointID); // fit with diamond + } + // fTPAFitter->SetParAxis(1); + if (!fitIsDone) chi2 = fTPAFitter->Fit(fConstrCharge,fConstrPT,fConstrPTErr); + // + RemoveHelixFitConstraint(); // suppress eventual constraints to not affect fit of the next track // - if ( chi2<0 || (chi2>fStartFac && fTPAFitter->GetNIterations()>=fTPAFitter->GetMaxIterations()) ) { //RRR - AliInfo("Track fit failed! skipping this track..."); - fTrack->Print(""); - fTPAFitter->FitHelixCrude(); - fTPAFitter->SetFitDone(); - fTPAFitter->Print(); + if ( !fitIsDone && (chi2<0 || (chi2>fNStdDev*fStartFac && fTPAFitter->GetNIterations()>=fTPAFitter->GetMaxIterations())) ) { //RRR + AliInfo(Form("Track fit failed! skipping this track... Chi2:%+e",chi2)); + if (fDiamondPointID>0) AliInfo(Form("VertexFree fit gave Chi2:%+e with residual %+e",chi2f,TMath::Sqrt(dca2))); + /* + fTrack->Print(""); + fTPAFitter->FitHelixCrude(); + fTPAFitter->SetFitDone(); + fTPAFitter->Print(); + */ fTPAFitter->Reset(); - fTrack = NULL; + // fTrack = NULL; return -5; } - fNLocal = fTPAFitter->IsFieldON() ? 5:4; // Attantion: the fitter might have decided to work in line mode + fNLocal = fTPAFitter->IsFieldON() ? 5:4; // Attention: the fitter might have decided to work in line mode + npts = fTPAFitter->GetLast() - fTPAFitter->GetFirst() + 1; // actual number of points /* - double *pr = fTPAFitter->GetParams(); - printf("FtPar: %+.5e %+.5e %+.5e %+.5e | chi2:%.3e\n",pr[2],pr[0],pr[3],pr[1],chi2); // RRR + double *pr = fTPAFitter->GetParams(); + printf("FtPar: %+.5e %+.5e %+.5e %+.5e | chi2:%.3e\n",pr[2],pr[0],pr[3],pr[1],chi2); // RRR */ } else { @@ -2127,7 +2385,7 @@ Int_t AliITSAlignMille2::ProcessTrack(const AliTrackPointArray *track) // [1] = global z coord. of straight line intersection at y=0 plane // [2] = px/py // [3] = pz/py - InitTrackParams(fInitTrackParamsMeth); + InitTrackParams(fIniTrackParamsMeth); /* double *pr = fLocalInitParam; printf("FtPar: %+.5e %+.5e %+.5e %+.5e |\n",pr[0],pr[1],pr[2],pr[3]); // RRR @@ -2142,38 +2400,8 @@ Int_t AliITSAlignMille2::ProcessTrack(const AliTrackPointArray *track) } } } + return npts; // - // printf("Params: "); for (int i=0;iGetPoint(fCluster,ipt); - fCluster.SetUniqueID(ipt+1); - AliDebug(2,Form("\n--- processing point %d --- \n",ipt)); - - // set geometry parameters for the the current module - if (InitModuleParams()) continue; - AliDebug(2,Form(" VolID=%d Index=%d InternalIdx=%d symname=%s\n", - track->GetVolumeID()[ipt], fCurrentModule->GetIndex(), - fCurrentModule->GetUniqueID(), AliGeomManager::SymName(track->GetVolumeID()[ipt]) )); - AliDebug(2,Form(" Preprocessed Point = ( %f , %f , %f ) \n",fCluster.GetX(),fCluster.GetY(),fCluster.GetZ())); - int res = fTPAFitter ? AddLocalEquationTPA(md[nloceq]) : AddLocalEquation(md[nloceq]); - if (res<0) {fTotBadLocEqPoints++; nloceq = 0; break;} - else if (res==0) nloceq++; - else {nloceq++; ngloeq++;} - } // end loop over points - // - fTrack=NULL; - // not enough good points? - if (nloceqSaveRecordData(); // RRR - // - return 0; } //________________________________________________________________________________________________________ @@ -2226,9 +2454,9 @@ Int_t AliITSAlignMille2::CalcIntersectionPoint(Double_t *lpar, Double_t *gpar) Double_t y2g = x2t*TMath::Sin(alpha) + y2t*TMath::Cos(alpha); Double_t z2g = z2t; - AliDebug(3,Form("Riemann frame: fAlpha = %f = %f ",alpha,alpha*180./TMath::Pi())); - AliDebug(3,Form(" prf_glo=( %f , %f , %f ) prf_rf=( %f , %f , %f )\n", x1g,y1g,z1g, x1t,y1t,z1t)); - AliDebug(3,Form(" mov_glo=( %f , %f , %f ) rf=( %f , %f , %f )\n",x2g,y2g,z2g, x2t,y2t,z2t)); + AliDebug(3,Form("Riemann frame: fAlpha = %+f = %+f ",alpha,alpha*180./TMath::Pi())); + AliDebug(3,Form(" prf_glo=( %+f , %+f , %+f ) prf_rf=( %+f , %+f , %+f )\n", x1g,y1g,z1g, x1t,y1t,z1t)); + AliDebug(3,Form(" mov_glo=( %+f , %+f , %+f ) rf=( %+f , %+f , %+f )\n",x2g,y2g,z2g, x2t,y2t,z2t)); if (TMath::Abs(y2g-y1g)<1e-15) { AliInfo("DeltaY=0! Cannot proceed..."); @@ -2255,7 +2483,7 @@ Int_t AliITSAlignMille2::CalcIntersectionPoint(Double_t *lpar, Double_t *gpar) p0g[1]=0.0; p0g[2]=lpar[1]; } - AliDebug(3,Form("Line vector: ( %f , %f , %f ) point:( %f , %f , %f )\n",v0g[0],v0g[1],v0g[2],p0g[0],p0g[1],p0g[2])); + AliDebug(3,Form("Line vector: ( %+f , %+f , %+f ) point:( %+f , %+f , %+f )\n",v0g[0],v0g[1],v0g[2],p0g[0],p0g[1],p0g[2])); // same in local coord. Double_t p0l[3],v0l[3]; @@ -2274,7 +2502,7 @@ Int_t AliITSAlignMille2::CalcIntersectionPoint(Double_t *lpar, Double_t *gpar) // global intersection point tempHMat->LocalToMaster(fPintLoc,fPintGlo); - AliDebug(3,Form("Intesect. point: L( %f , %f , %f ) G( %f , %f , %f )\n",fPintLoc[0],fPintLoc[1],fPintLoc[2],fPintGlo[0],fPintGlo[1],fPintGlo[2])); + AliDebug(3,Form("Intesect. point: L( %+f , %+f , %+f ) G( %+f , %+f , %+f )\n",fPintLoc[0],fPintLoc[1],fPintLoc[2],fPintGlo[0],fPintGlo[1],fPintGlo[2])); return 0; } @@ -2404,7 +2632,7 @@ Int_t AliITSAlignMille2::AddLocalEquation(Mille2Data &m) if (CalcIntersectionPoint(fLocalInitParam, fModuleInitParam)) return -1; for (Int_t i=0; i<3; i++) fPintLoc0[i]=fPintLoc[i]; - AliDebug(2,Form("Intersect. point: L( %f , %f , %f )",fPintLoc[0],fPintLoc[1],fPintLoc[2])); + AliDebug(2,Form("Intersect. point: L( %+f , %+f , %+f )",fPintLoc[0],fPintLoc[1],fPintLoc[2])); // calculate local derivatives numerically Bool_t zeroX = kTRUE; @@ -2458,9 +2686,13 @@ Int_t AliITSAlignMille2::AddLocalEquation(Mille2Data &m) } // // specific for special sensors + Int_t sddLR = -1; if ( fCurrentModule->IsSDD() && - (fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFT0)>=0 || - fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFDV)>=0) ) { + (fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFT0)>=0 || + // fCurrentModule->GetParOffset(sddLR = fMeasLoc[kX]>0 ? + fCurrentModule->GetParOffset(sddLR = GetVDriftSDD()>0 ? + AliITSAlignMille2Module::kDOFDVL : AliITSAlignMille2Module::kDOFDVR)>=0) + ) { // // assume for sensor local xloc = xloc0 + V0*dT0+dV*(T-T0) // where V0 and T are the nominal drift velocity, time and time0 @@ -2469,7 +2701,7 @@ Int_t AliITSAlignMille2::AddLocalEquation(Mille2Data &m) // dX/dV = dX/dxloc * dxloc/dV = dX/dxloc * (T-T0) // IMPORTANT: the geom derivatives are over the SENSOR LOCAL parameters // - if (!dfDone[AliITSAlignMille2Module::kDOFT0] || !dfDone[AliITSAlignMille2Module::kDOFDV]) { + if (!dfDone[AliITSAlignMille2Module::kDOFT0] || !dfDone[sddLR]) { // double dXdxlocsens=0., dZdxlocsens=0.; // @@ -2512,9 +2744,10 @@ Int_t AliITSAlignMille2::AddLocalEquation(Mille2Data &m) fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][2] = dZdxlocsens*vdrift; dfDone[AliITSAlignMille2Module::kDOFT0] = kTRUE; // - fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][0] = -dXdxlocsens*TMath::Sign(tdrift,vdrift); - fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][2] = -dZdxlocsens*TMath::Sign(tdrift,vdrift); - dfDone[AliITSAlignMille2Module::kDOFDV] = kTRUE; + double mltCorr = fIsSDDVDriftMult ? TMath::Abs(vdrift) : 1; + fDerivativeGlo[sddLR][0] = -dXdxlocsens*mltCorr*TMath::Sign(tdrift,vdrift); + fDerivativeGlo[sddLR][2] = -dZdxlocsens*mltCorr*TMath::Sign(tdrift,vdrift); + dfDone[sddLR] = kTRUE; // } // @@ -2524,10 +2757,10 @@ Int_t AliITSAlignMille2::AddLocalEquation(Mille2Data &m) m.fParMilleID[ifill++] = fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFT0); } // - if (fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFDV)>=0) { - m.fDerGlo[ifill][kX] = fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][0]; - m.fDerGlo[ifill][kZ] = fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][2]; - m.fParMilleID[ifill++] = fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFDV); + if (fCurrentModule->GetParOffset(sddLR)>=0) { + m.fDerGlo[ifill][kX] = fDerivativeGlo[sddLR][0]; + m.fDerGlo[ifill][kZ] = fDerivativeGlo[sddLR][2]; + m.fParMilleID[ifill++] = fCurrentModule->GetParOffset(sddLR); } } // @@ -2570,6 +2803,7 @@ Int_t AliITSAlignMille2::AddLocalEquationTPA(Mille2Data &m) // int status = 0; // derivatives over the global parameters ---------------------------------------->>> + Double_t dGL[3]; // derivative of global position vs local X (for SDD) Double_t dRdP[3][3]; // derivative of local residuals vs local position Double_t dPdG[AliITSAlignMille2Module::kMaxParGeom][3]; // derivatives of local position vs global params fTPAFitter->GetDResDPos(&fDerivativeGlo[0][0], curpoint); @@ -2590,7 +2824,11 @@ Int_t AliITSAlignMille2::AddLocalEquationTPA(Mille2Data &m) if (fCurrentModule->GetParOffset(i)<0) continue; // this parameter is not explicitly fitted // if (!TestWordBit(dfDone,i)) { // need to calculate new derivative - if (!jacobOK) {fCurrentModule->CalcDerivDPosDPar(fCluster.GetVolumeID(),fMeasLoc,&dPdG[0][0]); jacobOK = kTRUE;} + if (!jacobOK) { + if (fCurrentSensID!=kVtxSensID) fCurrentModule->CalcDerivDPosDPar(fCluster.GetVolumeID(),fMeasLoc,&dPdG[0][0]); + else for (int ip=AliITSAlignMille2Module::kMaxParGeom;ip--;) for (int jp=3;jp--;) dPdG[ip][jp] = (ip==jp) ? 1:0; + jacobOK = kTRUE; + } // dRes_j/dGlo_i = \sum_{k=1:3} dRes_j/dPos_k * dPos_k/dGlo_i fDerivativeGlo[i][kX] = dRdP[kX][kX]*dPdG[i][kX] + dRdP[kY][kX]*dPdG[i][kY] + dRdP[kZ][kX]*dPdG[i][kZ]; fDerivativeGlo[i][kY] = dRdP[kX][kY]*dPdG[i][kX] + dRdP[kY][kY]*dPdG[i][kY] + dRdP[kZ][kY]*dPdG[i][kZ]; @@ -2610,16 +2848,31 @@ Int_t AliITSAlignMille2::AddLocalEquationTPA(Mille2Data &m) // assume for sensor local xloc = xloc0 + V0*dT0+dV*(T-T0) // where V0 and T are the nominal drift velocity, time and time0 // and the dT0 and dV are the corrections: - // dX/dT0 = dX/dxloc * dxloc/dT0 = dX/dxloc * V0 - // dX/dV = dX/dxloc * dxloc/dV = dX/dxloc * (T-T0) + // drloc_i/dT0 = sum_j drloc_i/dMeasGlo_j * dMeasGlo_j/dT0 = + // = sum_j drloc_i/dMeasGlo_j sum_k dMeasGlo_j/dMeasLoc_k * dMeasLoc_k/dT0 + // = sum_j drloc_i/dMeasGlo_j dMeasGlo_j/dMeasLoc_X * V0 + // + // drloc_i/dV0 = sum_j drloc_i/dMeasGlo_j * dMeasGlo_j/dV0 = + // = sum_j drloc_i/dMeasGlo_j sum_k dMeasGlo_j/dMeasLoc_k * dMeasLoc_k/dV0 + // = sum_j drloc_i/dMeasGlo_j dMeasGlo_j/dMeasLoc_X * T0 + // IMPORTANT: the geom derivatives are over the SENSOR LOCAL parameters // + Bool_t jacOK = kFALSE; + //Int_t sddLR = fMeasLoc[kX]>0 ? AliITSAlignMille2Module::kDOFDVL : AliITSAlignMille2Module::kDOFDVR; + Int_t sddLR = GetVDriftSDD()>0 ? AliITSAlignMille2Module::kDOFDVL : AliITSAlignMille2Module::kDOFDVR; if (fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFT0)>=0) { if (!TestWordBit(dfDone, AliITSAlignMille2Module::kDOFT0)) { double vdrift = GetVDriftSDD(); - fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kX] = -dRdP[kX][kX]*vdrift; - fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kY] = -dRdP[kX][kY]*vdrift; - fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kZ] = -dRdP[kX][kZ]*vdrift; + JacobianPosGloLoc(kX,dGL); + jacOK = kTRUE; + fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kX] = + vdrift*(dRdP[kX][kX]*dGL[kX] + dRdP[kY][kX]*dGL[kY] + dRdP[kZ][kX]*dGL[kZ]); + fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kY] = + vdrift*(dRdP[kX][kY]*dGL[kX] + dRdP[kY][kY]*dGL[kY] + dRdP[kZ][kY]*dGL[kZ]); + fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kZ] = + vdrift*(dRdP[kX][kZ]*dGL[kX] + dRdP[kY][kZ]*dGL[kY] + dRdP[kZ][kZ]*dGL[kZ]); + // SetWordBit(dfDone, AliITSAlignMille2Module::kDOFT0); } m.fDerGlo[ifill][kX] = fDerivativeGlo[AliITSAlignMille2Module::kDOFT0][kX]; @@ -2628,18 +2881,23 @@ Int_t AliITSAlignMille2::AddLocalEquationTPA(Mille2Data &m) m.fParMilleID[ifill++] = fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFT0); } // - if (fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFDV)>=0) { - if (!TestWordBit(dfDone, AliITSAlignMille2Module::kDOFDV)) { + if (fCurrentModule->GetParOffset(sddLR)>=0) { + if (!TestWordBit(dfDone, sddLR)) { double tdrift = TMath::Sign(GetTDriftSDD(), GetVDriftSDD()); - fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][kX] = dRdP[kX][kX]*tdrift; - fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][kY] = dRdP[kX][kY]*tdrift; - fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][kZ] = dRdP[kX][kZ]*tdrift; - SetWordBit(dfDone, AliITSAlignMille2Module::kDOFDV); + double vdrift = fIsSDDVDriftMult ? TMath::Abs(GetVDriftSDD()) : 1; + if (!jacOK) JacobianPosGloLoc(kX,dGL); + fDerivativeGlo[sddLR][kX] = + -tdrift*vdrift*(dRdP[kX][kX]*dGL[kX] + dRdP[kY][kX]*dGL[kY] + dRdP[kZ][kX]*dGL[kZ]); + fDerivativeGlo[sddLR][kY] = + -tdrift*vdrift*(dRdP[kX][kY]*dGL[kX] + dRdP[kY][kY]*dGL[kY] + dRdP[kZ][kY]*dGL[kZ]); + fDerivativeGlo[sddLR][kZ] = + -tdrift*vdrift*(dRdP[kX][kZ]*dGL[kX] + dRdP[kY][kZ]*dGL[kY] + dRdP[kZ][kZ]*dGL[kZ]); + SetWordBit(dfDone, sddLR); } - m.fDerGlo[ifill][kX] = fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][kX]; - m.fDerGlo[ifill][kY] = fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][kY]; - m.fDerGlo[ifill][kZ] = fDerivativeGlo[AliITSAlignMille2Module::kDOFDV][kZ]; - m.fParMilleID[ifill++] = fCurrentModule->GetParOffset(AliITSAlignMille2Module::kDOFDV); + m.fDerGlo[ifill][kX] = fDerivativeGlo[sddLR][kX]; + m.fDerGlo[ifill][kY] = fDerivativeGlo[sddLR][kY]; + m.fDerGlo[ifill][kZ] = fDerivativeGlo[sddLR][kZ]; + m.fParMilleID[ifill++] = fCurrentModule->GetParOffset(sddLR); } } // @@ -2672,12 +2930,16 @@ void AliITSAlignMille2::SetLocalEquations(const Mille2Data *marr, Int_t neq) // Bool_t filled = kFALSE; for (int ic=3;ic--;) { - if (ic==kY && !fUseLocalYErr) continue; + // for the diamond point (if any) the Y residual is accounted + if (ic==kY && !fUseLocalYErr && !(m.fModuleID[0]==fDiamondModID)) continue; AliDebug(2,Form("setting local equation %c with fMeas=%.6f and fSigma=%.6f",fgkXYZ[ic],m.fMeas[ic], m.fSigma[ic])); - Bool_t zero = kFALSE; - for (int i=fNLocal; i--;) zero |= SetLocalDerivative( i, m.fDerLoc[i][ic] ); + Int_t nzero = 0; + for (int i=fNLocal; i--;) nzero += SetLocalDerivative(i,m.fDerLoc[i][ic] ); + if (nzero==fNLocal) { + AliInfo(Form("Skipping %c residual due to the zero derivatives!",fgkXYZ[ic])); + continue; + } for (int i=m.fNGlobFilled;i--;) SetGlobalDerivative( m.fParMilleID[i] , m.fDerGlo[i][ic] ); - if (zero) { AliInfo(Form("Skipping %c residual due to the zero derivatives!",fgkXYZ[ic])); continue; } fMillepede->SetLocalEquation(fGlobalDerivatives, fLocalDerivatives, m.fMeas[ic], m.fSigma[ic]); filled = kTRUE; // @@ -2685,6 +2947,16 @@ void AliITSAlignMille2::SetLocalEquations(const Mille2Data *marr, Int_t neq) // if (filled) for (int i=m.fNModFilled;i--;) GetMilleModule(m.fModuleID[i])->IncNProcessedPoints(); } + // + double wgh = 1; + if (GetWeightPt() && fTPAFitter) { + wgh = fTPAFitter->GetPt(); + if (wgh>10) wgh = 10.; + if (wgh<0) wgh = fTPAFitter->IsTypeCosmics() ? 7 : 0.5; + if (GetWeightPt()>0) wgh = TMath::Power(wgh,GetWeightPt()); + } + fMillepede->SetRecordWeight(wgh*fTrackWeight); + // } //________________________________________________________________________________________________________ @@ -2733,7 +3005,7 @@ Int_t AliITSAlignMille2::LoadSuperModuleFile(const Char_t *sfile) { // load definitions of supermodules from a root file // return 0 if success - + AliInfo(Form("Loading SuperModule definitions from %s",sfile)); TFile *smf=TFile::Open(sfile); if (!smf->IsOpen()) { AliInfo(Form("Cannot open supermodule file %s",sfile)); @@ -2922,6 +3194,24 @@ void AliITSAlignMille2::ApplyGaussianConstraint(const AliITSAlignMille2ConstrArr int nmod = cstr->GetNModules(); double jacobian[AliITSAlignMille2Module::kMaxParGeom][AliITSAlignMille2Module::kMaxParGeom]; // + // check if this not special SDDT0 constraint + if (cstr->GetPattern()==BIT(AliITSAlignMille2Module::kDOFT0)) { + for (int i=0;iGetNModules()-1;i++) { + AliITSAlignMille2Module *mdI = GetMilleModule(cstr->GetModuleID(i)); + if (!mdI->IsFreeDOF(AliITSAlignMille2Module::kDOFT0)) continue; + for (int j=i+1;jGetNModules();j++) { + AliITSAlignMille2Module *mdJ = GetMilleModule(cstr->GetModuleID(j)); + if (!mdJ->IsFreeDOF(AliITSAlignMille2Module::kDOFT0)) continue; + // + ResetLocalEquation(); + fGlobalDerivatives[mdI->GetParOffset(AliITSAlignMille2Module::kDOFT0)] = 1; + fGlobalDerivatives[mdJ->GetParOffset(AliITSAlignMille2Module::kDOFT0)] =-1; + AddConstraint(fGlobalDerivatives, 0, 1.E-6); + } + } + return; + } + for (int imd=nmod;imd--;) { int modID = cstr->GetModuleID(imd); AliITSAlignMille2Module* mod = GetMilleModule(modID); @@ -3025,6 +3315,13 @@ void AliITSAlignMille2::ApplyPreConstraints() cstr->SetApplied(-1); } } + // + // do we need to tie the SDD left/right VDrift corrections + for (int imd=0;imdIsSDD() && mod->IsVDriftLRSame()) TieSDDVDriftsLR(mod); + } + // } //________________________________________________________________________________________________________ @@ -3181,7 +3478,7 @@ void AliITSAlignMille2::PostConstrainModuleSubUnits(Int_t type,Int_t idm, Double } // parent->SetParVal(ip, parent->GetParVal(ip) - shift); - AliInfo(Form("%s constraint: added %f shift to param[%d] of %d children of module %d: %s", + AliInfo(Form("%s constraint: added %+f shift to param[%d] of %d children of module %d: %s", type==AliITSAlignMille2Constraint::kTypeMean ? "MEAN" : "MEDIAN",shift, ip,npc,idm,parent->GetName())); } @@ -3236,7 +3533,7 @@ void AliITSAlignMille2::PostConstrainOrphans(Int_t type,Double_t val, UInt_t pat npc++; } // - AliInfo(Form("%s constraint: added %f shift to param[%d] of %d orphan modules", + AliInfo(Form("%s constraint: added %+f shift to param[%d] of %d orphan modules", type==AliITSAlignMille2Constraint::kTypeMean ? "MEAN" : "MEDIAN",shift, ip,npc)); } @@ -3401,27 +3698,43 @@ Int_t AliITSAlignMille2::ProcessUserInfo(TList* userInfo) // TMap *cdbMap=0; TList* cdbList=0; - TObjString *objStr,*keyStr; + TObjString *objStr,*objStr1,*keyStr; + TString cdbStr; AliCDBManager* man = AliCDBManager::Instance(); + man->SetCacheFlag(kFALSE); // int run = userInfo->GetUniqueID(); AliInfo(Form("UserInfo corresponds to run#%d",run)); cdbMap = (TMap*)userInfo->FindObject("cdbMap"); + const TMap *curMap = man->GetStorageMap(); if (!cdbMap) {AliInfo("No CDB Map found in UserInfo");} else { - if ((objStr=(TObjString*)cdbMap->GetValue("default"))) { // first set default CDB path - fDefCDBpath = objStr->GetString(); - if (fDefCDBpath.BeginsWith("raw://")) fDefCDBpath = "raw://"; - AliInfo(Form("Default CDB Storage from UserInfo: %s",fDefCDBpath.Data())); + if ((objStr=(TObjString*)cdbMap->GetValue("default"))) { // first set default CDB path + if ((objStr1=(TObjString*)curMap->GetValue("default")) && objStr1->GetUniqueID()) { + AliInfo(Form("OCDB default path from UserInfo: %s is overriden by user setting %s",objStr->GetName(),objStr1->GetName())); + } + else { + cdbStr = objStr->GetString(); + man->UnsetDefaultStorage(); + if (man->GetRaw()) man->SetRaw(kFALSE); + if (cdbStr.BeginsWith("raw://")) cdbStr = "raw://"; + AliInfo(Form("Default CDB Storage from UserInfo: %s",cdbStr.Data())); + man->SetDefaultStorage( cdbStr.Data() ); // this may be overriden later by configuration file + } } - man->SetDefaultStorage( fDefCDBpath.Data() ); // this may be overriden later by configuration file - man->SetRun(run); + if (man->GetRaw() && run>0) man->SetRun(run); // // set specific paths relevant for alignment TIter itMap(cdbMap); while( (keyStr=(TObjString*)itMap.Next()) ) { TString keyS = keyStr->GetString(); if ( keyS == "default" ) continue; + // + TObjString* curPath = (TObjString*)curMap->GetValue(keyStr->GetName()); + if (curPath && curPath->GetUniqueID()) { + AliInfo(Form("Storage for %s from UserInfo\n is overriden by user setting %s",keyS.Data(),curPath->GetName())); + continue; + } man->SetSpecificStorage( keyS.Data(), cdbMap->GetValue(keyS)->GetName() ); } } @@ -3431,18 +3744,59 @@ Int_t AliITSAlignMille2::ProcessUserInfo(TList* userInfo) else { // Deltas used for TrackPointArray production TIter itList(cdbList); + ResetBit(kSameInitDeltasBit); while( (objStr=(TObjString*)itList.Next()) ) if (objStr->GetString().Contains("ITS/Align/Data")) { - fInitDeltaPath = objStr->GetString(); - AliInfo(Form("Production Misalignment from UserInfo: %s",fInitDeltaPath.Data())); + TString newpath = objStr->GetString(); + AliInfo(Form("Production Misalignment from UserInfo: %s",newpath.Data())); + if (newpath != fIniDeltaPath) fIniDeltaPath = newpath; + else { + AliInfo("Production Misalignment is the same as already loaded"); + SetBit(kSameInitDeltasBit); + } break; } // SDD response (time0 and drift speed correction) used for TrackPointArray production itList.Reset(); + ResetBit(kSameInitSDDRespBit); while( (objStr=(TObjString*)itList.Next()) ) if (objStr->GetString().Contains("ITS/Calib/RespSDD")) { - fInitSDDRespPath = objStr->GetString(); - AliInfo(Form("Production SDD Response from UserInfo: %s",fInitSDDRespPath.Data())); + TString newpath = objStr->GetString(); + AliInfo(Form("Production SDD Response from UserInfo: %s",newpath.Data())); + if (newpath != fIniSDDRespPath) fIniSDDRespPath = newpath; + else { + AliInfo("Production SDD Response is the same as already loaded"); + SetBit(kSameInitSDDRespBit); + } + break; + } + // + // SDD vdrift used for TrackPointArray production + itList.Reset(); + ResetBit(kSameInitSDDVDriftBit); + while( (objStr=(TObjString*)itList.Next()) ) + if (objStr->GetString().Contains("ITS/Calib/DriftSpeedSDD")){ + TString newpath = objStr->GetString(); + AliInfo(Form("Production SDD VDrift from UserInfo: %s",newpath.Data())); + if (newpath != fIniSDDVDriftPath) fIniSDDVDriftPath = newpath; + else { + AliInfo("Production SDD VDrift is the same as already loaded"); + SetBit(kSameInitSDDVDriftBit); + } + break; + } + // Diamond constraint + itList.Reset(); + ResetBit(kSameDiamondBit); + while( (objStr=(TObjString*)itList.Next()) ) + if (objStr->GetString().Contains("GRP/Calib/MeanVertexSPD")){ + TString newpath = objStr->GetString(); + AliInfo(Form("Diamond constraint from UserInfo: %s",newpath.Data())); + if (newpath != fDiamondPath) fDiamondPath = newpath; + else { + AliInfo("Production Diamond Constraint is the same as already loaded"); + SetBit(kSameDiamondBit); + } break; } // @@ -3461,19 +3815,21 @@ Int_t AliITSAlignMille2::ProcessUserInfo(TList* userInfo) Int_t AliITSAlignMille2::LoadSDDResponse(TString& path, AliITSresponseSDD *&resp) { if (path.IsNull()) return 0; + AliInfo(Form("Loading SDD response from %s",path.Data())); // AliCDBEntry *entry = 0; + delete resp; resp = 0; while(1) { if (path.BeginsWith("path: ")) { // must load from OCDB - AliCDBId* cdbId = AliCDBId::MakeFromString( path.Data() ); - entry = AliCDBManager::Instance()->Get( *cdbId ); - delete cdbId; + entry = GetCDBEntry(path.Data()); if (!entry) break; resp = (AliITSresponseSDD*) entry->GetObject(); entry->SetObject(NULL); entry->SetOwner(kTRUE); - delete entry; + // AliCDBManager::Instance()->UnloadFromCache(cdbId->GetPath()); // don't want cached object, read new copy + // delete cdbId; + // delete entry; break; } // @@ -3484,6 +3840,7 @@ Int_t AliITSAlignMille2::LoadSDDResponse(TString& path, AliITSresponseSDD *&resp resp = (AliITSresponseSDD*) entry->GetObject(); if (resp && resp->InheritsFrom(AliITSresponseSDD::Class())) entry->SetObject(NULL); else resp = 0; + entry->SetObject(NULL); entry->SetOwner(kTRUE); delete entry; } @@ -3497,23 +3854,152 @@ Int_t AliITSAlignMille2::LoadSDDResponse(TString& path, AliITSresponseSDD *&resp return 0; } +//________________________________________________________________________________________________________ +Int_t AliITSAlignMille2::LoadSDDVDrift(TString& path, TObjArray *&arr) +{ + if (path.IsNull()) return 0; + AliInfo(Form("Loading SDD VDrift from %s",path.Data())); + // + AliCDBEntry *entry = 0; + delete arr; + arr = 0; + while(1) { + if (path.BeginsWith("path: ")) { // must load from OCDB + entry = GetCDBEntry(path.Data()); + if (!entry) break; + arr = (TObjArray*) entry->GetObject(); + entry->SetObject(NULL); + entry->SetOwner(kTRUE); + // AliCDBManager::Instance()->UnloadFromCache(cdbId->GetPath()); // don't want cached object, read new copy + // delete cdbId; + // delete entry; + break; + } + // + if (gSystem->AccessPathName(path.Data())) break; + TFile* precf = TFile::Open(path.Data()); + if (precf->FindKey("TObjArray")) arr = (TObjArray*)precf->Get("TObjArray"); + else if (precf->FindKey("AliCDBEntry") && (entry=(AliCDBEntry*)precf->Get("AliCDBEntry"))) { + arr = (TObjArray*) entry->GetObject(); + if (arr && arr->InheritsFrom(TObjArray::Class())) entry->SetObject(NULL); + else arr = 0; + entry->SetObject(NULL); + entry->SetOwner(kTRUE); + delete entry; + } + // + precf->Close(); + delete precf; + break; + } + // + if (!arr) {AliError(Form("Failed to load SDD vdrift from %s",path.Data())); return -1;} + arr->SetOwner(kTRUE); + return 0; +} + +//________________________________________________________________________________________________________ +Int_t AliITSAlignMille2::LoadDiamond(TString& path) +{ + if (path.IsNull()) return 0; + AliInfo(Form("Loading Diamond Constraint from %s",path.Data())); + // + AliCDBEntry *entry = 0; + AliESDVertex *vtx = 0; + while(1) { + if (path.BeginsWith("path: ")) { // must load from OCDB + entry = GetCDBEntry(path.Data()); + if (!entry) break; + vtx = (AliESDVertex*) entry->GetObject(); + entry->SetObject(NULL); + entry->SetOwner(kTRUE); + // AliCDBManager::Instance()->UnloadFromCache(cdbId->GetPath()); // don't want cached object, read new copy + // delete cdbId; + // delete entry; + break; + } + // + if (gSystem->AccessPathName(path.Data())) break; + TFile* precf = TFile::Open(path.Data()); + if (precf->FindKey("AliESDVertex")) vtx = (AliESDVertex*)precf->Get("AliESDVertex"); + else if (precf->FindKey("AliCDBEntry") && (entry=(AliCDBEntry*)precf->Get("AliCDBEntry"))) { + vtx = (AliESDVertex*) entry->GetObject(); + if (vtx && vtx->InheritsFrom(AliESDVertex::Class())) entry->SetObject(NULL); + else vtx = 0; + entry->SetObject(NULL); + entry->SetOwner(kTRUE); + delete entry; + } + // + precf->Close(); + delete precf; + break; + } + // + if (!vtx) {AliError(Form("Failed to load Diamond constraint from %s",path.Data())); return -1;} + // + double cmat[6]; + float cmatF[6]; + vtx->GetCovMatrix(cmat); + AliITSAlignMille2Module* diamMod = GetMilleModuleByVID(kVtxSensVID); + if (diamMod) { + cmat[0] *= diamMod->GetSigmaXFactor()*diamMod->GetSigmaXFactor(); + cmat[2] *= diamMod->GetSigmaYFactor()*diamMod->GetSigmaYFactor(); + cmat[5] *= diamMod->GetSigmaZFactor()*diamMod->GetSigmaZFactor(); + cmat[1] *= diamMod->GetSigmaXFactor()*diamMod->GetSigmaYFactor(); + cmat[3] *= diamMod->GetSigmaXFactor()*diamMod->GetSigmaZFactor(); + cmat[4] *= diamMod->GetSigmaYFactor()*diamMod->GetSigmaZFactor(); + } + cmatF[0] = cmat[0]; // xx + cmatF[1] = cmat[1]; // xy + cmatF[2] = cmat[3]; // xz + cmatF[3] = cmat[2]; // yy + cmatF[4] = cmat[4]; // yz + cmatF[5] = cmat[5]; // zz + fDiamond.SetXYZ(vtx->GetX(),vtx->GetY(),vtx->GetZ(), cmatF); + // + Double_t t0 = cmatF[3]*cmatF[5] - cmatF[4]*cmatF[4]; + Double_t t1 = cmatF[1]*cmatF[5] - cmatF[2]*cmatF[4]; + Double_t t2 = cmatF[1]*cmatF[4] - cmatF[2]*cmatF[3]; + Double_t det = cmatF[0]*t0 - cmatF[1]*t1 + cmatF[2]*t2; + float cmatFI[6]; + if (TMath::Abs(det)<1e-36) { + AliError("Diamond constraint cov.matrix is singular"); + vtx->Print(); + exit(1); + } + cmatFI[0] = t0/det; + cmatFI[1] = -t1/det; + cmatFI[2] = t2/det; + cmatFI[3] = (cmatF[0]*cmatF[5] - cmatF[2]*cmatF[2])/det; + cmatFI[4] = (cmatF[1]*cmatF[2] - cmatF[0]*cmatF[4])/det; + cmatFI[5] = (cmatF[0]*cmatF[3] - cmatF[1]*cmatF[1])/det; + fDiamondI.SetXYZ(vtx->GetX(),vtx->GetY(),vtx->GetZ(), cmatFI); + AliInfo("Will use following Diamond Constraint (errors inverted):"); + fDiamondI.Print(""); + delete vtx; + return 0; +} + //________________________________________________________________________________________________________ Int_t AliITSAlignMille2::LoadDeltas(TString& path, TClonesArray *&arr) { if (path.IsNull()) return 0; + AliInfo(Form("Loading Alignment Deltas from %s",path.Data())); // AliCDBEntry *entry = 0; + delete arr; arr = 0; while(1) { if (path.BeginsWith("path: ")) { // must load from OCDB - AliCDBId *cdbId = AliCDBId::MakeFromString( path.Data() ); - entry = AliCDBManager::Instance()->Get( *cdbId ); - delete cdbId; + entry = GetCDBEntry(path.Data()); if (!entry) break; arr = (TClonesArray*) entry->GetObject(); entry->SetObject(NULL); entry->SetOwner(kTRUE); - delete entry; + // AliCDBManager::Instance()->UnloadFromCache(cdbId->GetPath()); // don't want cached object, read new copy + // delete cdbId; + // delete entry; break; } // @@ -3524,6 +4010,7 @@ Int_t AliITSAlignMille2::LoadDeltas(TString& path, TClonesArray *&arr) arr = (TClonesArray*) entry->GetObject(); if (arr && arr->InheritsFrom(TClonesArray::Class())) entry->SetObject(NULL); else arr = 0; + entry->SetObject(NULL); entry->SetOwner(kTRUE); delete entry; } @@ -3533,6 +4020,7 @@ Int_t AliITSAlignMille2::LoadDeltas(TString& path, TClonesArray *&arr) } // if (!arr) {AliError(Form("Failed to load Deltas from %s",path.Data())); return -1;} + // return 0; } @@ -3553,6 +4041,9 @@ Int_t AliITSAlignMille2::CacheMatricesCurr() // } // + TGeoHMatrix *mcurr = new TGeoHMatrix(); + fCacheMatrixCurr.AddAtAndExpand(mcurr,kVtxSensID); // special unit matrix for diamond constraint + // fCacheMatrixCurr.SetOwner(kTRUE); return 0; } @@ -3566,26 +4057,31 @@ Int_t AliITSAlignMille2::CacheMatricesOrig() AliInfo("Building sensors original matrices cache"); // fCacheMatrixOrig.Delete(); - if (!fInitDeltaPath.IsNull()) { - if (LoadDeltas(fInitDeltaPath,fPrealignment) || ApplyToGeometry()) + if (!fIniDeltaPath.IsNull()) { + TClonesArray* prealSav = fPrealignment; + fPrealignment = 0; + if (LoadDeltas(fIniDeltaPath,fPrealignment) || ApplyToGeometry()) { AliError("Failed to load/apply initial deltas used to produce points"); return -1;} + delete fPrealignment; + fPrealignment = prealSav; } // for (int idx=0;idx<=kMaxITSSensID;idx++) { int volID = AliITSAlignMille2Module::GetVolumeIDFromIndex(idx); TGeoHMatrix *morig = new TGeoHMatrix(); - if (fUsePreAlignment) AliITSAlignMille2Module::SensVolMatrix(volID,morig); - else AliITSAlignMille2Module::SensVolOrigGlobalMatrix(volID,morig); + AliITSAlignMille2Module::SensVolMatrix(volID,morig); fCacheMatrixOrig.AddAtAndExpand(morig,idx); } // + // + TGeoHMatrix *mcurr = new TGeoHMatrix(); + fCacheMatrixOrig.AddAtAndExpand(mcurr,kVtxSensID); // special unit matrix for diamond constraint + // fCacheMatrixOrig.SetOwner(kTRUE); - if (fUsePreAlignment) { // the initial deltas were temporary attached to prealignment array, clean and reinitialize geometry - delete fPrealignment; - fPrealignment = 0; - fUsePreAlignment = 0; - InitGeometry(); - } + + fUsePreAlignment = 0; + InitGeometry(); + // return 0; } @@ -3729,29 +4225,58 @@ AliITSresponseSDD* AliITSAlignMille2::CreateSDDResponse() // eventual precalibration // // if there was a precalibration provided, copy it to new arrray - AliITSresponseSDD *precal = GetSDDPrecalibration(); - if (!precal) precal = GetSDDInit(); + AliITSresponseSDD *precal = GetSDDPrecalResp(); + if (!precal) precal = GetSDDInitResp(); + Bool_t isPreCalMult = precal&&precal->IsVDCorrMult() ? kTRUE : kFALSE; AliITSresponseSDD *calibSDD = new AliITSresponseSDD(); - // - for (int ind=kSDDoffsID;indSetModuleTimeZero(ind, precal? precal->GetTimeZero(ind) : 0.); - calibSDD->SetDeltaVDrift(ind, precal? precal->GetDeltaVDrift(ind) : 0.); + calibSDD->SetVDCorrMult(fIsSDDVDriftMult); + // + // copy initial values to the new object + if (precal) { + calibSDD->SetTimeOffset(precal->GetTimeOffset()); + calibSDD->SetADC2keV(precal->GetADC2keV()); + calibSDD->SetChargevsTime(precal->GetChargevsTime()); + for (int ind=kSDDoffsID;indSetModuleTimeZero(ind, precal->GetTimeZero(ind)); + calibSDD->SetDeltaVDrift(ind, precal->GetDeltaVDrift(ind),kFALSE); + calibSDD->SetDeltaVDrift(ind, precal->GetDeltaVDrift(ind),kTRUE); + calibSDD->SetADCtokeV(ind,precal->GetADCtokeV(ind)); + } } + else for (int ind=kSDDoffsID;indSetModuleTimeZero(ind,0); // Bool_t save = kFALSE; for (int imd=GetNModules();imd--;) { AliITSAlignMille2Module* md = GetMilleModule(imd); if (!md->IsSDD()) continue; - if (md->IsFreeDOF(AliITSAlignMille2Module::kDOFT0) || - md->IsFreeDOF(AliITSAlignMille2Module::kDOFDV)) save = kTRUE; - // + if (md->IsFreeDOF(AliITSAlignMille2Module::kDOFT0) || + md->IsFreeDOF(AliITSAlignMille2Module::kDOFDVL) || + md->IsFreeDOF(AliITSAlignMille2Module::kDOFDVR)) save = kTRUE; + // for (int is=0;isGetNSensitiveVolumes();is++) { int ind = md->GetSensVolIndex(is); - float t0 = calibSDD->GetTimeZero(ind) + md->GetParVal(AliITSAlignMille2Module::kDOFT0); - float dv = calibSDD->GetDeltaVDrift(ind) + md->GetParVal(AliITSAlignMille2Module::kDOFDV); + float t0 = calibSDD->GetTimeZero(ind) + md->GetParVal(AliITSAlignMille2Module::kDOFT0); + double dvL = md->GetParVal(AliITSAlignMille2Module::kDOFDVL); + double dvR = md->GetParVal(AliITSAlignMille2Module::kDOFDVR); + if (!calibSDD->IsVDCorrMult()) { // save as additive correction + dvL *= 1e4; + dvR *= 1e4; + // + double conv = 1; + if (isPreCalMult) conv = 6.4; // convert multiplicative precal correction to additive + dvL += calibSDD->GetDeltaVDrift(ind,kFALSE)*conv; + dvR += calibSDD->GetDeltaVDrift(ind,kTRUE)*conv; + } + else { // save as multipicative correction + double conv = 1; + if (!isPreCalMult) conv = 1./6.4; // convert additive precal correction to multiplicative + dvL += calibSDD->GetDeltaVDrift(ind,kFALSE)*conv; + dvR += calibSDD->GetDeltaVDrift(ind,kTRUE)*conv; + } // calibSDD->SetModuleTimeZero(ind, t0); - calibSDD->SetDeltaVDrift(ind, dv); + calibSDD->SetDeltaVDrift(ind, dvL, kFALSE); // left side correction + calibSDD->SetDeltaVDrift(ind, dvR, kTRUE); // right side correction } } // @@ -3764,3 +4289,244 @@ AliITSresponseSDD* AliITSAlignMille2::CreateSDDResponse() return calibSDD; } +//_______________________________________________________________________________________ +Int_t AliITSAlignMille2::ReloadInitCalib(TList *userInfo) +{ + // Use provided UserInfo to + // load the initial calib parameters (geometry, SDD response...) + // Can be used if set of data was processed with different calibration + // + if (!userInfo) { + AliInfo("Reloading of the Calibration parameters was called with empty userInfo"); + return 1; + } + if (ProcessUserInfo(userInfo)) { + AliInfo("Error in processing user info"); + userInfo->Print(); + exit(1); + } + return ReloadInitCalib(); +} + +//_______________________________________________________________________________________ +Int_t AliITSAlignMille2::ReloadInitCalib() +{ + // Load the initial calib parameters (geometry, SDD response...) + // Can be used if set of data was processed with different calibration + // + // 1st cache original matrices + if (!TestBit(kSameInitDeltasBit)) { // need to reload geometry + if (InitGeometry()) { + AliInfo("Failed to re-load ideal geometry"); + exit(1); + } + if (CacheMatricesOrig()) { + AliInfo("Failed to cache new initial geometry"); + exit(1); + } + // + // then reload the prealignment geometry + if (LoadDeltas(fPreDeltaPath,fPrealignment)) { + AliInfo(Form("Failed to reload the prealigned geometry %s",fPreDeltaPath.Data())); + exit(1); + } + // + if (fPrealignment && ApplyToGeometry()) { + AliInfo(Form("Failed re-apply prealigned geometry %s",fPreDeltaPath.Data())); + exit(1); + } + // + // usually no need to re-cache the prealignment geometry, it was not changed + if (fCacheMatrixCurr.GetEntriesFast() != fCacheMatrixOrig.GetEntriesFast()) { + // CacheMatricesCurr(); + AliInfo(Form("Failed to cache the prealigned geometry %s",fPreDeltaPath.Data())); + exit(1); + } + } + else ResetBit(kSameInitDeltasBit); + // + // reload initial SDD response + if (!TestBit(kSameInitSDDRespBit)) { + if (LoadSDDResponse(fIniSDDRespPath, fIniRespSDD) ) { + AliInfo(Form("Failed to load new SDD response %s",fIniSDDRespPath.Data())); + exit(1); + } + } + else ResetBit(kSameInitSDDRespBit); + // + // reload initial SDD vdrift + if (!TestBit(kSameInitSDDVDriftBit)) { + if (LoadSDDVDrift(fIniSDDVDriftPath, fIniVDriftSDD) ) { + AliInfo(Form("Failed to load new SDD VDrift %s",fIniSDDVDriftPath.Data())); + exit(1); + } + } + else ResetBit(kSameInitSDDRespBit); + // + // reload diamond info + if (!TestBit(kSameDiamondBit)) { + if (LoadDiamond(fDiamondPath) ) { + AliInfo(Form("Failed to load new Diamond constraint %s",fDiamondPath.Data())); + exit(1); + } + } + else ResetBit(kSameInitSDDRespBit); + // + + + return 0; +} + +//_______________________________________________________________________________________ +void AliITSAlignMille2::JacobianPosGloLoc(int locid,double* jacobian) +{ + // calculate the locid row of the jacobian for transformation of the local coordinate to global at current point + TGeoHMatrix* mat = GetSensorCurrMatrixSID(fCurrentSensID); + const Double_t dpar = 1e-2; + double sav = fMeasLoc[locid]; + fMeasLoc[locid] += dpar; + mat->LocalToMaster(fMeasLoc,jacobian); + fMeasLoc[locid] = sav; // recover original value + for (int i=3;i--;) jacobian[i] = (jacobian[i]-fMeasGlo[i])/dpar; // the transformation is linear!!! +} + +//_______________________________________________________________________________________ +void AliITSAlignMille2::TieSDDVDriftsLR(AliITSAlignMille2Module* mod) +{ + // impose equality of Left/Right sides VDrift correction for SDD + ResetLocalEquation(); + if ( (mod->IsFreeDOF(AliITSAlignMille2Module::kDOFDVL) + mod->IsFreeDOF(AliITSAlignMille2Module::kDOFDVR))==1) { + AliError("Left/Right VDrift equality is requested for SDD module with only one side VDrift free"); + mod->Print(); + return; + } + SetGlobalDerivative(mod->GetParOffset(AliITSAlignMille2Module::kDOFDVL), 1.); + SetGlobalDerivative(mod->GetParOffset(AliITSAlignMille2Module::kDOFDVR), -1.); + AddConstraint(fGlobalDerivatives, 0, 1e-12); + // +} + +//_______________________________________________________________________________________ +void AliITSAlignMille2::ProcessSDDPointInfo(const AliTrackPoint* pnt,Int_t sID, Int_t pntID) +{ + // extract the drift information from SDD track point + // + fDriftTime0[pntID] = fIniRespSDD ? fIniRespSDD->GetTimeZero(sID) : 0.; + double tdif = pnt->GetDriftTime() - fDriftTime0[pntID]; + if (tdif<0) tdif = 1; + // + // VDrift extraction + double vdrift = 0; + Bool_t sddSide = kFALSE; + int sID0 = 2*(sID-kSDDoffsID); + double zanode = -999; + // + if (fIniVDriftSDD) { // SDD VDrift object is provided, use the vdrift from it + AliITSDriftSpeedArraySDD* drarr; + double vdR,vdL,xlR,xlL; + // sometimes xlocal on right side is negative due to the wrong calibration, need to test both hypothesis + double xlabs = TMath::Abs(fMeasLoc[kX]); + drarr = (AliITSDriftSpeedArraySDD*)fIniVDriftSDD->At(sID0); // left side, xloc>0 + zanode = fSegmentationSDD->GetAnodeFromLocal(xlabs,fMeasLoc[kZ]); + vdL = drarr->GetDriftSpeed(0, zanode); + if (fIniRespSDD) { + double corr = fIniRespSDD->GetDeltaVDrift(sID, kFALSE); + if (fIniRespSDD->IsVDCorrMult()) vdL *= (1+corr); + else vdL += corr; + } + xlL = (fSegmentationSDD->Dx() - vdL*tdif)*1e-4; + // + drarr = (AliITSDriftSpeedArraySDD*)fIniVDriftSDD->At(sID0+1); // right side, xloc<0 + zanode = fSegmentationSDD->GetAnodeFromLocal(-xlabs,fMeasLoc[kZ]) - 256; + vdR = drarr->GetDriftSpeed(0, zanode); + if (fIniRespSDD) { + double corr = fIniRespSDD->GetDeltaVDrift(sID, kTRUE); + if (fIniRespSDD->IsVDCorrMult()) vdR *= (1+corr); + else vdR += corr; + } + xlR = -(fSegmentationSDD->Dx() - vdR*tdif)*1e-4; + // + if (TMath::Abs(xlL-fMeasLoc[kX])Dx()*1e-4 - TMath::Abs(fMeasLoc[kX]))/tdif; + sddSide = fMeasLoc[kX]<0; // 0 = left (xloc>0) ; 1 = right (xloc<1) + } + // + if (fPreVDriftSDD) { // use imposed vdrift as a starting point + zanode = fSegmentationSDD->GetAnodeFromLocal(0.5-sddSide,fMeasLoc[kZ]); + if (sddSide) zanode -= 256; + vdrift = ((AliITSDriftSpeedArraySDD*)fPreVDriftSDD->At(sID0+sddSide))->GetDriftSpeed(0, zanode)*1e-4; + } + // + if (vdrift<0) vdrift = 0; + // at this point we have vdrift and t0 used to create the original point. + // see if precalibration was provided + if (fPreRespSDD) { + float t0Upd = fPreRespSDD->GetTimeZero(sID); + double corr = fPreRespSDD->GetDeltaVDrift(sID, sddSide); + if (fPreRespSDD->IsVDCorrMult()) vdrift *= 1+corr; // right side (xloc<0) may have different correction + else vdrift += corr*1e-4; + tdif = pnt->GetDriftTime() - t0Upd; + // correct Xlocal + fMeasLoc[0] = fSegmentationSDD->Dx()*1e-4 - vdrift*tdif; + if (sddSide) fMeasLoc[0] = -fMeasLoc[0]; + fDriftTime0[pntID] = t0Upd; + } + // TEMPORARY CORRECTION (if provided) --------------<<< + fDriftSpeed[pntID] = sddSide ? -vdrift : vdrift; + // + // printf("#%d: t:%+e x:%+e v:%+e: side:%d\n",pntID,fDriftTime0[pntID],fMeasLoc[0],fDriftSpeed[pntID],sddSide); +} + +//_______________________________________________________________________________________ +AliITSAlignMille2Module* AliITSAlignMille2::CreateVertexModule() +{ + // creates dummy module for vertex constraint + TGeoHMatrix mt; + AliITSAlignMille2Module* mod = new AliITSAlignMille2Module(kVtxSensID,kVtxSensVID,"VTX",&mt,0,0); + fMilleModule.AddAtAndExpand(mod,fNModules); + mod->SetGeomParamsGlobal(fUseGlobalDelta); + fDiamondModID = fNModules; + mod->SetUniqueID(fNModules++); + mod->SetNotInConf(kTRUE); + return mod; + // +} + +//_______________________________________________________________________________________ +AliCDBEntry* AliITSAlignMille2::GetCDBEntry(const char* path) +{ + // return object from the OCDB + AliCDBEntry *entry = 0; + AliInfo(Form("Loading object %s",path)); + AliCDBManager* man = AliCDBManager::Instance(); + AliCDBId* cdbId = AliCDBId::MakeFromString(path); + if (!cdbId) { + AliError("Failed to create cdbId"); + return 0; + } + // + AliCDBStorage* stor = man->GetDefaultStorage(); + if (!stor && !man->GetRaw()) man->SetDefaultStorage("raw://"); + if (man->GetRaw()) man->SetRun(cdbId->GetFirstRun()); + if (stor) { + TString tp = stor->GetType(); + if (tp.Contains("alien",TString::kIgnoreCase) && !gGrid) TGrid::Connect("alien:"); + } + entry = man->Get( *cdbId ); + man->ClearCache(); + // + delete cdbId; + return entry; + // +} + diff --git a/ITS/AliITSAlignMille2.h b/ITS/AliITSAlignMille2.h index 00fbe84d2d4..405ae4a11f0 100644 --- a/ITS/AliITSAlignMille2.h +++ b/ITS/AliITSAlignMille2.h @@ -35,6 +35,9 @@ class AliITSAlignMille2Constraint; class AliITSAlignMille2ConstrArray; class AliITSresponseSDD; class AliITSTPArrayFit; +class AliITSsegmentationSDD; +class AliITSDriftSpeedArraySDD; +class AliCDBEntry; class AliITSAlignMille2: public TObject { @@ -44,9 +47,11 @@ class AliITSAlignMille2: public TObject enum {kNLocal=5,kMaxPoints=100, kNParChGeom = AliITSAlignMille2Module::kMaxParGeom, kNParCh = AliITSAlignMille2Module::kMaxParTot, - kMaxITSSensID=2197,kMaxITSSensVID=14300,kMinITSSupeModuleID=14336, + kMaxITSSensID=2197,kVtxSensID=kMaxITSSensID+1,kMaxITSSensVID=14300,kVtxSensVID=14371, + kMinITSSupeModuleID=14336, kSDDoffsID=240,kNSDDmod=260}; // + enum {kSameInitDeltasBit=BIT(14),kSameInitSDDRespBit=BIT(15),kSameInitSDDVDriftBit=BIT(16),kSameDiamondBit=BIT(17)}; public: // AliITSAlignMille2(const Char_t *configFilename="AliITSAlignMille.conf",TList* userInfo=0); @@ -73,6 +78,7 @@ class AliITSAlignMille2: public TObject AliITSAlignMille2Module* GetMilleModule(Int_t id) const {return (AliITSAlignMille2Module*)fMilleModule[id];} AliITSAlignMille2Module* GetCurrentModule() const {return fCurrentModule;} AliITSAlignMille2Module* GetSuperModule(Int_t id) const {return (AliITSAlignMille2Module*)fSuperModule[id];} + AliITSAlignMille2Module* CreateVertexModule(); // AliAlignObjParams* GetPrealignedObject(const Char_t* symname) const; AliAlignObjParams* GetConstrRefObject(const Char_t* symname) const; @@ -83,8 +89,9 @@ class AliITSAlignMille2: public TObject const Char_t* GetGeometryPath() {return fGeometryPath.Data();} const Char_t* GetPreAlignmentPath() {return fPreDeltaPath.Data();} TClonesArray* GetPreAlignmentDeltas() const {return fPrealignment;} - AliITSresponseSDD* GetSDDPrecalibration() const {return fCorrectSDD;} - AliITSresponseSDD* GetSDDInit() const {return fInitialRecSDD;} + AliITSresponseSDD* GetSDDPrecalResp() const {return fPreRespSDD;} + AliITSresponseSDD* GetSDDInitResp() const {return fIniRespSDD;} + TObjArray* GetSDDInitVDrift() const {return fIniVDriftSDD;} void PrintCurrentModuleInfo() const {if (fCurrentModule) fCurrentModule->Print();} void Print(Option_t*) const; Bool_t IsConfigured() const {return fIsConfigured;} @@ -108,14 +115,17 @@ class AliITSAlignMille2: public TObject AliTrackPointArray *PrepareTrack(const AliTrackPointArray *track); AliTrackPointArray *GetCurrentTrack() const {return (AliTrackPointArray*)fTrack;} AliTrackPoint *GetCurrentCluster() const {return (AliTrackPoint*)&fCluster;} + void ProcessSDDPointInfo(const AliTrackPoint* pnt,Int_t sID, Int_t pntID); void SetCurrentTrack(const AliTrackPointArray *atp) {fTrack = (AliTrackPointArray*)atp;} void SetCurrentCluster(const AliTrackPoint &atp); void InitTrackParams(int meth=1); - Int_t ProcessTrack(const AliTrackPointArray *track); + Int_t ProcessTrack(const AliTrackPointArray *track, Double_t wgh=1.0); + Int_t FitTrack(); Int_t CheckCurrentTrack(); // Int_t CalcIntersectionPoint(Double_t *lpar, Double_t *gpar); Int_t CalcDerivatives(Int_t paridx, Bool_t islpar); + void JacobianPosGloLoc(int locid,double* jacobian); Double_t* GetLocalIntersectionPoint() const {return (Double_t*)fPintLoc;} Double_t* GetGlobalIntersectionPoint() const {return (Double_t*)fPintGlo;} AliTrackPointArray *SortTrack(const AliTrackPointArray *atp); @@ -144,8 +154,10 @@ class AliITSAlignMille2: public TObject // TGeoHMatrix* GetSensorCurrMatrixSID(Int_t sid) const; TGeoHMatrix* GetSensorCurrMatrixVID(Int_t vid) const; - + // + AliCDBEntry* GetCDBEntry(const char* path); // Hierarchical contraints + void TieSDDVDriftsLR(AliITSAlignMille2Module* mod); Bool_t PseudoParentsAllowed() const {return fAllowPseudoParents;} void ConstrainModuleSubUnitsMean(Int_t idm, Double_t val=0, UInt_t pattern=0xff); void ConstrainModuleSubUnitsMedian(Int_t idm, Double_t val=0, UInt_t pattern=0xff); @@ -157,6 +169,10 @@ class AliITSAlignMille2: public TObject void ApplyPreConstraints(); void ApplyPostConstraints(); // + void SetWeightPt(Double_t w=1) {fWeightPt = w;} + void SetSDDVDCorrMult(Bool_t v=kTRUE) {fIsSDDVDriftMult=v;} + Double_t GetWeightPt() const {return fWeightPt;} + Bool_t IsSDDVDCorrMult() const {return fIsSDDVDriftMult;} Bool_t IsParModConstrained(const AliITSAlignMille2Module* mod,Int_t par, Bool_t &meanmed, Bool_t &gaussian) const; Bool_t IsParModFamilyVaried(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999) const; Bool_t IsParFamilyFree(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999) const; @@ -172,6 +188,9 @@ class AliITSAlignMille2: public TObject // Double_t GetTDriftSDD() const; Double_t GetVDriftSDD() const; + Double_t GetDriftSpeed(Int_t id) const {return fDriftSpeed[id];} + Double_t GetDriftTime0(Int_t id) const {return fDriftTime0[id];} + // AliITSAlignMille2Constraint* GetConstraint(Int_t i) const {return (AliITSAlignMille2Constraint*)fConstraints.At(i);} AliITSAlignMille2Constraint* GetConstraint(const char* name) const {return (AliITSAlignMille2Constraint*)fConstraints.FindObject(name);} @@ -185,6 +204,7 @@ class AliITSAlignMille2: public TObject Double_t *GetSigmaLoc() const {return (Double_t*)fSigmaLoc;} Double_t GetBField() const {return fBField;} Bool_t IsFieldON() const {return fBOn;} + Bool_t IsDiamondUsed() const {return fUseDiamond;} Double_t *GetLocalInitParam() const {return (Double_t*)fLocalInitParam;} Double_t *GetLocalInitParEr() const {return (Double_t*)fLocalInitParEr;} Double_t GetLocalDif(int par, int coor) const {return fDerivativeLoc[par][coor];} @@ -219,7 +239,7 @@ class AliITSAlignMille2: public TObject // protected: // - struct Mille2Data { // structure to store data for 2 LocalEquations (X and Z) + struct Mille2Data { // structure to store data for LocalEquations (X and Z, optionally Y) enum {kMaxLev = 7}; Double_t fMeas[3]; // measured coordinates Double_t fSigma[3]; // measured errors @@ -237,11 +257,15 @@ class AliITSAlignMille2: public TObject Int_t LoadConfig(const Char_t *cfile="AliITSAlignMille.conf"); TObjArray* GetConfigRecord(FILE* stream, TString& recTitle, TString& recOpt, Bool_t rew); Int_t CheckConfigRecords(FILE* stream); + Int_t ReloadInitCalib(TList *userInfo); + Int_t ReloadInitCalib(); // void BuildHierarchy(); Int_t LoadSuperModuleFile(const Char_t *cfile="ITSMilleSuperModules.root"); Int_t LoadSDDResponse(TString& path, AliITSresponseSDD *&resp); + Int_t LoadSDDVDrift(TString& path, TObjArray *&arr); Int_t LoadDeltas(TString& path, TClonesArray *&arr); + Int_t LoadDiamond(TString& path); void ResetLocalEquation(); Int_t InitGeometry(); Int_t ApplyToGeometry(); @@ -253,7 +277,7 @@ class AliITSAlignMille2: public TObject // void SetGeometryPath(const Char_t* filename="geometry.root") { fGeometryPath = filename; } - void SetInitTrackParamsMeth(Int_t meth=1) {fInitTrackParamsMeth=meth;} + void SetInitTrackParamsMeth(Int_t meth=1) {fIniTrackParamsMeth=meth;} // void AddConstraint(Double_t *factor, Double_t value, Double_t sigma=0); void InitGlobalParameters(Double_t *par); @@ -275,13 +299,16 @@ class AliITSAlignMille2: public TObject protected: // enum { - kOCDBPath, + kOCDBDefaultPath, + kOCDBSpecificPath, kGeomFile, kSuperModileFile, kConstrRefFile, kPreDeltaFile, kPreCalSDDFile, + kPreVDriftSDDFile, kInitCalSDDFile, + kInitVDriftSDDFile, kInitDeltaFile, kGlobalDeltas, kConstrLocal, @@ -295,6 +322,7 @@ class AliITSAlignMille2: public TObject kResCutOther, kLocalSigFactor, kStartFactor, + kFinalFactor, kBField, kSparseMatrix, kRequirePoint, @@ -305,13 +333,18 @@ class AliITSAlignMille2: public TObject kTPAFitter, kUseLocalYErr, kMinPointsSens, + kSDDVDCorrMult, + kWeightPt, + kUseDiamond, + kSameSDDT0, // kNKeyWords }; // id's of the keywirds for config file records // millepede stuffs AliMillePede2 *fMillepede; // Detector independent alignment class - Double_t fStartFac; // Initial value for chi2 cut + Double_t fStartFac; // Initial factor for chi2 cut + Double_t fFinalFac; // Final factor for chi2 cut Double_t fResCutInitial; // Cut on residual for first iteration Double_t fResCut; // Cut on residual for other iterations Int_t fNGlobal; // Number of global parameters @@ -346,10 +379,10 @@ class AliITSAlignMille2: public TObject Double_t fConstrPTErr; // error on this constraint (0 - exact) Int_t fConstrCharge; // optional constraint on charge of Helix track (0 - no constraint) // - Double_t fDerivativeLoc[kNLocal][3]; // XYZ deriv. over local params + Double_t fDerivativeLoc[kNLocal][3]; // XYZ deriv. over local params Double_t fDerivativeGlo[kNParCh][3]; // XYZ deriv. over global params Int_t fMinNPtsPerTrack; // min number of points per track to accept it - Int_t fInitTrackParamsMeth; // method for track fit + Int_t fIniTrackParamsMeth; // method for track fit Int_t fTotBadLocEqPoints; // total number of reject points because of bad EqLoc AliTrackFitterRieman *fRieman; // riemann fitter for helices // @@ -369,20 +402,26 @@ class AliITSAlignMille2: public TObject // << new members // // OCDB stuff - TString fDefCDBpath; // default OCDB path - TString fInitDeltaPath; // where to take the deltas used to produce the points - TString fInitSDDRespPath; // where to take the initial SDD response used to produce the points + TList *fIniUserInfo; // initial user info (validity is not guaranteed after initialization) + TString fIniDeltaPath; // where to take the deltas used to produce the points + TString fIniSDDRespPath; // where to take the initial SDD response used to produce the points TString fPreCalSDDRespPath; // precalibration SDD response file name + TString fIniSDDVDriftPath; // initial SDD vdrift file name + TString fPreSDDVDriftPath; // initial SDD vdrift file name // geometry stuffs TString fGeometryPath; // Geometry file name TString fPreDeltaPath; // file with prealigned objects TString fConstrRefPath; // file with prealigned objects wrt which constraints are defined + TString fDiamondPath; // file with diamond constraint TGeoManager *fGeoManager; // pointer to Alice geomanager Bool_t fIsConfigured; // flag for loaded config file TArrayS fPreAlignQF; // prealignment flags (not used?) // - AliITSresponseSDD* fCorrectSDD; // array of SDD t0/vdrift calib params - AliITSresponseSDD* fInitialRecSDD; // array of SDD t0/vdrift calib params used to create the track points + AliITSresponseSDD* fIniRespSDD; // array of SDD t0/vdrift calib params used to create the track points + AliITSresponseSDD* fPreRespSDD; // array of SDD t0/vdrift calib params + TObjArray* fIniVDriftSDD; // array of AliITSDriftSpeedArraySDD objects used for original reco + TObjArray* fPreVDriftSDD; // array of AliITSDriftSpeedArraySDD objects to be used as a starting point instead of fIniVDriftSDD + AliITSsegmentationSDD* fSegmentationSDD; // extraction of SDD segmentation params TClonesArray* fPrealignment; // array of prealignment global deltas TClonesArray* fConstrRef; // array of refererence deltas with respect to which the constraint are defined (survey?) TObjArray fMilleModule; /// array of super modules to be aligned @@ -403,9 +442,17 @@ class AliITSAlignMille2: public TObject Int_t fExtraClustersMode; /// 1=remove random / 2=remove internal / 10=use only tracks with xcl // endpepo270809 // + Double_t fTrackWeight; //weight given by the user to current track + Double_t fWeightPt; //weight track equations by pT in this power + Bool_t fIsSDDVDriftMult; //use multiplicative correction for SDD vdrift Double_t fDriftSpeed[50]; //temporary array for drift times of SDD alitrackpoints Double_t fDriftTime0[50]; //temporary array for drift time 0's used for SDD alitrackpoints Double_t fExtClusterPar[9]; //array to store the parameters of the externally imposed cluster + AliTrackPoint fDiamond; //optional constraint on the vertex + AliTrackPoint fDiamondI; //constraint on the vertex with inverted error matrix + Bool_t fUseDiamond; //use diamond as a vertex constraint + Int_t fDiamondPointID; //ID of the diamond point in the track + Int_t fDiamondModID; //id of the fake diamond module // static AliITSAlignMille2* fgInstance; // global pointer on itself static Int_t fgInstanceID; // global counter of the instances diff --git a/ITS/AliITSAlignMille2ConstrArray.cxx b/ITS/AliITSAlignMille2ConstrArray.cxx index fd7a8c6c60d..73b9d29a6b8 100644 --- a/ITS/AliITSAlignMille2ConstrArray.cxx +++ b/ITS/AliITSAlignMille2ConstrArray.cxx @@ -34,7 +34,7 @@ AliITSAlignMille2ConstrArray::AliITSAlignMille2ConstrArray(const AliITSAlignMill {/* DUMMY */} //________________________________________________________________________________________________________ -void AliITSAlignMille2ConstrArray::AddModule(AliITSAlignMille2Module* mod) +void AliITSAlignMille2ConstrArray::AddModule(AliITSAlignMille2Module* mod, Bool_t needGeom) { int nmd = GetNModules(); // check if its already not there @@ -42,20 +42,22 @@ void AliITSAlignMille2ConstrArray::AddModule(AliITSAlignMille2Module* mod) fModuleIDs.Set(nmd+1); fModulePatt.Set(nmd+1); fModuleIDs[nmd] = mod->GetUniqueID(); - double jacobian[AliITSAlignMille2Module::kMaxParGeom][AliITSAlignMille2Module::kMaxParGeom]; - if (mod->GeomParamsGlobal()) mod->CalcDerivLocGlo(&jacobian[0][0]); - // - Short_t patt = GetPattern(); - if (mod->GeomParamsGlobal()) { - // the constraint is defined in the module's local frame. If the alignment of geom params is - // done in the global frame, we need to set the real parameter involved - patt &= 0xffff<< AliITSAlignMille2Module::kMaxParGeom; // reset the geometry parameters - for (int i=0;iGeomParamsGlobal()) mod->CalcDerivLocGlo(&jacobian[0][0]); + // + Short_t patt = GetPattern(); + if (mod->GeomParamsGlobal()) { + // the constraint is defined in the module's local frame. If the alignment of geom params is + // done in the global frame, we need to set the real parameter involved + patt &= 0xffff<< AliITSAlignMille2Module::kMaxParGeom; // reset the geometry parameters + for (int i=0;i0) fParCstr[dof] = fgkDummyConstraint+1.; // the parameter is free and unconstrained - else if (cstr<0) fParCstr[dof] = -cstr; // the parameter is free but constrained - else fParCstr[dof] = 0; // fixed parameter + if (AliITSAlignMille2::IsZero(cstr)) fParCstr[dof] = 0; // fixed parameter + else if (cstr>0) fParCstr[dof] = fgkDummyConstraint+1.; // the parameter is free and unconstrained + else fParCstr[dof] = -cstr; // the parameter is free but constrained } //------------------------------------------------------------- @@ -759,11 +759,14 @@ void AliITSAlignMille2Module::Print(Option_t*) const printf("Factors : X=%.2f Y=%.2f Z=%.2f\n" "DOF: %cTx:%5d| %cTy:%5d| %cTz:%5d| %cPsi:%5d| %cTheta:%5d| %cPhi:%5d|", fSigmaFactor[0],fSigmaFactor[1],fSigmaFactor[2], - IsFreeDOF(kDOFTX) ? '+':'-',fParOffs[kDOFTX],IsFreeDOF(kDOFTY) ? '+':'-',fParOffs[kDOFTY], - IsFreeDOF(kDOFTZ) ? '+':'-',fParOffs[kDOFTZ],IsFreeDOF(kDOFPS) ? '+':'-',fParOffs[kDOFPS], - IsFreeDOF(kDOFTH) ? '+':'-',fParOffs[kDOFTH],IsFreeDOF(kDOFPH) ? '+':'-',fParOffs[kDOFPH]); - if (IsSDD()) printf("%cT0:%5d| %cDV:%5d|",IsFreeDOF(kDOFT0)?'+':'-',fParOffs[kDOFT0], - IsFreeDOF(kDOFDV)?'+':'-',fParOffs[kDOFDV]); + IsFreeDOF(kDOFTX) ? '+':'-',GetParOffset(kDOFTX),IsFreeDOF(kDOFTY) ? '+':'-',GetParOffset(kDOFTY), + IsFreeDOF(kDOFTZ) ? '+':'-',GetParOffset(kDOFTZ),IsFreeDOF(kDOFPS) ? '+':'-',GetParOffset(kDOFPS), + IsFreeDOF(kDOFTH) ? '+':'-',GetParOffset(kDOFTH),IsFreeDOF(kDOFPH) ? '+':'-',GetParOffset(kDOFPH)); + if (IsSDD()) { + printf("%cT0:%5d| %cDVl:%5d| %cDVr:%5d|",IsFreeDOF(kDOFT0)?'+':'-',GetParOffset(kDOFT0), + IsFreeDOF(kDOFDVL)?'+':'-',GetParOffset(kDOFDVL),IsFreeDOF(kDOFDVR)?'+':'-',GetParOffset(kDOFDVR)); + if (IsVDriftLRSame()) printf("(dVL=dVR)"); + } printf("\n"); fMatrix->Print(); printf("%4d Sensitive volumes | %6d Processed Points\n",fNSensVol,fNProcPoints); @@ -797,7 +800,7 @@ void AliITSAlignMille2Module::AssignDetType() else if (tp.Contains("SDD",TString::kIgnoreCase)) fDetType = kSDD; else if (tp.Contains("SSD",TString::kIgnoreCase)) fDetType = kSSD; else fDetType = -1; - fNParTot = IsSDD() ? 8:6; + fNParTot = IsSDD() ? kMaxParTot:kMaxParGeom; fNParFree = 0; fParVals = new Float_t[fNParTot]; fParErrs = new Float_t[fNParTot]; diff --git a/ITS/AliITSAlignMille2Module.h b/ITS/AliITSAlignMille2Module.h index 3091166c7d3..1c82a6b3461 100644 --- a/ITS/AliITSAlignMille2Module.h +++ b/ITS/AliITSAlignMille2Module.h @@ -28,8 +28,8 @@ class AliITSAlignMille2Module : public TNamed { public: enum {kSPD,kSDD,kSSD}; - enum {kMaxParGeom=6,kMaxParTot=8,kSensDefBit=BIT(14),kGlobalGeomBit=BIT(15),kNotInConfBit=BIT(16)}; - enum {kDOFTX,kDOFTY,kDOFTZ,kDOFPS,kDOFTH,kDOFPH,kDOFT0,kDOFDV}; + enum {kMaxParGeom=6,kMaxParTot=9,kSensDefBit=BIT(14),kGlobalGeomBit=BIT(15),kNotInConfBit=BIT(16),kVdSDDSameLRBit=BIT(17)}; + enum {kDOFTX,kDOFTY,kDOFTZ,kDOFPS,kDOFTH,kDOFPH,kDOFT0,kDOFDVL,kDOFDVR}; // AliITSAlignMille2Module(); AliITSAlignMille2Module(UShort_t volid); @@ -53,10 +53,12 @@ public: Float_t GetSigmaYFactor() const {return fSigmaFactor[1];} Float_t GetSigmaZFactor() const {return fSigmaFactor[2];} Int_t GetNProcessedPoints() const {return fNProcPoints;} - Bool_t IsFreeDOF(Int_t dof) const {return fParCstr[dof]>0;} + Bool_t IsFreeDOF(Int_t dof) const {return dof0;} Bool_t AreSensorsProvided() const {return TestBit(kSensDefBit);} Bool_t GeomParamsGlobal() const {return TestBit(kGlobalGeomBit);} Bool_t IsNotInConf() const {return TestBit(kNotInConfBit);} + Bool_t IsVDriftLRSame() const {return TestBit(kVdSDDSameLRBit);} + // Bool_t IsIn(UShort_t volid) const; Bool_t IsAlignable() const; Bool_t BelongsTo(AliITSAlignMille2Module* parent) const; @@ -70,10 +72,10 @@ public: UShort_t GetNParTot() const {return fNParTot;} UShort_t GetNParFree() const {return fNParFree;} Float_t *GetParVals() const {return fParVals;} - Double_t GetParVal(int par) const {return fParVals[par];} - Double_t GetParErr(int par) const {return fParErrs[par];} - Double_t GetParConstraint(int par) const {return fParCstr[par];} - Int_t GetParOffset(Int_t par) const {return fParOffs[par];} + Double_t GetParVal(int par) const {return par0 && fParCstr[par] +#include ClassImp(AliITSTPArrayFit) @@ -87,7 +88,7 @@ Double_t AliITSTPArrayFit::fgRhoLITS[AliITSTPArrayFit::kMaxLrITS] = { AliITSTPArrayFit::AliITSTPArrayFit() : fkPoints(0),fParSol(0),fBz(0),fCharge(0),fPntFirst(-1), fPntLast(-1),fNPBooked(0),fParAxis(-1),fCovI(0),fChi2NDF(0), - fMaxIter(20),fIter(0),fEps(1e-6),fMass(0),fSwitch2Line(kFALSE),fMaxRforHelix(1.e6), + fMaxIter(20),fIter(0),fEps(1e-6),fMass(0),fSwitch2Line(kFALSE),fMaxRforHelix(6.e5), fkAxID(0),fkAxCID(0),fCurT(0), fFirstPosT(0),fNElsPnt(0),fElsId(0),fElsDR(0) { @@ -101,7 +102,7 @@ AliITSTPArrayFit::AliITSTPArrayFit() : AliITSTPArrayFit::AliITSTPArrayFit(Int_t np) : fkPoints(0),fParSol(0),fBz(0),fCharge(0),fPntFirst(-1), fPntLast(-1),fNPBooked(np),fParAxis(-1),fCovI(0),fChi2NDF(0), - fMaxIter(20),fIter(0),fEps(1e-6),fMass(0),fSwitch2Line(kFALSE),fMaxRforHelix(2.e3), + fMaxIter(20),fIter(0),fEps(1e-6),fMass(0),fSwitch2Line(kFALSE),fMaxRforHelix(6.e5), fkAxID(0),fkAxCID(0),fCurT(0),fFirstPosT(0),fNElsPnt(0),fElsId(0),fElsDR(0) { // constructor with booking of np points @@ -415,23 +416,28 @@ Double_t AliITSTPArrayFit::GetPosition(Double_t *xyzPCA, const Double_t *xyz, co } //____________________________________________________ -Double_t AliITSTPArrayFit::GetPosition(Double_t *xyzPCA, const AliTrackPoint *pntCovInv) const +Double_t AliITSTPArrayFit::GetPosition(Double_t *xyzPCA, const AliTrackPoint *pntCovInv, Bool_t useErr) const { // calculate the position of the track at PCA to pntCovInv // NOTE: the covariance matrix of the point must be inverted - Double_t covI[6],xyz[3] = {pntCovInv->GetX(),pntCovInv->GetY(),pntCovInv->GetZ()}; - for (int i=6;i--;) covI[i] = pntCovInv->GetCov()[i]; - Double_t t = GetParPCA(xyz,covI); + double t; + double xyz[3] = {pntCovInv->GetX(),pntCovInv->GetY(),pntCovInv->GetZ()}; + if (useErr) { + Double_t covI[6];; + for (int i=6;i--;) covI[i] = pntCovInv->GetCov()[i]; + t = GetParPCA(xyz,covI); + } + else t = GetParPCA(xyz); GetPosition(xyzPCA,t); return t; } //____________________________________________________ -void AliITSTPArrayFit::GetResiduals(Double_t *resPCA, const AliTrackPoint *pntCovInv) const +void AliITSTPArrayFit::GetResiduals(Double_t *resPCA, const AliTrackPoint *pntCovInv, Bool_t useErr) const { // calculate the residuals of the track at PCA to pntCovInv // NOTE: the covariance matrix of the point must be inverted - GetPosition(resPCA,pntCovInv); + GetPosition(resPCA,pntCovInv,useErr); resPCA[0] -= pntCovInv->GetX(); resPCA[1] -= pntCovInv->GetY(); resPCA[2] -= pntCovInv->GetZ(); @@ -670,7 +676,7 @@ void AliITSTPArrayFit::GetDResDParams(Double_t *dXYZdP, const Double_t *xyz, con { // get residual detivatives over the track parameters for the point with least weighted distance to the point // - if (!IsFieldON()) { // for the straight line calculate analytically + if (!IsHelix()) { // for the straight line calculate analytically GetDResDParamsLine(dXYZdP, xyz, covI); return; } @@ -704,7 +710,7 @@ void AliITSTPArrayFit::GetDResDPos(Double_t *dXYZdP, const Double_t *xyz, const // get residuals detivative over the point position for the point with least weighted distance to the point // - if (!IsFieldON()) { // for the straight line calculate analytically + if (!IsHelix()) { // for the straight line calculate analytically GetDResDPosLine(dXYZdP, /*xyz,*/ covI); return; } @@ -748,6 +754,9 @@ Double_t AliITSTPArrayFit::GetParPCAHelix(const Double_t* xyz, const Double_t* c Double_t dzD = -fParams[kR0]*fParams[kDip]; Double_t dphi = 0; // + double rEps = 1e-5/TMath::Abs(fParams[kR0]); // dphi corresponding to 0.1 micron + if (rEps>fEps) rEps = fEps; + // int it=0; do { cs = TMath::Cos(phi + fParams[kPhi0]); @@ -782,9 +791,10 @@ Double_t AliITSTPArrayFit::GetParPCAHelix(const Double_t* xyz, const Double_t* c ddchi2 = dxDD*dx + dyDD*dy + + dxD*dxD + dyD*dyD + dzD*dzD; } // - if (TMath::Abs(ddchi2)GetX(),*y=fkPoints->GetY(),*z=fkPoints->GetZ(),*cov=fkPoints->GetCov(); + // + if (fPntLast>arrU.GetSize()) { + arrU.Set(2*fPntLast); + arrV.Set(2*fPntLast); + arrW.Set(2*fPntLast); + } + parrU = arrU.GetArray(); + parrV = arrV.GetArray(); + parrW = arrW.GetArray(); + // + double uav=0,vav=0,wav=0,muu=0,muv=0,muw=0,mvv=0,mvw=0,mww=0; + int minRId = fPntFirst; + // + // get points span + double xmn=1e9,xmx=-1e9, ymn=1e9,ymx=-1e9; + for (int i=fPntFirst;i<=fPntLast;i++) { + parrW[i] = x[i]*x[i]+y[i]*y[i]; + if (parrW[i]x[i]) xmn = x[i]; + if (xmxy[i]) ymn = y[i]; + if (ymxfPntFirst ? fPntFirst:fPntFirst+1; + for (int i=fPntFirst;i<=fPntLast;i++) if (parrW[i]0 ? TMath::Sqrt(dfpp)/q : 0; + double ph = TMath::ATan( dfpp )/3.; + if (ph<0) ph += TMath::Pi()/3; + p = p>0 ? TMath::Sqrt(p) : 0; + const double kSqrt3 = 1.73205080; + double snp = TMath::Sin(ph); + double csp = TMath::Cos(ph); + // double eg1 = trace3 + 2*p*csp; + double eg2 = trace3 - p*(csp+kSqrt3*snp); // smallest one + // double eg3 = trace3 - p*(csp-kSqrt3*snp); + // eigenvector for min.eigenvalue + muut = muu-eg2; + mvvt = mvv-eg2; + mwwt = mww-eg2; + double n0 = muv*mvw-muw*mvvt; + double n1 = muv*muw-mvw*muut; + double n2 = muut*mvvt-muv*muv; + // normalize to largest one + double nrm = TMath::Abs(n0); + if (nrm>> + int sqb; + if (extQ) { + SetCharge(extQ); + sqb = fBz<0 ? -GetCharge():GetCharge(); + } + else { + // determine the charge from the collision type and field sign + // the negative Q*B will have positive Vc x dir product Z component + // with Vc={-xc,-yc} : vector from circle center to the origin + // and V0 - track direction vector (take {0,-1,1} for cosmics) + // If Bz is not provided, assume positive Bz + if ( IsTypeCosmics() ) sqb = xc>0 ? -1:1; + else { + // track direction vector as a - diference between the closest and the next to closest to origin points + double v0X = x[minRId1] - x[minRId]; + double v0Y = y[minRId1] - y[minRId]; + sqb = (yc*v0X - xc*v0Y)<0 ? -1:1; + } + SetCharge( fBz<0 ? -sqb : sqb); + } + // + Double_t phi = TMath::ATan2(yc,xc); + if (sqb<0) phi += TMath::Pi(); + if (phi > TMath::Pi()) phi -= 2.*TMath::Pi(); + else if (phi <-TMath::Pi()) phi += 2.*TMath::Pi(); + fParams[kPhi0] = phi; + fParams[kR0] = sqb<0 ? -rad:rad; + fParams[kD0] = xc*TMath::Cos(phi) + yc*TMath::Sin(phi) - fParams[kR0]; + // + // decide sign(Q*B) and fill cicrle parameters ------------------------- <<< + // + // find z-offset and dip + the parameter t of closest approach to hits - >>> + // + UInt_t hitLrPos=0; // pattern of hit layers at pos + UInt_t hitLrNeg=0; // and negative t's + + Double_t ss=0,st=0,sz=0,stt=0,szt=0; + for (int i=fPntFirst;i<=fPntLast;i++) { + // + Double_t ze2 = cov[i*6 + kZZ]; + Double_t t = TMath::ATan2(yc-y[i],xc-x[i]) - fParams[kPhi0]; // angle at measured z + if (fParams[kR0]<0) t += TMath::Pi(); + if (t > TMath::Pi()) t -= TMath::Pi()*2; + else if (t <-TMath::Pi()) t += TMath::Pi()*2; + if (ze20) hitLrPos |= (1<>> + if (eloss) { + fNElsPnt = fPntLast - fPntFirst + 1; + // + // to account for the energy loss in the passive volumes, calculate the relevant t-parameters + double* tcur = fCurT + fPntFirst; + double* ecur = fElsDR+ fPntFirst; + // + for (int ilp=3;ilp--;) { + int id = fgkPassivLrITS[ilp]; + double tp = GetHelixParAtR( fgkRLayITS[ id ] ); + if (tp<0) continue; // does not hit this radius + // + tcur[fNElsPnt] = GetSignQB()>0 ? -tp : tp; + ecur[fNElsPnt] = fgRhoLITS[ id ]; + fNElsPnt++; + // printf("Passive on lr %d %+e\n",ilp,tcur[fNElsPnt-1]); + // + if (IsTypeCosmics() && !IsZero(tp)) { // 2 crossings for cosmics + tcur[fNElsPnt] = -tcur[fNElsPnt-1]; + ecur[fNElsPnt] = ecur[fNElsPnt-1]; + fNElsPnt++; + //printf("Passive* on lr %d %+e\n",ilp,-tcur[fNElsPnt-1]); + } + // + } + // check if some active layers did not miss the hit, treat them as passive + for (int ilp=6;ilp--;) { + int id = fgkActiveLrITS[ilp]; + double tp = GetHelixParAtR( fgkRLayITS[ id ] ); + if (tp<0) continue; // does not hit this radius + // + if ( (GetSignQB()>0||IsTypeCosmics()) && !(hitLrNeg & (1<0) break; + // + Double_t cdip = 1./TMath::Sqrt(1.+fParams[kDip]*fParams[kDip]); + Double_t ptot = TMath::Abs(fParams[kR0]*fgkCQConv*fBz/cdip); // momentum and energy + Double_t etot = TMath::Sqrt(ptot*ptot + fMass*fMass); // in the point of closest approach to beam + Double_t normS[3]; + // + // Positive t-params: along the track direction for negative track, against for positive + Double_t pcur = ptot, ecurr = etot; + for (int ip=fFirstPosT;ipfPntLast) { // this is not a hit layer but passive layer + double php = TMath::ATan2(yc-fParams[kR0]*TMath::Cos(fParams[kPhi0]+t), + xc-fParams[kR0]*TMath::Cos(fParams[kPhi0]+t)); + normS[0] = -TMath::Cos(php); // normal to the cylinder at intersection point + normS[1] = -TMath::Sin(php); + normS[2] = 0; + } + else GetNormal(normS,fkPoints->GetCov()+tID*6); // vector normal to hit module + fElsDR[tID] = GetDRofELoss(t,cdip,fElsDR[tID],normS,ptot,etot); + } + // + // negaive t-params: against the track direction for negative track, along for positive + pcur = ptot; + ecurr = etot; + for (int ip=fFirstPosT;ip--;) { + int tID = fElsId[ip]; + Double_t t = fCurT[ tID ]; + // + if (tID>fPntLast) { // this is not a hit layer but passive layer + double php = TMath::ATan2(yc-fParams[kR0]*TMath::Cos(fParams[kPhi0]+t), + xc-fParams[kR0]*TMath::Cos(fParams[kPhi0]+t)); + normS[0] = -TMath::Cos(php); // normal to the cylinder at intersection point + normS[1] = -TMath::Sin(php); + normS[2] = 0; + } + else GetNormal(normS,fkPoints->GetCov()+tID*6); // vector normal to hit module + // + fElsDR[tID] = GetDRofELoss(t,cdip,fElsDR[tID],normS,ptot,etot); + } + } + // fill info needed to account for ELoss ------------------------------- <<< + // + return kTRUE; +} + +/* //________________________________________________________________________________________________________ Bool_t AliITSTPArrayFit::FitHelixCrude(Int_t extQ) { @@ -1006,6 +1306,19 @@ Bool_t AliITSTPArrayFit::FitHelixCrude(Int_t extQ) Double_t xc = -(rhs0*mi00 + rhs1*mi01 + rhs2*mi02)/2; Double_t yc = -(rhs0*mi01 + rhs1*mi11 + rhs2*mi12)/2; Double_t rho2 = (rhs0*mi02 + rhs1*mi12 + rhs2*mi22); + + // + // check + double bx = -2*xc; + double by = -2*yc; + double sm0=0,sm1=0; + for (int i=fPntFirst;i<=fPntLast;i++) { + double dst = bx*x[i]+by*y[i]+x[i]*x[i]+y[i]*y[i]+rho2; + sm0 += dst; + sm1 += dst*dst; + printf("Point %d: %+e %+e %+e\n",i,dst,sm0,sm1); + } + // Double_t rad = xc*xc + yc*yc - rho2; rad = (rad>fgkAlmostZero) ? (TMath::Sqrt(rad)):fgkAlmostZero; @@ -1181,7 +1494,7 @@ Bool_t AliITSTPArrayFit::FitHelixCrude(Int_t extQ) // return kTRUE; } - +*/ //____________________________________________________ Double_t AliITSTPArrayFit::FitHelix(Int_t extQ, Double_t extPT,Double_t extPTerr) { @@ -1237,9 +1550,15 @@ Double_t AliITSTPArrayFit::FitHelix(Int_t extQ, Double_t extPT,Double_t extPTerr dXYZdGlo[offs + kZ] = 0; // offs = kR0*3; // dXYZ/dR0 - dXYZdGlo[offs + kX] = cs0 - cst; - dXYZdGlo[offs + kY] = sn0 - snt; - dXYZdGlo[offs + kZ] = -fParams[kDip]*fCurT[ip]; + if (TMath::Abs(fParams[kR0])<0.9*fMaxRforHelix) { + dXYZdGlo[offs + kX] = cs0 - cst; + dXYZdGlo[offs + kY] = sn0 - snt; + dXYZdGlo[offs + kZ] = -fParams[kDip]*fCurT[ip]; + } + else { + dXYZdGlo[offs + kX] = dXYZdGlo[offs + kY] = dXYZdGlo[offs + kZ] = 0; + fParSol->AddConstraint(kR0,0,1.e2); + } // offs = kDZ*3; // dXYZ/dDZ dXYZdGlo[offs + kX] = 0; @@ -1251,9 +1570,12 @@ Double_t AliITSTPArrayFit::FitHelix(Int_t extQ, Double_t extPT,Double_t extPTerr dXYZdGlo[offs + kY] = 0; dXYZdGlo[offs + kZ] = -fParams[kR0]*fCurT[ip]; // + // /* dXYZdLoc[kX] = fParams[kR0]*snt; dXYZdLoc[kY] = -fParams[kR0]*cst; dXYZdLoc[kZ] = -fParams[kR0]*fParams[kDip]; + // */ + // dXYZdLoc[0] = dXYZdLoc[1] = dXYZdLoc[2] = 0; // fParSol->AddEquation(dXYZdGlo,dXYZdLoc,xyzRes,GetCovI(ip)); } @@ -1270,6 +1592,9 @@ Double_t AliITSTPArrayFit::FitHelix(Int_t extQ, Double_t extPT,Double_t extPTerr Double_t *deltaG = fParSol->GetGlobals(); // Double_t *deltaT = fParSol->GetLocals(); for (int ipar=5;ipar--;) fParams[ipar] -= deltaG[ipar]; + // + if (TMath::Abs(fParams[kR0])>0.9*fMaxRforHelix) fParams[kR0] = TMath::Sign(0.9*fMaxRforHelix,fParams[kR0]); + // for (int ip=fPntFirst;ip<=fPntLast;ip++) { fCurT[ip] = CalcParPCA(ip); // printf("iter%d : delta%2d : expl: %+e | %+e | R=%+e p0=%+e\n",iter,ip,deltaT[ip-fPntFirst], fCurT[ip],fParams[kR0],fParams[kPhi0]); @@ -1278,8 +1603,8 @@ Double_t AliITSTPArrayFit::FitHelix(Int_t extQ, Double_t extPT,Double_t extPTerr iter++; // fChi2NDF = CalcChi2NDF(); - // printf("%d | %+.2e %+.2e %+.2e %+.2e %+.2e | chi2: %+.4e %+.4e\n",iter,deltaG[0],deltaG[1],deltaG[2],deltaG[3],deltaG[4],fChi2NDF,fChi2NDF-chiprev); - // printf("->> %+.2e %+.2e %+.2e %+.2e %+.2e | Chi2: %+.6e %+.6e\n",fParams[0],fParams[1],fParams[2],fParams[3],fParams[4],fChi2NDF,fChi2NDF-chiprev); + // printf("%2d | %+.2e %+.2e %+.2e %+.2e %+.2e | chi2: %+.4e %+.4e\n",iter,deltaG[0],deltaG[1],deltaG[2],deltaG[3],deltaG[4],fChi2NDF,fChi2NDF-chiprev); + // printf("->> %+.2e %+.2e %+.2e %+.2e %+.2e | Chi2: %+.6e %+.6e\n",fParams[0],fParams[1],fParams[2],fParams[3],fParams[4],fChi2NDF,fChi2NDF-chiprev); double difchi2 = chiprev - fChi2NDF; if ( difchi21e-5 && !IsSwitched2Line();} + Bool_t IsHelix() const {return fParAxis<0;} + Bool_t IsFieldON() const {return TMath::Abs(fBz)>1e-5;} Bool_t IsTypeCosmics() const {return TestBit(kCosmicsBit);} Bool_t IsTypeCollision() const {return !IsTypeCosmics();} Int_t GetCharge() const {return fCharge;} @@ -73,8 +74,8 @@ class AliITSTPArrayFit : public TObject void GetResiduals(Double_t *res, Int_t ipnt) const; void GetResiduals(Double_t *resPCA, const Double_t* xyz, const Double_t* covI=0) const; Double_t GetPosition( Double_t *xyzPCA, const Double_t* xyz, const Double_t* covI=0) const; - Double_t GetPosition( Double_t *xyzPCA, const AliTrackPoint *pntCovInv) const; - void GetResiduals(Double_t *xyzPCA, const AliTrackPoint *pntCovInv) const; + Double_t GetPosition( Double_t *xyzPCA, const AliTrackPoint *pntCovInv,Bool_t useErr=kFALSE) const; + void GetResiduals(Double_t *xyzPCA, const AliTrackPoint *pntCovInv,Bool_t useErr=kFALSE) const; void GetPosition(Double_t *xyz, Double_t t) const; void GetPosition(Double_t *xyz, Int_t pnt) const; void GetDirCos(Double_t *dircos, Double_t t) const; @@ -135,6 +136,10 @@ class AliITSTPArrayFit : public TObject Int_t GetNIterations() const {return fIter;} Double_t GetEps() const {return fEps;} Double_t GetMass() const {return fMass;} + // + Double_t GetPt() const; + Double_t GetP() const; + // void Switch2Line(Bool_t v=kTRUE) {fSwitch2Line = v;} void SetMaxRforHelix(Double_t r) {fMaxRforHelix = r>0 ? r : 1e9;} diff --git a/ITS/AliITSresponseSDD.cxx b/ITS/AliITSresponseSDD.cxx index 9dfe3027678..c9de5113b66 100644 --- a/ITS/AliITSresponseSDD.cxx +++ b/ITS/AliITSresponseSDD.cxx @@ -48,6 +48,7 @@ TObject(), fADCtokeV[i]=fgkADC2keVDefault; } SetVDCorr2Side(kTRUE); // default for new objects will be separate corrections for 2 sides (bwd compatible) + // SetVDCorrMult(kTRUE); // default for new objects will have multiplicative correction v'=(1+corr)*v (bwd compatible) } //_________________________________________________________________________ void AliITSresponseSDD::SetHalfLadderATimeZero(Int_t lay, Int_t lad, Float_t tzero){ diff --git a/ITS/AliITSresponseSDD.h b/ITS/AliITSresponseSDD.h index 2026ffc335a..49ba761f409 100644 --- a/ITS/AliITSresponseSDD.h +++ b/ITS/AliITSresponseSDD.h @@ -18,7 +18,7 @@ class AliITSresponseSDD : public TObject { public: - enum {kVDCorr2Side = BIT(14)}; // if bit set, the object contains separate corrections for 2 sides + enum {kVDCorr2Side = BIT(14),kVDCorrMult = BIT(15)}; // if bit set, the object contains separate corrections for 2 sides // AliITSresponseSDD(); virtual ~AliITSresponseSDD(){}; @@ -61,7 +61,9 @@ class AliITSresponseSDD : public TObject { } // Bool_t IsVDCorr2Side() const {return TestBit(kVDCorr2Side);} + Bool_t IsVDCorrMult() const {return TestBit(kVDCorrMult);} void SetVDCorr2Side(Bool_t v=kTRUE) {SetBit(kVDCorr2Side,v);} + void SetVDCorrMult(Bool_t v=kTRUE) {SetBit(kVDCorrMult,v);} // static Float_t DefaultTimeOffset() {return fgkTimeOffsetDefault;} virtual void SetTimeOffset(Float_t to){fTimeOffset = to;} -- 2.43.0