]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFClusterFinder.cxx
Fixing 2 warnings
[u/mrichter/AliRoot.git] / TOF / AliTOFClusterFinder.cxx
index 5878b302481492e17f572bab84c8e46873e2277b..3cd99b50ecde72cc9da4957d0726919bb053e308 100644 (file)
@@ -136,6 +136,10 @@ Revision 0.01  2005/07/25 A. De Caro
 
 //extern TFile *gFile;
 
+using std::cout;
+using std::endl;
+using std::ofstream;
+using std::ios;
 ClassImp(AliTOFClusterFinder)
 
 AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib):
@@ -147,6 +151,7 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib):
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
+  fNumberOfTofTrgPads(0),
   fVerbose(0),
   fDecoderVersion(0),
   fTOFcalib(calib),
@@ -178,6 +183,7 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *c
   fDigits(new TClonesArray("AliTOFdigit", 4000)),
   fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
   fNumberOfTofClusters(0),
+  fNumberOfTofTrgPads(0),
   fVerbose(0),
   fDecoderVersion(0),
   fTOFcalib(calib),
@@ -208,6 +214,7 @@ AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) :
   fDigits(source.fDigits),
   fRecPoints(source.fRecPoints),
   fNumberOfTofClusters(0),
+  fNumberOfTofTrgPads(0),
   fVerbose(0),
   fDecoderVersion(source.fDecoderVersion),
   fTOFcalib(source.fTOFcalib),
@@ -261,12 +268,17 @@ AliTOFClusterFinder::~AliTOFClusterFinder()
       fRecPoints=0;
     }
 
-  if (fTofClusters || fNumberOfTofClusters) {
-    for (Int_t ii=0; ii<fNumberOfTofClusters; ii++)
+  //if (fTofClusters || fNumberOfTofClusters) {
+  if (fNumberOfTofClusters) {
+    for (Int_t ii=0; ii<kTofMaxCluster; ii++) {
       if (fTofClusters[ii]) fTofClusters[ii]->Delete();
+      delete fTofClusters[ii];
+    }
     fNumberOfTofClusters=0;
    }
 
+   fNumberOfTofTrgPads=0;
+
 }
 //______________________________________________________________________________
 
@@ -356,7 +368,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
   FillRecPoint();
 
   fTreeR->Fill();
-  ResetRecpoint();
+//  ResetRecpoint();
 
   fTOFLoader = fRunLoader->GetLoader("TOFLoader");  
   fTOFLoader->WriteRecPoints("OVERWRITE");
@@ -445,7 +457,7 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree
   FillRecPoint();
 
   clusterTree->Fill();
-  ResetRecpoint();
+//  ResetRecpoint();
 
   AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
                  stopwatch.RealTime(),stopwatch.CpuTime()));
@@ -476,8 +488,8 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
   TClonesArray * clonesRawData;
   Int_t dummy = -1;
 
-  Int_t detectorIndex[5];
-  Int_t parTOF[7];
+  Int_t detectorIndex[5]={-1,-1,-1,-1,-1};
+  Int_t parTOF[7]={-1,-1,-1,-1,-1,-1,-1};
 
   ofstream ftxt;
   if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
@@ -529,6 +541,11 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
        ftxt << "  " << tofRawDatum->GetTDCchannel();
       }
 
+      if ( tofRawDatum->GetTRM()==3 &&
+         (tofRawDatum->GetTDC()> 11 && tofRawDatum->GetTDC()< 15) ) FillTOFtriggerMap(indexDDL, tofRawDatum);
+
+      for (Int_t aa=0; aa<5; aa++) detectorIndex[aa] = -1;
+
       fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
                                         tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
       dummy = detectorIndex[3];
@@ -580,7 +597,7 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
        if (parTOF[0]<10) ftxt << "      " << parTOF[0] << endl;
        else if (parTOF[0]>=10 && parTOF[0]<100)   ftxt << "    " << parTOF[0] << endl;
        else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << "    " << parTOF[0] << endl;
-       else ftxt << "   " << parTOF[3] << endl;
+       else ftxt << "   " << parTOF[0] << endl;
       }
 
     } // closed loop on TOF raw data per current DDL file
@@ -598,7 +615,7 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
 
   clustersTree->Fill();
 
-  ResetRecpoint();
+//  ResetRecpoint();
 
   AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
                   stopwatch.RealTime(),stopwatch.CpuTime()));
@@ -741,7 +758,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader
        if (parTOF[0]<10) ftxt << "      " << parTOF[0] << endl;
        else if (parTOF[0]>=10 && parTOF[0]<100)   ftxt << "    " << parTOF[0] << endl;
        else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << "    " << parTOF[0] << endl;
-       else ftxt << "   " << parTOF[3] << endl;
+       else ftxt << "   " << parTOF[0] << endl;
       }
 
     } // closed loop on TOF raw data per current DDL file
@@ -758,7 +775,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader
   FillRecPoint();
 
   fTreeR->Fill();
-  ResetRecpoint();
+//  ResetRecpoint();
 
   fTOFLoader = fRunLoader->GetLoader("TOFLoader");
   fTOFLoader->WriteRecPoints("OVERWRITE");
@@ -793,6 +810,10 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
     fTOFLoader->MakeTree("D");
     fTreeD = fTOFLoader->TreeD();
     }
+  else {
+    AliFatal("Can not get TreeD");
+    return;
+  }
 
   Int_t bufsize = 32000;
   fDigits->Clear();
@@ -1036,18 +1057,19 @@ void AliTOFClusterFinder::FillRecPoint()
   TClonesArray &lRecPoints = *fRecPoints;
   
   for (ii=0; ii<fNumberOfTofClusters; ii++) {
-
-    digitIndex = fTofClusters[ii]->GetIndex();
-    for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
-    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
-    parTOF[5] = fTofClusters[ii]->GetDeltaBC();//deltaBC
-    parTOF[6] = fTofClusters[ii]->GetL0L1Latency();//L0-L1 latency
-    status=fTofClusters[ii]->GetStatus();
+    AliTOFcluster* clOr = fTofClusters[ii];
+    fTofClusters[ii] = 0;
+    digitIndex = clOr->GetIndex();
+    for(jj=0; jj<5; jj++) detectorIndex[jj] = clOr->GetDetInd(jj);
+    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] = clOr->GetDeltaBC();//deltaBC
+    parTOF[6] = clOr->GetL0L1Latency();//L0-L1 latency
+    status=clOr->GetStatus();
     Double_t posClus[3];
     Double_t covClus[6];
     UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
@@ -1056,17 +1078,18 @@ void AliTOFClusterFinder::FillRecPoint()
 
     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;
   } // loop on clusters
 
 }
@@ -1203,6 +1226,7 @@ void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
 
     tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
     fTofClusters[ii]->SetTDC(tdcCorr);
+
   } // loop on clusters
 
 }
@@ -1247,6 +1271,18 @@ void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
     tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
     fTofClusters[ii]->SetTDC(tdcBin);
 
+    // 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 = tdcBin*24.4 - length * 0.0333564095198152043; // subtract the minimal time in
+
+    if(timealligned > -1000 && timealligned < 24000 && fTOFcalib->IsChannelEnabled(index)){
+      fNumberOfTofTrgPads++;
+    }
+
   } // loop on clusters
 
 }
@@ -1260,6 +1296,7 @@ void AliTOFClusterFinder::ResetRecpoint()
   //
 
   fNumberOfTofClusters = 0;
+  fNumberOfTofTrgPads = 0;
   if (fRecPoints) fRecPoints->Clear();
 
 }
@@ -1432,3 +1469,58 @@ void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov
   return;
 
 }
+//-------------------------------------------------------------------------
+void AliTOFClusterFinder::FillTOFtriggerMap(Int_t iDDL, AliTOFrawData *tofRawDatum)
+{
+
+  /* get cluster info */
+  //Int_t trm = tofRawDatum->GetTRM();
+  // Int_t tdc = tofRawDatum->GetTDC();
+//   Int_t tdc_ch = tofRawDatum->GetTDCchannel();
+  Int_t chain = tofRawDatum->GetTRMchain();
+  Int_t l0l1 = tofRawDatum->GetL0L1Latency();
+  Double_t corr = l0l1 * AliTOFGeometry::BunchCrossingBinWidth();
+  AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
+  Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
+  corr += ctpLatency;
+
+  Double_t timeTOF=tofRawDatum->GetTOF()*AliTOFGeometry::TdcBinWidth();
+  timeTOF-=corr;
+  //Int_t timeRaw_bc = Int_t(timeTOF/1000/24.4); // per ora non usata
+
+  //Int_t timeRaw_bc = Int_t((tofRawDatum->GetTOF()*AliTOFGeometry::TdcBinWidth())/1000/24.4); // per ora non usata
+
+  /*
+  const  Int_t crate_CTTM[72] = { 0,  1, 37, 36,  2,  3, 39, 38,  4,  5,
+                                 41, 40,  6,  7, 43, 42,  8,  9, 45, 44,
+                                 10, 11, 47, 46, 12, 13, 49, 48, 14, 15,
+                                 51, 50, 16, 17, 53, 52, 18, 19, 55, 54,
+                                 20, 21, 57, 56, 22, 23, 59, 58, 24, 25,
+                                 61, 60, 26, 27, 63, 62, 28, 29, 65, 64,
+                                 30, 31, 67, 66, 32, 33, 69, 68, 34, 35,
+                                 71, 70};
+  */
+
+  Int_t cttmCrate=-1;
+//   Int_t cttmBit = tdc_ch + (tdc-12)*AliTOFGeometry::NCh();
+  switch(iDDL%AliTOFGeometry::NDDL()){
+  case 1:
+    cttmCrate=1;
+    break;
+  case 3:
+    cttmCrate=36;
+    break;
+  default:
+    break;
+  }
+  cttmCrate+=2*(Int_t)(iDDL/AliTOFGeometry::NDDL());
+  if(chain==0) {
+    if (iDDL<36) cttmCrate--;
+    else cttmCrate++;
+  }
+
+
+
+
+}
+