1 /**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //-----------------------------------------------------------------
17 // Implementation of the tracks residuals analysis class
18 // It provides an access to the track space points
19 // written along the esd tracks. The class enables
20 // the user to plug any track fitter (deriving from
21 // AliTrackFitter class) and minimization fo the
22 // track residual sums (deriving from the AliTrackResiduals).
23 //-----------------------------------------------------------------
25 #include <Riostream.h>
29 #include <TClonesArray.h>
36 #include <TGraphErrors.h>
37 #include "TGeoMatrix.h"
38 #include "TGeoManager.h"
39 #include "TGeoPhysicalNode.h"
40 #include "TMatrixDSym.h"
41 #include "TMatrixDSymEigen.h"
45 #include "AliAlignmentTracks.h"
46 #include "AliTrackPointArray.h"
47 #include "AliAlignObjParams.h"
48 #include "AliTrackResiduals.h"
49 #include "AliTrackFitter.h"
50 #include "AliTrackFitterKalman.h"
51 #include "AliTrackFitterRieman.h"
52 #include "AliTrackResiduals.h"
53 #include "AliTrackResidualsChi2.h"
54 #include "AliTrackResidualsFast.h"
56 #include "AliITSgeomTGeo.h"
58 #include "AliITSResidualsAnalysis.h"
60 ClassImp(AliITSResidualsAnalysis)
62 //____________________________________________________________________________
63 AliITSResidualsAnalysis::AliITSResidualsAnalysis():
84 fTrackDirLambdaAll(0),
85 fTrackDirLambda2All(0),
103 fRealignObjFileIsOpen(kFALSE),
105 fAliTrackPoints("AliTrackPoints.root"),
106 fGeom("geometry.root"),
117 //____________________________________________________________________________
118 AliITSResidualsAnalysis::AliITSResidualsAnalysis(const TString aliTrackPoints,
120 AliAlignmentTracks(),
140 fTrackDirLambdaAll(0),
141 fTrackDirLambda2All(0),
142 fTrackDirAlphaAll(0),
159 fRealignObjFileIsOpen(kFALSE),
161 fAliTrackPoints(aliTrackPoints),
166 // Standard Constructor (alitrackpoints)
172 //____________________________________________________________________________
173 AliITSResidualsAnalysis::AliITSResidualsAnalysis(const TArrayI *volIDs):
174 AliAlignmentTracks(),
194 fTrackDirLambdaAll(0),
195 fTrackDirLambda2All(0),
196 fTrackDirAlphaAll(0),
213 fRealignObjFileIsOpen(kFALSE),
215 fAliTrackPoints("AliTrackPoints.root"),
216 fGeom("geometry.root"),
220 // Original Constructor
222 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
223 InitHistograms(volIDs);
227 //____________________________________________________________________________
228 AliITSResidualsAnalysis::~AliITSResidualsAnalysis()
234 if(fvolidsToBin) delete[] fvolidsToBin;
235 if(fLastVolVolid) delete[] fLastVolVolid;
236 if(fCoordToBinTable) delete[] fCoordToBinTable;
237 if(fHistCoordGlobY) delete[] fHistCoordGlobY;
238 if(fVolResHistRPHI) delete fVolResHistRPHI;
239 if(fResHistZ) delete fResHistZ;
241 for(Int_t i=0; i<fnHist; i++) delete fResHistX[i];
244 if(fResHistXLocsddL){
245 for(Int_t i=0; i<fnHist; i++) delete fResHistXLocsddL[i];
246 delete [] fResHistXLocsddL;
248 if(fResHistXLocsddR){
249 for(Int_t i=0; i<fnHist; i++) delete fResHistXLocsddR[i];
250 delete [] fResHistXLocsddR;
252 if(fPullHistRPHI) delete fPullHistRPHI;
253 if(fPullHistZ) delete fPullHistZ;
254 if(fTrackDirPhi) delete fTrackDirPhi;
255 if(fTrackDirLambda) delete fTrackDirLambda;
256 if(fTrackDirLambda2) delete fTrackDirLambda2;
257 if(fTrackDirAlpha) delete fTrackDirAlpha;
258 if(fTrackDirPhiAll) delete fTrackDirPhiAll;
259 if(fTrackDirLambdaAll) delete fTrackDirLambdaAll;
260 if(fTrackDirLambda2All) delete fTrackDirLambda2All;
261 if(fTrackDirAlphaAll) delete fTrackDirAlphaAll;
262 if(fTrackDir) delete fTrackDir;
263 if(fTrackDirAll) delete fTrackDirAll;
264 if(fTrackDir2All) delete fTrackDir2All;
265 if(fTrackDirXZAll) delete fTrackDirXZAll;
266 if(fResHistGlob) delete fResHistGlob;
267 if(fhistCorrVol) delete fhistCorrVol;
268 if(fVolNTracks) delete fVolNTracks;
269 if(fhEmpty) delete fhEmpty;
270 if(fhistVolNptsUsed) delete fhistVolNptsUsed;
271 if(fhistVolUsed) delete fhistVolUsed;
272 if(fSigmaVolZ) delete fSigmaVolZ;
273 if(fpTrackVolIDs) delete fpTrackVolIDs;
274 if(fVolVolids) delete fVolVolids;
275 if(fVolUsed) delete fVolUsed;
276 if(fClonesArray) delete fClonesArray;
278 SetFileNameTrackPoints("");
279 SetFileNameGeometry("");
283 //____________________________________________________________________________
284 void AliITSResidualsAnalysis::InitHistograms(const TArrayI *volIDs)
287 // Method that sets and creates the required hisstrograms
288 // with the correct binning (it dos not fill them)
292 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
294 TString histnameRPHI="HistRPHI_volID_",aux;
295 TString histnameZ="HistZ_volID_";
296 TString histnameX="HistX_volID_";
297 TString histnameGlob="HistGlob_volID_";
298 TString histnameCorrVol="HistCorrVol_volID";
299 TString histnamePullRPHI="HistPullRPHI_volID_";
300 TString histnamePullZ="HistPullZ_volID_";
302 TString histnameDirPhi="HistTrackDirPhi_volID_";
303 TString histnameDirLambda="HistTrackDirLambda_volID_";
304 TString histnameDirLambda2="HistTrackDirLambda2_volID_";
305 TString histnameDirAlpha="HistTrackDirAlpha_volID_";
306 TString histnameDir="HistTrackDir_volID_";
308 fnHist=volIDs->GetSize();
309 fVolResHistRPHI=new TH1F*[fnHist];
310 fResHistGlob=new TH1F*[fnHist];
311 fResHistZ=new TH1F*[fnHist];
312 fResHistX=new TH1F*[fnHist];
313 fResHistXLocsddL=new TH1F*[fnHist];
314 fResHistXLocsddR=new TH1F*[fnHist];
315 fHistCoordGlobY=new TH1F*[fnHist];
316 fPullHistRPHI=new TH1F*[fnHist];
317 fPullHistZ=new TH1F*[fnHist];
318 fhistCorrVol=new TH2F*[fnHist];
320 fTrackDirPhi=new TH1F*[fnHist];
321 fTrackDirLambda=new TH1F*[fnHist];
322 fTrackDirLambda2=new TH1F*[fnHist];
323 fTrackDirAlpha=new TH1F*[fnHist];
325 fTrackDirPhiAll=new TH1F("fTrackDirPhiAll","fTrackDirPhiAll",100,-180,180);
326 fTrackDirLambdaAll=new TH1F("fTrackDirLambdaAll","fTrackDirLambdaAll",100,-180,180);
327 fTrackDirLambda2All=new TH1F("fTrackDirLambda2All","fTrackDirLambda2All",100,0,180);
328 fTrackDirAlphaAll=new TH1F("fTrackDirAlphaAll","fTrackDirAlphaAll",100,-180,180);
330 fTrackDirAll=new TH2F("fTrackDirAll","Hist with trakcs directions",100,-180,180,100,-180,180);
331 fTrackDir2All=new TH2F("fTrackDir2All","Hist with trakcs directions",100,-180,180,100,-180,180);
332 fTrackDirXZAll=new TH2F("fTrackDirXZAll","Hist with trakcs directions from XZ ",100,-3.,3.,100,-3.,3.);
334 fTrackDir=new TH2F*[fnHist];
337 Float_t **binningZPhi=new Float_t*[2];
342 CheckSingleLayer(volIDs,binningZPhi);
343 fvolidsToBin=new Int_t*[fnPhi*fnZ];
344 binningphi=binningZPhi[0];
345 binningz=binningZPhi[1];
346 binning=SetBinning(volIDs,binningphi,binningz);
348 if(binning){ //ONLY FOR A SINGLE LAYER!
349 fVolNTracks=new TH2F("fVolNTracks","Hist with N tracks passing through a given module==(r,phi) zone",fnPhi,binningphi,fnZ,binningz);
350 fhistVolNptsUsed=new TH2F("fhistVolNptsUsed","Hist with N points used for given module==(r,phi) ",fnPhi,binningphi,fnZ,binningz);
351 fhistVolUsed=new TH2F("fhistVolUsed","Hist with N modules used for a given module==(r,phi) zone",fnPhi,binningphi,fnZ,binningz);
352 fSigmaVolZ=new TH2F("fSigmaVolZ","Hist with Sigma of Residual distribution for each module",fnPhi,binningphi,fnZ,binningz);
353 fhEmpty=new TH2F("fhEmpty","Hist for getting binning",fnPhi,binningphi,fnZ,binningz);
354 fVolNTracks->SetXTitle("Volume #phi");
355 fVolNTracks->SetYTitle("Volume z ");
356 fhistVolNptsUsed->SetXTitle("Volume #phi");
357 fhistVolNptsUsed->SetYTitle("Volume z ");
358 fhistVolUsed->SetXTitle("Volume #phi");
359 fhistVolUsed->SetYTitle("Volume z ");
360 fSigmaVolZ->SetXTitle("Volume #phi");
361 fSigmaVolZ->SetYTitle("Volume z ");
363 fVolNTracks=new TH2F("fVolNTracks","Hist with N tracks passing through a given module==(r,phi) zone",50,-3.2,3.2,100,-80,80);
364 fhistVolNptsUsed=new TH2F("fhistVolNptsUsed","Hist with N points used for given module==(r,phi) ",50,-3.2,3.2,100,-80,80);
365 fhistVolUsed=new TH2F("fhistVolUsed","Hist with N modules used for a given module==(r,phi) zone",50,-3.2,3.2,100,-80,80);
366 fSigmaVolZ=new TH2F("fSigmaVolZ","Hist with Sigma of Residual distribution for each module",50,-3.2,3.2,100,-80,80);
367 fhEmpty=new TH2F("fhEmpty","Hist for getting binning",50,-3.2,3.2,100,-80,80);
368 fVolNTracks->SetXTitle("Volume #phi");
369 fVolNTracks->SetYTitle("Volume z ");
370 fhistVolNptsUsed->SetXTitle("Volume #phi");
371 fhistVolNptsUsed->SetYTitle("Volume z ");
372 fhistVolUsed->SetXTitle("Volume #phi");
373 fhistVolUsed->SetYTitle("Volume z ");
374 fSigmaVolZ->SetXTitle("Volume #phi");
375 fSigmaVolZ->SetYTitle("Volume z ");
378 fpTrackVolIDs=new TArrayI(fnHist);
379 fVolUsed=new TArrayI*[fnHist];
380 fVolVolids=new TArrayI*[fnHist];
381 fLastVolVolid=new Int_t[fnHist];
383 for (Int_t nhist=0;nhist<fnHist;nhist++){
384 fpTrackVolIDs->AddAt(volIDs->At(nhist),nhist);
386 aux+=volIDs->At(nhist);
387 fVolResHistRPHI[nhist]=new TH1F("histname","histname",20000,-5.0,5.0);
388 fVolResHistRPHI[nhist]->SetName(aux.Data());
389 fVolResHistRPHI[nhist]->SetTitle(aux.Data());
392 aux+=volIDs->At(nhist);
393 fResHistZ[nhist]=new TH1F("histname","histname",20000,-5.0,5.0);
394 fResHistZ[nhist]->SetName(aux.Data());
395 fResHistZ[nhist]->SetTitle(aux.Data());
398 aux+=volIDs->At(nhist);
399 fResHistX[nhist]=new TH1F("histname","histname",20000,-5.0,5.0);
400 fResHistX[nhist]->SetName(aux.Data());
401 fResHistX[nhist]->SetTitle(aux.Data());
404 aux+=volIDs->At(nhist);
405 aux.Append("LocalSDDLeft");
406 fResHistXLocsddL[nhist]=new TH1F("histname","histname",20000,-5.0,5.0);
407 fResHistXLocsddL[nhist]->SetName(aux.Data());
408 fResHistXLocsddL[nhist]->SetTitle(aux.Data());
411 aux+=volIDs->At(nhist);
412 aux.Append("LocalSDDRight");
413 fResHistXLocsddR[nhist]=new TH1F("histname","histname",20000,-5.0,5.0);
414 fResHistXLocsddR[nhist]->SetName(aux.Data());
415 fResHistXLocsddR[nhist]->SetTitle(aux.Data());
417 aux="fHistCoordGlobY";
418 fHistCoordGlobY[nhist]=new TH1F("histname","histname",24000,-30.,30.);
419 fHistCoordGlobY[nhist]->SetName(aux.Data());
420 fHistCoordGlobY[nhist]->SetTitle(aux.Data());
422 aux=histnamePullRPHI;
423 aux+=volIDs->At(nhist);
424 fPullHistRPHI[nhist]=new TH1F("histname","histname",100,-7.,7.);
425 fPullHistRPHI[nhist]->SetName(aux.Data());
426 fPullHistRPHI[nhist]->SetTitle(aux.Data());
429 aux+=volIDs->At(nhist);
430 fPullHistZ[nhist]=new TH1F("histname","histname",100,-7.,7.);
431 fPullHistZ[nhist]->SetName(aux.Data());
432 fPullHistZ[nhist]->SetTitle(aux.Data());
435 aux+=volIDs->At(nhist);
436 fTrackDirPhi[nhist]=new TH1F("histname","histname",100,-180,180);
437 fTrackDirPhi[nhist]->SetName(aux.Data());
438 fTrackDirPhi[nhist]->SetTitle(aux.Data());
440 aux=histnameDirLambda;
441 aux+=volIDs->At(nhist);
442 fTrackDirLambda[nhist]=new TH1F("histname","histname",100,0,180);
443 fTrackDirLambda[nhist]->SetName(aux.Data());
444 fTrackDirLambda[nhist]->SetTitle(aux.Data());
446 aux=histnameDirLambda2;
447 aux+=volIDs->At(nhist);
448 fTrackDirLambda2[nhist]=new TH1F("histname","histname",100,0,180);
449 fTrackDirLambda2[nhist]->SetName(aux.Data());
450 fTrackDirLambda2[nhist]->SetTitle(aux.Data());
452 aux=histnameDirAlpha;
453 aux+=volIDs->At(nhist);
454 fTrackDirAlpha[nhist]=new TH1F("histname","histname",100,-180,180);
455 fTrackDirAlpha[nhist]->SetName(aux.Data());
456 fTrackDirAlpha[nhist]->SetTitle(aux.Data());
459 aux+=volIDs->At(nhist);
460 fTrackDir[nhist]=new TH2F("histname","histname",100,-90.,90.,100,-180.,180.);
461 fTrackDir[nhist]->SetName(aux.Data());
462 fTrackDir[nhist]->SetTitle(aux.Data());
465 aux+=volIDs->At(nhist);
466 fResHistGlob[nhist]=new TH1F("histname","histname",400,-0.08,0.08);
467 fResHistGlob[nhist]->SetName(aux.Data());
468 fResHistGlob[nhist]->SetTitle(aux.Data());
471 aux+=volIDs->At(nhist);
472 fhistCorrVol[nhist]=new TH2F("histname","histname",50,-3.2,3.2,100,-80,80);
475 fhistCorrVol[nhist]->SetName(aux.Data());
476 fhistCorrVol[nhist]->SetTitle(aux.Data());
477 fhistCorrVol[nhist]->SetXTitle("Volume #varphi");
478 fhistCorrVol[nhist]->SetYTitle("Volume z ");
479 fVolVolids[nhist]=new TArrayI(100);
480 fVolUsed[nhist]=new TArrayI(1000);
481 fLastVolVolid[nhist]=0;
487 delete [] binningZPhi;
489 delete [] binningphi;
494 //____________________________________________________________________________
495 void AliITSResidualsAnalysis::ListVolUsed(TTree *pointsTree,TArrayI ***arrayIndex,Int_t **lastIndex)
498 // This is copied from AliAlignmentClass::LoadPoints() method
500 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
501 Int_t volIDalignable,volIDpoint,iModule;
503 AliTrackPointArray* array = 0;
504 pointsTree->SetBranchAddress("SP", &array);
507 for(Int_t ivol=0;ivol<fnHist;ivol++){
509 volIDalignable=fpTrackVolIDs->At(ivol);
510 AliGeomManager::ELayerID iLayer = AliGeomManager::VolUIDToLayer((UShort_t)volIDalignable,iModule);
512 Int_t nArraysId = lastIndex[iLayer-AliGeomManager::kFirstLayer][iModule];
513 TArrayI *index = arrayIndex[iLayer-AliGeomManager::kFirstLayer][iModule];
514 for (Int_t iArrayId = 0;iArrayId < nArraysId; iArrayId++) {
517 Int_t entry = (*index)[iArrayId];
519 pointsTree->GetEvent(entry);
521 AliWarning("Wrong space point array index!");
525 // Get the space-point array
526 Int_t modnum,nPoints = array->GetNPoints();
528 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
531 array->GetPoint(p,iPoint);
533 AliGeomManager::ELayerID layer = AliGeomManager::VolUIDToLayer(p.GetVolumeID(),modnum);
534 // check if the layer id is valid
535 if ((layer < AliGeomManager::kFirstLayer) ||
536 (layer >= AliGeomManager::kLastLayer)) {
537 AliError(Form("Layer index is invalid: %d (%d -> %d) !",
538 layer,AliGeomManager::kFirstLayer,AliGeomManager::kLastLayer-1));
543 if ((modnum >= AliGeomManager::LayerSize(layer)) ||
545 AliError(Form("Module number inside layer %d is invalid: %d (0 -> %d)",
546 layer,modnum,AliGeomManager::LayerSize(layer)));
549 if (layer > AliGeomManager::kSSD2) continue; // ITS only
552 volIDpoint=(Int_t)p.GetVolumeID();
553 if (volIDpoint==volIDalignable) continue;
554 Int_t size = fVolVolids[ivol]->GetSize();
555 // If needed allocate new size
556 if (fLastVolVolid[ivol]>=size){// Warning: fLAST[NHIST] is useless
557 fVolVolids[ivol]->Set(size + 1000);
561 fVolVolids[ivol]->AddAt(volIDpoint,fLastVolVolid[ivol]);
562 fLastVolVolid[ivol]++;
563 Bool_t usedVol=kFALSE;
564 for(Int_t used=0;used<lastused;used++){
565 if(fVolUsed[ivol]->At(used)==volIDpoint){
573 size = fVolUsed[ivol]->GetSize();
574 // If needed allocate new size
575 if (lastused>= size){
576 fVolUsed[ivol]->Set(size + 1000);
578 fVolUsed[ivol]->AddAt(volIDpoint,lastused);
582 FillVolumeCorrelationHists(ivol,volIDalignable,volIDpoint,usedVol);
591 //____________________________________________________________________________
592 void AliITSResidualsAnalysis::FillVolumeCorrelationHists(Int_t ivol,Int_t volIDalignable,Int_t volIDpoint,Bool_t usedVol) const
595 // Fill the histograms with the correlations between volumes
599 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
600 Double_t translGlobal[3];
603 // const char *symname,*volpath;
605 TGeoPhysicalNode *pn;
606 TGeoHMatrix *globMatrix;
609 symname = AliGeomManager::SymName(volIDalignable);
610 pne = gGeoManager->GetAlignableEntry(symname);
611 volpath=pne->GetTitle();
612 pn=gGeoManager->MakePhysicalNode(volpath);
613 globMatrix=pn->GetMatrix();
616 AliGeomManager::GetOrigTranslation(volIDalignable,translGlobal);
617 // radius=TMath::Sqrt(transGlobal[0]*transGlobal[0]+transGlobal[1]*transGlobal[1]);
618 phi=TMath::ATan2(translGlobal[1],translGlobal[0]);
619 fhistVolNptsUsed->Fill(phi,translGlobal[2]);
621 fhistVolUsed->Fill(phi,translGlobal[2]);
624 /* symname = AliGeomManager::SymName(volIDpoint);
625 pne = gGeoManager->GetAlignableEntry(symname);
626 volpath=pne->GetTitle();
627 pn=gGeoManager->MakePhysicalNode(volpath);
628 globMatrix=pn->GetMatrix();
629 transGlobal=globMatrix->GetTranslation();
631 AliGeomManager::GetOrigTranslation(volIDpoint,translGlobal);
632 // radius=TMath::Sqrt(transGlobal[0]*transGlobal[0]+transGlobal[1]*transGlobal[1]);
633 phi=TMath::ATan2(translGlobal[1],translGlobal[0]);
635 fhistCorrVol[ivol]->Fill(phi,translGlobal[2]);
640 //____________________________________________________________________________
641 void AliITSResidualsAnalysis::FillResidualsH(AliTrackPointArray *points,
642 AliTrackPointArray *pTrack) const
645 // Method that fills the histograms with the residuals
649 Float_t xyz[3],xyz2[3];
650 Double_t xyzD[3],xyz2D[3];
651 Double_t loc[3],loc2[3];
653 Float_t resRPHI,resGlob,resZ,resX;
655 Double_t pullrphi,sign,phi;
658 for(Int_t ipoint=0;ipoint<points->GetNPoints();ipoint++){
660 //pTrack->GetPoint(pTr,ipoint);
661 points->GetPoint(p,ipoint);
662 volIDpoint=(Int_t)p.GetVolumeID();
665 pTrack->GetPoint(pTr,ipoint);
668 for(Int_t i=0;i<3;i++){
673 phi = TMath::ATan2(xyz[1],xyz[0]);//<-watch out: phi of the pPoints!
678 resRPHI=TMath::Sqrt((xyz2[0]-xyz[0])*(xyz2[0]-xyz[0])+(xyz2[1]-xyz[1])*(xyz2[1]-xyz[1]));
680 sign=TMath::ATan2(xyz2[1],xyz2[0])-TMath::ATan2(xyz[1],xyz[0]);
682 sign=sign/TMath::Abs(sign);
683 resRPHI=resRPHI*sign;
691 resGlob=TMath::Sqrt((xyz2[0]-xyz[0])*(xyz2[0]-xyz[0])+(xyz2[1]-xyz[1])*(xyz2[1]-xyz[1])+(xyz2[2]-xyz[2])*(xyz2[2]-xyz[2]));
693 for(Int_t ivolIDs=0;ivolIDs<fpTrackVolIDs->GetSize();ivolIDs++){
694 if(volIDpoint==fpTrackVolIDs->At(ivolIDs)){
696 fVolResHistRPHI[ivolIDs]->Fill(resRPHI);
697 fResHistZ[ivolIDs]->Fill(resZ);
698 fResHistX[ivolIDs]->Fill(resX);
699 fHistCoordGlobY[ivolIDs]->Fill(xyz[1]);
701 Int_t modIndex = -1; // SDD Section
702 if(AliGeomManager::VolUIDToLayer(volIDpoint)==3) modIndex=volIDpoint-6144+240;
703 if(AliGeomManager::VolUIDToLayer(volIDpoint)==4) modIndex=volIDpoint-8192+240+84;
705 AliITSgeomTGeo::GlobalToLocal(modIndex,xyzD,loc); // error here!?
706 AliITSgeomTGeo::GlobalToLocal(modIndex,xyz2D,loc2);
707 Float_t rexloc=loc2[0]-loc[0];
708 //cout<<"Residual: "<<volIDpoint<<" "<<loc[0]<<" -> "<<rexloc<<endl;
710 fResHistXLocsddR[ivolIDs]->Fill(rexloc);
712 fResHistXLocsddL[ivolIDs]->Fill(rexloc);
715 fResHistGlob[ivolIDs]->Fill(resGlob);
717 fTrackDirPhiAll->Fill(phi);
718 fTrackDirPhi[ivolIDs]->Fill(phi);
722 Float_t globalPhi,globalZ;
723 if(kTRUE||(fvolidsToBin[ivolIDs][0]!=volIDpoint)){
724 binphi=GetBinPhiZ((Int_t)volIDpoint,&binz);
727 // This in the case of alignment of one entire layer
728 // (fnHIst=layersize) may reduce iterations:
729 // remind of that fsingleLayer->fnHista<layerSize
730 binphi=fvolidsToBin[ivolIDs][1];
731 binz=fvolidsToBin[ivolIDs][2];
733 globalPhi=fCoordToBinTable[binphi][binz][0];
734 globalZ=fCoordToBinTable[binphi][binz][1];
736 fVolNTracks->Fill(globalPhi,globalZ);
738 else fVolNTracks->Fill(TMath::ATan2(xyz[1],xyz[0]),xyz[2]);
744 //____________________________________________________________________________
745 Bool_t AliITSResidualsAnalysis::SaveHists(Int_t minNpoints, TString outname) const
748 // Saves the histograms into a tree and saves the tree into a file
753 TFile *hFile=new TFile(outname.Data(),"RECREATE","File containing the Residuals Tree");
755 // TTree with the residuals
756 TTree *analysisTree=new TTree("analysisTree","Tree with the residuals");
758 // Declares Variables to be stored into the TTree
759 TF1 *gauss=new TF1("gauss","gaus",-10.,10.);
760 Int_t volID,entries,nHistAnalyzed=0;
761 Double_t meanResRPHI,meanResZ,meanResX,rmsResRPHI,rmsResZ,rmsResX,coordVol[3],x,y,z;
762 TH1F *histRPHI = new TH1F();
763 TH1F *histZ = new TH1F();
764 TH1F *histX = new TH1F();
765 TH1F *histXLocsddL = new TH1F();
766 TH1F *histXLocsddR = new TH1F();
767 TH1F *histCoordGlobY = new TH1F();
768 // Note: 0 = RPHI, 1 = Z
771 // Branching the TTree
772 analysisTree->Branch("volID",&volID,"volID/I");
773 analysisTree->Branch("x",&x,"x/D");
774 analysisTree->Branch("y",&y,"y/D");
775 analysisTree->Branch("z",&z,"z/D");
776 analysisTree->Branch("meanResRPHI",&meanResRPHI,"meanResRPHI/D");
777 analysisTree->Branch("meanResZ",&meanResZ,"meanResZ/D");
778 analysisTree->Branch("meanResX",&meanResX,"meanResX/D");
779 analysisTree->Branch("rmsResRPHI",&rmsResRPHI,"rmsResRPHI/D");
780 analysisTree->Branch("rmsResZ",&rmsResZ,"rmsResZ/D");
782 analysisTree->Branch("histRPHI","TH1F",&histRPHI,128000,0);
783 analysisTree->Branch("histZ","TH1F",&histZ,128000,0);
784 analysisTree->Branch("histX","TH1F",&histX,128000,0);
785 analysisTree->Branch("histXLocsddL","TH1F",&histXLocsddL,128000,0);
786 analysisTree->Branch("histXLocsddR","TH1F",&histXLocsddR,128000,0);
787 analysisTree->Branch("histCoordGlobY","TH1F",&histCoordGlobY,128000,0);
791 for(Int_t j=0;j<fnHist;j++){
793 volID=fpTrackVolIDs->At(j);
794 AliGeomManager::GetTranslation(volID,coordVol);
799 entries=(Int_t)(fResHistGlob[j]->GetEntries());
802 if(entries>=minNpoints){
806 //entries=(Int_t)fVolResHistRPHI[j]->GetEntries();
809 histRPHI=fVolResHistRPHI[j];
810 rmsResRPHI=fVolResHistRPHI[j]->GetRMS();
813 gauss->SetRange(-3*rmsResRPHI,3*rmsResRPHI);
814 fVolResHistRPHI[j]->Fit("gauss","QRN");
815 meanResRPHI=gauss->GetParameter(1);
817 meanResRPHI=fVolResHistRPHI[j]->GetMean();
822 rmsResZ=fResHistZ[j]->GetRMS();
825 gauss->SetRange(-3*rmsResZ,3*rmsResZ);
826 fResHistZ[j]->Fit("gauss","QRN");
827 meanResZ=gauss->GetParameter(1);
829 meanResZ=fResHistZ[j]->GetMean();
834 rmsResX=fResHistX[j]->GetRMS();
837 gauss->SetRange(-3*rmsResX,3*rmsResX);
838 fResHistX[j]->Fit("gauss","QRN");
839 meanResX=gauss->GetParameter(1);
841 meanResX=fResHistX[j]->GetMean();
844 histXLocsddL=fResHistXLocsddL[j];
845 histXLocsddR=fResHistXLocsddR[j];
846 histCoordGlobY=fHistCoordGlobY[j];
848 analysisTree->Fill();
852 //entries=(Int_t)fVolResHistRPHI[j]->GetEntries();
855 histRPHI=fVolResHistRPHI[j];
868 histXLocsddL=fResHistXLocsddL[j];
869 histXLocsddR=fResHistXLocsddR[j];
870 histCoordGlobY=fHistCoordGlobY[j];
872 analysisTree->Fill();
879 cout<<"-> Modules Analyzed: "<<nHistAnalyzed<<endl;
880 cout<<" With "<<blimps<<" events"<<endl;
884 analysisTree->Write();
885 fVolNTracks->Write();
888 //TCanvas *color = new TCanvas("color","fhistVolUsed",800,600);
889 //fhistVolUsed->DrawCopy("COLZ");
891 fhistVolUsed->Write();
892 /* fTrackDirPhiAll->Write();
893 fTrackDirLambdaAll->Write();
894 fTrackDirLambda2All->Write();
895 fTrackDirAlphaAll->Write();
896 fTrackDirAll->Write();
897 fTrackDir2All->Write();
898 fTrackDirXZAll->Write();
900 fhistVolNptsUsed->Write();
901 hFile->mkdir("CorrVol");
902 hFile->cd("CorrVol");
903 for(Int_t corr=0;corr<fnHist;corr++)fhistCorrVol[corr]->Write();
906 // fhistVolNptsUsed->Write();
915 //____________________________________________________________________________
916 void AliITSResidualsAnalysis::DrawHists() const
919 // Draws the histograms of the residuals and of the number of tracks
923 for(Int_t canv=0;canv<fnHist;canv++){
924 cname="canv Residuals";
926 TCanvas *c=new TCanvas(cname.Data(),cname.Data(),700,700);
929 fVolResHistRPHI[canv]->Draw();
931 fResHistZ[canv]->Draw();
933 fResHistGlob[canv]->Draw();
935 cname="canv NVolTracks";
937 TCanvas *c2=new TCanvas(cname.Data(),cname.Data(),700,700);
944 //____________________________________________________________________________
945 void AliITSResidualsAnalysis::CheckSingleLayer(const TArrayI *volids,Float_t **binningzphi)
948 // Checks if volumes array is a single (ITS) layer or not
950 // binningzphi=new Float_t*[2];
952 AliGeomManager::ELayerID iLayer = AliGeomManager::VolUIDToLayer((UShort_t)volids->At(0),iModule);
953 //Check that one single Layer is going to be aligned
954 for(Int_t nvol=0;nvol<volids->GetSize();nvol++){
955 if(iLayer != AliGeomManager::VolUIDToLayer((UShort_t)volids->At(nvol),iModule)){
956 printf("Wrong Layer! \n %d , %d , %d ,%d \n",(Int_t)AliGeomManager::VolUIDToLayer((UShort_t)volids->At(nvol),iModule),nvol,volids->GetSize(),iModule);
962 //Bool_t used=kFALSE;
964 case AliGeomManager::kSPD1:{
965 fnPhi=kPhiSPD1;//kPhiSPD1;
967 binningzphi[0]=new Float_t[kPhiSPD1+1];
968 binningzphi[1]=new Float_t[kZSPD1+1];
969 fCoordToBinTable=new Double_t**[kPhiSPD1];
970 for(Int_t j=0;j<fnPhi;j++){
971 fCoordToBinTable[j]=new Double_t*[kZSPD1];
974 case AliGeomManager::kSPD2:{
975 fnPhi=kPhiSPD2;//kPhiSPD1;
977 binningzphi[0]=new Float_t[kPhiSPD2+1];
978 binningzphi[1]=new Float_t[kZSPD2+1];
979 fCoordToBinTable=new Double_t**[kPhiSPD2];
980 for(Int_t j=0;j<fnPhi;j++){
981 fCoordToBinTable[j]=new Double_t*[kZSPD2];
984 }; break; case AliGeomManager::kSDD1:{
985 fnPhi=kPhiSDD1;//kPhiSPD1;
987 binningzphi[0]=new Float_t[kPhiSDD1+1];
988 binningzphi[1]=new Float_t[kZSDD1+1];
989 fCoordToBinTable=new Double_t**[kPhiSDD1];
990 for(Int_t j=0;j<fnPhi;j++){
991 fCoordToBinTable[j]=new Double_t*[kZSDD1];
993 }; break; case AliGeomManager::kSDD2:{
994 fnPhi=kPhiSDD2;//kPhiSPD1;
996 binningzphi[0]=new Float_t[kPhiSDD2+1];
997 binningzphi[1]=new Float_t[kZSDD2+1];
998 fCoordToBinTable=new Double_t**[kPhiSDD2];
999 for(Int_t j=0;j<fnPhi;j++){
1000 fCoordToBinTable[j]=new Double_t*[kZSDD2];
1002 }; break; case AliGeomManager::kSSD1:{
1003 fnPhi=kPhiSSD1;//kPhiSPD1;
1004 fnZ=kZSSD1;//nZSPD1;
1005 binningzphi[0]=new Float_t[kPhiSSD1+1];
1006 binningzphi[1]=new Float_t[kZSSD1+1];
1007 fCoordToBinTable=new Double_t**[kPhiSSD1];
1008 for(Int_t j=0;j<fnPhi;j++){
1009 fCoordToBinTable[j]=new Double_t*[kZSSD1];
1011 }; break; case AliGeomManager::kSSD2:{
1012 fnPhi=kPhiSSD2;//kPhiSPD1;
1013 fnZ=kZSSD2;//nZSPD1;
1014 binningzphi[0]=new Float_t[kPhiSSD2+1];
1015 binningzphi[1]=new Float_t[kZSSD2+1];
1016 fCoordToBinTable=new Double_t**[kPhiSSD2];
1017 for(Int_t j=0;j<fnPhi;j++){
1018 fCoordToBinTable[j]=new Double_t*[kZSSD2];
1023 printf("Wrong Layer Label! \n");
1024 fsingleLayer=kFALSE;
1025 //////////////////////
1028 binningzphi[0]=new Float_t[1];
1029 binningzphi[1]=new Float_t[1];
1030 fCoordToBinTable=new Double_t**[1];
1031 for(Int_t j=0;j<fnPhi;j++){
1032 fCoordToBinTable[j]=new Double_t*[1];
1035 /////////////////////
1043 //____________________________________________________________________________
1044 Bool_t AliITSResidualsAnalysis::SetBinning(const TArrayI *volids,Float_t *phiBin,Float_t *zBin)
1047 // Sets the correct binning
1050 if(!fsingleLayer)return kFALSE;
1051 // const char *volpath,*symname;
1053 Int_t *orderArrayPhi,*orderArrayZ;
1055 Double_t *phiArray,*zArray,*phiArrayOrdered,*zArrayOrdered;
1056 Double_t translGlobal[3];
1057 Double_t lastPhimin=-10;
1058 Double_t lastZmin=-99;
1060 /* TGeoPNEntry *pne;
1061 TGeoPhysicalNode *pn;
1062 TGeoHMatrix *globMatrix;*/
1063 // to delete: orderPhiZ phiArray zArray phiArrayOrdered zArrayOrdered orderArrayPhi orderArrayZ
1067 orderPhiZ=new Int_t**[fnPhi];
1068 phiArray=new Double_t[fnPhi];//phiBin[nModulesPhi+1];
1069 zArray=new Double_t[fnZ];//zBin[nModulesZ+1];
1070 phiArrayOrdered=new Double_t[fnPhi];
1071 zArrayOrdered=new Double_t[fnZ];
1072 orderArrayPhi=new Int_t[fnPhi];
1073 orderArrayZ=new Int_t[fnZ];
1074 for(Int_t k=0;k<fnZ;k++){
1078 for(Int_t k=0;k<fnPhi;k++){
1081 orderPhiZ[k]=new Int_t*[fnZ];
1085 AliGeomManager::ELayerID iLayer = AliGeomManager::VolUIDToLayer((UShort_t)volids->At(0),iModule);
1087 Int_t lastPhi=0,lastZ=0;
1088 for(iModule=0;iModule<AliGeomManager::LayerSize(iLayer);iModule++){
1089 fvolidsToBin[iModule]=new Int_t[3];
1090 volID=AliGeomManager::LayerToVolUID(iLayer,iModule);
1091 fvolidsToBin[iModule][0]=volID;
1092 /* symname = AliGeomManager::SymName(volID);
1093 pne = gGeoManager->GetAlignableEntry(symname);
1094 volpath=pne->GetTitle();
1095 pn=gGeoManager->MakePhysicalNode(volpath);
1096 globMatrix=pn->GetMatrix();
1097 translGlobal=globMatrix->GetTranslation();
1100 AliGeomManager::GetOrigTranslation(volID,translGlobal);
1102 for(Int_t j=0;j<lastPhi;j++){
1104 if(TMath::Abs(phiArray[j]-TMath::ATan2(translGlobal[1],translGlobal[0]))<2*TMath::Pi()/(10*fnPhi)){//10 is a safety factor but....
1105 fvolidsToBin[iModule][1]=j;
1111 phiArray[lastPhi]=TMath::ATan2(translGlobal[1],translGlobal[0]);
1112 fvolidsToBin[iModule][1]=lastPhi;
1113 if(phiArray[lastPhi]<lastPhimin)lastPhimin=phiArray[lastPhi];
1116 printf("Wrong Phi! \n");
1120 for(Int_t j=0;j<lastZ;j++){
1122 if(TMath::Abs(zArray[j]-translGlobal[2])<0.1){
1123 fvolidsToBin[iModule][2]=j;
1129 fvolidsToBin[iModule][2]=lastZ;
1130 zArray[lastZ]=translGlobal[2];
1131 if(zArray[lastZ]<lastZmin)lastZmin=zArray[lastZ];
1134 printf("Wrong Z! \n");
1140 //ORDERING THE ARRAY OF PHI AND Z VALUES
1141 for(Int_t order=0;order<fnPhi;order++){
1142 for(Int_t j=0;j<fnPhi;j++){
1143 if((j!=order)&&(phiArray[order]>phiArray[j]))orderArrayPhi[order]++;
1147 for(Int_t order=0;order<fnPhi;order++){
1148 for(Int_t j=0;j<fnPhi;j++){
1149 if(orderArrayPhi[j]==order){
1150 phiArrayOrdered[order]=phiArray[j];
1157 for(Int_t order=0;order<fnZ;order++){
1158 for(Int_t j=0;j<fnZ;j++){
1159 if((j!=order)&&(zArray[order]>zArray[j]))orderArrayZ[order]++;
1164 for(Int_t order=0;order<fnZ;order++){
1165 for(Int_t j=0;j<fnZ;j++){
1166 if(orderArrayZ[j]==order){
1167 zArrayOrdered[order]=zArray[j];
1174 //Filling the fCoordToBinTable
1175 for(Int_t j=0;j<fnPhi;j++){
1176 for(Int_t i=0;i<fnZ;i++){
1177 orderPhiZ[j][i]=new Int_t[2];
1178 orderPhiZ[j][i][0]=orderArrayPhi[j];
1179 orderPhiZ[j][i][1]=orderArrayZ[i];
1184 for(Int_t j=0;j<fnPhi;j++){
1185 for(Int_t i=0;i<fnZ;i++){
1186 fCoordToBinTable[j][i]=new Double_t[2];
1187 fCoordToBinTable[j][i][0]=phiArrayOrdered[j];
1188 fCoordToBinTable[j][i][1]=zArrayOrdered[i];
1189 printf("Now (binphi,binz)= %d, %d e (phi,z)=%f,%f \n",j,i,fCoordToBinTable[j][i][0],fCoordToBinTable[j][i][1]);
1193 for(iModule=0;iModule<fnPhi*fnZ;iModule++){
1194 istar=fvolidsToBin[iModule][1];
1195 jstar=fvolidsToBin[iModule][2];
1196 fvolidsToBin[iModule][1]=orderPhiZ[istar][jstar][0];
1197 fvolidsToBin[iModule][2]=orderPhiZ[istar][jstar][1];
1200 //now constructing the binning
1201 for(Int_t iModPhi=0;iModPhi<fnPhi-1;iModPhi++){
1202 phiBin[iModPhi+1]=(Float_t)phiArrayOrdered[iModPhi]+0.5*(phiArrayOrdered[iModPhi+1]-phiArrayOrdered[iModPhi]);
1205 phiBin[0]=(Float_t)phiArrayOrdered[0]-(phiArrayOrdered[1]-phiArrayOrdered[0])/2.;
1207 phiBin[fnPhi]=(Float_t)phiArrayOrdered[fnPhi-1]+(phiArrayOrdered[fnPhi-1]-phiArrayOrdered[fnPhi-2])/2.;
1208 for(Int_t iModPhi=0;iModPhi<fnPhi+1;iModPhi++){
1209 printf("Mean Phi mod %d su %d: %f \n",iModPhi+1,fnPhi,phiBin[iModPhi]);
1212 for(Int_t iModZ=0;iModZ<fnZ-1;iModZ++){
1213 zBin[iModZ+1]=(Float_t)zArrayOrdered[iModZ]+0.5*(zArrayOrdered[iModZ+1]-zArrayOrdered[iModZ]);
1215 zBin[0]=(Float_t)zArrayOrdered[0]-0.5*(zArrayOrdered[1]-zArrayOrdered[0]);
1216 zBin[fnZ]=(Float_t)zArrayOrdered[fnZ-1]+0.5*(zArrayOrdered[1]-zArrayOrdered[0]);
1219 for(Int_t iModPhi=0;iModPhi<fnZ+1;iModPhi++){
1220 printf("Mean Z mod %d su %d: %f \n",iModPhi+1,fnZ,zBin[iModPhi]);
1227 for(Int_t j=0;j<fnPhi;j++){
1228 for(Int_t i=0;i<fnZ;i++){
1229 for(Int_t k=0;k<2;k++){
1230 delete orderPhiZ[j][i][k];
1236 delete [] orderPhiZ;
1239 delete [] phiArrayOrdered;
1240 delete [] zArrayOrdered;
1241 delete [] orderArrayPhi;
1242 delete [] orderArrayZ;
1247 //____________________________________________________________________________
1248 Int_t AliITSResidualsAnalysis::GetBinPhiZ(const Int_t volID,Int_t *binz) const
1251 // Returns the correct Phi-Z bin
1255 printf("No Single Layer reAlignment! \n");
1259 for(Int_t j=0;j<fnPhi*fnZ;j++){
1261 printf("Wrong volume UID introduced! fnHist: %d volID: %d iter: %d \n",fnHist,volID,j);
1264 if(fvolidsToBin[j][0]==volID){
1266 *binz=fvolidsToBin[j][2];
1267 return fvolidsToBin[j][1];
1275 //___________________________________________________________________________
1276 Int_t AliITSResidualsAnalysis::WhichSector(Int_t module) const
1279 // This method returns the number of the SPD Sector
1280 // to which belongs the module (Sectors 0-9)
1282 //--->cSect = 0 <---
1306 || module==4111) return 0;
1308 //--->cSect = 1 <---
1332 || module==4127) return 1;
1334 //--->cSect = 2 <---
1358 || module==4143) return 2;
1360 //--->cSect = 3 <---
1384 || module==4159) return 3;
1386 //--->cSect = 4 <---
1410 || module==4175) return 4;
1412 //--->cSect = 5 <---
1436 || module==4191) return 5;
1438 //--->cSect = 6 <---
1462 || module==4207) return 6;
1464 //--->cSect = 7 <---
1488 || module==4223) return 7;
1490 //--->cSect = 8 <---
1514 || module==4239) return 8;
1516 //--->cSect = 9 <---
1540 || module==4255) return 9;
1542 //printf("Module not belonging to SPD, sorry!");
1547 //____________________________________________________________________________
1548 TArrayI* AliITSResidualsAnalysis::GetSPDSectorsVolids(Int_t sectors[10]) const
1551 // This method gets the volID Array for the chosen sectors.
1552 // You have to pass an array with a 1 for each selected sector.
1553 // i.e. sectors[10] = {1,1,0,0,0,0,0,0,1,0} -> Sector 0, 1, 9 selected.
1559 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
1561 for(Int_t co=0;co<10;co++){ //counts the number of sectors chosen
1562 if(sectors[co]==1) nSect++;
1565 if(nSect<1){ //if no sector chosen -> exit
1566 Printf("Error! No Sector/s Selected!");
1570 TArrayI *volIDs = new TArrayI(nSect*24);
1572 if(sectors[0]==1){ //--->cSect = 0 <---
1573 volIDs->AddAt(2048,iModule); iModule++;
1574 volIDs->AddAt(2049,iModule); iModule++;
1575 volIDs->AddAt(2050,iModule); iModule++;
1576 volIDs->AddAt(2051,iModule); iModule++;
1577 volIDs->AddAt(2052,iModule); iModule++;
1578 volIDs->AddAt(2053,iModule); iModule++;
1579 volIDs->AddAt(2054,iModule); iModule++;
1580 volIDs->AddAt(2055,iModule); iModule++;
1581 volIDs->AddAt(4096,iModule); iModule++;
1582 volIDs->AddAt(4097,iModule); iModule++;
1583 volIDs->AddAt(4098,iModule); iModule++;
1584 volIDs->AddAt(4099,iModule); iModule++;
1585 volIDs->AddAt(4100,iModule); iModule++;
1586 volIDs->AddAt(4101,iModule); iModule++;
1587 volIDs->AddAt(4102,iModule); iModule++;
1588 volIDs->AddAt(4103,iModule); iModule++;
1589 volIDs->AddAt(4104,iModule); iModule++;
1590 volIDs->AddAt(4105,iModule); iModule++;
1591 volIDs->AddAt(4106,iModule); iModule++;
1592 volIDs->AddAt(4107,iModule); iModule++;
1593 volIDs->AddAt(4108,iModule); iModule++;
1594 volIDs->AddAt(4109,iModule); iModule++;
1595 volIDs->AddAt(4110,iModule); iModule++;
1596 volIDs->AddAt(4111,iModule); iModule++;
1598 if(sectors[1]==1){ //--->cSect = 1 <//---
1599 volIDs->AddAt(2056,iModule); iModule++;
1600 volIDs->AddAt(2057,iModule); iModule++;
1601 volIDs->AddAt(2058,iModule); iModule++;
1602 volIDs->AddAt(2059,iModule); iModule++;
1603 volIDs->AddAt(2060,iModule); iModule++;
1604 volIDs->AddAt(2061,iModule); iModule++;
1605 volIDs->AddAt(2062,iModule); iModule++;
1606 volIDs->AddAt(2063,iModule); iModule++;
1607 volIDs->AddAt(4112,iModule); iModule++;
1608 volIDs->AddAt(4113,iModule); iModule++;
1609 volIDs->AddAt(4114,iModule); iModule++;
1610 volIDs->AddAt(4115,iModule); iModule++;
1611 volIDs->AddAt(4116,iModule); iModule++;
1612 volIDs->AddAt(4117,iModule); iModule++;
1613 volIDs->AddAt(4118,iModule); iModule++;
1614 volIDs->AddAt(4119,iModule); iModule++;
1615 volIDs->AddAt(4120,iModule); iModule++;
1616 volIDs->AddAt(4121,iModule); iModule++;
1617 volIDs->AddAt(4122,iModule); iModule++;
1618 volIDs->AddAt(4123,iModule); iModule++;
1619 volIDs->AddAt(4124,iModule); iModule++;
1620 volIDs->AddAt(4125,iModule); iModule++;
1621 volIDs->AddAt(4126,iModule); iModule++;
1622 volIDs->AddAt(4127,iModule); iModule++;
1624 if(sectors[2]==1){//--->cSect = 2 <//---
1625 volIDs->AddAt(2064,iModule); iModule++;
1626 volIDs->AddAt(2065,iModule); iModule++;
1627 volIDs->AddAt(2066,iModule); iModule++;
1628 volIDs->AddAt(2067,iModule); iModule++;
1629 volIDs->AddAt(2068,iModule); iModule++;
1630 volIDs->AddAt(2069,iModule); iModule++;
1631 volIDs->AddAt(2070,iModule); iModule++;
1632 volIDs->AddAt(2071,iModule); iModule++;
1633 volIDs->AddAt(4128,iModule); iModule++;
1634 volIDs->AddAt(4129,iModule); iModule++;
1635 volIDs->AddAt(4130,iModule); iModule++;
1636 volIDs->AddAt(4131,iModule); iModule++;
1637 volIDs->AddAt(4132,iModule); iModule++;
1638 volIDs->AddAt(4133,iModule); iModule++;
1639 volIDs->AddAt(4134,iModule); iModule++;
1640 volIDs->AddAt(4135,iModule); iModule++;
1641 volIDs->AddAt(4136,iModule); iModule++;
1642 volIDs->AddAt(4137,iModule); iModule++;
1643 volIDs->AddAt(4138,iModule); iModule++;
1644 volIDs->AddAt(4139,iModule); iModule++;
1645 volIDs->AddAt(4140,iModule); iModule++;
1646 volIDs->AddAt(4141,iModule); iModule++;
1647 volIDs->AddAt(4142,iModule); iModule++;
1648 volIDs->AddAt(4143,iModule); iModule++;
1650 if(sectors[3]==1){//--->cSect = 3 <//---
1651 volIDs->AddAt(2072,iModule); iModule++;
1652 volIDs->AddAt(2073,iModule); iModule++;
1653 volIDs->AddAt(2074,iModule); iModule++;
1654 volIDs->AddAt(2075,iModule); iModule++;
1655 volIDs->AddAt(2076,iModule); iModule++;
1656 volIDs->AddAt(2077,iModule); iModule++;
1657 volIDs->AddAt(2078,iModule); iModule++;
1658 volIDs->AddAt(2079,iModule); iModule++;
1659 volIDs->AddAt(4144,iModule); iModule++;
1660 volIDs->AddAt(4145,iModule); iModule++;
1661 volIDs->AddAt(4146,iModule); iModule++;
1662 volIDs->AddAt(4147,iModule); iModule++;
1663 volIDs->AddAt(4148,iModule); iModule++;
1664 volIDs->AddAt(4149,iModule); iModule++;
1665 volIDs->AddAt(4150,iModule); iModule++;
1666 volIDs->AddAt(4151,iModule); iModule++;
1667 volIDs->AddAt(4152,iModule); iModule++;
1668 volIDs->AddAt(4153,iModule); iModule++;
1669 volIDs->AddAt(4154,iModule); iModule++;
1670 volIDs->AddAt(4155,iModule); iModule++;
1671 volIDs->AddAt(4156,iModule); iModule++;
1672 volIDs->AddAt(4157,iModule); iModule++;
1673 volIDs->AddAt(4158,iModule); iModule++;
1674 volIDs->AddAt(4159,iModule); iModule++;
1676 if(sectors[4]==1){//--->cSect = 4 <//---
1677 volIDs->AddAt(2080,iModule); iModule++;
1678 volIDs->AddAt(2081,iModule); iModule++;
1679 volIDs->AddAt(2082,iModule); iModule++;
1680 volIDs->AddAt(2083,iModule); iModule++;
1681 volIDs->AddAt(2084,iModule); iModule++;
1682 volIDs->AddAt(2085,iModule); iModule++;
1683 volIDs->AddAt(2086,iModule); iModule++;
1684 volIDs->AddAt(2087,iModule); iModule++;
1685 volIDs->AddAt(4160,iModule); iModule++;
1686 volIDs->AddAt(4161,iModule); iModule++;
1687 volIDs->AddAt(4162,iModule); iModule++;
1688 volIDs->AddAt(4163,iModule); iModule++;
1689 volIDs->AddAt(4164,iModule); iModule++;
1690 volIDs->AddAt(4165,iModule); iModule++;
1691 volIDs->AddAt(4166,iModule); iModule++;
1692 volIDs->AddAt(4167,iModule); iModule++;
1693 volIDs->AddAt(4168,iModule); iModule++;
1694 volIDs->AddAt(4169,iModule); iModule++;
1695 volIDs->AddAt(4170,iModule); iModule++;
1696 volIDs->AddAt(4171,iModule); iModule++;
1697 volIDs->AddAt(4172,iModule); iModule++;
1698 volIDs->AddAt(4173,iModule); iModule++;
1699 volIDs->AddAt(4174,iModule); iModule++;
1700 volIDs->AddAt(4175,iModule); iModule++;
1702 if(sectors[5]==1){//--->cSect = 5 <//---
1703 volIDs->AddAt(2088,iModule); iModule++;
1704 volIDs->AddAt(2089,iModule); iModule++;
1705 volIDs->AddAt(2090,iModule); iModule++;
1706 volIDs->AddAt(2091,iModule); iModule++;
1707 volIDs->AddAt(2092,iModule); iModule++;
1708 volIDs->AddAt(2093,iModule); iModule++;
1709 volIDs->AddAt(2094,iModule); iModule++;
1710 volIDs->AddAt(2095,iModule); iModule++;
1711 volIDs->AddAt(4176,iModule); iModule++;
1712 volIDs->AddAt(4177,iModule); iModule++;
1713 volIDs->AddAt(4178,iModule); iModule++;
1714 volIDs->AddAt(4179,iModule); iModule++;
1715 volIDs->AddAt(4180,iModule); iModule++;
1716 volIDs->AddAt(4181,iModule); iModule++;
1717 volIDs->AddAt(4182,iModule); iModule++;
1718 volIDs->AddAt(4183,iModule); iModule++;
1719 volIDs->AddAt(4184,iModule); iModule++;
1720 volIDs->AddAt(4185,iModule); iModule++;
1721 volIDs->AddAt(4186,iModule); iModule++;
1722 volIDs->AddAt(4187,iModule); iModule++;
1723 volIDs->AddAt(4188,iModule); iModule++;
1724 volIDs->AddAt(4189,iModule); iModule++;
1725 volIDs->AddAt(4190,iModule); iModule++;
1726 volIDs->AddAt(4191,iModule); iModule++;
1728 if(sectors[6]==1){//--->cSect = 6 <//---
1729 volIDs->AddAt(2096,iModule); iModule++;
1730 volIDs->AddAt(2097,iModule); iModule++;
1731 volIDs->AddAt(2098,iModule); iModule++;
1732 volIDs->AddAt(2099,iModule); iModule++;
1733 volIDs->AddAt(2100,iModule); iModule++;
1734 volIDs->AddAt(2101,iModule); iModule++;
1735 volIDs->AddAt(2102,iModule); iModule++;
1736 volIDs->AddAt(2103,iModule); iModule++;
1737 volIDs->AddAt(4192,iModule); iModule++;
1738 volIDs->AddAt(4193,iModule); iModule++;
1739 volIDs->AddAt(4194,iModule); iModule++;
1740 volIDs->AddAt(4195,iModule); iModule++;
1741 volIDs->AddAt(4196,iModule); iModule++;
1742 volIDs->AddAt(4197,iModule); iModule++;
1743 volIDs->AddAt(4198,iModule); iModule++;
1744 volIDs->AddAt(4199,iModule); iModule++;
1745 volIDs->AddAt(4200,iModule); iModule++;
1746 volIDs->AddAt(4201,iModule); iModule++;
1747 volIDs->AddAt(4202,iModule); iModule++;
1748 volIDs->AddAt(4203,iModule); iModule++;
1749 volIDs->AddAt(4204,iModule); iModule++;
1750 volIDs->AddAt(4205,iModule); iModule++;
1751 volIDs->AddAt(4206,iModule); iModule++;
1752 volIDs->AddAt(4207,iModule); iModule++;
1754 if(sectors[7]==1){ //--->cSect = 7 <//---
1755 volIDs->AddAt(2104,iModule); iModule++;
1756 volIDs->AddAt(2105,iModule); iModule++;
1757 volIDs->AddAt(2106,iModule); iModule++;
1758 volIDs->AddAt(2107,iModule); iModule++;
1759 volIDs->AddAt(2108,iModule); iModule++;
1760 volIDs->AddAt(2109,iModule); iModule++;
1761 volIDs->AddAt(2110,iModule); iModule++;
1762 volIDs->AddAt(2111,iModule); iModule++;
1763 volIDs->AddAt(4208,iModule); iModule++;
1764 volIDs->AddAt(4209,iModule); iModule++;
1765 volIDs->AddAt(4210,iModule); iModule++;
1766 volIDs->AddAt(4211,iModule); iModule++;
1767 volIDs->AddAt(4212,iModule); iModule++;
1768 volIDs->AddAt(4213,iModule); iModule++;
1769 volIDs->AddAt(4214,iModule); iModule++;
1770 volIDs->AddAt(4215,iModule); iModule++;
1771 volIDs->AddAt(4216,iModule); iModule++;
1772 volIDs->AddAt(4217,iModule); iModule++;
1773 volIDs->AddAt(4218,iModule); iModule++;
1774 volIDs->AddAt(4219,iModule); iModule++;
1775 volIDs->AddAt(4220,iModule); iModule++;
1776 volIDs->AddAt(4221,iModule); iModule++;
1777 volIDs->AddAt(4222,iModule); iModule++;
1778 volIDs->AddAt(4223,iModule); iModule++;
1780 if(sectors[8]==1){//--->cSect = 8 <//---
1781 volIDs->AddAt(2112,iModule); iModule++;
1782 volIDs->AddAt(2113,iModule); iModule++;
1783 volIDs->AddAt(2114,iModule); iModule++;
1784 volIDs->AddAt(2115,iModule); iModule++;
1785 volIDs->AddAt(2116,iModule); iModule++;
1786 volIDs->AddAt(2117,iModule); iModule++;
1787 volIDs->AddAt(2118,iModule); iModule++;
1788 volIDs->AddAt(2119,iModule); iModule++;
1789 volIDs->AddAt(4224,iModule); iModule++;
1790 volIDs->AddAt(4225,iModule); iModule++;
1791 volIDs->AddAt(4226,iModule); iModule++;
1792 volIDs->AddAt(4227,iModule); iModule++;
1793 volIDs->AddAt(4228,iModule); iModule++;
1794 volIDs->AddAt(4229,iModule); iModule++;
1795 volIDs->AddAt(4230,iModule); iModule++;
1796 volIDs->AddAt(4231,iModule); iModule++;
1797 volIDs->AddAt(4232,iModule); iModule++;
1798 volIDs->AddAt(4233,iModule); iModule++;
1799 volIDs->AddAt(4234,iModule); iModule++;
1800 volIDs->AddAt(4235,iModule); iModule++;
1801 volIDs->AddAt(4236,iModule); iModule++;
1802 volIDs->AddAt(4237,iModule); iModule++;
1803 volIDs->AddAt(4238,iModule); iModule++;
1804 volIDs->AddAt(4239,iModule); iModule++;
1806 if(sectors[9]==1){//--->cSect = 9 <//---
1807 volIDs->AddAt(2120,iModule); iModule++;
1808 volIDs->AddAt(2121,iModule); iModule++;
1809 volIDs->AddAt(2122,iModule); iModule++;
1810 volIDs->AddAt(2123,iModule); iModule++;
1811 volIDs->AddAt(2124,iModule); iModule++;
1812 volIDs->AddAt(2125,iModule); iModule++;
1813 volIDs->AddAt(2126,iModule); iModule++;
1814 volIDs->AddAt(2127,iModule); iModule++;
1815 volIDs->AddAt(4240,iModule); iModule++;
1816 volIDs->AddAt(4241,iModule); iModule++;
1817 volIDs->AddAt(4242,iModule); iModule++;
1818 volIDs->AddAt(4243,iModule); iModule++;
1819 volIDs->AddAt(4244,iModule); iModule++;
1820 volIDs->AddAt(4245,iModule); iModule++;
1821 volIDs->AddAt(4246,iModule); iModule++;
1822 volIDs->AddAt(4247,iModule); iModule++;
1823 volIDs->AddAt(4248,iModule); iModule++;
1824 volIDs->AddAt(4249,iModule); iModule++;
1825 volIDs->AddAt(4250,iModule); iModule++;
1826 volIDs->AddAt(4251,iModule); iModule++;
1827 volIDs->AddAt(4252,iModule); iModule++;
1828 volIDs->AddAt(4253,iModule); iModule++;
1829 volIDs->AddAt(4254,iModule); iModule++;
1830 volIDs->AddAt(4255,iModule); iModule++;
1837 //____________________________________________________________________________
1838 TArrayI* AliITSResidualsAnalysis::GetITSLayersVolids(Int_t layers[6]) const
1841 // This method gets the volID Array for the chosen layers.
1842 // You have to pass an array with a 1 for each selected layer.
1843 // i.e. layers[6] = {1,1,0,0,1,1} -> SPD + SSD
1846 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
1848 Int_t size=0,last=0;
1850 // evaluates the size of the array
1851 for(Int_t i=0;i<6;i++) if(layers[i]==1) size+=AliGeomManager::LayerSize(i+1);
1854 printf("Error: no layer selected");
1858 TArrayI *volids = new TArrayI(size);
1860 // fills the volId array only for the chosen layers
1861 for(Int_t ilayer=1;ilayer<7;ilayer++){
1863 if(layers[ilayer-1]!=1) continue;
1865 for(Int_t imod=0;imod<AliGeomManager::LayerSize(ilayer);imod++){
1866 volids->AddAt(AliGeomManager::LayerToVolUID(ilayer,imod),last);
1875 //____________________________________________________________________________
1876 void AliITSResidualsAnalysis::GetTrackDirClusterCov(AliTrackPoint *point,Double_t &phi,Double_t &lambda,Double_t &lambda2,Double_t &alpha,Double_t &xovery,Double_t &zovery) const
1883 const Float_t *covvector=point->GetCov();
1884 cov(0,0)=covvector[0];
1885 cov(1,0)=cov(0,1)=covvector[1];
1886 cov(2,0)=cov(0,2)=covvector[2];
1887 cov(1,1)=covvector[3];
1888 cov(1,2)=cov(2,1)=covvector[4];
1889 cov(2,2)=covvector[5];
1891 Double_t determinant=cov.Determinant();
1892 if(determinant!=0.){
1894 TVectorD eigenvalues(3);
1895 const TMatrixDSymEigen keigen(cov);
1896 eigenvalues=keigen.GetEigenValues();
1897 vect=keigen.GetEigenVectors();
1898 Double_t mainvect[3];
1899 mainvect[0]=vect(0,0);
1900 mainvect[1]=vect(1,0);
1901 mainvect[2]=vect(2,0);
1902 if(mainvect[1]!=0.){
1903 xovery=mainvect[0]/mainvect[1];
1904 zovery=mainvect[2]/mainvect[1];
1911 mainvect[0]=-1.*mainvect[0];
1912 mainvect[1]=-1.*mainvect[1];
1913 mainvect[2]=-1.*mainvect[2];
1915 lambda2=TMath::ATan2(TMath::Sqrt(mainvect[0]*mainvect[0]+mainvect[2]*mainvect[2]),mainvect[1])*TMath::RadToDeg();
1916 lambda=TMath::ATan2(mainvect[2],TMath::Sqrt(mainvect[0]*mainvect[0]+mainvect[1]*mainvect[1]))*TMath::RadToDeg();
1917 phi=TMath::ATan2(mainvect[0],mainvect[2])*TMath::RadToDeg();
1918 alpha=TMath::ATan2(mainvect[1],mainvect[0])*TMath::RadToDeg();
1920 else printf("determinant =0!, skip this point \n");
1925 //____________________________________________________________________________
1926 void AliITSResidualsAnalysis::CalculateResiduals(const TArrayI *volids,
1927 const TArrayI *volidsfit,
1928 AliGeomManager::ELayerID layerRangeMin,
1929 AliGeomManager::ELayerID layerRangeMax,
1932 // CalculateResiduals for a set of detector volumes.
1933 // Tracks are fitted only within
1934 // the range defined by the user
1935 // (by layerRangeMin and layerRangeMax)
1936 // or within the set of volidsfit
1937 // Repeat the procedure 'iterations' times
1939 Int_t nVolIds = volids->GetSize();
1940 if (nVolIds == 0) { AliError("Volume IDs array is empty!"); return; }
1942 // Load only the tracks with at least one
1943 // space point in the set of volume (volids)
1946 //AliAlignmentTracks::SetPointsFilename(GetFileNameTrackPoints());
1947 AliAlignmentTracks::BuildIndex();
1949 ListVolUsed(fPointsTree,fArrayIndex,fLastIndex);
1950 AliTrackPointArray **points;
1953 LoadPoints(volids, points,pointsDim);
1955 Int_t nArrays = fPointsTree->GetEntries();
1957 if (nArrays == 0){ AliError("Points array is empty!"); return; }
1958 AliTrackFitter *fitter = CreateFitter();
1963 for (Int_t iArray = 0; iArray < nArrays; iArray++){
1965 cout<<"Investigating "<<iArray<<"/"<<nArrays<<endl;
1967 if (!points[iArray]){
1968 cout<<" Skipping: "<<iArray<<endl;
1972 fitter->SetTrackPointArray(points[iArray],kTRUE); // Watch out, problems
1978 if(fitter->Fit(volids,volidsfit,layerRangeMin,layerRangeMax) == kFALSE){
1980 cout<<"->BAD: "<<iArray<<endl;
1982 } //else cout<<"->GOOD: "<<iArray<<endl;
1984 AliTrackPointArray *pVolId,*pTrack;
1986 fitter->GetTrackResiduals(pVolId,pTrack);
1987 FillResidualsH(pVolId,pTrack);
1991 cout<<" -> nVolIds: "<<nVolIds<<endl;
1992 cout<<" -> Non-Fitted tracks: "<<ecount<<"/"<<totcount<<endl;
1994 UnloadPoints(pointsDim,points);
1995 SaveHists(3,outname);
2003 //______________________________________________________________________________
2004 void AliITSResidualsAnalysis::ProcessVolumes(Int_t fit,
2007 TString misalignmentFile,
2012 // This function process the AliTrackPoints and volID (into residuals)
2015 // setting up geometry and the trackpoints file
2016 if(!gGeoManager) AliGeomManager::LoadGeometry(GetFileNameGeometry());
2018 SetPointsFilename(GetFileNameTrackPoints());
2020 // creating some tools
2021 AliTrackFitter *fitter;
2023 fitter = new AliTrackFitterKalman();
2024 }else fitter = new AliTrackFitterRieman();
2026 fitter->SetMinNPoints(minPoints);
2028 SetTrackFitter(fitter);
2030 if(misalignmentFile=="")printf("NO FAKE MISALIGNMENT\n");
2032 Bool_t misal=Misalign(misalignmentFile,"ITSAlignObjs");
2034 printf("PROBLEM WITH FAKE MISALIGNMENT!");
2039 CalculateResiduals(volIDs,volIDsFit,AliGeomManager::kSPD1,AliGeomManager::kSSD2,outname);