]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPreprocessor.cxx
Compilation on Windoiws/Cygwin
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPreprocessor.cxx
index 477ee7f5556ea4333375a351a7d4d904d763644d..9a0e628c465f1549daec60f21a423209a793c5fb 100644 (file)
@@ -80,6 +80,8 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
 
   if(runType=="STANDALONE") {
     Bool_t ledOK = ProcessLEDRun();
+    Bool_t badmap_OK = FindBadChannelsEmc();
+    if(!badmap_OK) Log(Form("WARNING! FindBadChannels() completed with BAD status!"));
     if(ledOK) return 0;
     else
       return 1;
@@ -87,12 +89,9 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
   
   if(runType=="PHYSICS") {
     
-    Bool_t badmap_OK = FindBadChannelsEmc();
-    if(!badmap_OK) Log(Form("WARNING!! FindBadChannels() completed with BAD status!"));
-    
     Bool_t calibEmc_OK = CalibrateEmc();
     
-    if(calibEmc_OK && badmap_OK) return 0;
+    if(calibEmc_OK) return 0;
     else
       return 1;
   }
@@ -131,6 +130,7 @@ Bool_t AliPHOSPreprocessor::ProcessLEDRun()
   
   TIter iter(list);
   TObjString *source;
+  Bool_t firedOK = kFALSE;
   
   while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
     
@@ -146,6 +146,25 @@ Bool_t AliPHOSPreprocessor::ProcessLEDRun()
       return kFALSE;
     }
 
+    TH1I* fFiredCells = (TH1I*)f.Get("fFiredCells");
+
+    if(!fFiredCells) {
+      Log(Form("fFiredCells histogram not found in %s, skip this source.",fileName.Data()));
+      firedOK=kFALSE;
+    }
+    else {
+      const Double_t nFiredCells = fFiredCells->GetMean();
+      if(nFiredCells>100 && nFiredCells<600) { 
+       firedOK = kTRUE;
+       Log(Form("Number of fired cells per event is %d.",nFiredCells));
+      }
+      else {
+       Log(Form("Number of fired cells per event is %d, possibly not a LED run!",nFiredCells));
+       firedOK = kFALSE;
+      }
+      
+    }
+
     const Int_t nMod=5; // 1:5 modules
     const Int_t nCol=56; //1:56 columns in each module
     const Int_t nRow=64; //1:64 rows in each module
@@ -154,12 +173,14 @@ Bool_t AliPHOSPreprocessor::ProcessLEDRun()
       for(Int_t col=0; col<nCol; col++) {
        for(Int_t row=0; row<nRow; row++) {
 
-         //High Gain to Low Gain ratio 
-          Float_t ratio = HG2LG(mod,row,col,&f);
-          calibData.SetHighLowRatioEmc(mod+1,col+1,row+1,ratio);
-         if(ratio != 16.)
-           AliInfo(Form("mod %d iX %d iZ %d  ratio %.3f\n",mod,row,col,ratio));
-         
+         //High Gain to Low Gain ratio
+         if(firedOK) {
+           Float_t ratio = HG2LG(mod,row,col,&f);
+           calibData.SetHighLowRatioEmc(mod+1,col+1,row+1,ratio);
+           if(ratio != 16.)
+             AliInfo(Form("mod %d iX %d iZ %d  ratio %.3f\n",mod,row,col,ratio));
+         }       
+
          if(clb) {
            Double_t coeff = clb->GetADCchannelEmc(mod+1,col+1,row+1);
            calibData.SetADCchannelEmc(mod+1,col+1,row+1,coeff);
@@ -173,7 +194,7 @@ Bool_t AliPHOSPreprocessor::ProcessLEDRun()
 
   } // end of loop over files
 
-  //Store bad channels map
+  //Store the updated High Gain/Low Gain ratios
   AliCDBMetaData emcMetaData;
 
   //Data valid from current run fRun until updated (validityInfinite=kTRUE)
@@ -296,8 +317,22 @@ Bool_t AliPHOSPreprocessor::DoFindBadChannelsEmc(Int_t system, TList* list, AliP
       Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
       return kFALSE;
     }
+
+    TH1I* fFiredCells = (TH1I*)f.Get("fFiredCells");
+
+    if(!fFiredCells) {
+      Log(Form("fFiredCells histogram not found in %s, skip this source.",fileName.Data()));
+      continue;
+    }
+
+    const Double_t nFiredCells = fFiredCells->GetMean();
+
+    if(nFiredCells<100. || nFiredCells>600. ) {
+      Log(Form("Number of fired cells per event is %d, possibly not a LED run!",nFiredCells));
+      continue; // not a LED run!
+    }
     
-    Log(Form("Begin check for bad channels."));
+    Log(Form("Number of fired cells per event %d. Begin check for bad channels.",nFiredCells));
     
     for(Int_t mod=0; mod<5; mod++) {
       for(Int_t iX=0; iX<64; iX++) {
@@ -445,7 +480,7 @@ Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliP
     
     if(nkeys< 2){
       Log(Form("Not enough histograms (%d) for calibration.",nkeys));
-      return 0;
+      return 1; // it's not fatal! May be short run..
     }
     
     while(!ok){
@@ -484,7 +519,7 @@ Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliP
       
       if(!ok && counter > nkeys){
        Log("No histogram with enough statistics for reference. Exit.");
-       return 0;
+       return 1; // Not fatal, just wait..
       }
     }
     
@@ -499,14 +534,10 @@ Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliP
     for(Int_t mod=0; mod<nMod; mod++) {
       for(Int_t col=0; col<nCol; col++) {
        for(Int_t row=0; row<nRow; row++) {
-
-         //High Gain to Low Gain ratio
-         Float_t ratio = HG2LG(mod,row,col,&f);
-         calibData.SetHighLowRatioEmc(mod+1,col+1,row+1,ratio);
          
          sprintf(hnam,"%d_%d_%d_1",mod,row,col); // high gain!
          h2 = (TH2F*)f.Get(hnam);
-
+         
          //TODO: dead channels exclusion!
          if(h2) {
            h1 = h2->ProjectionX();