1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 alignment steering 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 //-----------------------------------------------------------------
28 #include "AliAlignmentTracks.h"
29 #include "AliTrackPointArray.h"
30 #include "AliAlignObjAngles.h"
31 #include "AliTrackFitterRieman.h"
32 #include "AliTrackResidualsChi2.h"
36 ClassImp(AliAlignmentTracks)
38 //______________________________________________________________________________
39 AliAlignmentTracks::AliAlignmentTracks():
41 fPointsFilename("AliTrackPoints.root"),
46 fIsIndexBuilt(kFALSE),
53 // Default constructor
58 //______________________________________________________________________________
59 AliAlignmentTracks::AliAlignmentTracks(TChain *esdchain):
61 fPointsFilename("AliTrackPoints.root"),
66 fIsIndexBuilt(kFALSE),
73 // Constructor in the case
74 // the user provides an already
75 // built TChain with ESD trees
81 //______________________________________________________________________________
82 AliAlignmentTracks::AliAlignmentTracks(const char *esdfilename, const char *esdtreename):
83 fESDChain(new TChain(esdtreename)),
84 fPointsFilename("AliTrackPoints.root"),
89 fIsIndexBuilt(kFALSE),
96 // Constructor in the case
97 // the user provides a single ESD file
98 // or a directory containing ESD files
99 fESDChain->Add(esdfilename);
106 //______________________________________________________________________________
107 AliAlignmentTracks::~AliAlignmentTracks()
110 if (fESDChain) delete fESDChain;
118 if (fPointsFile) fPointsFile->Close();
121 //______________________________________________________________________________
122 void AliAlignmentTracks::AddESD(TChain *esdchain)
124 // Add a chain with ESD files
126 fESDChain->Add(esdchain);
128 fESDChain = esdchain;
131 //______________________________________________________________________________
132 void AliAlignmentTracks::AddESD(const char *esdfilename, const char *esdtreename)
134 // Add a single file or
135 // a directory to the chain
136 // with the ESD files
138 fESDChain->AddFile(esdfilename,TChain::kBigNumber,esdtreename);
140 fESDChain = new TChain(esdtreename);
141 fESDChain->Add(esdfilename);
145 //________________________________________________________________________
147 void AliAlignmentTracks::ProcessESD(Bool_t onlyITS,
150 Float_t minMom,Float_t maxMom,
151 Float_t minAbsSinPhi,Float_t maxAbsSinPhi,
152 Float_t minSinTheta,Float_t maxSinTheta)
154 // Analyzes and filters ESD tracks
155 // Stores the selected track space points
156 // into the output file
158 if (!fESDChain) return;
161 fESDChain->SetBranchAddress("ESD",&esd);
162 AliESDfriend *esdf = 0;
163 fESDChain->SetBranchStatus("ESDfriend*",1);
164 fESDChain->SetBranchAddress("ESDfriend.",&esdf);
166 // Open the output file
167 if (fPointsFilename.Data() == "") {
168 AliWarning("Incorrect output filename!");
172 TFile *pointsFile = TFile::Open(fPointsFilename,"RECREATE");
173 if (!pointsFile || !pointsFile->IsOpen()) {
174 AliWarning(Form("Can't open %s !",fPointsFilename.Data()));
178 TTree *pointsTree = new TTree("spTree", "Tree with track space point arrays");
179 const AliTrackPointArray *array = 0;
180 AliTrackPointArray *array2 = 0;
181 if(onlyITS) { // only ITS AliTrackPoints
182 pointsTree->Branch("SP","AliTrackPointArray", &array2);
184 pointsTree->Branch("SP","AliTrackPointArray", &array);
188 while (fESDChain->GetEntry(ievent++)) {
191 esd->SetESDfriend(esdf); //Attach the friend to the ESD
193 Int_t ntracks = esd->GetNumberOfTracks();
194 for (Int_t itrack=0; itrack < ntracks; itrack++) {
195 AliESDtrack * track = esd->GetTrack(itrack);
196 if (!track) continue;
198 if(track->GetNcls(0) < minITSpts) continue;
200 if(track->GetP()<minMom || track->GetP()>maxMom) continue;
201 Float_t abssinphi = TMath::Abs(TMath::Sin(track->GetAlpha()+TMath::ASin(track->GetSnp())));
202 if(abssinphi<minAbsSinPhi || abssinphi>maxAbsSinPhi) continue;
203 Float_t sintheta = TMath::Sin(0.5*TMath::Pi()-TMath::ATan(track->GetTgl()));
204 if(sintheta<minSinTheta || sintheta>maxSinTheta) continue;
206 // UInt_t status = AliESDtrack::kITSpid;
207 // status|=AliESDtrack::kTPCpid;
208 // status|=AliESDtrack::kTRDpid;
209 // if ((track->GetStatus() & status) != status) continue;
212 array = track->GetTrackPointArray();
215 array2 = new AliTrackPointArray(track->GetNcls(0));
216 Int_t ipt,volId,modId,layerId;
218 for(ipt=0; ipt<array->GetNPoints(); ipt++) {
219 array->GetPoint(point,ipt);
220 volId = point.GetVolumeID();
221 layerId = AliGeomManager::VolUIDToLayer(volId,modId);
223 array2->AddPoint(jpt,&point);
233 if (!pointsTree->Write()) {
234 AliWarning("Can't write the tree with track point arrays!");
241 //______________________________________________________________________________
242 void AliAlignmentTracks::ProcessESDCosmics(Bool_t onlyITS,
245 Float_t minMom,Float_t maxMom,
246 Float_t minAbsSinPhi,Float_t maxAbsSinPhi,
247 Float_t minSinTheta,Float_t maxSinTheta)
249 // Analyzes and filters ESD tracks
250 // Merges inward and outward tracks in one single track
251 // Stores the selected track space points
252 // into the output file
254 if (!fESDChain) return;
257 fESDChain->SetBranchAddress("ESD",&esd);
258 AliESDfriend *esdf = 0;
259 fESDChain->SetBranchStatus("ESDfriend*",1);
260 fESDChain->SetBranchAddress("ESDfriend.",&esdf);
262 // Open the output file
263 if (fPointsFilename.Data() == "") {
264 AliWarning("Incorrect output filename!");
268 TFile *pointsFile = TFile::Open(fPointsFilename,"RECREATE");
269 if (!pointsFile || !pointsFile->IsOpen()) {
270 AliWarning(Form("Can't open %s !",fPointsFilename.Data()));
274 TTree *pointsTree = new TTree("spTree", "Tree with track space point arrays");
275 const AliTrackPointArray *array = 0;
276 AliTrackPointArray *array2 = 0;
277 pointsTree->Branch("SP","AliTrackPointArray", &array2);
280 while (fESDChain->GetEntry(ievent++)) {
283 esd->SetESDfriend(esdf); //Attach the friend to the ESD
285 Int_t ntracks = esd->GetNumberOfTracks();
287 Int_t goodtracks[10];
288 for (Int_t itrack=0; itrack < ntracks; itrack++) {
289 AliESDtrack * track = esd->GetTrack(itrack);
290 if (!track) continue;
292 if(track->GetNcls(0) < minITSpts) continue;
294 if(track->GetP()<minMom || track->GetP()>maxMom) continue;
295 Float_t abssinphi = TMath::Abs(TMath::Sin(track->GetAlpha()+TMath::ASin(track->GetSnp())));
296 if(abssinphi<minAbsSinPhi || abssinphi>maxAbsSinPhi) continue;
297 Float_t sintheta = TMath::Sin(0.5*TMath::Pi()-TMath::ATan(track->GetTgl()));
298 if(sintheta<minSinTheta || sintheta>maxSinTheta) continue;
300 if(ngt<10) goodtracks[ngt]=itrack;
304 if(ngt!=2) continue; // this can be changed to check that the two tracks match
306 AliESDtrack * track1 = esd->GetTrack(goodtracks[0]);
307 AliESDtrack * track2 = esd->GetTrack(goodtracks[1]);
311 ntotpts = track1->GetNcls(0)+track2->GetNcls(0);
313 ntotpts = track1->GetTrackPointArray()->GetNPoints()+
314 track2->GetTrackPointArray()->GetNPoints();
316 array2 = new AliTrackPointArray(ntotpts);
318 Int_t ipt,volId,modId,layerId;
320 array = track1->GetTrackPointArray();
321 for(ipt=0; ipt<array->GetNPoints(); ipt++) {
322 array->GetPoint(point,ipt);
324 volId = point.GetVolumeID();
325 layerId = AliGeomManager::VolUIDToLayer(volId,modId);
326 if(layerId>6) continue;
328 array2->AddPoint(jpt,&point);
331 array = track2->GetTrackPointArray();
332 for(ipt=0; ipt<array->GetNPoints(); ipt++) {
333 array->GetPoint(point,ipt);
335 volId = point.GetVolumeID();
336 layerId = AliGeomManager::VolUIDToLayer(volId,modId);
337 if(layerId>6) continue;
339 array2->AddPoint(jpt,&point);
346 if (!pointsTree->Write()) {
347 AliWarning("Can't write the tree with track point arrays!");
354 //______________________________________________________________________________
355 void AliAlignmentTracks::ProcessESD(TSelector *selector)
357 AliWarning(Form("ESD processing based on selector is not yet implemented (%p) !",selector));
360 //______________________________________________________________________________
361 void AliAlignmentTracks::BuildIndex()
363 // Build index of points tree entries
364 // Used for access based on the volume IDs
365 if (fIsIndexBuilt) return;
367 fIsIndexBuilt = kTRUE;
369 // Dummy object is created in order
370 // to initialize the volume paths
371 AliAlignObjAngles alobj;
373 fPointsFile = TFile::Open(fPointsFilename);
374 if (!fPointsFile || !fPointsFile->IsOpen()) {
375 AliWarning(Form("Can't open %s !",fPointsFilename.Data()));
379 // AliTrackPointArray* array = new AliTrackPointArray;
380 AliTrackPointArray* array = 0;
381 fPointsTree = (TTree*) fPointsFile->Get("spTree");
383 AliWarning("No pointsTree found!");
386 fPointsTree->SetBranchAddress("SP", &array);
388 Int_t nArrays = (Int_t)fPointsTree->GetEntries();
389 for (Int_t iArray = 0; iArray < nArrays; iArray++)
391 fPointsTree->GetEvent(iArray);
392 if (!array) continue;
393 for (Int_t ipoint = 0; ipoint < array->GetNPoints(); ipoint++) {
394 UShort_t volId = array->GetVolumeID()[ipoint];
395 // check if the volId is valid
396 if (!AliGeomManager::SymName(volId)) {
397 AliError(Form("The volume id %d has no default volume name !",
402 Int_t layerId = AliGeomManager::VolUIDToLayer(volId,modId)
403 - AliGeomManager::kFirstLayer;
404 if (!fArrayIndex[layerId][modId]) {
405 //first entry for this volume
406 fArrayIndex[layerId][modId] = new TArrayI(1000);
409 Int_t size = fArrayIndex[layerId][modId]->GetSize();
410 // If needed allocate new size
411 if (fLastIndex[layerId][modId] >= size)
412 fArrayIndex[layerId][modId]->Set(size + 1000);
415 // Check if the index is already filled
416 Bool_t fillIndex = kTRUE;
417 if (fLastIndex[layerId][modId] != 0) {
418 if ((*fArrayIndex[layerId][modId])[fLastIndex[layerId][modId]-1] == iArray)
421 // Fill the index array and store last filled index
423 (*fArrayIndex[layerId][modId])[fLastIndex[layerId][modId]] = iArray;
424 fLastIndex[layerId][modId]++;
431 //______________________________________________________________________________
432 void AliAlignmentTracks::InitIndex()
434 // Initialize the index arrays
435 Int_t nLayers = AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer;
436 fLastIndex = new Int_t*[nLayers];
437 fArrayIndex = new TArrayI**[nLayers];
438 for (Int_t iLayer = 0; iLayer < (AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer); iLayer++) {
439 fLastIndex[iLayer] = new Int_t[AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer)];
440 fArrayIndex[iLayer] = new TArrayI*[AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer)];
441 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++) {
442 fLastIndex[iLayer][iModule] = 0;
443 fArrayIndex[iLayer][iModule] = 0;
448 //______________________________________________________________________________
449 void AliAlignmentTracks::ResetIndex()
451 // Reset the value of the last filled index
452 // Do not realocate memory
454 fIsIndexBuilt = kFALSE;
456 for (Int_t iLayer = 0; iLayer < AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer; iLayer++) {
457 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++) {
458 fLastIndex[iLayer][iModule] = 0;
463 //______________________________________________________________________________
464 void AliAlignmentTracks::DeleteIndex()
466 // Delete the index arrays
467 // Called by the destructor
468 for (Int_t iLayer = 0; iLayer < (AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer); iLayer++) {
469 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++) {
470 if (fArrayIndex[iLayer][iModule]) {
471 delete fArrayIndex[iLayer][iModule];
472 fArrayIndex[iLayer][iModule] = 0;
475 delete [] fLastIndex[iLayer];
476 delete [] fArrayIndex[iLayer];
478 delete [] fLastIndex;
479 delete [] fArrayIndex;
482 //______________________________________________________________________________
483 Bool_t AliAlignmentTracks::ReadAlignObjs(const char *alignObjFileName, const char* arrayName)
485 // Read alignment object from a file
486 // To be replaced by a call to CDB
487 AliWarning(Form("Method not yet implemented (%s in %s) !",arrayName,alignObjFileName));
492 //______________________________________________________________________________
493 void AliAlignmentTracks::InitAlignObjs()
495 // Initialize the alignment objects array
496 Int_t nLayers = AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer;
497 fAlignObjs = new AliAlignObj**[nLayers];
498 for (Int_t iLayer = 0; iLayer < (AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer); iLayer++) {
499 fAlignObjs[iLayer] = new AliAlignObj*[AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer)];
500 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++) {
501 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer+ AliGeomManager::kFirstLayer,iModule);
502 fAlignObjs[iLayer][iModule] = new AliAlignObjAngles(AliGeomManager::SymName(volid),volid,0,0,0,0,0,0,kTRUE);
507 //______________________________________________________________________________
508 void AliAlignmentTracks::ResetAlignObjs()
510 // Reset the alignment objects array
511 for (Int_t iLayer = 0; iLayer < (AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer); iLayer++) {
512 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++)
513 fAlignObjs[iLayer][iModule]->SetPars(0,0,0,0,0,0);
517 //______________________________________________________________________________
518 void AliAlignmentTracks::DeleteAlignObjs()
520 // Delete the alignment objects array
521 for (Int_t iLayer = 0; iLayer < (AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer); iLayer++) {
522 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++)
523 if (fAlignObjs[iLayer][iModule])
524 delete fAlignObjs[iLayer][iModule];
525 delete [] fAlignObjs[iLayer];
527 delete [] fAlignObjs;
531 void AliAlignmentTracks::AlignDetector(AliGeomManager::ELayerID firstLayer,
532 AliGeomManager::ELayerID lastLayer,
533 AliGeomManager::ELayerID layerRangeMin,
534 AliGeomManager::ELayerID layerRangeMax,
537 // Align detector volumes within
538 // a given layer range
539 // (could be whole detector).
540 // Tracks are fitted only within
541 // the range defined by the user.
543 for (Int_t iLayer = firstLayer; iLayer <= lastLayer; iLayer++)
544 nModules += AliGeomManager::LayerSize(iLayer);
545 TArrayI volIds(nModules);
548 for (Int_t iLayer = firstLayer; iLayer <= lastLayer; iLayer++) {
549 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
550 UShort_t volId = AliGeomManager::LayerToVolUID(iLayer,iModule);
551 volIds.AddAt(volId,modnum);
556 while (iterations > 0) {
557 AlignVolumes(&volIds,0x0,layerRangeMin,layerRangeMax);
562 //______________________________________________________________________________
563 void AliAlignmentTracks::AlignLayer(AliGeomManager::ELayerID layer,
564 AliGeomManager::ELayerID layerRangeMin,
565 AliGeomManager::ELayerID layerRangeMax,
568 // Align detector volumes within
570 // Tracks are fitted only within
571 // the range defined by the user.
572 Int_t nModules = AliGeomManager::LayerSize(layer);
573 TArrayI volIds(nModules);
574 for (Int_t iModule = 0; iModule < nModules; iModule++) {
575 UShort_t volId = AliGeomManager::LayerToVolUID(layer,iModule);
576 volIds.AddAt(volId,iModule);
579 while (iterations > 0) {
580 AlignVolumes(&volIds,0x0,layerRangeMin,layerRangeMax);
585 //______________________________________________________________________________
586 void AliAlignmentTracks::AlignVolume(UShort_t volId, UShort_t volIdFit,
589 // Align single detector volume to
591 // Tracks are fitted only within
592 // the second volume.
594 volIds.AddAt(volId,0);
595 TArrayI volIdsFit(1);
596 volIdsFit.AddAt(volIdFit,0);
598 while (iterations > 0) {
599 AlignVolumes(&volIds,&volIdsFit);
604 //______________________________________________________________________________
605 void AliAlignmentTracks::AlignVolumes(const TArrayI *volids, const TArrayI *volidsfit,
606 AliGeomManager::ELayerID layerRangeMin,
607 AliGeomManager::ELayerID layerRangeMax,
610 // Align a set of detector volumes.
611 // Tracks are fitted only within
612 // the range defined by the user
613 // (by layerRangeMin and layerRangeMax)
614 // or within the set of volidsfit
615 // Repeat the procedure 'iterations' times
617 Int_t nVolIds = volids->GetSize();
619 AliError("Volume IDs array is empty!");
623 // Load only the tracks with at least one
624 // space point in the set of volume (volids)
626 AliTrackPointArray **points;
627 // Start the iterations
628 while (iterations > 0) {
629 Int_t nArrays = LoadPoints(volids, points);
630 if (nArrays == 0) return;
632 AliTrackResiduals *minimizer = CreateMinimizer();
633 minimizer->SetNTracks(nArrays);
634 minimizer->InitAlignObj();
635 AliTrackFitter *fitter = CreateFitter();
636 for (Int_t iArray = 0; iArray < nArrays; iArray++) {
637 if (!points[iArray]) continue;
638 fitter->SetTrackPointArray(points[iArray], kFALSE);
639 if (fitter->Fit(volids,volidsfit,layerRangeMin,layerRangeMax) == kFALSE) continue;
640 AliTrackPointArray *pVolId,*pTrack;
641 fitter->GetTrackResiduals(pVolId,pTrack);
642 minimizer->AddTrackPointArrays(pVolId,pTrack);
644 minimizer->Minimize();
646 // Update the alignment object(s)
647 if (fDoUpdate) for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) {
648 UShort_t volid = (*volids)[iVolId];
650 AliGeomManager::ELayerID iLayer = AliGeomManager::VolUIDToLayer(volid,iModule);
651 AliAlignObj *alignObj = fAlignObjs[iLayer-AliGeomManager::kFirstLayer][iModule];
652 *alignObj *= *minimizer->GetAlignObj();
656 UnloadPoints(nArrays, points);
662 //______________________________________________________________________________
663 Int_t AliAlignmentTracks::LoadPoints(const TArrayI *volids, AliTrackPointArray** &points)
665 // Load track point arrays with at least
666 // one space point in a given set of detector
667 // volumes (array volids).
668 // Use the already created tree index for
672 AliError("Tree with the space point arrays not initialized!");
677 Int_t nVolIds = volids->GetSize();
679 AliError("Volume IDs array is empty!");
685 for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) {
686 UShort_t volid = (*volids)[iVolId];
688 AliGeomManager::ELayerID iLayer = AliGeomManager::VolUIDToLayer(volid,iModule);
690 // In case of empty index
691 if (fLastIndex[iLayer-AliGeomManager::kFirstLayer][iModule] == 0) {
692 AliWarning(Form("There are no space-points belonging to the volume which is to be aligned (Volume ID =%d)!",volid));
695 nArrays += fLastIndex[iLayer-AliGeomManager::kFirstLayer][iModule];
699 AliError("There are no space-points belonging to all of the volumes which are to be aligned!");
704 AliTrackPointArray* array = 0;
705 fPointsTree->SetBranchAddress("SP", &array);
707 // Allocate the pointer to the space-point arrays
708 points = new AliTrackPointArray*[nArrays];
709 for (Int_t i = 0; i < nArrays; i++) points[i] = 0x0;
711 // Init the array used to flag already loaded tree entries
712 Bool_t *indexUsed = new Bool_t[(UInt_t)fPointsTree->GetEntries()];
713 for (Int_t i = 0; i < fPointsTree->GetEntries(); i++)
714 indexUsed[i] = kFALSE;
716 // Start the loop over the volume ids
718 for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) {
719 UShort_t volid = (*volids)[iVolId];
721 AliGeomManager::ELayerID iLayer = AliGeomManager::VolUIDToLayer(volid,iModule);
723 Int_t nArraysId = fLastIndex[iLayer-AliGeomManager::kFirstLayer][iModule];
724 TArrayI *index = fArrayIndex[iLayer-AliGeomManager::kFirstLayer][iModule];
727 for (Int_t iArrayId = 0; iArrayId < nArraysId; iArrayId++) {
730 Int_t entry = (*index)[iArrayId];
731 if (indexUsed[entry] == kTRUE) continue;
732 fPointsTree->GetEvent(entry);
734 AliWarning("Wrong space point array index!");
737 indexUsed[entry] = kTRUE;
739 // Get the space-point array
740 Int_t nPoints = array->GetNPoints();
741 points[iArray] = new AliTrackPointArray(nPoints);
742 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
743 array->GetPoint(p,iPoint);
745 AliGeomManager::ELayerID layer = AliGeomManager::VolUIDToLayer(p.GetVolumeID(),modnum);
746 // check if the layer id is valid
747 if ((layer < AliGeomManager::kFirstLayer) ||
748 (layer >= AliGeomManager::kLastLayer)) {
749 AliError(Form("Layer index is invalid: %d (%d -> %d) !",
750 layer,AliGeomManager::kFirstLayer,AliGeomManager::kLastLayer-1));
753 if ((modnum >= AliGeomManager::LayerSize(layer)) ||
755 AliError(Form("Module number inside layer %d is invalid: %d (0 -> %d)",
756 layer,modnum,AliGeomManager::LayerSize(layer)));
760 // Misalignment is introduced here
761 // Switch it off in case of real
764 AliAlignObj *misalignObj = fMisalignObjs[layer-AliGeomManager::kFirstLayer][modnum];
766 misalignObj->Transform(p);
768 // End of misalignment
770 AliAlignObj *alignObj = fAlignObjs[layer-AliGeomManager::kFirstLayer][modnum];
771 alignObj->Transform(p);
772 points[iArray]->AddPoint(iPoint,&p);
784 //______________________________________________________________________________
785 void AliAlignmentTracks::UnloadPoints(Int_t n, AliTrackPointArray **points)
787 // Unload track point arrays for a given
789 for (Int_t iArray = 0; iArray < n; iArray++)
790 delete points[iArray];
794 //______________________________________________________________________________
795 AliTrackFitter *AliAlignmentTracks::CreateFitter()
797 // Check if the user has already supplied
798 // a track fitter object.
799 // If not, create a default one.
801 fTrackFitter = new AliTrackFitterRieman;
806 //______________________________________________________________________________
807 AliTrackResiduals *AliAlignmentTracks::CreateMinimizer()
809 // Check if the user has already supplied
810 // a track residuals minimizer object.
811 // If not, create a default one.
813 fMinimizer = new AliTrackResidualsChi2;
818 //______________________________________________________________________________
819 Bool_t AliAlignmentTracks::Misalign(const char *misalignObjFileName, const char* arrayName)
821 // The method reads from a file a set of AliAlignObj which are
822 // then used to apply misalignments directly on the track
823 // space-points. The method is supposed to be used only for
824 // fast development and debugging of the alignment algorithms.
825 // Be careful not to use it in the case of 'real' alignment
826 // scenario since it will bias the results.
828 // Initialize the misalignment objects array
829 Int_t nLayers = AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer;
830 fMisalignObjs = new AliAlignObj**[nLayers];
831 for (Int_t iLayer = 0; iLayer < (AliGeomManager::kLastLayer - AliGeomManager::kFirstLayer); iLayer++) {
832 fMisalignObjs[iLayer] = new AliAlignObj*[AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer)];
833 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer + AliGeomManager::kFirstLayer); iModule++)
834 fMisalignObjs[iLayer][iModule] = 0x0;
837 // Open the misliagnment file and load the array with
838 // misalignment objects
839 TFile* inFile = TFile::Open(misalignObjFileName,"READ");
840 if (!inFile || !inFile->IsOpen()) {
841 AliError(Form("Could not open misalignment file %s !",misalignObjFileName));
845 TClonesArray* array = ((TClonesArray*) inFile->Get(arrayName));
847 AliError(Form("Could not find misalignment array %s in the file %s !",arrayName,misalignObjFileName));
853 // Store the misalignment objects for further usage
854 Int_t nObjs = array->GetEntriesFast();
855 AliGeomManager::ELayerID layerId; // volume layer
856 Int_t modId; // volume ID inside the layer
857 for(Int_t i=0; i<nObjs; i++)
859 AliAlignObj* alObj = (AliAlignObj*)array->UncheckedAt(i);
860 alObj->GetVolUID(layerId,modId);
861 fMisalignObjs[layerId-AliGeomManager::kFirstLayer][modId] = alObj;