+//-------------------------------------------------------------------------------
+const AliITSRecoParam *AliAlignmentDataFilterITS::GetRecoParam() const
+{
+ //
+ // Return the ITSRecoParam object
+ //
+ if(AliITSReconstructor::GetRecoParam()) {
+ return AliITSReconstructor::GetRecoParam();
+ } else if(fITSRecoParam) {
+ return fITSRecoParam;
+ } else return NULL;
+}
+//--------------------------------------------------------------------------------
+Int_t AliAlignmentDataFilterITS::WriteTrackPointsInIdealGeom(Char_t *fin,
+ Char_t *fout,
+ Char_t *fmis,
+ Char_t *fgeo,
+ Bool_t prn)
+{
+ //
+ // Convert AliTrackPoints in fin, reconstructed with fmis, back
+ // to ideal geometry
+ //
+ // M. Lunardon
+ //
+
+
+ TGeoHMatrix deltahm;
+ TGeoHMatrix hcov;
+
+ // Load geometry
+ if (gSystem->AccessPathName(fgeo)) {
+ printf("couldn't find geometry file %s - skipping...\n",fmis);
+ return -1;
+ }
+
+ TFile *geofile=TFile::Open(fgeo);
+ TGeoManager *fgGeometry=NULL;
+
+ fgGeometry=(TGeoManager*)geofile->Get("ALICE");
+
+ if (!fgGeometry)
+ fgGeometry=(TGeoManager*)geofile->Get("Geometry");
+
+ if (!fgGeometry) {
+ AliCDBEntry *entry = (AliCDBEntry*)geofile->Get("AliCDBEntry");
+ if (entry)
+ fgGeometry = (TGeoManager*)entry->GetObject();
+ }
+
+ if (!fgGeometry) return -1;
+ AliGeomManager::SetGeometry(fgGeometry);
+ if(!AliGeomManager::GetGeometry()) return -1;
+
+
+ // open alignment file
+ if (gSystem->AccessPathName(fmis)) {
+ printf("couldn't open alignment file %s - skipping...\n",fmis);
+ return -2;
+ }
+ TFile *pref = TFile::Open(fmis);
+ if (!pref->IsOpen()) return -2;
+
+
+ /// apply alignment to ideal geometry
+ TClonesArray *prea=(TClonesArray*)pref->Get("ITSAlignObjs");
+ if (!prea) {
+ if (pref->Get("AliCDBEntry"))
+ prea = (TClonesArray*) ((AliCDBEntry*)pref->Get("AliCDBEntry"))->GetObject();
+ }
+ if (!prea) return -3;
+ Int_t nprea=prea->GetEntriesFast();
+ printf("Array of input misalignments with %d entries\n",nprea);
+ AliGeomManager::ApplyAlignObjsToGeom(*prea); // apply all levels of objs
+
+ AliTrackPointArray *tpain=NULL;
+ TFile *tpainfile=NULL;
+ TTree *treein=NULL;
+ AliTrackPoint point;
+ AliITSAlignMille2Module *m2[2200];
+ for (Int_t i=0; i<2198; i++)
+ m2[i]=new AliITSAlignMille2Module(AliITSAlignMille2Module::GetVolumeIDFromIndex(i));
+
+ // open input file
+ if (gSystem->AccessPathName(fin)) {
+ printf("couldn't open file %s - skipping...\n",fin);
+ return -4;
+ }
+ tpainfile = TFile::Open(fin);
+ if (!tpainfile->IsOpen()) return -4;
+
+ treein=(TTree*)tpainfile->Get("spTree");
+ if (!treein) return -5;
+ Float_t curv,curverr,runNumber;
+ TObjString *itsaligndata=0;
+ TObjString *itscalibrespsdd = 0;
+ treein->SetBranchAddress("SP", &tpain);
+ treein->SetBranchAddress("curv", &curv);
+ treein->SetBranchAddress("curverr", &curverr);
+ treein->SetBranchAddress("run",&runNumber);
+ treein->SetBranchAddress("ITSAlignData",&itsaligndata);
+ treein->SetBranchAddress("ITSCalibRespSDD",&itscalibrespsdd);
+
+ int ntrks=treein->GetEntries();
+ printf("Reading %d tracks from %s\n",ntrks,fin);
+
+
+ // open output file
+ TFile *pointsFile = TFile::Open(fout,"RECREATE");
+ if (!pointsFile || !pointsFile->IsOpen()) {
+ printf("Can't open output file %s !",fout);
+ return -6;
+ }
+ AliTrackPointArray *array = new AliTrackPointArray();
+
+ // new!
+ TTree *treeout=(TTree*)treein->Clone("spTree");
+ treeout->Reset();
+ treeout->SetBranchAddress("SP", &array);
+ treeout->SetBranchAddress("curv", &curv);
+ treeout->SetBranchAddress("curverr", &curverr);
+ treeout->SetBranchAddress("run",&runNumber);
+ treeout->SetBranchAddress("ITSAlignData",&itsaligndata);
+ treeout->SetBranchAddress("ITSCalibRespSDD",&itscalibrespsdd);
+
+ // tracks main loop
+ for (Int_t it=0; it<ntrks; it++) {
+ if (!(it%5000) ) printf("...processing track n. %d\n",it);
+
+ treein->GetEvent(it);
+
+ //////////////////////////////
+
+ AliTrackPointArray *atp=tpain;
+ AliTrackPointArray *atps=NULL;
+ Int_t npts=atp->GetNPoints();
+
+ AliTrackPoint p;
+ // check points in specific places
+
+ // build a new track
+ atps=new AliTrackPointArray(npts);
+
+ Int_t npto=0;
+ for (int i=0; i<npts; i++) {
+ atp->GetPoint(p,i);
+
+ UShort_t volid=atp->GetVolumeID()[i];
+ Int_t index=AliITSAlignMille2Module::GetIndexFromVolumeID(volid);
+
+
+ // dealign point
+ // get MODIFIED matrix
+ TGeoHMatrix *svMatrix = m2[index]->GetSensitiveVolumeMatrix(p.GetVolumeID());
+ //TGeoHMatrix *svOrigMatrix = mm->GetSensitiveVolumeOrigGlobalMatrix(p.GetVolumeID());
+
+ Double_t pg[3],pl[3];
+ pg[0]=p.GetX();
+ pg[1]=p.GetY();
+ pg[2]=p.GetZ();
+ if (prn) printf("Global coordinates of measured point : X=%f Y=%f Z=%f \n",pg[0],pg[1],pg[2]);
+ svMatrix->MasterToLocal(pg,pl);
+
+ // check that things went OK: local y should be 0.
+ if(TMath::Abs(pl[1])>1.e-6) {
+ printf("AliAlignmentDataFilterITS::WriteTrackPointsInIdealGeom: ERROR, local y = %f (should be zero)\n",pl[1]);
+ return -7;
+ }