]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFillHisto.cxx
bugfix: only increment CTP counters for data events, skip for SOD and EOD
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.cxx
index f78b97f547f927a4e2784c9fed553ae7002984f3..4e0b3c68468ded28a3a6883c463c1cf7894b8b56 100644 (file)
@@ -48,6 +48,7 @@
 #include <TDirectory.h>
 #include <TTreeStream.h>
 #include <TVectorD.h>
+#include <TLinearFitter.h>
 
 #include "AliLog.h"
 
@@ -119,7 +120,6 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   :TObject()
   ,fGeo(0)
   ,fIsHLT(kFALSE)
-  ,fMcmCorrectAngle(kFALSE)
   ,fCH2dOn(kFALSE)
   ,fPH2dOn(kFALSE)
   ,fPRF2dOn(kFALSE)
@@ -147,9 +147,9 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fNumberTrack(0)
   ,fTimeMax(0)
   ,fSf(10.0)
-  ,fNumberBinCharge(100)
-  ,fNumberBinPRF(40)
-  ,fNgroupprf(0)
+  ,fNumberBinCharge(50)
+  ,fNumberBinPRF(10)
+  ,fNgroupprf(3)
   ,fAmpTotal(0x0)
   ,fPHPlace(0x0)
   ,fPHValue(0x0)
@@ -188,7 +188,6 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   :TObject(c)
   ,fGeo(0)
   ,fIsHLT(c.fIsHLT)
-  ,fMcmCorrectAngle(c.fMcmCorrectAngle)
   ,fCH2dOn(c.fCH2dOn)
   ,fPH2dOn(c.fPH2dOn)
   ,fPRF2dOn(c.fPRF2dOn)
@@ -404,23 +403,10 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos()
       fCalibraVector->SetDetCha0(k,fCalibraMode->GetDetChamb0(k));
       fCalibraVector->SetDetCha2(k,fCalibraMode->GetDetChamb2(k));
     }
-    TString namech("Nz");
-    namech += fCalibraMode->GetNz(0);
-    namech += "Nrphi";
-    namech += fCalibraMode->GetNrphi(0);
-    fCalibraVector->SetNameCH((const char* ) namech);
-    TString nameph("Nz");
-    nameph += fCalibraMode->GetNz(1);
-    nameph += "Nrphi";
-    nameph += fCalibraMode->GetNrphi(1);
-    fCalibraVector->SetNamePH((const char* ) nameph);
-    TString nameprf("Nz");
-    nameprf += fCalibraMode->GetNz(2);
-    nameprf += "Nrphi";
-    nameprf += fCalibraMode->GetNrphi(2);
-    nameprf += "Ngp";
-    nameprf += fNgroupprf;
-    fCalibraVector->SetNamePRF((const char* ) nameprf);
+    fCalibraVector->SetNzNrphi(0,fCalibraMode->GetNz(0),fCalibraMode->GetNrphi(0));
+    fCalibraVector->SetNzNrphi(1,fCalibraMode->GetNz(1),fCalibraMode->GetNrphi(1));
+    fCalibraVector->SetNzNrphi(2,fCalibraMode->GetNz(2),fCalibraMode->GetNrphi(2));
+    fCalibraVector->SetNbGroupPRF(fNgroupprf);
   }
  
   // Create the 2D histos corresponding to the pad groupCalibration mode
@@ -491,7 +477,7 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos()
 
 }
 //____________Offline tracking in the AliTRDtracker____________________________
-Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t)
+Bool_t AliTRDCalibraFillHisto::UpdateHistograms(const AliTRDtrack *t)
 {
   //
   // Use AliTRDtrack for the calibration
@@ -628,7 +614,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t)
   
 }
 //____________Offline tracking in the AliTRDtracker____________________________
-Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
+Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
 {
   //
   // Use AliTRDtrackV1 for the calibration
@@ -691,7 +677,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
     // loop over the clusters
     ////////////////////////////
     Int_t nbclusters = 0;
-    for(int jc=0; jc<AliTRDseed::kNtb; jc++){
+    for(int jc=0; jc<AliTRDseedV1::kNtb; jc++){
       if(!(cl = tracklet->GetClusters(jc))) continue;
       nbclusters++;
       
@@ -709,10 +695,12 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
     // Fill the stuffs if a good tracklet
     ////////////////////////////////////////
     if (fGoodTracklet) {
-      
+
       // drift velocity unables to cut bad tracklets 
       Bool_t  pass = FindP1TrackPHtrackletV1(tracklet, nbclusters);
        
+      //printf("pass %d and nbclusters %d\n",pass,nbclusters);
+
       // Gain calibration
       if (fCH2dOn) {
        FillTheInfoOfTheTrackCH(nbclusters);
@@ -735,7 +723,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
 // Routine inside the update with AliTRDtrack
 ///////////////////////////////////////////////////////////////////////////////////
 //____________Offine tracking in the AliTRDtracker_____________________________
-Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1)
+Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1)
 {
   //
   // Drift velocity calibration:
@@ -927,7 +915,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   ////////////////////////////
   Int_t  nbli = 0;
   AliTRDcluster *cl                   = 0x0;
-  for(int ic=0; ic<AliTRDseed::kNtb; ic++){
+  for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
     if(!(cl = tracklet->GetClusters(ic))) continue;
     if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
     
@@ -942,16 +930,13 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
     fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
     nbli++;  
 
+    //////////////////////////////
+    // Check no shared clusters
+    //////////////////////////////
+    for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
+      if((cl = tracklet->GetClusters(icc)))  crossrow = 1;
+    }
   }
-
-  //////////////////////////////
-  // Check no shared clusters
-  //////////////////////////////
-
-  for(int ic=AliTRDseed::kNtb; ic<AliTRDseed::knTimebins; ic++){
-    if((cl = tracklet->GetClusters(ic)))  crossrow = 1;
-  }
-
   
   ////////////////////////////////////
   // Do the straight line fit now
@@ -1032,7 +1017,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   return kTRUE;
 }
 //____________Offine tracking in the AliTRDtracker_____________________________
-Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, Int_t index1)
+Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1)
 {
   //
   // PRF width calibration
@@ -1096,8 +1081,9 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
   for(Int_t k = 0;  k < npoints; k++){
     //Take the cluster
     AliTRDcluster *cl  = (AliTRDcluster *) t->GetCluster(k+index0);
+    if(!cl) continue;
     Short_t  *signals  = cl->GetSignals();
-    Double_t     time  = cl->GetLocalTimeBin();
+    Double_t     time  = cl->GetPadTime();
     //Calculate x if possible 
     Float_t xcenter    = 0.0;    
     Bool_t  echec1      = kTRUE;   
@@ -1152,8 +1138,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
   for(Int_t k = 0;  k < npoints; k++){
     //Take the cluster
     AliTRDcluster *cl      = (AliTRDcluster *) t->GetCluster(k+index0);
-    Short_t  *signals      = cl->GetSignals();              // signal
-    Double_t     time      = cl->GetLocalTimeBin();              // time bin
+    Short_t *signals       = cl->GetSignals();              // signal
+    Double_t time          = cl->GetPadTime();              // time bin
     Float_t padPosTracklet = line[0]+line[1]*time;          // reconstruct position from fit
     Float_t padPos         = cl->GetPadCol();               // middle pad
     Double_t dpad          = padPosTracklet - padPos;       // reconstruct position relative to middle pad from fit 
@@ -1397,11 +1383,9 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   //////////////////////
 
   Int_t nb3pc    = 0;              // number of three pads clusters used for fit 
-  Double_t *padPositions;          // to see the difference between the fit and the 3 pad clusters position
-  padPositions = new Double_t[AliTRDseed::kNtb];
-  for(Int_t k = 0; k < AliTRDseed::kNtb; k++){
-    padPositions[k] = 0.0;
-  } 
+  // to see the difference between the fit and the 3 pad clusters position
+  Double_t padPositions[AliTRDseedV1::kNtb];
+  memset(padPositions, 0, AliTRDseedV1::kNtb*sizeof(Double_t)); 
   fLinearFitterTracklet->ClearPoints();  
   
   //printf("loop clusters \n");
@@ -1409,14 +1393,13 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   // loop over the clusters
   ////////////////////////////
   AliTRDcluster *cl                   = 0x0;
-  for(int ic=0; ic<AliTRDseed::kNtb; ic++){
+  for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
     // reject shared clusters on pad row
-    if(((ic+AliTRDseed::kNtb) < AliTRDseed::knTimebins) && (cl = tracklet->GetClusters(ic+AliTRDseed::kNtb))) continue;
-    //    
+    if((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) {
+      if((cl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb))) continue;
+    }
     if(!(cl = tracklet->GetClusters(ic))) continue;
-   
-    
-    Double_t     time  = cl->GetLocalTimeBin();
+    Double_t     time  = cl->GetPadTime();
     if((time<=7) || (time>=21)) continue;
     Short_t  *signals  = cl->GetSignals(); 
     Float_t xcenter    = 0.0;    
@@ -1461,9 +1444,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   // fit with a straight line
   /////////////////////////////
   if(nb3pc < 3){ 
-    delete [] padPositions;
     fLinearFitterTracklet->ClearPoints();  
-    delete [] padPositions;
     return kFALSE;
   }
   fLinearFitterTracklet->Eval();
@@ -1479,14 +1460,14 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   ////////////////////////////////////////////////
   // Fill the PRF: Second loop over clusters
   //////////////////////////////////////////////
-  for(int ic=0; ic<AliTRDseed::kNtb; ic++){
+  for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
     // reject shared clusters on pad row
-    if(((ic+AliTRDseed::kNtb) < AliTRDseed::knTimebins) && (cl = tracklet->GetClusters(ic+AliTRDseed::kNtb))) continue;
+    if(((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) && (cl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb))) continue;
     //
     if(!(cl = tracklet->GetClusters(ic))) continue;
 
     Short_t  *signals      = cl->GetSignals();              // signal
-    Double_t     time      = cl->GetLocalTimeBin();         // time bin
+    Double_t     time      = cl->GetPadTime();         // time bin
     Float_t padPosTracklet = line[0]+line[1]*time;          // reconstruct position from fit
     Float_t padPos         = cl->GetPadCol();               // middle pad
     Double_t dpad          = padPosTracklet - padPos;       // reconstruct position relative to middle pad from fit 
@@ -1679,15 +1660,13 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   } // second loop over clusters
 
 
-  delete [] padPositions;
   return kTRUE;
-  
 }
 ///////////////////////////////////////////////////////////////////////////////////////
 // Pad row col stuff: see if masked or not
 ///////////////////////////////////////////////////////////////////////////////////////
 //_____________________________________________________________________________
-void AliTRDCalibraFillHisto::CheckGoodTrackletV1(AliTRDcluster *cl)
+void AliTRDCalibraFillHisto::CheckGoodTrackletV1(const AliTRDcluster *cl)
 {
   //
   // See if we are not near a masked pad
@@ -1698,7 +1677,7 @@ void AliTRDCalibraFillHisto::CheckGoodTrackletV1(AliTRDcluster *cl)
   
 }
 //_____________________________________________________________________________
-void AliTRDCalibraFillHisto::CheckGoodTrackletV0(Int_t detector, Int_t row, Int_t col)
+void AliTRDCalibraFillHisto::CheckGoodTrackletV0(const Int_t detector,const Int_t row,const Int_t col)
 {
   //
   // See if we are not near a masked pad
@@ -1919,7 +1898,7 @@ void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
 // Per tracklet: store or reset the info, fill the histos with the info
 //////////////////////////////////////////////////////////////////////////////////////////
 //_____________________________________________________________________________
-void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col)
+void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col)
 {
   //
   // Store the infos in fAmpTotal, fPHPlace and fPHValue
@@ -1928,7 +1907,10 @@ void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl
   
   // time bin of the cluster not corrected
   Int_t    time     = cl->GetPadTime();
-   
+  Float_t  charge   = TMath::Abs(cl->GetQ());  
+
+  //printf("Store::time %d, amplitude %f\n",time,dqdl);
+  
   //Correct for the gain coefficient used in the database for reconstruction
   Float_t correctthegain = 1.0;
   if(fIsHLT) correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack);
@@ -1945,13 +1927,16 @@ void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl
 
   // Fill the fAmpTotal with the charge
   if (fCH2dOn) {
-    if((!fLimitChargeIntegration) || (cl->IsInChamber())) fAmpTotal[(Int_t) group[0]] += correction;
+    if((!fLimitChargeIntegration) || (cl->IsInChamber())) {
+      //printf("Store::group %d, amplitude %f\n",group[0],correction);
+      fAmpTotal[(Int_t) group[0]] += correction;
+    }
   }
 
   // Fill the fPHPlace and value
   if (fPH2dOn) {
     fPHPlace[time] = group[1];
-    fPHValue[time] = correction;
+    fPHValue[time] = charge;
   }
   
 }
@@ -1994,6 +1979,8 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
   Int_t fd            = -1;   // Premiere zone non nulle
   Float_t totalcharge = 0.0;  // Total charge for the supermodule histo
 
+  //printf("CH2d nbclusters %d, fNumberClusters %d, fNumberClustersf %d\n",nbclusters,fNumberClusters,fNumberClustersf);
+
   if(nbclusters < fNumberClusters) return;
   if(nbclusters > fNumberClustersf) return;
 
@@ -2001,9 +1988,12 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
   // Normalize with the number of clusters
   Double_t normalizeCst = fRelativeScale;
   if(fNormalizeNbOfCluster) normalizeCst = normalizeCst*nbclusters;
+
+  //printf("Number of groups in one detector %d\n",fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0));
   
   // See if the track goes through different zones
   for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
+    //printf("fAmpTotal %f for %d\n",fAmpTotal[k],k);
     if (fAmpTotal[k] > 0.0) {
       totalcharge += fAmpTotal[k];
       nb++;
@@ -2013,6 +2003,7 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
     }
   }
 
+  //printf("CH2d: nb %d, fd %d, calibration group %d, amplitude %f, detector %d\n",nb,fd,fCalibraMode->GetXbins(0),fAmpTotal[fd]/normalizeCst,fDetectorPreviousTrack);
     
   switch (nb)
     { 
@@ -2308,7 +2299,6 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo
   // 0 timebin problem
   // 1 no input
   // 2 input
-  //
   // Same algorithm as TestBeam but different reader
   //
   
@@ -2486,10 +2476,10 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t no
 //_________________________________________________________________________
 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(
 #ifdef ALI_DATE
-                                              eventHeaderStruct *event,
+                                              const eventHeaderStruct *event,
                                               Bool_t nocheck
 #else
-                                              eventHeaderStruct* /*event*/,
+                                              const eventHeaderStruct* /*event*/,
                                               Bool_t /*nocheck*/
            
 #endif 
@@ -3196,4 +3186,3 @@ void AliTRDCalibraFillHisto::AnalyseLinearFitter()
     }
   }
 }
-