diff --git a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/ISCT_CalibHistoSvc.cxx b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/ISCT_CalibHistoSvc.cxx deleted file mode 100644 index 83d901596e143792109bfe9ed5acf2c68b4f4f1c..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/ISCT_CalibHistoSvc.cxx +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -/** - * @file ISCT_CalibHistoSvc.cxx - * Implementation file to interface class for histograms in the SCT_CalibAlgs package - * @author Shaun Roe -**/ -#include "SCT_CalibAlgs/ISCT_CalibHistoSvc.h" -#include "TH1I.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TMath.h" -#include <stdexcept> // out_of_range exception - -int ISCT_CalibHistoSvc::m_nLb=0; -int ISCT_CalibHistoSvc::m_nLbMerge=0; - -ISCT_CalibHistoSvc::ISCT_CalibHistoSvc():m_numberOfEventsHisto(0),m_thistSvc(0),m_pSCTHelper(0) { - //std::cout<<"Instantiation of ISCT_CalibHistoSvc"<<std::endl; - //nop -} - -int -ISCT_CalibHistoSvc::getNumberOfEventsInBin(const int nbin) { - if (m_numberOfEventsHisto) return m_numberOfEventsHisto->GetBinContent(nbin); - std::cout << "ERROR: a histogram pointer, m_numberOfEventsHisto, is zero" << std::endl; - return 0; -} - -int -ISCT_CalibHistoSvc::size() { - return m_numberOfEventsHisto->GetEntries(); -} - - -int -ISCT_CalibHistoSvc::size(const int histogramIndex) { - TH1F* pHisto=0; - int result=0; - try { - pHisto=m_phistoVector.at(histogramIndex); - result = pHisto->GetEntries(); - } catch (const std::out_of_range& outOfRange) { - //do nothing, result is zero if the vector<>.at() throws - } - return result; -} - -double -ISCT_CalibHistoSvc::getBinForHistogramIndex(const int bin, const int histogramIndex) { - TH1F* pHisto=0; - double result=0.0; - try { - pHisto=m_phistoVector.at(histogramIndex); - result = pHisto->GetBinContent(bin); - } catch (const std::out_of_range& outOfRange) { - //do nothing, result is zero if the vector<>.at() throws - } - return result; -} - -void -//ISCT_CalibHistoSvc::binHistograms(const int eventsPerWindow){ -ISCT_CalibHistoSvc::binHistograms(const int nLbMerged) { - - int nLb = numberOfLb(); - int yAxisBins = TMath::Ceil(1.0*nLb/nLbMerged); - // int totalEventNumber = m_numberOfEventsHisto->GetEntries(); - - // int yAxisBins = TMath::Ceil(1.0*totalEventNumber/eventsPerWindow); - for (std::vector<TH2F *>::iterator it = m_phistoVector2D.begin() ; it != m_phistoVector2D.end(); ++it) { - (*it)->SetBins(768, -0.5, 768+0.5,yAxisBins,0.5,nLbMerged*yAxisBins+0.5); - } - // std::cout<<eventsPerWindow<<std::endl; - -} - -void -ISCT_CalibHistoSvc::setNumberOfLb(const int nLb) { - m_nLb=nLb; -} - -int -ISCT_CalibHistoSvc::numberOfLb() { - return m_nLb; -} - -void -ISCT_CalibHistoSvc::setLbToMerge(const int nLbMerge) { - m_nLbMerge=nLbMerge; -} - -int -ISCT_CalibHistoSvc::LbToMerge() { - return m_nLbMerge; -} - diff --git a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibHitmapSvc.cxx b/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibHitmapSvc.cxx deleted file mode 100644 index 60d8ab2f6e513982e69df58e9d133366ac260253..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/src/SCT_CalibHitmapSvc.cxx +++ /dev/null @@ -1,208 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** - * @file SCT_CalibHitmapSvc.cxx - * Implementation file for the SCT_CalibHitmapSvc class - * @author Shaun Roe -**/ - -#include "SCT_CalibHitmapSvc.h" -#include "SCT_CalibUtilities.h" -#include "SCT_CalibNumbers.h" - - - -// RAW data access -#include "InDetRawData/InDetRawDataCLASS_DEF.h" -#include "InDetRawData/SCT3_RawData.h" -#include "StoreGate/ReadHandle.h" - -#include "Identifier/Identifier.h" -#include "Identifier/IdentifierHash.h" -#include "GaudiKernel/ITHistSvc.h" - -#include "TH1I.h" -#include "TH1F.h" -#include "TFile.h" -#include "TFileCollection.h" -#include "THashList.h" - -using namespace std; -using namespace SCT_CalibAlgs; -const static string pathRoot("/HitMaps/"); -const static string detectorNames[] = { "negativeEndcap", "barrel", "positiveEndcap" }; -const static string detectorPaths[]={"SCTEC/", "SCTB/","SCTEA/"}; - - - -SCT_CalibHitmapSvc::SCT_CalibHitmapSvc(const std::string &name, ISvcLocator * svc) : AthService(name,svc), - m_detStore("DetectorStore", name), - m_evtStore("StoreGateSvc", name), - m_pSCTHelper(0), - m_sct_waferHash(0), - m_sct_firstStrip(0), - m_sct_rdoGroupSize(0), - m_rdoContainerKey(std::string("SCT_RDOs")) -{ -} - -StatusCode -SCT_CalibHitmapSvc::initialize(){ - if ( service( "THistSvc", m_thistSvc ).isFailure() ) return msg( MSG::ERROR) << "Unable to retrieve pointer to THistSvc" << endmsg, StatusCode::FAILURE; - if ( m_detStore->retrieve( m_pSCTHelper, "SCT_ID").isFailure()) return msg( MSG::ERROR) << "Unable to retrieve SCTHelper" << endmsg, StatusCode::FAILURE; - // - m_waferItrBegin = m_pSCTHelper->wafer_begin(); - m_waferItrEnd = m_pSCTHelper->wafer_end(); - // - - // Read Handle Key - ATH_CHECK(m_rdoContainerKey.initialize()); - - return StatusCode::SUCCESS; -} - -StatusCode -SCT_CalibHitmapSvc::finalize(){ - msg(MSG::VERBOSE) << "SCT_CalibHitmapSvc::finalize()"<<endmsg; - if (m_sct_waferHash) delete m_sct_waferHash; - if (m_sct_rdoGroupSize) delete m_sct_rdoGroupSize; - if (m_sct_firstStrip) delete m_sct_firstStrip; - return StatusCode::SUCCESS; -} - -StatusCode -SCT_CalibHitmapSvc::queryInterface(const InterfaceID & riid, void** ppvInterface ){ - if ( ISCT_CalibHistoSvc::interfaceID().versionMatch(riid) ) { - *ppvInterface = dynamic_cast<ISCT_CalibHistoSvc*>(this); - } else { - return AthService::queryInterface(riid, ppvInterface); - } - addRef(); - return StatusCode::SUCCESS; -} - -bool -SCT_CalibHitmapSvc::book(){ - bool result(true); - //pointers to the histos are deleted by m_thistSvc methods - m_phistoVector.clear(); - string histoName=pathRoot+"GENERAL/"; - //histogram for numbers of events - m_numberOfEventsHisto=new TH1I("events","Events",1,0.5,1.5); - if( m_thistSvc->regHist( histoName.c_str(), m_numberOfEventsHisto ).isFailure() ) { - msg( MSG::ERROR ) << "Error in booking EventNumber histogram" << endmsg; - } - //histograms for each wafer - SCT_ID::const_id_iterator waferItr = m_waferItrBegin; - std::string hitmapPaths[3]; - for (int i(0);i<3;++i){ - hitmapPaths[i]=pathRoot+detectorPaths[i]; - } - for( ; waferItr not_eq m_waferItrEnd; ++waferItr ) { - const Identifier & waferId = *waferItr; - const int bec( m_pSCTHelper->barrel_ec( waferId ) ); - const string formattedPosition=formatPosition(waferId, m_pSCTHelper); - std::string histotitle = string( "SCT " ) + detectorNames[ bec2Index(bec) ] + string( " Hitmap: plane " ) + formattedPosition; - std::string name=hitmapPaths[bec2Index(m_pSCTHelper->barrel_ec( waferId ))] + formattedPosition; - TH1F* hitmapHisto_tmp = new TH1F( TString( formattedPosition ), TString( histotitle ), nbins, firstStrip-0.5, lastStrip+0.5 ); - - //cout<<name.c_str()<<endl; - if( m_thistSvc->regHist( name.c_str(), hitmapHisto_tmp ).isFailure()) { - msg( MSG::ERROR ) << "Error in booking Hitmap histogram" << endmsg; - } else { - m_phistoVector.push_back( hitmapHisto_tmp ); - } - - } - return result; -} - -bool -SCT_CalibHitmapSvc::read(const std::string & fileName){ - bool result(true); - //pointers to the histos are deleted by m_thistSvc methods - m_phistoVector.clear(); - TFile *fileHitmap = TFile::Open( fileName.c_str() ); - msg( MSG::INFO ) << "opening Hitmap file : " << fileName.c_str() << endmsg; - - if(fileHitmap==NULL) { - msg( MSG::ERROR ) << "can not open Hitmap file : " << fileName.c_str() << endmsg; - return result; - } - //histogram for numbers of events - m_numberOfEventsHisto = (TH1I*) fileHitmap->Get("GENERAL/events"); - if( m_numberOfEventsHisto==NULL ) { - msg( MSG::ERROR ) << "Error in reading EventNumber histogram" << endmsg; - } - //histograms for each wafer - SCT_ID::const_id_iterator waferItr = m_waferItrBegin; - for( ; waferItr not_eq m_waferItrEnd; ++waferItr ) { - const Identifier & waferId = *waferItr; - const string formattedPosition=formatPosition(waferId, m_pSCTHelper); - std::string name=detectorPaths[bec2Index(m_pSCTHelper->barrel_ec( waferId ))] + formattedPosition; - TH1F* hitmapHisto_tmp = (TH1F*) fileHitmap->Get(name.c_str()); - if( hitmapHisto_tmp==NULL ) { - msg( MSG::ERROR ) << "Error in reading Hitmap histogram" << endmsg; - } else { - m_phistoVector.push_back( hitmapHisto_tmp ); - } - } - return result; -} - -bool -SCT_CalibHitmapSvc::fill(const bool fromData){ - //cout<<"fromData "<<fromData<<endl; - if (fromData){ - return fillFromData(); - } - bool result(true); - //--- Number of events - m_numberOfEventsHisto->Fill( 1 ); - // both ways hshould give the same results - // int eventNumber = m_numberOfEventsHisto->GetBinContent(1); - // int eventNumber = m_numberOfEventsHisto->GetEntries(); - - //--- Fill hitmap - const int MaxEntry = m_sct_waferHash->size(); - for( int i = 0; i != MaxEntry; ++i ) { - const int theFirstStrip = (*m_sct_firstStrip)[i]; - const int endStrip = (*m_sct_rdoGroupSize)[i] + theFirstStrip; - const int index = (*m_sct_waferHash)[i]; - TH1F * pThisHisto=m_phistoVector[ index ]; - for( int strip(theFirstStrip); strip !=endStrip; ++strip) { - pThisHisto->Fill( strip); - } - } - return result; -} - -bool -SCT_CalibHitmapSvc::fillFromData(){ - bool result(true); - m_numberOfEventsHisto->Fill( 1 ); - // unused int eventNumber = m_numberOfEventsHisto->GetEntries(); - SG::ReadHandle<SCT_RDO_Container> prdoContainer(m_rdoContainerKey); - if (not prdoContainer.isValid() ) msg(MSG::ERROR) <<"Failed to retrieve the SCT RDO container"<<endmsg; - SCT_RDO_Container::const_iterator itr=prdoContainer->begin(); - const SCT_RDO_Container::const_iterator end=prdoContainer->end(); - for (;itr !=end;++itr){ - const InDetRawDataCollection<SCT_RDORawData>* SCT_Collection(*itr); - if (not SCT_Collection) continue; - const Identifier waferId = SCT_Collection->identify(); - const IdentifierHash waferHash = m_pSCTHelper->wafer_hash(waferId); - TH1F * pThisHisto =m_phistoVector[(int)waferHash]; - DataVector<SCT_RDORawData>::const_iterator rdoItr = SCT_Collection->begin(); - const DataVector<SCT_RDORawData>::const_iterator rdoEnd = SCT_Collection->end(); - for(;rdoItr != rdoEnd;++rdoItr){ - int strip=m_pSCTHelper->strip((*rdoItr)->identify()); - const int endStrip=(*rdoItr)->getGroupSize() + strip; - for (;strip != endStrip;++strip){ - pThisHisto->Fill(strip); - } - } - } - return result; -}