+//______________________________________________________________________
+void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
+ // Calculates the array of ladders on layer 2 to be used with a
+ // given ladder on layer 1
+ if(ladwid == fLadOnLay2 && fLadders)return;
+ fLadOnLay2=ladwid;
+ Int_t ladtot1=AliITSgeomTGeo::GetNLadders(1);
+ if(fLadders) delete [] fLadders;
+ fLadders=new UShort_t[ladtot1];
+
+
+ Double_t pos1[3],pos2[3];
+ Int_t mod1=AliITSgeomTGeo::GetModuleIndex(2,1,1);
+ AliITSgeomTGeo::GetTranslation(mod1,pos1); // position of the module in the MRS
+ Double_t phi0=TMath::ATan2(pos1[1],pos1[0]);
+ if(phi0<0) phi0+=2*TMath::Pi();
+ Int_t mod2=AliITSgeomTGeo::GetModuleIndex(2,2,1);
+ AliITSgeomTGeo::GetTranslation(mod2,pos2);
+ Double_t phi2=TMath::ATan2(pos2[1],pos2[0]);
+ if(phi2<0) phi2+=2*TMath::Pi();
+ Double_t deltaPhi= phi0-phi2; // phi width of a layer2 module
+
+ for(Int_t i= 0; i<ladtot1;i++){
+ Int_t modlad= AliITSgeomTGeo::GetModuleIndex(1,i+1,1);
+ Double_t posmod[3];
+ AliITSgeomTGeo::GetTranslation(modlad,posmod);
+ Double_t phimod=TMath::ATan2(posmod[1],posmod[0]);
+ if(phimod<0) phimod+=2*TMath::Pi();
+ Double_t phi1= phimod+deltaPhi*double(fLadOnLay2);
+ if(phi1<0) phi1+=2*TMath::Pi();
+ if(phi1>2*TMath::Pi()) phi1-=2*TMath::Pi();
+ Double_t philad1=phi0-phi1;
+ UShort_t lad1;
+ Double_t ladder1=(philad1)/(deltaPhi) +1.;
+ if(ladder1<1){ladder1=40+ladder1;}
+ lad1=int(ladder1+0.5);
+ fLadders[i]=lad1;
+ }
+}
+
+
+//______________________________________________________________________
+void AliITSVertexer::Init(TString filename){
+ // Initialize the vertexer in case of
+ // analysis of an entire file
+ AliRunLoader *rl = AliRunLoader::Instance();
+ if(!rl){
+ AliFatal("Run Loader not found");
+ return;
+ }
+ if (fLastEvent < 0) SetLastEvent(rl->GetNumberOfEvents()-1);
+
+ AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
+ if(!filename.Contains("default"))itsloader->SetVerticesFileName(filename);
+ if(!filename.Contains("null"))itsloader->LoadVertices("recreate");
+}
+