Fixed Warnings in Reconstructioner and Prob
[u/mrichter/AliRoot.git] / TOF / AliTOFReconstructioner.cxx
index d1a5dda9bf9fa2becfaefaee3fdf35927ccb500e..466eef1a431cca8baa78895ba0fa5714adac967c 100644 (file)
 //////////////////////////////////////////////////////////////////////////////
 
 
-#include "TTask.h"
-#include "TBenchmark.h"
-#include "TTree.h"
-#include "TSystem.h"
-#include "TFile.h"
-#include "TParticle.h"
-
 #include "AliConst.h"
 #include "AliRun.h"
 #include "AliTOFConstants.h"
 #include "AliDetector.h"
 #include "AliMC.h"
 
-#include <TClonesArray.h>
-#include "../TGeant3/TGeant3.h"
-#include "TFile.h"
-#include <TF1.h>
-#include <TF2.h>
 #include "TTask.h"
+#include "TBenchmark.h"
 #include "TTree.h"
 #include "TSystem.h"
+#include "TFile.h"
+#include "TParticle.h"
+#include <TClonesArray.h>
+#include "TGeant3.h"
+#include "TVirtualMC.h"
+#include <TF1.h>
+#include <TF2.h>
 #include "TROOT.h"
 #include "TFolder.h"
 #include "TNtuple.h"
@@ -86,7 +82,6 @@ ClassImp(AliTOFReconstructioner)
 {
   // default ctor
   fNevents = 0 ; 
-  fg3      = 0;
   foutputfile  = 0; 
   foutputntuple= 0;
   fZnoise  = 0;
@@ -100,7 +95,6 @@ ClassImp(AliTOFReconstructioner)
   // ctor
   //
   fNevents = 0 ;     // Number of events to reconstruct, 0 means all evens in current file
-  fg3      = 0;
   foutputfile  = 0; 
   foutputntuple= 0;
   fZnoise  = 0;
@@ -122,9 +116,6 @@ ClassImp(AliTOFReconstructioner)
   gAlice->Init();
   gAlice->Print(); 
 
-  // set the fg3 pointer to geometry used by IsInsideThePad method
-  fg3 = (TGeant3*) gMC;         
-
   CreateNTuple();  
 
   // add Task to //root/Tasks folder
@@ -221,11 +212,7 @@ void AliTOFReconstructioner::Init(Option_t* opt)
   //
   // dtor
   //
-  if (fg3)
-    {
-      delete fg3;
-      fg3 = 0;
-    }
+
   if (foutputfile)
     {
       delete foutputfile;
@@ -385,7 +372,7 @@ void AliTOFReconstructioner::Exec(const char* datafile, Option_t *option)
       } 
     }
 
-    Float_t * toftime = new Float_t toftime[fMaxAllTracks]; 
+    Float_t * toftime = new Float_t[fMaxAllTracks]; 
     InitArray(toftime, fMaxAllTracks);
     AliTOFPad* pixelArray = new AliTOFPad[fMaxPixels];
     Int_t* iTOFpixel        = new Int_t[fMaxAllTracks];
@@ -591,7 +578,7 @@ void AliTOFReconstructioner::PrintParameters()const
 }
 
 //__________________________________________________________________
-void AliTOFReconstructioner::IsInsideThePad(TGeant3 *g3, Float_t x, Float_t y, Float_t z, Int_t *nGeom, Float_t& zPad, Float_t& xPad) 
+void AliTOFReconstructioner::IsInsideThePad(TVirtualMC *vmc, Float_t x, Float_t y, Float_t z, Int_t *nGeom, Float_t& zPad, Float_t& xPad) 
 {
   //   input: x,y,z - coordinates of a hit
   //   output: array  nGeom[]
@@ -632,6 +619,8 @@ void AliTOFReconstructioner::IsInsideThePad(TGeant3 *g3, Float_t x, Float_t y, F
   xTOF[1]=y;
   xTOF[2]=z;
   
+  TGeant3 * g3 = (TGeant3*) vmc;
+
   g3->Gmedia(xTOF, numed);
   gcvolu=g3->Gcvolu();
   nLevel=gcvolu->nlevel;
@@ -1512,18 +1501,24 @@ Bool_t AliTOFReconstructioner::operator==( AliTOFReconstructioner const & tofrec
   // split the member variables in analogous categories
   
   // time resolution and edge effect parameters
-  Bool_t dummy0=(fTimeResolution==tofrec.fTimeResolution)&&(fpadefficiency==tofrec.fpadefficiency)&&(fEdgeEffect==tofrec.fEdgeEffect)&&(fEdgeTails==tofrec.fEdgeTails)&&(fHparameter==tofrec.fHparameter)&&(fH2parameter==tofrec.fH2parameter)&&(fKparameter==tofrec.fKparameter)&&(fK2parameter==tofrec.fK2parameter);
+  Bool_t dummy0=(fTimeResolution==tofrec.fTimeResolution)&&(fpadefficiency==tofrec.fpadefficiency)&&(fEdgeEffect==tofrec.fEdgeEffect)&&(fEdgeTails==tofrec.fEdgeTails)&&(fHparameter==tofrec.fHparameter)&&(fH2parameter==tofrec.fH2parameter)&&(fKparameter==t
+ofrec.fKparameter)&&(fK2parameter==tofrec.fK2parameter);
   
   // pad efficiency parameters
-  Bool_t dummy1=(fEffCenter==tofrec.fEffCenter)&&(fEffBoundary==tofrec.fEffBoundary)&&(fEff2Boundary==tofrec.fEff2Boundary)&&(fEff3Boundary==tofrec.fEff3Boundary)&&(fResCenter==tofrec.fResCenter)&&(fResBoundary==tofrec.fResBoundary)&&(fResSlope==tofrec.fResSlope);
+  Bool_t dummy1=(fEffCenter==tofrec.fEffCenter)&&(fEffBoundary==tofrec.fEffBoundary)&&(fEff2Boundary==tofrec.fEff2Boundary)&&(fEff3Boundary==tofrec.fEff3Boundary)&&(fResCenter==tofrec.fResCenter)&&(fResBoundary==tofrec.fResBoundary)&&(fResSlope==tofrec.fR
+esSlope);
 
   // time walk parameters
-  Bool_t dummy2=(fTimeWalkCenter==tofrec.fTimeWalkCenter)&&(fTimeWalkBoundary==tofrec.fTimeWalkBoundary)&&(fTimeWalkSlope==tofrec.fTimeWalkSlope)&&(fTimeDelayFlag==tofrec.fTimeDelayFlag)&&(fPulseHeightSlope==tofrec.fPulseHeightSlope)&&(fTimeDelaySlope==tofrec.fTimeDelaySlope);
+  Bool_t dummy2=(fTimeWalkCenter==tofrec.fTimeWalkCenter)&&(fTimeWalkBoundary==tofrec.fTimeWalkBoundary)&&(fTimeWalkSlope==tofrec.fTimeWalkSlope)&&(fTimeDelayFlag==tofrec.fTimeDelayFlag)&&(fPulseHeightSlope==tofrec.fPulseHeightSlope)&&(fTimeDelaySlope==to
+frec.fTimeDelaySlope);
 
   // ADC-TDC correlation parameters
-  Bool_t dummy3=(fMinimumCharge==tofrec.fMinimumCharge)&&(fChargeSmearing==tofrec.fChargeSmearing )&&(fLogChargeSmearing==tofrec.fLogChargeSmearing )&&(fTimeSmearing==tofrec.fTimeSmearing )&&(fAverageTimeFlag==tofrec.fAverageTimeFlag)&&(fChargeFactorForMatching==tofrec.fChargeFactorForMatching)&&(fMatchingStyle==tofrec.fMatchingStyle);
+  Bool_t dummy3=(fMinimumCharge==tofrec.fMinimumCharge)&&(fChargeSmearing==tofrec.fChargeSmearing )&&(fLogChargeSmearing==tofrec.fLogChargeSmearing )&&(fTimeSmearing==tofrec.fTimeSmearing )&&(fAverageTimeFlag==tofrec.fAverageTimeFlag)&&(fChargeFactorForMa
+tching==tofrec.fChargeFactorForMatching)&&(fMatchingStyle==tofrec.fMatchingStyle);
   
-  Bool_t dummy4=(fTrackingEfficiency==tofrec.fTrackingEfficiency)&&(fSigmavsp==tofrec.fSigmavsp)&&(fSigmaZ==tofrec.fSigmaZ)&&(fSigmarphi==tofrec.fSigmarphi)&&(fSigmap==tofrec.fSigmap)&&(fSigmaPhi==tofrec.fSigmaPhi)&&(fSigmaTheta==tofrec.fSigmaTheta)&&(fNoise==tofrec.fNoise)&&(fNoiseSlope==tofrec.fNoiseSlope)&&(fField==tofrec.fField)&&(fRadLenTPC==tofrec.fRadLenTPC)&&(fCorrectionTRD==tofrec.fCorrectionTRD)&&(fLastTPCRow==tofrec.fLastTPCRow)&&(fRadiusvtxBound==tofrec.fRadiusvtxBound)&&(fMaxTestTracks==tofrec.fMaxTestTracks)&&(fStep==tofrec.fStep)&&(fMaxPixels==tofrec.fMaxPixels)&&(fMaxAllTracks==tofrec.fMaxAllTracks)&&(fMaxTracks==tofrec.fMaxTracks)&&(fMaxTOFHits==tofrec.fMaxTOFHits)&&(fPBound==tofrec.fPBound);
+  Bool_t dummy4=(fTrackingEfficiency==tofrec.fTrackingEfficiency)&&(fSigmavsp==tofrec.fSigmavsp)&&(fSigmaZ==tofrec.fSigmaZ)&&(fSigmarphi==tofrec.fSigmarphi)&&(fSigmap==tofrec.fSigmap)&&(fSigmaPhi==tofrec.fSigmaPhi)&&(fSigmaTheta==tofrec.fSigmaTheta)&&(fNo
+ise==tofrec.fNoise)&&(fNoiseSlope==tofrec.fNoiseSlope)&&(fField==tofrec.fField)&&(fRadLenTPC==tofrec.fRadLenTPC)&&(fCorrectionTRD==tofrec.fCorrectionTRD)&&(fLastTPCRow==tofrec.fLastTPCRow)&&(fRadiusvtxBound==tofrec.fRadiusvtxBound)&&(fMaxTestTracks==tofre
+c.fMaxTestTracks)&&(fStep==tofrec.fStep)&&(fMaxPixels==tofrec.fMaxPixels)&&(fMaxAllTracks==tofrec.fMaxAllTracks)&&(fMaxTracks==tofrec.fMaxTracks)&&(fMaxTOFHits==tofrec.fMaxTOFHits)&&(fPBound==tofrec.fPBound);
 
   if( dummy0 && dummy1 && dummy2 && dummy3 && dummy4)
     return kTRUE ;
@@ -1563,7 +1558,8 @@ void AliTOFReconstructioner::InitArray(Int_t array[], Int_t nlocations)
 
 
 //____________________________________________________________________________
-void AliTOFReconstructioner::ReadTOFHits(Int_t ntracks, TTree* treehits, TClonesArray* tofhits, Int_t ***MapPixels, Int_t* kTOFhitFirst, AliTOFPad* pixelArray , Int_t* iTOFpixel, Float_t* toftime, AliTOFRecHit* hitArray, Int_t& isHitOnFiredPad, Int_t& ipixel)
+void AliTOFReconstructioner::ReadTOFHits(Int_t ntracks, TTree* treehits, TClonesArray* tofhits, Int_t ***MapPixels, Int_t* kTOFhitFirst, AliTOFPad* pixelArray , Int_t* iTOFpixel, Float_t* toftime, AliTOFRecHit* hitArray, Int_t& isHitOnFiredPad, Int_t& ipi
+xel)
 {
   //
   // Read TOF hits for the current event and fill arrays
@@ -1655,15 +1651,18 @@ void AliTOFReconstructioner::ReadTOFHits(Int_t ntracks, TTree* treehits, TClones
        Float_t x = tofHit->X(); tofpos[0]=x;
        Float_t y = tofHit->Y(); tofpos[1]=y;
        Float_t z = tofHit->Z(); tofpos[2]=z;
-       
+       /* var used for QA
        Float_t tofradius = TMath::Sqrt(x*x+y*y); // radius cilindrical coordinate of the TOF hit
+       */
        // momentum components (cosine) when striking the TOF
        Float_t pxtof = tofHit->GetPx();
        Float_t pytof = tofHit->GetPy();
        Float_t pztof = tofHit->GetPz();
        // scalar product indicating the direction of the particle when striking the TOF 
+       /* var used for QA
        // (>0 for outgoing particles)
        Float_t isGoingOut = (x*pxtof+y*pytof+z*pztof)/TMath::Sqrt(x*x+y*y+z*z);
+       */
        Float_t momtof = tofHit->GetMom();
        // now momentum components when striking the TOF
        pxtof *= momtof;
@@ -1723,7 +1722,7 @@ void AliTOFReconstructioner::ReadTOFHits(Int_t ntracks, TTree* treehits, TClones
          }
        } //end if(ipart!=ipartLast)
 
-       IsInsideThePad(fg3,x,y,z,npixel,zPad,xPad);
+       IsInsideThePad(gMC,x,y,z,npixel,zPad,xPad);
 
        Int_t sec  = tofHit->GetSector();
        Int_t pla  = tofHit->GetPlate();
@@ -1741,7 +1740,7 @@ void AliTOFReconstructioner::ReadTOFHits(Int_t ntracks, TTree* treehits, TClones
        
        
        if (npixel[4]==0){
-         IsInsideThePad(fg3,x,y,z,npixel,zPad,xPad);
+         IsInsideThePad(gMC,x,y,z,npixel,zPad,xPad);
          if (npixel[4]==0){          
            nHitOutofTofVolumes++;
          }
@@ -1954,7 +1953,7 @@ void AliTOFReconstructioner::AddNoiseFromOuter(Option_t *option, Int_t ***MapPix
        }
       }
 
-      istrip=(Int_t)(zNoise-zLen[iplate-1])/((zLen[iplate]-zLen[iplate-1])/zStrips[iplate-1]); //the strip number in the plate
+      istrip=(Int_t)((zNoise-zLen[iplate-1])/((zLen[iplate]-zLen[iplate-1])/zStrips[iplate-1])); //the strip number in the plate
       istrip++;
 
       ipadAlongX = (Int_t)(AliTOFConstants::fgkNpadX*gRandom->Rndm())+1;
@@ -2349,27 +2348,33 @@ void AliTOFReconstructioner::Matching(AliTOFTrack* trackArray, AliTOFRecHit* hit
     Float_t x=trackArray[itrack-1].GetRxTPC();
     Float_t y=trackArray[itrack-1].GetRyTPC();
     Float_t z=trackArray[itrack-1].GetRzTPC();
+    /* vars used for QA
     Float_t RxTPC=x;
     Float_t RyTPC=y;
     Float_t RzTPC=z;
+    */
     Float_t Wx=x;
     Float_t Wy=y;
     Float_t Wz=z;
     Float_t px=trackArray[itrack-1].GetPxTPC();
     Float_t py=trackArray[itrack-1].GetPyTPC();
     Float_t pz=trackArray[itrack-1].GetPzTPC();
+    /* vars used for QA
     Float_t pxTPC=px;
     Float_t pyTPC=py;
     Float_t pzTPC=pz;
-
+    */
     Float_t p = TMath::Sqrt(px*px+py*py+pz*pz);
+    /* var used for QA
     Float_t pTPC=p;
-
+    */
     Float_t rho = TMath::Sqrt(x*x+y*y);
     Float_t phi=0.;
     if(TMath::Abs(x)>0. || TMath::Abs(y)>0.) phi=TMath::ATan2(y,x);
     if(phi<0.) phi=phi+2.*TMath::Pi();
+    /* var used for QA
     Float_t phiTPC=phi*kRaddeg;
+    */
     if(fSigmavsp) {
       if(p==0) printf(" p=%f in g=0.022/p\n",p);
       g=0.022/p;
@@ -2382,7 +2387,9 @@ void AliTOFReconstructioner::Matching(AliTOFTrack* trackArray, AliTOFRecHit* hit
     }
     x=rho*TMath::Cos(phi);
     y=rho*TMath::Sin(phi);
+    /* var used for QA
     Float_t zTPC=z;
+    */
     if(fSigmavsp) {
       if(p==0) printf(" p=%f in g=0.0275/p\n",p);
       g=0.0275/p;
@@ -2580,7 +2587,7 @@ void AliTOFReconstructioner::Matching(AliTOFTrack* trackArray, AliTOFRecHit* hit
        gz=zHelixCenter+s*sinlam;
        rho=TMath::Sqrt(gx*gx+gy*gy);
        
-       IsInsideThePad(fg3,gx,gy,gz,npixel,zPad,xPad);
+       IsInsideThePad(gMC,gx,gy,gz,npixel,zPad,xPad);
        
        iplate += npixel[1];
        iPadAlongX += npixel[4];
@@ -2712,7 +2719,7 @@ void AliTOFReconstructioner::Matching(AliTOFTrack* trackArray, AliTOFRecHit* hit
          testZ[itest-1]=wZ;
          testWeight[itest-1]=weight;
        } else {
-         Int_t k;
+         Int_t k=0;
          for(Int_t i=0;i<itest;i++) {
            k=0;
            if(testPixel[i]==wPixel) {
@@ -2944,11 +2951,14 @@ void AliTOFReconstructioner::Matching(AliTOFTrack* trackArray, AliTOFRecHit* hit
       if(iTOFpixel[ipart] && match!=3) {
        particle = (TParticle*)gAlice->Particle(ipart);  //for V3.05
 
-       printf("          ipixel=%i (Sector=%i, Plate=%i, Strip=%i, Pixel=%i), fired by %i track\n",iTOFpixel[ipart],pixelArray[iTOFpixel[ipart]-1].GetSector(),pixelArray[iTOFpixel[ipart]-1].GetPlate(),pixelArray[iTOFpixel[ipart]-1].GetStrip(),pixelArray[iTOFpixel[ipart]-1].GetPixel(),pixelArray[iTOFpixel[ipart]-1].GetTrack());   
-       printf("     indexOfTestTrack=%i itest=%i weightTestTracksOutTof[4]=%f weightTestTracksOutTof[2]=%f weightTestTracksOutTof[1]=%f weightTestTracksOutTof[0]=%f\n",indexOfTestTrack,itest,weightTestTracksOutTof[3],weightTestTracksOutTof[2],weightTestTracksOutTof[1],weightTestTracksOutTof[0]);
+       printf("          ipixel=%i (Sector=%i, Plate=%i, Strip=%i, Pixel=%i), fired by %i track\n",iTOFpixel[ipart],pixelArray[iTOFpixel[ipart]-1].GetSector(),pixelArray[iTOFpixel[ipart]-1].GetPlate(),pixelArray[iTOFpixel[ipart]-1].GetStrip(),pixelArray[iTOFpix
+el[ipart]-1].GetPixel(),pixelArray[iTOFpixel[ipart]-1].GetTrack());   
+       printf("     indexOfTestTrack=%i itest=%i weightTestTracksOutTof[4]=%f weightTestTracksOutTof[2]=%f weightTestTracksOutTof[1]=%f weightTestTracksOutTof[0]=%f\n",indexOfTestTrack,itest,weightTestTracksOutTof[3],weightTestTracksOutTof[2],weightTestTracksOu
+tTof[1],weightTestTracksOutTof[0]);
        if(itest) {
 
-         printf("     take ipixel=%i (Sector=%i, Plate=%i, Strip=%i, Pixel=%i), (fired by %i track), match=%i\n",wPixel,pixelArray[wPixel-1].GetSector(),pixelArray[wPixel-1].GetPlate(),pixelArray[wPixel-1].GetStrip(),pixelArray[wPixel-1].GetPixel(),pixelArray[wPixel-1].GetTrack(),match);   
+         printf("     take ipixel=%i (Sector=%i, Plate=%i, Strip=%i, Pixel=%i), (fired by %i track), match=%i\n",wPixel,pixelArray[wPixel-1].GetSector(),pixelArray[wPixel-1].GetPlate(),pixelArray[wPixel-1].GetStrip(),pixelArray[wPixel-1].GetPixel(),pixelArray[w
+Pixel-1].GetTrack(),match);   
        }
       }
     }