float checkIDRegion(double myEta, double myPhi, double deltaR, TString runnumber) { // Get the histograms TFile *f = new TFile("IDDQ_152409.root","READ"); // The active/inactive maps (not using the BS) TH2F *active; TH2F *inactive; gFile->GetObject("etaPhiDeadBLayer",inactive); gFile->GetObject("etaPhiActiveBLayer",active); // The raw number of tracks passing active or inactive B-Layer modules // for bins within the region. int nInactive = 0; int nActive = 0; if(myPhi < 0) myPhi += 2*3.14; // Define the region Double_t etaMin = myEta-deltaR; Double_t etaMax = myEta+deltaR; Double_t phiMin = myPhi-deltaR; Double_t phiMax = myPhi+deltaR; // Step size is set by the histogram binning Double_t stepSize = active->GetBinWidth(1); // Number of steps Int_t etaSteps = (etaMax-etaMin)/stepSize; Int_t phiSteps = (phiMax-phiMin)/stepSize; // The points to check Double_t theEta; Double_t thePhi; theEta=etaMin; for(int i=0; i<=etaSteps+1; i++){ thePhi=phiMin; for (int k =0; k<=phiSteps+1; k++){ // Checks the current point. (Updates nInactive and nActive) checkIDDQ(theEta,thePhi,nInactive, nActive, runnumber,inactive,active); thePhi = thePhi + stepSize; } theEta = theEta + stepSize; } // cout << "Eta: " << myEta << " Phi: " << myPhi << endl; // // If we dont see any inactive declare the region as good. // if(nInactive == 0) // cout << " Not near inactive BLayer region " << endl; // // // If we see tracks passing inactive regions, // // report it and provide the difference in the nActive and nInactive // // as an indication of how questionable the region is. // else{ // cout << " Near inactive BLayer region " << endl; // cout << " Saftey score: " << std::setprecision(2) << float(nInactive)/(nActive + nInactive) << endl; // } f->Close(); float safetyscore = 0; // All good unless told otherwise if (nActive) { safetyscore = float(nInactive)/(nActive + nInactive); } return safetyscore; }