Modifications for TOFnoiseda:
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Apr 2009 17:16:01 +0000 (17:16 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Apr 2009 17:16:01 +0000 (17:16 +0000)
- acquisition (matching) window now read from TOFFEE
- threshold set in a Config file in OCDB (TOF/Calib/ConfigNoise)
- modified test histograms added

TOF/AliTOFNoiseConfigHandler.cxx
TOF/AliTOFNoiseConfigHandler.h
TOF/AliTOFPreprocessor.cxx
TOF/AliTOFPreprocessor.h
TOF/CreateConfigMapNoise.C [new file with mode: 0644]
TOF/ShuttleInput/TOFoutNoiseLDC_00.root
TOF/ShuttleInput/TOFoutNoiseLDC_02.root
TOF/TOFNoiseConfig.xml
TOF/TOFPreprocessor.C
TOF/TOFnoiseda.cxx

index a2b279b636fd104d54758afdb8b3540dd8cd5b0d..caac1aa8a0feaefd730dbeb6b5f357aa59c6f1c1 100644 (file)
@@ -39,8 +39,7 @@ ClassImp(AliTOFNoiseConfigHandler)
 //_____________________________________________________________________________\r
 AliTOFNoiseConfigHandler::AliTOFNoiseConfigHandler()\r
        :TObject(),\r
-        fDebugFlag(0),\r
-        fAcquisitionWindow(0)\r
+        fDebugFlag(0)\r
 {\r
        //\r
        // AliTOFNoiseConfigHandler default constructor\r
@@ -50,8 +49,7 @@ AliTOFNoiseConfigHandler::AliTOFNoiseConfigHandler()
 //_____________________________________________________________________________\r
 AliTOFNoiseConfigHandler::AliTOFNoiseConfigHandler(const AliTOFNoiseConfigHandler &sh)\r
        :TObject(sh),\r
-        fDebugFlag(sh.fDebugFlag),\r
-        fAcquisitionWindow(sh.fAcquisitionWindow)\r
+        fDebugFlag(sh.fDebugFlag)\r
 {\r
        //\r
        // AliTOFNoiseConfigHandler copy constructor\r
@@ -119,12 +117,8 @@ void AliTOFNoiseConfigHandler::OnStartElement(const char *name, const TList *att
                                fDebugFlag = 0;\r
                        }\r
                }\r
-               if (attrName == "AcquisitionWindow"){\r
-                       fAcquisitionWindow = (Int_t)(((TString)(attr->GetValue())).Atoi());\r
-               }\r
        }       \r
        AliDebug(2,Form("Debug Flag = %i",fDebugFlag)); \r
-       AliDebug(2,Form("Acquisition Window = %i",fAcquisitionWindow)); \r
        return;\r
 }\r
 //_____________________________________________________________________________\r
index a429d85ad6a3be31148e9908c4373df03eca1eec..671a9a25f38e80433d16209c98742fd676667866 100644 (file)
@@ -38,11 +38,9 @@ public:
   void          OnCdataBlock(const char *name, Int_t len);
 
   Int_t GetDebugFlag() const {return fDebugFlag;}
-  Int_t GetAcquisitionWindow() const {return fAcquisitionWindow;}
 
  private:
   Int_t fDebugFlag;          // debug flag: 0-->off, 1-->on
-  Int_t fAcquisitionWindow;  // acquisition window width in ns
 
   ClassDef(AliTOFNoiseConfigHandler,0);    // The XML file handler for the OCDB
 };
index 2d3bd7c69194559e6dfc940504c20d2828270770..780d08e206d746dfc0c8662e25bcecbe0ebc841c 100644 (file)
@@ -84,7 +84,8 @@ AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
   fNChannels(0),
   fStoreRefData(kTRUE),
   fFDRFlag(kFALSE),
-  fStatus(0)
+  fStatus(0),
+  fMatchingWindow(0)
 {
   // constructor
   AddRunType("PHYSICS");
@@ -743,6 +744,32 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
          return 20;
   }
 
+  Float_t noiseThr = 1;   // setting default threshold for noise to 1 Hz
+  // reading config map
+  AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
+  if (!cdbEntry) {
+         Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
+  }
+  else {
+         TMap *configMap = (TMap*)cdbEntry->GetObject();
+         if (!configMap){
+                 Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
+         }
+         else{
+                 TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
+                 if (strNoiseThr) {
+                         TString tmpstr = strNoiseThr->GetString();
+                         noiseThr = tmpstr.Atoi();
+                 }
+                 else {
+                         Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
+                 }
+         }
+  }
+
+  delete cdbEntry;
+  cdbEntry = 0x0;
+
   TH1::AddDirectory(0);
 
   Bool_t resultNoiseRef=kFALSE;
@@ -759,13 +786,20 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
   TFile * daqFile=0x0;
   TH1F * h1=0x0;
   
-  //retrieving Noise data 
+  // useful counters
+  Int_t nNoise = 0;
+  Int_t nNoisyChannels = 0;
+  Int_t nNotNoisyChannels = 0;
+  Int_t nChannelsFromDA = 0;
+  Int_t nMatchingWindowNullNonZero = 0;
+  Int_t nMatchingWindowNullEqualZero = 0;
+
+  // retrieving Noise data 
   TList* listNoise = GetFileSources(kDAQ, "NOISE");
   if (listNoise !=0x0 && listNoise->GetEntries()!=0)
          {
                  AliInfo("The following sources produced files with the id NOISE");
                  listNoise->Print();
-                 Int_t nNoise = 0;
                  for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
                          Int_t nNoiseSource = 0;
                          TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
@@ -779,62 +813,51 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
                                  h1 = (TH1F*) daqFile->Get("hTOFnoise");
                                  for (Int_t ibin=0;ibin<kSize;ibin++){
                                          if ((h1->GetBinContent(ibin+1))!=-1){
+                                                 nNoiseSource++;
+                                                 // checking the matching window for current channel
+                                                 if (fMatchingWindow[ibin] == 0){
+                                                         Log(Form("Matching window for channel %i null, but the channel has entries! skipping channel, BUT Please check!",ibin));
+                                                         if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++;                                             
+                                                         if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++;                                           
+                                                         continue;
+                                                 }
                                                  if ((htofNoise->GetBinContent(ibin+1))==-1){
-                                                         htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
+                                                         htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9));
+                                                         if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1)));
                                                  }
                                                  else {
                                                          Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
                                                  }
                                          }
                                  }
-                                 // elaborating infos
-                                 for (Int_t ich =0;ich<fNChannels;ich++){
-                                         if (h1->GetBinContent(ich+1)==-1) continue;
-                                         AliDebug(3,Form(" channel %i noise status before noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
-                                         //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
-                                         
-                                         /* check whether channel has been read out during current run.
-                                          * if the status is bad it means it has not been read out.
-                                          * in this case skip channel in order to leave its status 
-                                          * unchanged */
-                                         if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
-                                                 continue;
-                                         
-                                         nNoise++;
-                                         nNoiseSource++;
-                                         if (h1->GetBinContent(ich+1)>=1){  // setting limit for noise to 1 Hz
-                                                 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
-                                                 AliDebug(2,Form( " channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
-                                         }
-                                         else {
-                                                 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
-                                                 AliDebug(2,Form(" channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
-                                         }
-                                 }
-                                 
+
+                                 Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
                                  daqFile->Close();
                                  delete daqFile;
                                  delete h1;
-                                 
+                                 daqFile = 0x0;
+                                 h1 = 0x0;
+
                          }
-                         
                          else{
                                  Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle "); 
                                  delete listNoise;
+                                 listNoise = 0x0;
                                  delete htofNoise;
                                  htofNoise = 0x0;
                                  if (fStatus){
                                          delete fStatus;
                                          fStatus = 0;
                                  }
+                                 if (fMatchingWindow){
+                                         delete [] fMatchingWindow;
+                                         fMatchingWindow = 0;
+                                 }
                                  return 13;//return error code for failure in retrieving Ref Data 
                          }
-                         
-                         AliDebug(2,Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
-                 }
-                 AliDebug(2,Form(" Number of channels processed during noise run = %i",nNoise));
-                 delete listNoise;
+                 }               
          }
+                         
   else{
          Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle "); 
          delete htofNoise;
@@ -843,10 +866,53 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
                  delete fStatus;
                  fStatus = 0;
          }
+         if (fMatchingWindow){
+                 delete [] fMatchingWindow;
+                 fMatchingWindow = 0;
+         }
          return 13;//return error code for failure in retrieving Ref Data 
   }    
   
-  daqFile=0;
+  // elaborating infos to set NOISE status
+  for (Int_t ich =0;ich<fNChannels;ich++){
+         if (htofNoise->GetBinContent(ich+1)== -1) continue;
+
+         nChannelsFromDA++;
+
+         AliDebug(3,Form(" channel %i noise status before noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
+         //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
+         
+         /* check whether channel has been read out during current run.
+          * if the status is bad it means it has not been read out.
+          * in this case skip channel in order to leave its status 
+          * unchanged */
+
+         if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
+                 continue;
+         
+         nNoise++;
+         if (htofNoise->GetBinContent(ich+1) >= noiseThr){
+                 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
+                 AliDebug(3,Form( " channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
+                 nNoisyChannels++;
+         }
+         else {
+                 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
+                 AliDebug(3,Form(" channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
+                 nNotNoisyChannels++;
+         }
+  }
+  
+  Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA));
+  Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise));
+  Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels));
+  Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels));
+  Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero));
+  Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero));
+
+  delete listNoise;
+  
+  //daqFile=0;
   
   //storing in OCDB
   
@@ -864,6 +930,10 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
            delete fStatus;
            fStatus = 0;
     }
+    if (fMatchingWindow){
+           delete [] fMatchingWindow;
+           fMatchingWindow = 0;
+    }
     return 14;//return error code for problems in storing Noise data 
   }
 
@@ -885,6 +955,10 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
              delete fStatus;
              fStatus = 0;
       }
+      if (fMatchingWindow){
+             delete [] fMatchingWindow;
+             fMatchingWindow = 0;
+      }
       return 12;//return error code for failure in storing Ref Data 
     }
   }
@@ -897,6 +971,11 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
     fStatus = 0;
   }
 
+  if (fMatchingWindow){
+         delete [] fMatchingWindow;
+         fMatchingWindow = 0;
+  }
+
   return 0;
 }
 //_____________________________________________________________________________
@@ -928,6 +1007,8 @@ UInt_t AliTOFPreprocessor::ProcessFEEData()
    * if stored FEE is different from current FEE set update flag.
    * if there is no stored FEE in OCDB set update flag */
   
+  fMatchingWindow = new Int_t[fNChannels];
+
   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
   if (!cdbEntry) {
          /* no CDB entry found. set update flag */
@@ -949,19 +1030,20 @@ UInt_t AliTOFPreprocessor::ProcessFEEData()
          /* compare current FEE channel status with stored one 
           * if different set update flag and break loop */
          //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
+         fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel);
          if (feeReader.IsChannelEnabled(iChannel)) {
                  hCurrentFEE.SetBinContent(iChannel + 1, 1);
                  if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
                          updateOCDB = kTRUE;
                          fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
-                         AliDebug(2,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
+                         AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
                  }
          }
          else {
                  if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
                          updateOCDB = kTRUE;
                          fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
-                         AliDebug(2,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
+                         AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
                  }
          }
   }
index 72f79f9ac5a03b883a03558167dbb5af25305224..a54ac7b94ff394fa457020da030e992625e85dc9 100644 (file)
@@ -53,6 +53,8 @@ class AliTOFPreprocessor : public AliPreprocessor
     Bool_t fStoreRefData;                    // Flag to decide storage of Ref Data
     Bool_t fFDRFlag;                         // Flag for FDR runs 
     AliTOFChannelOnlineStatusArray *fStatus; // Array with TOF channels' status
-    ClassDef(AliTOFPreprocessor, 0);
+    Int_t *fMatchingWindow;                  //[fNChannels]
+                                             // Array of matching windows (one per channel) - to be used in noise runs
+    ClassDef(AliTOFPreprocessor, 0);         
 };
 #endif
diff --git a/TOF/CreateConfigMapNoise.C b/TOF/CreateConfigMapNoise.C
new file mode 100644 (file)
index 0000000..17e5720
--- /dev/null
@@ -0,0 +1,17 @@
+void CreateConfigMapNoise(const char* noiseThr="1"){
+
+       // Create Configuration Map entry for OCDB 
+       // to configure AliTOFPreprocessor to run over Noise runs
+       // USAGE: 
+       // - "NoiseThr" is the threshold to declare a channel as noisy 
+       
+       TMap *mapTOF = new TMap();
+       mapTOF->Add(new TObjString("NoiseThr"),new TObjString(noiseThr));
+       AliCDBManager *man = AliCDBManager::Instance();
+       man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+       AliCDBId id("TOF/Calib/ConfigNoise",0,AliCDBRunRange::Infinity());
+       AliCDBMetaData* md = new AliCDBMetaData();
+       md->SetResponsible("Chiara Zampolli");
+       md->SetComment("Configuration parameter for nose runs");
+       man->Put(mapTOF,id,md);
+}
index bf4e225bbf1be1eb290f2b082ec0888f46a0acb0..558ef21917c244beee08e9fa2b26397f03557d0c 100644 (file)
Binary files a/TOF/ShuttleInput/TOFoutNoiseLDC_00.root and b/TOF/ShuttleInput/TOFoutNoiseLDC_00.root differ
index f368187dc9606df6cc750bdac55123039c2bac67..ac4385c1207db4adf1d59c3b9e5ce17f3ec130c6 100644 (file)
Binary files a/TOF/ShuttleInput/TOFoutNoiseLDC_02.root and b/TOF/ShuttleInput/TOFoutNoiseLDC_02.root differ
index 4de03c7a41de05d8991cf882c3e70d409903e500..8a1ef001f36773718770ee3fb25cf2ae3874af90 100644 (file)
@@ -3,9 +3,8 @@
 <!ELEMENT TOFConfig (Folder)>
 <!ELEMENT Folder EMPTY>
 <!ATTLIST Folder DebugFlag CDATA #REQUIRED>
-<!ATTLIST Folder AcquisitionWindow CDATA #REQUIRED>
 ]>
 <TOFConfig>
-<Folder DebugFlag="On" AcquisitionWindow="200">
+<Folder DebugFlag="On">
 </Folder>
 </TOFConfig>
index ec59993be553d9b521183aee46d4b5686266e3a9..64679b5fcfdac413bdd8d1fafd66859c4abb7ac8 100644 (file)
@@ -37,18 +37,22 @@ void TOFPreprocessor(Char_t * RunType="PHYSICS")
   // processing files. for the time being, the files are local.
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
-  shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20080310.163032.4000");
-  char filename[100];
-  char LDCname[5];
+  shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20090401.182503.67577");
+
+  TString filename;
+  TString LDCname;
+  //char filename[100];
+  //char LDCname[5];
 
   for (Int_t iLDC=0;iLDC<2;iLDC++){
-    sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
-    sprintf(LDCname,"LDC%i",iLDC*2);
+    filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
+    LDCname.Form("LDC%i",iLDC*2);
     shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename);
-    sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
-    sprintf(LDCname,"LDC%i",iLDC*2);
+    filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
+    LDCname.Form("LDC%i",iLDC*2);
     shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename);
   }
+  
 
   // instantiation of the preprocessor
   AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
index 9ca0ce980620596088bdd391f38626c8184ea188..e7d9c69f2b60bd83eda22c18417450c753f75413 100644 (file)
@@ -98,14 +98,10 @@ int main(int argc, char **argv) {
          printf("Failed parsing config file! retunring... \n");
          return -1;
   }
+
   Int_t debugFlag = tofHandler->GetDebugFlag();
-  Int_t acquisitionWindow = tofHandler->GetAcquisitionWindow();
-  if (acquisitionWindow == 0){
-         printf("Problems with the acquisition window, set to zero! returning...\n");
-         return -1;
-  }
+
   printf("the debug flag is %i\n",debugFlag);
-  printf("the acquisition window is %i (ns)\n",acquisitionWindow);
 
   /* init some counters */
   int nevents_physics=0;
@@ -229,9 +225,9 @@ int main(int argc, char **argv) {
              Volume[3] = Volume[4];
              Volume[4] = dummy;
              Int_t index = geom->GetIndex(Volume);
-             Bool_t found =kFALSE;
              // to check array indexes
              /*
+             Bool_t found =kFALSE;
              for (Int_t j=0;j<nchDDL;j++){
                if (index==array[j]) {
                  found = kTRUE;
@@ -283,7 +279,7 @@ int main(int argc, char **argv) {
 
   Int_t noisyChannels = 0;
   Int_t checkedChannels = 0;
-  Float_t time = nevents_physics*acquisitionWindow*1E-9; // acquisition time in s
+  Float_t time = nevents_physics; // acquisition time in number of events
   //printf(" Noise run lasted %f s \n",time);
   for (Int_t ibin =1;ibin<=size;ibin++){
     Float_t cont = htofNoise->GetBinContent(ibin);