X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSOnlineSPDphysAnalyzer.cxx;h=98342cfda6d73d6dbec32446abc96299b7156db0;hb=08b801a6de165ef29fb388dc4fc9c0516b7b9486;hp=f12f08da77876f25dd172ad21a55db66bcdd8d4a;hpb=38aa9b59172968d2b8d2eeebba24604619d6216e;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSOnlineSPDphysAnalyzer.cxx b/ITS/AliITSOnlineSPDphysAnalyzer.cxx index f12f08da778..98342cfda6d 100644 --- a/ITS/AliITSOnlineSPDphysAnalyzer.cxx +++ b/ITS/AliITSOnlineSPDphysAnalyzer.cxx @@ -34,7 +34,9 @@ #include #include -AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(const Char_t *fileName, AliITSOnlineCalibrationSPDhandler* handler) : +using std::ifstream; + +AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(const Char_t *fileName, AliITSOnlineCalibrationSPDhandler* handler, Bool_t readFromGridFile) : fFileName(fileName),fPhysObj(NULL),fHandler(handler), fNrEnoughStatChips(0),fNrDeadChips(0),fNrInefficientChips(0), fNrEqHits(0),fbDeadProcessed(kFALSE), @@ -44,7 +46,7 @@ AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(const Char_t *fileName, fMinNrEqHitsForDeadChips(60000),fRatioToMeanForInefficientChip(0.1) { // constructor - Init(); + Init(readFromGridFile); } AliITSOnlineSPDphysAnalyzer::AliITSOnlineSPDphysAnalyzer(AliITSOnlineSPDphys* physObj, AliITSOnlineCalibrationSPDhandler* handler) : @@ -114,16 +116,18 @@ AliITSOnlineSPDphysAnalyzer& AliITSOnlineSPDphysAnalyzer::operator=(const AliITS return *this; } -void AliITSOnlineSPDphysAnalyzer::Init() { +void AliITSOnlineSPDphysAnalyzer::Init(Bool_t readFromGridFile) { // initialize container obj - FILE* fp0 = fopen(fFileName.Data(), "r"); - if (fp0 == NULL) { - return; - } - else { - fclose(fp0); + if (!readFromGridFile) { + FILE* fp0 = fopen(fFileName.Data(), "r"); + if (fp0 == NULL) { + return; + } + else { + fclose(fp0); + } } - fPhysObj = new AliITSOnlineSPDphys(fFileName.Data()); + fPhysObj = new AliITSOnlineSPDphys(fFileName.Data(), readFromGridFile); } void AliITSOnlineSPDphysAnalyzer::SetParam(const Char_t *pname, const Char_t *pval) { @@ -267,6 +271,91 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessNoisyPixels() { return nrEnoughStatChips; } +UInt_t AliITSOnlineSPDphysAnalyzer::ProcessNoisyPixels(UInt_t eq, UInt_t nrEvts) { + // process noisy pixel data , returns number of chips with enough statistics + if (fPhysObj==NULL) { + Warning("AliITSOnlineSPDphysAnalyzer::ProcessNoisyPixels","No data!"); + return 0; + } + // do we have enough events to even try the algorithm? + if (nrEvts < fMinEventsForNoisy) { + Warning("AliITSOnlineSPDphysAnalyzer::ProcessNoisyPixels","Nr events (%d) < fMinEventsForNoisy (%d)!",nrEvts,fMinEventsForNoisy); + return 0; + } + // handler should be initialized + if (fHandler==NULL) { + Error("AliITSOnlineSPDphysAnalyzer::ProcessNoisyPixels","Calibration handler is not initialized!"); + return 0; + } + + UInt_t nrEnoughStatChips = 0; + + for (UInt_t hs=0; hs<6; hs++) { + for (UInt_t chip=0; chip<10; chip++) { + + UInt_t nrPixels = 0; + UInt_t nrChipHits = 0; + UInt_t nrMostHits = 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 (nrHits>0) nrPixels++; // don't include pixels that might be dead + nrPixels++; + if (nrHits>fDefinitelyNoisyRatio*nrEvts) { + fHandler->SetNoisyPixel(eq,hs,chip,col,row); + nrPixels--; + nrChipHits-=nrHits; + } + else { + if (nrMostHits0) { // otherwise there are for sure no noisy + // Binomial with n events and probability p for pixel hit + UInt_t n = nrEvts; + if (nrPixels>0 && n>0) { + + Double_t p = (Double_t)nrChipHits/nrPixels/n; + + // Bin(n,k=0): + Double_t bin = pow((Double_t)(1-p),(Double_t)n); + // Bin(n,k) + UInt_t k=1; + while ((bin>fThreshNoisy || k=noiseLimit) { + 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 >= noiseLimit) { + fHandler->SetNoisyPixel(eq,hs,chip,col,row); + } + } + } + } + } + } + + } + + } // for chip + } // for hs + + return nrEnoughStatChips; +} + UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() { // process dead pixel data , returns number of chips with enough statistics @@ -476,11 +565,42 @@ void AliITSOnlineSPDphysAnalyzer::Exponent(Double_t &val, Int_t &valExp) const { valExp--; } } +//____________________________________________________________________________________________________ +TH2F* AliITSOnlineSPDphysAnalyzer::GetPhysicalHitMapTot() { + // creates and returns a pointer to a hitmap histo (equipment opened up) + // physical representation of the half stave hitmap. - - + if (fPhysObj==NULL) { + Error("AliITSOnlineSPDphysAnalyzer::GetPhysicalHitMapTot","No data!"); + return NULL; + } + TString histoname = Form("Eq %d",GetEqNr()); + TH2F* hPhysicalHitMapTot = new TH2F(histoname.Data(),histoname.Data(),32*10,-0.5,32*10-0.5,256*6,-0.5,256*6-0.5); + hPhysicalHitMapTot->SetNdivisions(-10,"X"); + hPhysicalHitMapTot->SetNdivisions(-006,"Y"); + hPhysicalHitMapTot->SetTickLength(0,"X"); + hPhysicalHitMapTot->SetTickLength(0,"Y"); + hPhysicalHitMapTot->GetXaxis()->SetLabelColor(gStyle->GetCanvasColor()); + hPhysicalHitMapTot->GetYaxis()->SetLabelColor(gStyle->GetCanvasColor()); + Int_t correctChip=-1; + for (UInt_t hs=0; hs<6; hs++) { + for (UInt_t chipNr=0; chipNr<10; chipNr++) { + if(GetEqNr()<10) correctChip=9-chipNr; + else correctChip=chipNr; + for (UInt_t col=0; col<32; col++) { + for (UInt_t row=0; row<256; row++) { + if(hs>1) hPhysicalHitMapTot->Fill(correctChip*32+(31-col),(5-hs)*256+row,fPhysObj->GetHits(hs,chipNr,col,row)); + else hPhysicalHitMapTot->Fill(correctChip*32+col,(5-hs)*256+row,fPhysObj->GetHits(hs,chipNr,col,row)); + } + } + } + } + return hPhysicalHitMapTot; +} +//_____________________________________________________________________________________________________ TH2F* AliITSOnlineSPDphysAnalyzer::GetHitMapTot() { // creates and returns a pointer to a hitmap histo (half sector style a la spdmood) + // This histogram shown the read out numbering pattern, it is not the physical one. if (fPhysObj==NULL) { Error("AliITSOnlineSPDphysAnalyzer::GetHitMapTot","No data!"); return NULL; @@ -504,7 +624,7 @@ TH2F* AliITSOnlineSPDphysAnalyzer::GetHitMapTot() { } return fHitMapTot; } - +//________________________________________________________________________________________________________ TH2F* AliITSOnlineSPDphysAnalyzer::GetHitMapChip(UInt_t hs, UInt_t chip) { // creates and returns a pointer to a hitmap histo (chip style a la spdmood) if (fPhysObj==NULL) { @@ -521,9 +641,11 @@ TH2F* AliITSOnlineSPDphysAnalyzer::GetHitMapChip(UInt_t hs, UInt_t chip) { returnHisto->SetMinimum(0); for (UInt_t col=0; col<32; col++) { for (UInt_t row=0; row<256; row++) { - returnHisto->Fill(col,row,fPhysObj->GetHits(hs,chip,col,row)); + if(hs<2) returnHisto->Fill(31-col,row,fPhysObj->GetHits(hs,chip,col,row)); + else returnHisto->Fill(col,row,fPhysObj->GetHits(hs,chip,col,row)); } } return returnHisto; } +