new method (ProcessNoiseMap) added , it saves a new object in OCDB (OCDB/HMPID/Calib...
authorgvolpe <gvolpe@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Feb 2010 11:36:23 +0000 (11:36 +0000)
committergvolpe <gvolpe@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Feb 2010 11:36:23 +0000 (11:36 +0000)
HMPID/AliHMPIDPreprocessor.cxx
HMPID/AliHMPIDPreprocessor.h
HMPID/Hshuttle.C

index 4e38d0b..12d3f3a 100644 (file)
@@ -42,7 +42,7 @@ UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
 
   TString runType = GetRunType();
   Log(Form(" AliHMPIDPreprocessor: RunType is %s",runType.Data()));
-  
+  Bool_t statusNoise=kFALSE, statusDcs=kFALSE;
 // start to check event type and procedures
   
   Log("HMPID - Process in Preprocessor started");
@@ -55,17 +55,52 @@ UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
     } else {
        Log("HMPID - Pedestal processing successful!!");                    return kFALSE;  // ok for pedestals
     }
-  } else if ( runType=="STANDALONE" || runType=="PHYSICS"){
-  if (!ProcDcs(pMap)){
-       Log("HMPID - ERROR - DCS processing failed!!");                     return kTRUE;   // error in DCS processing
-    } else {
-       Log("HMPID - DCS processing successful!!");                         return kFALSE;  // ok for DCS
-    }
-  } else {
+  }//CALIBRATION
+  else if ( runType=="STANDALONE" || runType=="PHYSICS"){   
+   statusDcs=ProcDcs(pMap);
+   statusNoise=ProcNoiseMap();
+   if(!statusDcs || !statusNoise) { Log(Form("HMPID - ERROR - Noise Map(%d) and/or DCS(%d) processing failed!! (0=OK, 1=FAILED)",statusNoise,statusDcs)); return kTRUE; }  // error in Noise Map or DCS processing
+   else                           { Log("HMPID - Noise Map and DCS processing successful!!");  return kFALSE;}  // ok
+  }//STANDALONE or PHYSICS run
+   else {
     Log("HMPID - Nothing to do with preprocessor for HMPID, bye!");         return kFALSE;  // ok - nothing done
   }
 }//Process()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Bool_t AliHMPIDPreprocessor::ProcNoiseMap()
+{
+  //
+  // Goal: Process the Noise Map created by the HMP Physics DA to mask 
+  // noisy channels from reconstruction and follow changes in accepatnce
+  // eg. DDL turn on/off after PEDESTAL run and between PHYSICS runs.
+  // Returns kFALSE on success
+  Bool_t stProcNoise=kFALSE;
+  TFile  *fNoiseFile;
+  TH2F   *hNoiseMap = 0x0;
+  
+  TList *pNoiseSource=GetFileSources(kDAQ,"HmpPhysicsDaNoiseMap.root"); //get list of DAQ source names containing id "HmpPhysicsDaNoiseMap" --> defined in HMPIDphysda.cxx
+  if(!pNoiseSource) {Log(Form("ERROR: Retrieval of sources for noise map: HmpPhysicsDaNoiseMap.root is failed!")); return stProcNoise;}
+  
+  TString noiseFile = GetFile(kDAQ,Form("HmpPhysicsDaNoiseMap.root"),((TObjString*)pNoiseSource->At(0))->GetName());
+  if(noiseFile.Length()==0) {Log(Form("ERROR retrieving noise map file: HmpPhysicsDaNoiseMap.root")); return stProcNoise;}
+  
+  fNoiseFile = TFile::Open(noiseFile.Data(),"read");
+  if(!fNoiseFile) {Log(Form("ERROR cannot open NoiseFile: %s!",noiseFile.Data())); return stProcNoise;}
+  hNoiseMap = (TH2F*) fNoiseFile->Get("hHmpNoiseMaps");
+  
+  AliCDBMetaData metaDataHisto;
+  metaDataHisto.SetBeamPeriod(0);
+  metaDataHisto.SetResponsible("AliHMPIDPreprocessor"); 
+  metaDataHisto.SetComment("AliHMPIDPreprocessor stores the Noise Map object as Reference Data.");
+  AliInfo("Storing Reference Data");
+  stProcNoise = Store("Calib","NoiseMap",hNoiseMap,&metaDataHisto,0,kTRUE);
+  if(!stProcNoise) {
+    Log("HMPID - failure to store Noise Map data results in OCDB");    
+  }
+  return stProcNoise;
+}//ProcNoiseMap
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Bool_t AliHMPIDPreprocessor::ProcDcs(TMap* pMap)
 {
 // Process: 1 (old). inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator
@@ -258,13 +293,15 @@ Bool_t AliHMPIDPreprocessor::ProcPed()
 // Returns: kTRUE on success
   
   Bool_t stPedStore=kFALSE;
+  Bool_t stDeadMaskedStore=kFALSE;
   AliHMPIDDigit dig;
   AliHMPIDRawStream rs;
   Int_t nSigCut,r,d,a,hard;  Float_t mean,sigma;
   Int_t  runNumber,ldcId,timeStamp,nEv,nDdlEv,nBadEv;  Char_t tName[10]; 
   Float_t nBadEvPer;
   
-  TObjArray aDaqSig(7); aDaqSig.SetOwner(kTRUE); for(Int_t i=0;i<7;i++) aDaqSig.AddAt(new TMatrix(160,144),i); //TObjArray of 7 TMatrixF, m(padx,pady)=sigma
+  TObjArray aDaqSig(7);     aDaqSig.SetOwner(kTRUE);     for(Int_t i=0;i<7;i++) aDaqSig.AddAt(new TMatrix(160,144),i);         //TObjArray of 7 TMatrixF, m(padx,pady)=sigma
+  TObjArray aDeadMasked(7); aDeadMasked.SetOwner(kTRUE); for(Int_t i=0;i<7;i++) aDeadMasked.AddAt(new TMatrix(160,144),i);     //TObjArray of 7 TMatrixF, m(padx,pady)=pedestal
   
   for(Int_t iddl=0;iddl<AliHMPIDRawStream::kNDDL;iddl++)            //retrieve the files from LDCs independently the DDL<->LDC connection
   {
@@ -281,7 +318,7 @@ Bool_t AliHMPIDPreprocessor::ProcPed()
     
     if(!infile.is_open()) {Log("No pedestal file found for HMPID,bye!");continue;}
     TMatrix *pM=(TMatrixF*)aDaqSig.At(iddl/2);
-  
+    TMatrix *pDM=(TMatrixF*)aDeadMasked.At(iddl/2);
     infile>>tName>>runNumber;Printf("Xcheck: reading run %i",runNumber);
     infile>>tName>>ldcId;
     infile>>tName>>timeStamp;
@@ -296,11 +333,16 @@ Bool_t AliHMPIDPreprocessor::ProcPed()
       dig.SetPad(rs.GetPad(iddl,r,d,a));
       dig.SetQ((Int_t)mean);
       (*pM)(dig.PadChX(),dig.PadChY()) = sigma;
+      if( (mean == AliHMPIDParam::kPadMeanZeroCharge && sigma == AliHMPIDParam::kPadSigmaZeroCharge) || 
+          (mean == AliHMPIDParam::kPadMeanMasked     && sigma == AliHMPIDParam::kPadSigmaMasked)     ) 
+        {(*pDM)(dig.PadChX(),dig.PadChY()) = mean;} 
       }
     }
     infile.close();
     Log(Form("Pedestal file for DDL %i read successfully",iddl));
   
+    
   }//LDCs reading entries
 
  }//DDL 
@@ -310,11 +352,11 @@ Bool_t AliHMPIDPreprocessor::ProcPed()
   metaData.SetResponsible("AliHMPIDPreprocessor"); 
   metaData.SetComment("HMPID processor fills TObjArrays.");  
   stPedStore = Store("Calib","DaqSig",&aDaqSig,&metaData,0,kTRUE);
-//  stPedStore = Store("Calib","DaqSig",&aDaqSig,&metaData);
-  if(!stPedStore) {
-    Log("HMPID - failure to store PEDESTAL data results in OCDB");    
-  }
-  return stPedStore;
+  if(!stPedStore) {     Log("HMPID - failure to store PEDESTAL data results in OCDB");      }
+  stDeadMaskedStore = Store("Calib","Masked",&aDeadMasked,&metaData,0,kTRUE);
+  if(!stDeadMaskedStore) {     Log("HMPID - failure to store DEAD & MASKED channel map  in OCDB");      }
+  Bool_t pedRes=stPedStore*stDeadMaskedStore;
+  return pedRes;
   
 }//ProcPed()  
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index 63be3d3..db0ba94 100644 (file)
@@ -21,13 +21,14 @@ public:
            }
   virtual ~AliHMPIDPreprocessor(                             )                                 {}
 protected:
-  virtual void     Initialize(Int_t run, UInt_t startTime, UInt_t endTime); //
-  virtual UInt_t   Process   (TMap* pDcsMap                              ); //process everthing
-          Bool_t   ProcDcs   (TMap* pDcsMap                              ); //process DCS data points
-          Bool_t   ProcPed   (                                           ); //process pedestal files
-          Double_t ProcTrans (TMap *pDcsMap                              );
+  virtual void     Initialize  (Int_t run, UInt_t startTime, UInt_t endTime); //
+  virtual UInt_t   Process     (TMap* pDcsMap                              ); //process everthing
+          Bool_t   ProcDcs     (TMap* pDcsMap                              ); //process DCS data points
+          Bool_t   ProcNoiseMap(                                           ); //process Nosie Map from HMP Physics DA
+          Bool_t   ProcPed     (                                           ); //process pedestal files
+          Double_t ProcTrans   (TMap *pDcsMap                              );
           Double_t DefaultEMean();                                          //set a default value in ePhotMean                             
-  ClassDef(AliHMPIDPreprocessor, 0);
+  ClassDef(AliHMPIDPreprocessor, 1);
 };
 
 #endif
index 03befe4..d3fbd41 100644 (file)
@@ -8,9 +8,9 @@ void Hshuttle(Int_t runTime=1500)
   TMap *pDcsMap = new TMap;       pDcsMap->SetOwner(1);          //DCS archive map
   
   AliTestShuttle* pShuttle = new AliTestShuttle(0,0,1000000);   
-//  pShuttle->SetInputRunType("PHYSICS");
-//  pShuttle->SetInputRunType("CALIBRATION");
-  pShuttle->SetInputRunType("PHYSICS");
+  //pShuttle->SetInputRunType("PHYSICS");
+  pShuttle->SetInputRunType("CALIBRATION");
+  //pShuttle->SetInputRunType("STANDALONE");
   SimPed();   
   for(Int_t ldc=51;ldc<=52;ldc++) 
   {
@@ -18,15 +18,38 @@ void Hshuttle(Int_t runTime=1500)
    if(ldc==52) {for(Int_t iddl=8;iddl<=13;iddl++) pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP",Form("HmpidPedDdl%02i.txt",iddl),Form("LDC%i",ldc),Form("HmpidPedDdl%02i.txt",iddl));}
   }
   SimMap(pDcsMap,runTime); pShuttle->SetDCSInput(pDcsMap);                                    //DCS map
+  SimNoiseMap();           pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP", "HmpPhysicsDaNoiseMap.root", "MON", "./HmpPhysicsDaNoiseMap.root");                                                                          //Simulate Noise Map
   
+    
   AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle); pShuttle->Process();              //here goes preprocessor  
 //  delete pp;   
 
   DrawInput(pDcsMap); DrawOutput();
-  gSystem->Exec("rm -rf HmpidPedDdl*.txt");
-
+  
+  gSystem->Exec("rm -rf HmpidPedDdl*.txt");                 //delete simulated files
+  gSystem->Exec("rm -rf ./HmpPhysicsDaNoiseMap.root");      //delete simulated file
+  
 }//Hshuttle()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void SimNoiseMap()
+{
+  //
+  // Simulate the noise map that will be extracted by the HMP Physics DA from PHYSICS and STANDALONE runs
+  //
+  TRandom rnd;
+  TH2F *hHmpNoiseMaps=new TH2F("hHmpNoiseMaps","Noise Maps Ch: 0-7;Ch 0-7: pad X;Ch0, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6 pad Y ;Noise level (\%)",160,0,160,144*7,0,144*7); //In y we have all 7 chambers
+  Int_t events=2000;
+  for(Int_t nev=0;nev<events;nev++) 
+    for(Int_t npads=0;npads<350;npads++)  //average 5- pads times 7 chambers
+      hHmpNoiseMaps->Fill(rnd.Integer(160),rnd.Integer(7)*144+rnd.Integer(144));
+  
+  if(events!=0) hHmpNoiseMaps->Scale(1.0/events);
+  TFile *fout = new TFile("HmpPhysicsDaNoiseMap.root","recreate");
+  hHmpNoiseMaps->Write();
+  fout->Close();
+  Printf("==> HMP Noise Map simulation has finished!");
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void SimPed()
 {
   Int_t iDDLmin=0,iDDLmax=13;
@@ -47,7 +70,9 @@ void SimPed()
         for(Int_t adr=0;adr<=47;adr++){
           Float_t mean  = 150+200*gRandom->Rndm();
           Float_t sigma = 1+0.3*gRandom->Gaus();
-          Int_t inhard=((Int_t(mean+nSigmas*sigma))<<9)+Int_t(mean); //right calculation, xchecked with Paolo 8/4/2008
+          if(ddl==7 && row == 10 && dil == 6 ) {mean =  AliHMPIDParam::kPadMeanMasked ; sigma = AliHMPIDParam::kPadSigmaMasked;}                 //to test the dead channel map
+          if(ddl==7 && row == 10 && dil == 4 ) {mean =  AliHMPIDParam::kPadMeanMasked ; sigma = AliHMPIDParam::kPadSigmaMasked;}                 //to test the dead channel map
+          Int_t inhard=((Int_t(mean+nSigmas*sigma))<<9)+Int_t(mean);                                                                             //right calculation, xchecked with Paolo 8/4/2008
           out << Form("%2i %2i %2i %5.3f %5.3f %4.4x \n",row,dil,adr,mean,sigma,inhard);
         }
 
@@ -162,28 +187,43 @@ void DrawInput(TMap *pDcsMap)
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void DrawOutput()
 {
-  AliCDBManager::Instance()->SetDefaultStorage("local://$HOME"); AliCDBManager::Instance()->SetRun(0);
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); AliCDBManager::Instance()->SetRun(0);
   AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre");
   AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean");
   AliCDBEntry *pDaqSigEnt=AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");
+  AliCDBEntry *pDaqMaskedEnt=AliCDBManager::Instance()->Get("HMPID/Calib/Masked");
+  AliCDBEntry *pNoiseEnt=AliCDBManager::Instance()->Get("HMPID/Calib/NoiseMap");
   
-  if(!pQthreEnt || !pNmeanEnt || !pDaqSigEnt) return;
+  if(!pQthreEnt || !pNmeanEnt || !pDaqSigEnt || !pDaqMaskedEnt) return;
   
   TObjArray *pNmean =(TObjArray*)pNmeanEnt ->GetObject(); 
   TObjArray *pQthre =(TObjArray*)pQthreEnt ->GetObject(); 
   TObjArray *pDaqSig=(TObjArray*)pDaqSigEnt->GetObject();
-   
+  TObjArray *pDaqMasked=(TObjArray*)pDaqMaskedEnt->GetObject();
+  TH2F      *pNoiseMap = (TH2F*)pNoiseEnt->GetObject();      
+  
   TF1 *pRad0,*pRad1,*pRad2;  
   TCanvas *c2=new TCanvas("c2","Output",800,800); c2->Divide(3,3);
+  TCanvas *c3=new TCanvas("c3","Output Masked",800,800); c3->Divide(3,3);
+  TCanvas *c4=new TCanvas("c4","Noise",800,800); 
   
   TH1F *pSig[7];
+  TH2F *phMask[7]; 
   
   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
     TMatrix *pM=(TMatrix*)pDaqSig->At(iCh);
+    TMatrix *pmMask=(TMatrix*)pDaqMasked->At(iCh);
     
     pSig[iCh]=new TH1F(Form("sig%i",iCh),"Sigma;[QDC]",100,-5,20); //pSig[iCh]->SetLineColor(iCh+kRed);
-    for(Int_t padx=0;padx<160;padx++) for(Int_t pady=0;pady<144;pady++) pSig[iCh]->Fill((*pM)(padx,pady));
-    
+    phMask[iCh]=new TH2F(Form("phMask%i",iCh),"Maksed;pad x;pad y;Q (ADC)",160,0,160,144,0,144); 
+    for(Int_t padx=0;padx<160;padx++) 
+    {
+      for(Int_t pady=0;pady<144;pady++)
+      { 
+        pSig[iCh]->Fill((*pM)(padx,pady));
+        phMask[iCh]->Fill(padx,pady,(*pmMask)(padx,pady));
+       }
+     }
     c2->cd(7);    if(iCh==0) pSig[iCh]->Draw(); else pSig[iCh]->Draw("same");
     
     if(iCh==6) c2->cd(1);  if(iCh==5) c2->cd(2);                          
@@ -193,6 +233,17 @@ void DrawOutput()
     TF1 *pRad0=(TF1*)pNmean->At(iCh*3+0); pRad0->Draw();  pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
     TF1 *pRad1=(TF1*)pNmean->At(iCh*3+1); pRad1->Draw("same");
     TF1 *pRad2=(TF1*)pNmean->At(iCh*3+2); pRad2->Draw("same");
-  }//chambers loop    
+     
+    if(iCh==6) c3->cd(1);  if(iCh==5) c3->cd(2);                          
+    if(iCh==4) c3->cd(4);  if(iCh==3) c3->cd(5);  if(iCh==2) c3->cd(6);
+                           if(iCh==1) c3->cd(8);  if(iCh==0) c3->cd(9); 
+     phMask[iCh]->Draw("colz");
+    
+  }//chambers loop   
+  
+  c4->cd();
+  pNoiseMap->Draw("colz");
+  
+   
 }//DrawOutput()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++