]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineSPDphysAnalyzer.cxx
warnings with gcc 4.3.2
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDphysAnalyzer.cxx
index 4f7eaa85f6b8e6a6d3f889360af8b188868c69e9..f12f08da77876f25dd172ad21a55db66bcdd8d4a 100644 (file)
@@ -38,10 +38,10 @@ AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(const Char_t *fileName,
   fFileName(fileName),fPhysObj(NULL),fHandler(handler),
   fNrEnoughStatChips(0),fNrDeadChips(0),fNrInefficientChips(0),
   fNrEqHits(0),fbDeadProcessed(kFALSE),
-  fThreshNoisy(1),fThreshNoisyExp(-12),fThreshDead(1),fThreshDeadExp(-12),
+  fThreshNoisy(1e-9),fThreshDead(1e-9),
   fMinEventsForNoisy(10000),fMinEventsForDead(10000),
-  fDefinitelyNoisyRatio(0.1),
-  fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1)//!!!
+  fDefinitelyNoisyRatio(0.3),
+  fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1)
 {
   // constructor  
   Init();
@@ -51,10 +51,10 @@ AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(AliITSOnlineSPDphys* ph
   fFileName("test.root"),fPhysObj(NULL),fHandler(handler),
   fNrEnoughStatChips(0),fNrDeadChips(0),fNrInefficientChips(0),
   fNrEqHits(0),fbDeadProcessed(kFALSE),
-  fThreshNoisy(1),fThreshNoisyExp(-12),fThreshDead(1),fThreshDeadExp(-12),
+  fThreshNoisy(1e-9),fThreshDead(1e-9),
   fMinEventsForNoisy(10000),fMinEventsForDead(10000),
-  fDefinitelyNoisyRatio(0.1),
-  fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1)//!!!
+  fDefinitelyNoisyRatio(0.3),
+  fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1)
 {
   // alt constructor
   fPhysObj = physObj;
@@ -64,17 +64,15 @@ AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(const AliITSOnlineSPDph
   fFileName("test.root"),fPhysObj(NULL),fHandler(NULL),
   fNrEnoughStatChips(0),fNrDeadChips(0),fNrInefficientChips(0),
   fNrEqHits(0),fbDeadProcessed(kFALSE),
-  fThreshNoisy(1),fThreshNoisyExp(-12),fThreshDead(1),fThreshDeadExp(-12),
+  fThreshNoisy(1e-9),fThreshDead(1e-9),
   fMinEventsForNoisy(10000),fMinEventsForDead(10000),
-  fDefinitelyNoisyRatio(0.1),
-  fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1)//!!!
+  fDefinitelyNoisyRatio(0.3),
+  fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1)
 {
   // copy constructor, only copies the filename and params (not the processed data)
   fFileName=handle.fFileName;
   fThreshNoisy = handle.fThreshNoisy;
-  fThreshNoisyExp = handle.fThreshNoisyExp;
   fThreshDead = handle.fThreshDead;
-  fThreshDeadExp = handle.fThreshDeadExp;
   fMinEventsForNoisy = handle.fMinEventsForNoisy;
   fMinEventsForDead = handle.fMinEventsForDead;
   fDefinitelyNoisyRatio = handle.fDefinitelyNoisyRatio;
@@ -96,9 +94,7 @@ AliITSOnlineSPDphysAnalyzer& AliITSOnlineSPDphysAnalyzer::operator=(const AliITS
     
     fFileName=handle.fFileName;
     fThreshNoisy = handle.fThreshNoisy;
-    fThreshNoisyExp = handle.fThreshNoisyExp;
     fThreshDead = handle.fThreshDead;
-    fThreshDeadExp = handle.fThreshDeadExp;
     fMinEventsForNoisy = handle.fMinEventsForNoisy;
     fMinEventsForDead = handle.fMinEventsForDead;
     fDefinitelyNoisyRatio = handle.fDefinitelyNoisyRatio;
@@ -137,19 +133,11 @@ void AliITSOnlineSPDphysAnalyzer::SetParam(const Char_t *pname, const Char_t *pv
   //  printf("Setting Param %s  to %s\n",name.Data(),val.Data());
   if (name.CompareTo("MistakeProbabilityNoisy")==0) {
     Double_t mistakeProbabilityNoisy = val.Atof();
-    fThreshNoisy = mistakeProbabilityNoisy;
-    fThreshNoisyExp = 0;
-    Exponent(fThreshNoisy,fThreshNoisyExp);
-    fThreshNoisy/=(20*6*10*32*256);
-    Exponent(fThreshNoisy,fThreshNoisyExp);
+    fThreshNoisy = mistakeProbabilityNoisy/(20*6*10*32*256);
   }
   else if (name.CompareTo("MistakeProbabilityDead")==0) {
     Double_t mistakeProbabilityDead = val.Atof();
-    fThreshDead = mistakeProbabilityDead;
-    fThreshDeadExp = 0;
-    Exponent(fThreshDead,fThreshDeadExp);
-    fThreshDead/=(20*6*10*32*256);
-    Exponent(fThreshDead,fThreshDeadExp);
+    fThreshDead = mistakeProbabilityDead/(20*6*10*32*256);
   }
   else if (name.CompareTo("fMinEventsForNoisy")==0) {
     fMinEventsForNoisy = val.Atoi();
@@ -243,19 +231,13 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessNoisyPixels() {
 
          Double_t p = (Double_t)nrChipHits/nrPixels/n;
 
-         Double_t bin = 1;
-         Int_t binExp = 0;
          // Bin(n,k=0):
-         for (UInt_t i=0; i<n; i++) {
-           bin*=(1-p);
-           Exponent(bin,binExp);
-         }
+         Double_t bin = pow((Double_t)(1-p),(Double_t)n);
          // Bin(n,k)
          UInt_t k=1;
-         while (((binExp>fThreshNoisyExp || (binExp==fThreshNoisyExp && bin>fThreshNoisy)) || k<n*p) && k<=n) {
+         while ((bin>fThreshNoisy || k<n*p) && k<=n) {
            k++;
            bin = bin*(n-k+1)/k*p/(1-p);
-           Exponent(bin,binExp);
          }
          
          // can we find noisy pixels...?
@@ -292,6 +274,7 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
     Warning("AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels","No data!");
     return 0;
   }
+
   // do we have enough events to even try the algorithm?
   if (GetNrEvents() < fMinEventsForDead) {
     Warning("AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels","Nr events (%d) < fMinEventsForDead (%d)!",GetNrEvents(),fMinEventsForDead);
@@ -303,7 +286,7 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
     return 0;
   }
 
-  AliITSOnlineCalibrationSPDhandler *deadChipHandler = new AliITSOnlineCalibrationSPDhandler();
+  AliITSIntMap* possiblyDead  = new AliITSIntMap();
   AliITSIntMap* possiblyIneff = new AliITSIntMap();
 
   fNrEnoughStatChips = 0;
@@ -312,140 +295,129 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
   UInt_t nrPossiblyDeadChips = 0;
   fNrEqHits = 0;
 
-  for (UInt_t hs=0; hs<6; hs++) {
-    for (UInt_t chip=0; chip<10; chip++) {
-      Bool_t good=kFALSE;
-
-      AliITSOnlineCalibrationSPDhandler *deadPixelHandler = new AliITSOnlineCalibrationSPDhandler();
 
-      UInt_t nrPossiblyDeadPixels = 0;
-      UInt_t nrPixels = 0;
-      UInt_t nrChipHits = 0;
-      for (UInt_t col=0; col<32; col++) {
-       for (UInt_t row=0; row<256; row++) {
-         UInt_t nrHits = fPhysObj->GetHits(hs,chip,col,row);
-         nrChipHits += nrHits;
-         if (!fHandler->IsPixelNoisy(GetEqNr(),hs,chip,col,row)) {
-           // don't include noisy pixels
-           nrPixels++;
-           if (nrHits==0) {
-             nrPossiblyDeadPixels++;
-             deadPixelHandler->SetDeadPixel(GetEqNr(),hs,chip,col,row);
+  for (UInt_t hs=0; hs<6; hs++) {
+    if (!fHandler->IsActiveHS(GetEqNr(),hs)) {
+      fNrDeadChips+=10;
+    }
+    else {
+      for (UInt_t chip=0; chip<10; chip++) {
+       if (!fHandler->IsActiveChip(GetEqNr(),hs,chip)) {
+         fNrDeadChips++;
+       }
+       else {
+         // perform search for individual dead pixels...
+         Bool_t good=kFALSE;
+
+         UInt_t nrPossiblyDeadPixels = 0;
+         UInt_t nrPixels = 0;
+         UInt_t nrChipHits = 0;
+         for (UInt_t col=0; col<32; col++) {
+           for (UInt_t row=0; row<256; row++) {
+             UInt_t nrHits = fPhysObj->GetHits(hs,chip,col,row);
+             nrChipHits += nrHits;
+             if (!fHandler->IsPixelNoisy(GetEqNr(),hs,chip,col,row)) {
+               // don't include noisy pixels
+               nrPixels++;
+               if (nrHits==0) {
+                 nrPossiblyDeadPixels++;
+               }
+               else {
+                 fHandler->UnSetDeadPixel(GetEqNr(),hs,chip,col,row); // unset (no action unless dead before)
+               }
+             }
+             else {
+               nrChipHits -= nrHits; // this is needed when running offline (online nrHits should be 0 already)
+             }
            }
          }
-         else {
-           nrChipHits -= nrHits; // this is needed when running offline (online nrHits should be 0 already)
+         fNrEqHits+=nrChipHits;
+
+         if (nrChipHits>0) {
+           // make sure the chip is not flagged as dead
+           fHandler->SetDeadChip(GetEqNr(),hs,chip,kFALSE);
          }
-       }
-      }
-      fNrEqHits+=nrChipHits;
-
-      // check all pixels that were declared dead from before...
-      UInt_t nrDeadBefore = fHandler->GetNrDeadC(GetEqNr(),hs,chip);
-      UInt_t nrNoisyNow   = fHandler->GetNrNoisyC(GetEqNr(),hs,chip);
-      if (nrDeadBefore+nrNoisyNow==8192) {
-       if (nrChipHits>0) {
-         fHandler->UnSetDeadChip(GetEqNr(),hs,chip);
-       }
-      }
-      else {
-       AliITSOnlineCalibrationSPDhandler *tmpHand = new AliITSOnlineCalibrationSPDhandler();
-       for (UInt_t index=0; index<nrDeadBefore; index++) {
-         UInt_t col = fHandler->GetDeadColAtC(GetEqNr(),hs,chip,index);
-         UInt_t row = fHandler->GetDeadRowAtC(GetEqNr(),hs,chip,index);
-         if (fPhysObj->GetHits(hs,chip,col,row)>0) {
-           //      fHandler->UnSetDeadPixel(GetEqNr(),hs,chip,col,row);
-           tmpHand->SetDeadPixel(GetEqNr(),hs,chip,col,row);
+
+         if (nrPossiblyDeadPixels==0) {
+           // no need to see if we have enough statistics...
+           fNrEnoughStatChips++;
+           good=kTRUE;
+           //  printf("%3d",good);
+           //  if (chip==9) printf("\n");
+           continue;
          }
-       }
-       UInt_t nrToRemove = tmpHand->GetNrDead();
-       for (UInt_t index=0; index<nrToRemove; index++) {
-         fHandler->UnSetDeadPixel(GetEqNr(),hs,chip,tmpHand->GetDeadColAtC(GetEqNr(),hs,chip,index),tmpHand->GetDeadRowAtC(GetEqNr(),hs,chip,index));
-       }
-       delete tmpHand;
-      }
 
+         if (nrChipHits==0) {
+           nrPossiblyDeadChips++;
+           possiblyDead->Insert(hs,chip);
+           good=kFALSE;
+           //  printf("%3d",good);
+           //  if (chip==9) printf("\n");
+           continue;
+         }
 
+         // Binomial with n events and probability p for pixel hit
+         UInt_t n = GetNrEvents();
+         if (nrPixels>0 && n>0) {
 
+           Double_t p = (Double_t)nrChipHits/nrPixels/n;
 
-      if (nrPossiblyDeadPixels==0) {
-       // no need to see if we have enough statistics...
-       fNrEnoughStatChips++;
-       good=kTRUE;
-       delete deadPixelHandler;
-       good=kTRUE;
-       printf("%3d",good);
-       if (chip==9) printf("\n");
-       continue;
-      }
+           // probability of falsely assigning a dead pixel
+           Double_t falselyDeadProb = pow((Double_t)(1-p),(Double_t)n);
+           //      printf("falselyprob=%e\n",falselyDeadProb);
 
-      if (nrChipHits==0) {
-       nrPossiblyDeadChips++;
-       deadChipHandler->SetDeadChip(GetEqNr(),hs,chip);
-       delete deadPixelHandler;
-       good=kFALSE;
-       printf("%3d",good);
-       if (chip==9) printf("\n");
-       continue;
-      }
-
-      // Binomial with n events and probability p for pixel hit
-      UInt_t n = GetNrEvents();
-      if (nrPixels>0 && n>0) {
+           // can we find dead pixels...?
+           if (falselyDeadProb<fThreshDead) {
+             fNrEnoughStatChips++;
+             good=kTRUE;
+             // add dead pixels to handler
+             for (UInt_t col=0; col<32; col++) {
+               for (UInt_t row=0; row<256; row++) {
+                 UInt_t nrHits = fPhysObj->GetHits(hs,chip,col,row);
+                 if (nrHits==0) {
+                   if (!fHandler->IsPixelNoisy(GetEqNr(),hs,chip,col,row)) {
+                     // don't include noisy pixels
+                     fHandler->SetDeadPixel(GetEqNr(),hs,chip,col,row);
+                   }
+                 }
+               }
+             }
+           }
+           if (!good) {
+             // this might be an inefficient chip
+             possiblyIneff->Insert(hs*10+chip,nrChipHits);
+           }
 
-       Double_t p = (Double_t)nrChipHits/nrPixels/n;
+         }
+         else {
+           if (n>0) {
+             // this is a completely noisy chip... put in category enough stat
+             fNrEnoughStatChips++;
+             good=kTRUE;
+           }
+         }
 
-       // probability of falsely assigning a dead pixel
-       Double_t falselyDeadProb = 1;
-       Int_t falselyDeadProbExp = 0;
-       for (UInt_t i=0; i<n; i++) {
-         falselyDeadProb*=(1-p);
-         Exponent(falselyDeadProb,falselyDeadProbExp);
-       }
+         //      printf("%3d",good);
+         //      if (chip==9) printf("\n");
 
-       // can we find dead pixels...?
-       if (falselyDeadProbExp<fThreshDeadExp || (falselyDeadProbExp==fThreshDeadExp && falselyDeadProb<fThreshDead)) {
-         fNrEnoughStatChips++;
-         good=kTRUE;
-         // add dead pixels to handler
-         fHandler->AddDeadFrom(deadPixelHandler);
-       }
-       else {
-         // this might be an inefficient chip
-         possiblyIneff->Insert(hs*10+chip,nrChipHits);
        }
-
-      }
-      else {
-       if (n>0) {
-         // this is a completely noisy chip... put in category enough stat
-         fNrEnoughStatChips++;
-         good=kTRUE;
-       }
-      }
-
-      delete deadPixelHandler;
-
-      printf("%3d",good);
-      if (chip==9) printf("\n");
-
-    } // for chip
+      } // for chip
+    }
   } // for hs
 
+  Int_t key,val;
 
   // dead chips?
   if (fNrEqHits>fMinNrEqHitsForDeadChips) {
-    fHandler->AddDeadFrom(deadChipHandler);
-    fNrDeadChips=nrPossiblyDeadChips;
-  }
-  else {
-    fNrDeadChips=0;
+    while (possiblyDead->Pop(key,val)) {
+      fHandler->SetDeadChip(GetEqNr(),key,val,kFALSE);
+    }
+    fNrDeadChips+=nrPossiblyDeadChips;
   }
-  delete deadChipHandler;
-
+  delete possiblyDead;
 
   // inefficient chips?
-  Int_t key,val;
   while (possiblyIneff->Pop(key,val)) {
     if (val<fNrEqHits/60*fRatioToMeanForInefficientChip) {
       fNrInefficientChips++;