]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/Cal/AliTRDCalDet.cxx
Two functions with extended signature (Julian)
[u/mrichter/AliRoot.git] / TRD / Cal / AliTRDCalDet.cxx
index 15a05f02060a6e396c2e07d6022db434c691c798..48e8db6642d0233e9d3d7e4feef963ea56754e87 100644 (file)
@@ -529,11 +529,11 @@ void AliTRDCalDet::Divide(const AliTRDCalDet * calDet)
     }
 }
 //_____________________________________________________________________________
-Double_t AliTRDCalDet::CalcMean(Bool_t wghtPads)
+Double_t AliTRDCalDet::CalcMean(Bool_t wghtPads, Int_t &calib)
 {
   // Calculate the mean value after rejection of the chambers not calibrated
   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
-  //  
+  // calib = number of used chambers for the mean calculation
 
   Int_t iSM;
   Double_t sum = 0.0;
@@ -598,19 +598,95 @@ Double_t AliTRDCalDet::CalcMean(Bool_t wghtPads)
     }
     det++;
   }
-  
+
   delete []meanSM;
   delete []meanSMWP;
 
+  calib=ndet;
+  return (sum!=0.0 ? sum/ndet : -1);
+}
+//_____________________________________________________________________________
+Double_t AliTRDCalDet::CalcMean(Bool_t wghtPads)
+{
+  // Calculate the mean value after rejection of the chambers not calibrated
+  // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
+  // calib = number of used chambers for the mean calculation
+
+  Int_t iSM;
+  Double_t sum = 0.0;
+  Int_t ndet = 0;
+  Double_t meanALL = 0.0;
+  Double_t meanWP = 0.0;
+  Double_t pads=0.0;
+  Double_t padsALL=(144*16*24+144*12*6)*18;
+  Double_t *meanSM = new Double_t[18];
+  Double_t *meanSMWP = new Double_t[18];
   
+  for (Int_t i = 0; i < 18; i++) {
+    meanSM[i]=0.0;
+    meanSMWP[i]=0.0;
+  }
+
+  Int_t det = 0;
+  while(det < 540) {
+    Float_t val= fData[det];
+    iSM = (Int_t)(det / (6*5));
+    pads=(((Int_t) (det % (6 * 5)) / 6) == 2) ? 144*12 : 144*16;
+    meanALL+=val/540.;
+    meanSM[iSM]+=val/30.;
+    meanWP+=val*(pads/padsALL);
+    meanSMWP[iSM]+=val*(pads/(padsALL/18.));
+    
+    /*    
+         printf(" det %d  val %.3f meanALL %.5f meanWP %.5f meanSM[%d] %.5f meanSMWP[%d] %.5f \n",
+         det,
+         val,
+         meanALL,
+         meanWP,
+         iSM,
+         meanSM[iSM],
+         iSM,
+         meanSMWP[iSM]);
+    */
+   
+    det++;
+  }
+
+  // debug
+  /*
+    printf(" ALL %.5f \n",meanALL);
+    printf(" WP %.5f \n",meanWP);
+    for(Int_t i=0; i<18; i++) printf(" SM %02d %.5f \n",i,meanSM[i]);
+    for(Int_t i=0; i<18; i++) printf(" SM %02d %.5f \n",i,meanSMWP[i]);
+  */
+
+  det=0;
+  while(det < 540) {
+    Float_t val= fData[det];
+    if (( (!wghtPads) &&
+          (TMath::Abs(val - meanALL) > 0.0001) &&
+          (TMath::Abs(val - meanSM[(Int_t)(det / (6*5))]) > 0.0001) ) ||
+        ( (wghtPads) &&
+          (TMath::Abs(val - meanWP) > 0.0001) &&
+          (TMath::Abs(val - meanSMWP[(Int_t)(det / (6*5) )]) > 0.0001) )
+        ) {
+      sum+=val;
+      ndet++;
+    }
+    det++;
+  }
+
+  delete []meanSM;
+  delete []meanSMWP;
+
   return (sum!=0.0 ? sum/ndet : -1);
 }
 //_____________________________________________________________________________
-Double_t AliTRDCalDet::CalcRMS(Bool_t wghtPads)
+Double_t AliTRDCalDet::CalcRMS(Bool_t wghtPads, Int_t &calib)
 {
   // Calculate the RMS value after rejection of the chambers not calibrated
   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
-  //  
+  // calib = number of used chambers for the mean calculation
   
   Int_t iSM;
   Double_t sum = 0.0;
@@ -662,6 +738,65 @@ Double_t AliTRDCalDet::CalcRMS(Bool_t wghtPads)
   delete []meanSM;
   delete []meanSMWP;
   
+  calib=ndet;
+  return (sum!=0.0 ? TMath::Sqrt(sum/ndet) : -1);
+}
+//_____________________________________________________________________________
+Double_t AliTRDCalDet::CalcRMS(Bool_t wghtPads)
+{
+  // Calculate the RMS value after rejection of the chambers not calibrated
+  // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
+  // calib = number of used chambers for the mean calculation
+  
+  Int_t iSM;
+  Double_t sum = 0.0;
+  Int_t ndet = 0;
+  Double_t meanALL = 0.0;
+  Double_t meanWP = 0.0;
+  Double_t pads=0.0;
+  Double_t padsALL=(144*16*24+144*12*6)*18;
+  Double_t *meanSM = new Double_t[18];
+  Double_t *meanSMWP = new Double_t[18];
+  
+  for (Int_t i = 0; i < 18; i++) {
+    meanSM[i]=0.0;
+    meanSMWP[i]=0.0;
+  }
+  
+  Int_t det = 0;
+  while(det < 540) {
+    Float_t val= fData[det];
+    iSM = (Int_t)(det / (6*5));
+    pads=(((Int_t) (det % (6 * 5)) / 6) == 2) ? 144*12 : 144*16;
+    meanALL+=val/540.;
+    meanSM[iSM]+=val/30.;
+    meanWP+=val*(pads/padsALL);
+    meanSMWP[iSM]+=val*(pads/(padsALL/18.));
+    det++;
+  }
+  
+  Double_t mean;
+  if(!wghtPads) mean= meanALL;
+  if(wghtPads) mean= meanWP;
+  
+  det=0;
+  while(det < 540) {
+    Float_t val= fData[det];
+    if (( (!wghtPads) &&
+                (TMath::Abs(val - meanALL) > 0.0001) &&
+                (TMath::Abs(val - meanSM[(Int_t)(det / (6*5))]) > 0.0001) ) ||
+        ( (wghtPads) &&
+                (TMath::Abs(val - meanWP) > 0.0001) &&
+                (TMath::Abs(val - meanSMWP[(Int_t)(det / (6*5) )]) > 0.0001) )
+        ) {
+      sum+=(val-mean)*(val-mean);
+      ndet++;
+    }
+    det++;
+  }
+  
+  delete []meanSM;
+  delete []meanSMWP;
   
   return (sum!=0.0 ? TMath::Sqrt(sum/ndet) : -1);
 }