+//____________________________________________________________________________
+Int_t AliITSTrackleterSPDEff::Clusters2Tracks(AliESDEvent *esd){
+// This method is used to find the tracklets.
+// It is called from AliReconstruction
+// The vertex is supposed to be associated to the Tracker (i.e. to this) already
+// The cluster is supposed to be associated to the Tracker already
+// In case Monte Carlo is required, the appropriate linking to Stack and TrackRef is attempted
+//
+ Int_t rc=1;
+ // apply cuts on the vertex quality
+ const AliESDVertex *vertex = esd->GetVertex();
+ if(vertex->GetNContributors()<fMinContVtx) return 0;
+ //
+ AliRunLoader* runLoader = AliRunLoader::Instance();
+ if (!runLoader) {
+ Error("Clusters2Tracks", "no run loader found");
+ return rc;
+ }
+ AliStack *pStack=0x0; TTree *tRefTree=0x0;
+ if(GetMC()) {
+ runLoader->LoadKinematics("read");
+ runLoader->LoadTrackRefs("read");
+ pStack= runLoader->Stack();
+ tRefTree= runLoader->TreeTR();
+ }
+ Reconstruct(pStack,tRefTree);
+
+ if (GetLightBkgStudyInParallel()) {
+ AliStack *dummy1=0x0; TTree *dummy2=0x0;
+ ReflectClusterAroundZAxisForLayer(1);
+ Reconstruct(dummy1,dummy2,kTRUE);
+ }
+ return 0;
+}
+//____________________________________________________________________________
+Int_t AliITSTrackleterSPDEff::PostProcess(AliESDEvent *){
+//
+// It is called from AliReconstruction
+//
+//
+//
+//
+ Int_t rc=0;
+ if(GetMC()) SavePredictionMC("TrackletsMCpred.root");
+ if(GetHistOn()) rc=(Int_t)WriteHistosToFile();
+ if(GetLightBkgStudyInParallel()) {
+ TString name="AliITSPlaneEffSPDtrackletBkg.root";
+ TFile* pefile = TFile::Open(name, "RECREATE");
+ rc*=fPlaneEffBkg->Write();
+ pefile->Close();
+ }
+ return rc;
+}
+//____________________________________________________________________
+void
+AliITSTrackleterSPDEff::LoadClusterArrays(TTree* itsClusterTree) {
+ // This method
+ // - gets the clusters from the cluster tree
+ // - convert them into global coordinates
+ // - store them in the internal arrays
+ // - count the number of cluster-fired chips
+
+ //AliDebug(1,"Loading clusters and cluster-fired chips ...");
+
+ fNClustersLay1 = 0;
+ fNClustersLay2 = 0;
+
+ TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
+ TBranch* itsClusterBranch=itsClusterTree->GetBranch("ITSRecPoints");
+
+ itsClusterBranch->SetAddress(&itsClusters);
+
+ Int_t nItsSubs = (Int_t)itsClusterTree->GetEntries();
+ Float_t cluGlo[3]={0.,0.,0.};
+
+ // loop over the its subdetectors
+ for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
+
+ if (!itsClusterTree->GetEvent(iIts))
+ continue;
+
+ Int_t nClusters = itsClusters->GetEntriesFast();
+
+ // number of clusters in each chip of the current module
+ Int_t layer = 0;
+
+ // loop over clusters
+ while(nClusters--) {
+ AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
+
+ layer = cluster->GetLayer();
+ if (layer>1) continue;
+
+ cluster->GetGlobalXYZ(cluGlo);
+ Float_t x = cluGlo[0];
+ Float_t y = cluGlo[1];
+ Float_t z = cluGlo[2];
+
+ if (layer==0) {
+ fClustersLay1[fNClustersLay1][0] = x;
+ fClustersLay1[fNClustersLay1][1] = y;
+ fClustersLay1[fNClustersLay1][2] = z;
+
+ for (Int_t i=0; i<3; i++)
+ fClustersLay1[fNClustersLay1][3+i] = cluster->GetLabel(i);
+ fNClustersLay1++;
+ if(fHistOn) {
+ Int_t det=cluster->GetDetectorIndex();
+ if(det<0 || det>79) {AliError("Cluster with det. index out of boundaries"); return;}
+ fhClustersInModuleLay1[det]->Fill((Double_t)cluster->GetDetLocalZ(),(Double_t)cluster->GetDetLocalX());
+ }
+ }
+ if (layer==1) {
+ fClustersLay2[fNClustersLay2][0] = x;
+ fClustersLay2[fNClustersLay2][1] = y;
+ fClustersLay2[fNClustersLay2][2] = z;
+
+ for (Int_t i=0; i<3; i++)
+ fClustersLay2[fNClustersLay2][3+i] = cluster->GetLabel(i);
+ fNClustersLay2++;
+ if(fHistOn) {
+ Int_t det=cluster->GetDetectorIndex();
+ if(det<0 || det>159) {AliError("Cluster with det. index out of boundaries"); return;}
+ fhClustersInModuleLay2[det]->Fill((Double_t)cluster->GetDetLocalZ(),(Double_t)cluster->GetDetLocalX());
+ }
+ }
+
+ }// end of cluster loop
+
+ } // end of its "subdetector" loop
+ if (itsClusters) {
+ itsClusters->Delete();
+ delete itsClusters;
+ itsClusters = 0;
+ }
+ AliDebug(1,Form("(clusters in layer 1 : %d, layer 2: %d)",fNClustersLay1,fNClustersLay2));
+}
+//_________________________________________________________________________
+void
+AliITSTrackleterSPDEff::SetLightBkgStudyInParallel(Bool_t b) {
+// This method:
+// - set Bool_t fLightBackgroundStudyInParallel = b
+// a) if you set this kTRUE, then the estimation of the
+// SPD efficiency is done as usual for data, but in
+// parallel a light (i.e. without control histograms, etc.)
+// evaluation of combinatorial background is performed
+// with the usual ReflectClusterAroundZAxisForLayer method.
+// b) if you set this kFALSE, then you would not have a second
+// container for PlaneEfficiency statistics to be used for background
+// (fPlaneEffBkg=0). If you want to have a full evaluation of the
+// background (with all control histograms and additional data
+// members referring to the background) then you have to call the
+// method SetReflectClusterAroundZAxisForLayer(kTRUE) esplicitily
+ fLightBkgStudyInParallel=b;
+ if(fLightBkgStudyInParallel) {
+ if(!fPlaneEffBkg) fPlaneEffBkg = new AliITSPlaneEffSPD();
+ }
+ else {
+ delete fPlaneEffBkg;
+ fPlaneEffBkg=0;
+ }
+}
+