]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFClusterFinderV1.cxx
free arrays before of return in PropagateBack
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinderV1.cxx
index e1250695c6dc0e8c37256628ee220fa9becaf477..607bfdc04f3d1fd14b981527a028214897cd4d0d 100644 (file)
@@ -44,6 +44,7 @@ Revision 0.01  2008/05/10 A. De Caro
 #include "AliDAQ.h"
 #include "AliLog.h"
 #include "AliRawReader.h"
+#include "AliLoader.h"
 #include "AliRunLoader.h"
 #include "AliGeomManager.h"
 
@@ -59,6 +60,10 @@ Revision 0.01  2008/05/10 A. De Caro
 #include "AliTOFReconstructor.h"
 #include "AliTOFRecoParam.h"
 
+using std::endl;
+using std::cout;
+using std::ofstream;
+using std::ios;
 ClassImp(AliTOFClusterFinderV1)
 
 //_____________________________________________________________________________
@@ -69,6 +74,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliTOFcalib *calib):
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
   fNumberOfTofDigits(0),
+  fNumberOfTofTrgPads(0),
   fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
   fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
   fVerbose(0),
@@ -110,6 +116,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(AliRunLoader* runLoader, AliTOFcali
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
   fNumberOfTofDigits(0),
+  fNumberOfTofTrgPads(0),
   fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
   fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
   fVerbose(0),
@@ -151,6 +158,7 @@ AliTOFClusterFinderV1::AliTOFClusterFinderV1(const AliTOFClusterFinderV1 &source
    fRecPoints(source.fRecPoints),
    fNumberOfTofClusters(0),
    fNumberOfTofDigits(0),
+   fNumberOfTofTrgPads(0),
    fkRecoParam(0),//AliTOFReconstructor::GetRecoParam()),
    fMaxDeltaTime(0),//fkRecoParam->GetMaxDeltaTime()),
    fVerbose(0),
@@ -187,6 +195,9 @@ AliTOFClusterFinderV1& AliTOFClusterFinderV1::operator=(const AliTOFClusterFinde
   for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
   fDigits=source.fDigits;
   fRecPoints=source.fRecPoints;
+  fNumberOfTofClusters=source.fNumberOfTofClusters;
+  fNumberOfTofTrgPads=source.fNumberOfTofTrgPads;
+  fNumberOfTofDigits=source.fNumberOfTofDigits;
   fVerbose=source.fVerbose;
   fDecoderVersion=source.fDecoderVersion;
   fTOFcalib=source.fTOFcalib;
@@ -247,6 +258,8 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   Int_t inholes = 0;
 
+  ResetRecpoint();
+
   fDigits->Clear();
   TClonesArray &aDigits = *fDigits;
 
@@ -343,7 +356,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(TTree* digitsTree, TTree* clusterTr
 
   AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
 
-  ResetRecpoint();
+//  ResetRecpoint();
 
   fTOFdigitMap->Clear();
 
@@ -366,6 +379,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
   TStopwatch stopwatch;
   stopwatch.Start();
 
+  ResetRecpoint();
 
   AliDebug(2, "TreeD re-creation");
   //TTree *digitsTree = new TTree();
@@ -384,7 +398,7 @@ void AliTOFClusterFinderV1::Digits2RecPoints(AliRawReader *rawReader, TTree *clu
 
   AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
 
-  ResetRecpoint();
+//  ResetRecpoint();
 
   fTOFdigitMap->Clear();
 
@@ -480,6 +494,18 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
       digit[2] = tofRawDatum->GetTOT();
       digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
 
+      // noferini
+      Float_t pos[3];
+      AliTOFGeometry::GetPosPar(detectorIndex, pos);
+      Float_t length = 0.;
+      for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic];
+      length = TMath::Sqrt(length);
+      Float_t timealligned = tdcCorr*24.4 - length * 0.0333564095198152043; // subtract the minimal time in
+      
+      if(status &&  timealligned > -1000 && timealligned < 24000){
+       fNumberOfTofTrgPads++;
+      }
+
       dummy = detectorIndex[3];
       detectorIndex[3] = detectorIndex[4];//padx
       detectorIndex[4] = dummy;//padz
@@ -498,6 +524,7 @@ void AliTOFClusterFinderV1::Raw2Digits(AliRawReader *rawReader, TTree* digitsTre
       last = fDigits->GetEntriesFast();
       new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
       if (status) fTOFdigitMap->AddDigit(detectorIndex, last);
+      
 
       if (fVerbose==2) {
        if (indexDDL<10) ftxt << "  " << indexDDL;
@@ -682,53 +709,54 @@ void AliTOFClusterFinderV1::FillRecPoint()
   UShort_t volIdClus;
 
   for (ii=0; ii<fNumberOfTofClusters; ii++) {
-
-    digitIndex = fTofClusters[ii]->GetIndex();
-    for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
+    AliTOFcluster* clOr = fTofClusters[ii];
+    fTofClusters[ii] = 0;
+    digitIndex = clOr->GetIndex();
+    for(jj=0; jj<5; jj++) detectorIndex[jj] = clOr->GetDetInd(jj);
     volIdClus = fTOFGeometry->GetAliSensVolIndex(detectorIndex[0],detectorIndex[1],detectorIndex[2]);
     //volIdClus = GetClusterVolIndex(detectorIndex);
-    for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj);
-    parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC
-    parTOF[1] = fTofClusters[ii]->GetToT(); // TOT
-    parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT
-    parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND
-    parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW
+    for(jj=0; jj<3; jj++) trackLabels[jj] = clOr->GetLabel(jj);
+    parTOF[0] = clOr->GetTDC(); // TDC
+    parTOF[1] = clOr->GetToT(); // TOT
+    parTOF[2] = clOr->GetADC(); // ADC=TOT
+    parTOF[3] = clOr->GetTDCND(); // TDCND
+    parTOF[4] = clOr->GetTDCRAW();//RAW
     parTOF[5] = 0;
     parTOF[6] = 0;
-    status = fTofClusters[ii]->GetStatus();
+    status = clOr->GetStatus();
 
-    posClus[0] = fTofClusters[ii]->GetX();
-    posClus[1] = fTofClusters[ii]->GetY();
-    posClus[2] = fTofClusters[ii]->GetZ();
+    posClus[0] = clOr->GetX();
+    posClus[1] = clOr->GetY();
+    posClus[2] = clOr->GetZ();
 
     //for (jj=0; jj<6; jj++) covClus[jj] = 0.;
-    //((AliCluster*)fTofClusters[ii])->GetGlobalCov(covClus);
+    //((AliCluster*)clOr)->GetGlobalCov(covClus);
 
     new(lRecPoints[ii]) AliTOFcluster(volIdClus, (Double_t)posClus[0], (Double_t)posClus[1], (Double_t)posClus[2],
-                                     (Double_t)(fTofClusters[ii]->GetSigmaX2()),
-                                     (Double_t)(fTofClusters[ii]->GetSigmaXY()),
-                                     (Double_t)(fTofClusters[ii]->GetSigmaXZ()),
-                                     (Double_t)(fTofClusters[ii]->GetSigmaY2()),
-                                     (Double_t)(fTofClusters[ii]->GetSigmaYZ()),
-                                     (Double_t)(fTofClusters[ii]->GetSigmaZ2()),
+                                     (Double_t)(clOr->GetSigmaX2()),
+                                     (Double_t)(clOr->GetSigmaXY()),
+                                     (Double_t)(clOr->GetSigmaXZ()),
+                                     (Double_t)(clOr->GetSigmaY2()),
+                                     (Double_t)(clOr->GetSigmaYZ()),
+                                     (Double_t)(clOr->GetSigmaZ2()),
                                      //(Double_t)covClus[0], (Double_t)covClus[1], (Double_t)covClus[2],
                                      //(Double_t)covClus[3], (Double_t)covClus[4], (Double_t)covClus[5],
                                      trackLabels, detectorIndex, parTOF, status, digitIndex);
 
     AliDebug(2, Form(" %4d  %4d  %f %f %f  %f %f %f %f %f %f  %3d %3d %3d  %2d %1d %2d %1d %2d  %4d %3d %3d %4d %4d  %1d  %4d", 
                     ii, volIdClus, posClus[0], posClus[1], posClus[2],
-                    fTofClusters[ii]->GetSigmaX2(),
-                    fTofClusters[ii]->GetSigmaXY(),
-                    fTofClusters[ii]->GetSigmaXZ(),
-                    fTofClusters[ii]->GetSigmaY2(),
-                    fTofClusters[ii]->GetSigmaYZ(),
-                    fTofClusters[ii]->GetSigmaZ2(),
+                    clOr->GetSigmaX2(),
+                    clOr->GetSigmaXY(),
+                    clOr->GetSigmaXZ(),
+                    clOr->GetSigmaY2(),
+                    clOr->GetSigmaYZ(),
+                    clOr->GetSigmaZ2(),
                     trackLabels[0], trackLabels[1], trackLabels[2],
                     detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
                     parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
                     status, digitIndex));
 
-
+    delete clOr;
   }
 
   for (Int_t iSector=0; iSector<AliTOFGeometry::NSectors(); iSector++)
@@ -3207,6 +3235,7 @@ void AliTOFClusterFinderV1::ResetRecpoint()
   //
 
   fNumberOfTofClusters = 0;
+  fNumberOfTofTrgPads = 0;
   if (fRecPoints) fRecPoints->Clear();
 
 }
@@ -3219,6 +3248,7 @@ void AliTOFClusterFinderV1::ResetDigits()
   //
 
   fNumberOfTofDigits = 0;
+  fNumberOfTofTrgPads = 0;
   if (fDigits) fDigits->Clear();
 
 }