]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/TPCcalib/AliTPCSelectorTracks.cxx
Adding the
[u/mrichter/AliRoot.git] / TPC / TPCcalib / AliTPCSelectorTracks.cxx
index bd003db5588d75d12fe380dcc981dbddaf98f7c7..5a6f37cd59424e5cb3519e86085fbe7f3db680cf 100644 (file)
@@ -85,22 +85,42 @@ void AliTPCSelectorTracks::InitComponent(){
   // they have to be added in the following manner:
   //    chain->GetUserInfo()->AddLast(clusterParam);
   //    chain->GetUserInfo()->AddLast(cuts);
-  //
+  // 
+  static Int_t counter=0;
   if (!fChain){
-    printf("EROOR - chain not initialized\n");
+    Error("InitComponent","EROOR - chain not initialized\n");
   }
- AliTPCClusterParam *clusterParam  = (AliTPCClusterParam*)fChain->GetUserInfo()->FindObject("AliTPCClusterParam");
-  if (clusterParam != 0) printf("clusterParam found in fChain! \n");
+  Info("InitComponent",Form("Selector initialization No\t%d\n", counter));
+  counter++;
+  //
+  
+
+  AliTPCClusterParam *clusterParam  = (AliTPCClusterParam*)fChain->GetUserInfo()->FindObject("AliTPCClusterParam");
+  //
+  if (clusterParam == 0) Error("InitComponent","CLUSTER PARAM NOT FOUND IN CHAIN! \n");
+  //
   AliTPCcalibTracksCuts *cuts = (AliTPCcalibTracksCuts*)fChain->GetUserInfo()->FindObject("calibTracksCuts");
-  if (cuts != 0) printf("cuts found in fChain! \n");
-  Int_t debugLevel=1;
-  if (gProof) debugLevel = gProof->GetLogLevel();
-    fCalibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts,1);
-   fOutput->AddLast(fCalibTracks);
+  if (cuts != 0) Info("InitComponent","cuts found in fChain! \n");
+  else{
+    Error("InitComponent","CUTS NOT FOUND IN CHAIN\n");
+  }
+  if (clusterParam==0 && fInput){
+    clusterParam = (AliTPCClusterParam*)fInput->FindObject("AliTPCClusterParam");
+    Error("InitComponent","CLUSTER PARAM NOT FOUND IN PROOF\n");
+  }
+  if (cuts==0 &&fInput ){    
+    cuts = (AliTPCcalibTracksCuts*)fInput->FindObject("calibTracksCuts");
+    Error("InitComponent","CUTS NOT FOUND IN PROOF\n");
+  }
+  if (!cuts || !clusterParam) {
+    if (fInput) fInput->Print();
+    return;
+  }
+  fCalibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
+  fOutput->AddLast(fCalibTracks);
    
-   //fCalibTracksGain = new AliTPCcalibTracksGain("calibTracksGain", "Gain calibration object for tracks");
-   //fOutput->AddLast(fCalibTracksGain);
+  fCalibTracksGain = new AliTPCcalibTracksGain("calibTracksGain", "Gain calibration object for tracks", cuts);
+   fOutput->AddLast(fCalibTracksGain);
    fInit=kTRUE;
 }
 
@@ -116,12 +136,26 @@ void AliTPCSelectorTracks::SlaveBegin(TTree * tree)
 }
 
 
+void AliTPCSelectorTracks::SlaveTerminate()
+{
+   // The SlaveTerminate() function is called after all entries or objects
+   // have been processed. When running with PROOF SlaveTerminate() is called
+   // on each slave server.
+  printf ("SlaveTerminate.. \n");
+  printf ("Terminate CalibTrackGain.. \n");
+  if (fCalibTracksGain) fCalibTracksGain->Terminate();
+}
+
+
+
+
 Int_t AliTPCSelectorTracks::ProcessIn(Long64_t entry)
 {
   //
   //
   //
   if (!fInit) InitComponent();
+  if (!fInit) return 0;
   Int_t status = ReadEvent(entry);
   if (status<0) return status; 
   Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();     
@@ -147,8 +181,7 @@ Int_t AliTPCSelectorTracks::ProcessIn(Long64_t entry)
       fNClusters->Fill(seed->GetNumberOfClusters());
       //
       fCalibTracks->Process(seed, esdTrack);   // analysis is done in fCalibTracks
-      //if (!AliTPCcalibTracksGain::AcceptTrack(seed)) {/*cerr << "not accepted" << endl;*/ continue; }
-      //fCalibTracksGain->AddTrack(seed);
+      fCalibTracksGain->Process(seed);
     }
   }
   CleanESD();
@@ -173,16 +206,18 @@ void AliTPCSelectorTracks::Terminate()
 //          for (UInt_t iFitType = 0; iFitType < 3; iFitType++)
 //             fCalibTracksGain->Evaluate(iSegment, iPadType, iFitType);
 //       }
-//    }   
+//    }    
    TFile file(fgkOutputFileName, "recreate");
+   fCalibTracksGain  = (AliTPCcalibTracksGain*)fOutput->FindObject("calibTracksGain");
+   if (fCalibTracksGain) fCalibTracksGain->Evaluate();
    fOutput->Write();
    file.Close();
    printf("Successfully written file to '%s'.", fgkOutputFileName);
-
 
    Info("Destructor","Destuctor");
    //delete fCalibTracksGain;
-   delete fCalibTracks;
+   //delete fCalibTracks;
 //   printf ("Terminate... \n");
 //   if (!fOutput) return;
 //   TFile file("Output.root","recreate");