#include <EcalMipGraphs.h>
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 62 of file EcalMipGraphs.h.
EcalMipGraphs::EcalMipGraphs | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 43 of file EcalMipGraphs.cc.
References abscissa, allFedsTimingHist_, fedMap_, fileService, edm::ParameterSet::getUntrackedParameter(), i, maskedChannels_, maskedEBs_, maskedFEDs_, naiveEvtNum_, and seedCrys_.
: EBRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEB")), EERecHitCollection_ (iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEE")), EBDigis_ (iConfig.getParameter<edm::InputTag>("EBDigiCollection")), EEDigis_ (iConfig.getParameter<edm::InputTag>("EEDigiCollection")), headerProducer_ (iConfig.getParameter<edm::InputTag> ("headerProducer")), runNum_(-1), side_ (iConfig.getUntrackedParameter<int>("side", 3)), threshold_ (iConfig.getUntrackedParameter<double>("amplitudeThreshold", 12.0)), minTimingAmp_ (iConfig.getUntrackedParameter<double>("minimumTimingAmplitude", 0.100)) { vector<int> listDefaults; listDefaults.push_back(-1); maskedChannels_ = iConfig.getUntrackedParameter<vector<int> >("maskedChannels", listDefaults); maskedFEDs_ = iConfig.getUntrackedParameter<vector<int> >("maskedFEDs", listDefaults); seedCrys_ = iConfig.getUntrackedParameter<vector<int> >("seedCrys",vector<int>()); vector<string> defaultMaskedEBs; defaultMaskedEBs.push_back("none"); maskedEBs_ = iConfig.getUntrackedParameter<vector<string> >("maskedEBs",defaultMaskedEBs); fedMap_ = new EcalFedMap(); string title1 = "Jitter for all FEDs"; string name1 = "JitterAllFEDs"; allFedsTimingHist_ = fileService->make<TH1F>(name1.c_str(),title1.c_str(),150,-7,7); // load up the maskedFED list with the proper FEDids if(maskedFEDs_[0]==-1) { //if "actual" EB id given, then convert to FEDid and put in listFEDs_ if(maskedEBs_[0] != "none") { maskedFEDs_.clear(); for(vector<string>::const_iterator ebItr = maskedEBs_.begin(); ebItr != maskedEBs_.end(); ++ebItr) { maskedFEDs_.push_back(fedMap_->getFedFromSlice(*ebItr)); } } } for (int i=0; i<10; i++) abscissa[i] = i; naiveEvtNum_ = 0; }
EcalMipGraphs::~EcalMipGraphs | ( | ) |
Definition at line 93 of file EcalMipGraphs.cc.
{ }
void EcalMipGraphs::analyze | ( | edm::Event const & | iEvent, |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 104 of file EcalMipGraphs.cc.
References canvasNames_, EBDigis_, EBdigisHandle, EBRecHitCollection_, EEDigis_, EEdigisHandle, EERecHitCollection_, edm::EventID::event(), FEDsAndDCCHeaders_, fileService, edm::EventSetup::get(), edm::Event::getByLabel(), headerProducer_, edm::EventBase::id(), listEBChannels, listEEChannels, naiveEvtNum_, names, edm::EventID::run(), runNum_, and selectHits().
{ // get the headers // (one header for each supermodule) edm::Handle<EcalRawDataCollection> DCCHeaders; iEvent.getByLabel(headerProducer_, DCCHeaders); for (EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin(); headerItr != DCCHeaders->end (); ++headerItr) { FEDsAndDCCHeaders_[headerItr->id()+600] = *headerItr; } int ievt = iEvent.id().event(); naiveEvtNum_++; if(runNum_==-1) { runNum_ = iEvent.id().run(); canvasNames_ = fileService->make<TTree>("canvasNames","Names of written canvases"); names = new std::vector<string>(); canvasNames_->Branch("names","vector<string>",&names); } //We only want the 3x3's for this event... listEBChannels.clear(); listEEChannels.clear(); Handle<EcalRecHitCollection> EBhits; Handle<EcalRecHitCollection> EEhits; ESHandle<CaloTopology> caloTopo; iSetup.get<CaloTopologyRecord>().get(caloTopo); iEvent.getByLabel(EBRecHitCollection_, EBhits); iEvent.getByLabel(EERecHitCollection_, EEhits); // Now, retrieve the crystal digi from the event iEvent.getByLabel(EBDigis_, EBdigisHandle); iEvent.getByLabel(EEDigis_, EEdigisHandle); //debug //LogWarning("EcalMipGraphs") << "event " << ievt << " EBhits collection size " << EBhits->size(); //LogWarning("EcalMipGraphs") << "event " << ievt << " EEhits collection size " << EEhits->size(); selectHits(EBhits, ievt, caloTopo); selectHits(EEhits, ievt, caloTopo); }
void EcalMipGraphs::beginRun | ( | edm::Run const & | , |
edm::EventSetup const & | c | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 370 of file EcalMipGraphs.cc.
References ecalElectronicsMap_, edm::EventSetup::get(), patZpeak::handle, and edm::ESHandle< T >::product().
{ edm::ESHandle< EcalElectronicsMapping > handle; c.get< EcalMappingRcd >().get(handle); ecalElectronicsMap_ = handle.product(); }
void EcalMipGraphs::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 379 of file EcalMipGraphs.cc.
References canvasNames_, intToString(), maskedChannels_, maskedFEDs_, and seedFrequencyMap_.
{ canvasNames_->Fill(); string frequencies = ""; for(std::map<std::string,int>::const_iterator itr = seedFrequencyMap_.begin(); itr != seedFrequencyMap_.end(); ++itr) { if(itr->second > 1) { frequencies+=itr->first; frequencies+=" Frequency: "; frequencies+=intToString(itr->second); frequencies+="\n"; } } LogWarning("EcalMipGraphs") << "Found seeds with frequency > 1: " << "\n\n" << frequencies; std::string channels; for(std::vector<int>::const_iterator itr = maskedChannels_.begin(); itr != maskedChannels_.end(); ++itr) { channels+=intToString(*itr); channels+=","; } std::string feds; for(std::vector<int>::const_iterator itr = maskedFEDs_.begin(); itr != maskedFEDs_.end(); ++itr) { feds+=intToString(*itr); feds+=","; } LogWarning("EcalMipGraphs") << "Masked channels are: " << channels; LogWarning("EcalMipGraphs") << "Masked FEDs are: " << feds << " and that is all!"; }
std::string EcalMipGraphs::floatToString | ( | float | num | ) | [private] |
Definition at line 426 of file EcalMipGraphs.cc.
Referenced by selectDigi().
{ using namespace std; ostringstream myStream; myStream << num << flush; return(myStream.str()); //returns the string form of the stringstream object }
int EcalMipGraphs::getEEIndex | ( | EcalElectronicsId | elecId | ) | [private] |
Definition at line 349 of file EcalMipGraphs.cc.
References EcalElectronicsId::dccId(), L1Comparator_cfi::FEDid, EcalElectronicsId::stripId(), EcalElectronicsId::towerId(), and EcalElectronicsId::xtalId().
Referenced by selectDigi(), and selectHits().
void EcalMipGraphs::initHists | ( | int | FED | ) | [private] |
Definition at line 356 of file EcalMipGraphs.cc.
References fedMap_, FEDsAndTimingHists_, fileService, EcalFedMap::getSliceFromFed(), and intToString().
Referenced by selectHits().
{ using namespace std; string title1 = "Jitter for "; title1.append(fedMap_->getSliceFromFed(FED)); string name1 = "JitterFED"; name1.append(intToString(FED)); TH1F* timingHist = fileService->make<TH1F>(name1.c_str(),title1.c_str(),150,-7,7); FEDsAndTimingHists_[FED] = timingHist; }
std::string EcalMipGraphs::intToString | ( | int | num | ) | [private] |
Definition at line 418 of file EcalMipGraphs.cc.
Referenced by endJob(), initHists(), selectDigi(), and selectHits().
{ using namespace std; ostringstream myStream; myStream << num << flush; return(myStream.str()); //returns the string form of the stringstream object }
TGraph * EcalMipGraphs::selectDigi | ( | DetId | det, |
int | ievt | ||
) | [private] |
Definition at line 152 of file EcalMipGraphs.cc.
References abscissa, EcalMGPASample::adc(), crysAndAmplitudesMap_, EcalElectronicsId::dccId(), DetId::det(), EBdigisHandle, DetId::Ecal, ecalElectronicsMap_, EEdigisHandle, relval_parameters_module::energy, L1Comparator_cfi::FEDid, fedMap_, FEDsAndDCCHeaders_, fileService, floatToString(), EcalMGPASample::gainId(), ecalMGPA::gainId(), gainRatio, getEEIndex(), EcalElectronicsMapping::getElectronicsId(), EcalFedMap::getSliceFromFed(), i, intToString(), naiveEvtNum_, mergeVDriftHistosByStation::name, ordinate, EcalDataFrame::sample(), EcalDataFrame::size(), and indexGen::title.
Referenced by selectHits().
{ int emptyY[10]; for (int i=0; i<10; i++) emptyY[i] = 0; TGraph* emptyGraph = fileService->make<TGraph>(10, abscissa, emptyY); emptyGraph->SetTitle("NOT ECAL"); //If the DetId is not from Ecal, return if(thisDet.det() != DetId::Ecal) return emptyGraph; emptyGraph->SetTitle("NO DIGIS"); //find digi we need -- can't get find() to work; need DataFrame(DetId det) to work? EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(thisDet); int FEDid = 600+elecId.dccId(); bool isBarrel = true; if(FEDid < 610 || FEDid > 645) isBarrel = false; int cryIndex = isBarrel ? ((EBDetId)thisDet).hashedIndex() : getEEIndex(elecId); int ic = isBarrel ? ((EBDetId)thisDet).ic() : cryIndex; string sliceName = fedMap_->getSliceFromFed(FEDid); EcalDataFrame df; if(isBarrel) { EBDigiCollection::const_iterator digiItr = EBdigisHandle->begin(); while(digiItr != EBdigisHandle->end() && ((*digiItr).id() != (EBDetId)thisDet)) { ++digiItr; } if(digiItr==EBdigisHandle->end()) { //LogWarning("EcalMipGraphs") << "Cannot find digi for ic:" << ic // << " FED:" << FEDid << " evt:" << naiveEvtNum_; return emptyGraph; } else df = *digiItr; } else { EEDigiCollection::const_iterator digiItr = EEdigisHandle->begin(); while(digiItr != EEdigisHandle->end() && ((*digiItr).id() != (EEDetId)thisDet)) { ++digiItr; } if(digiItr==EEdigisHandle->end()) { //LogWarning("EcalMipGraphs") << "Cannot find digi for ic:" << ic // << " FED:" << FEDid << " evt:" << naiveEvtNum_; return emptyGraph; } else df = *digiItr; } int gainId = FEDsAndDCCHeaders_[FEDid].getMgpaGain(); int gainHuman; if (gainId ==1) gainHuman =12; else if (gainId ==2) gainHuman =6; else if (gainId ==3) gainHuman =1; else gainHuman =-1; double pedestal = 200; emptyGraph->SetTitle("FIRST TWO SAMPLES NOT GAIN12"); if(df.sample(0).gainId()!=1 || df.sample(1).gainId()!=1) return emptyGraph; //goes to the next digi else { ordinate[0] = df.sample(0).adc(); ordinate[1] = df.sample(1).adc(); pedestal = (double)(ordinate[0]+ordinate[1])/(double)2; } for (int i=0; i < df.size(); ++i ) { if (df.sample(i).gainId() != 0) ordinate[i] = (int)(pedestal+(df.sample(i).adc()-pedestal)*gainRatio[df.sample(i).gainId()-1]); else ordinate[i] = 49152; //Saturation of gain1 } TGraph* oneGraph = fileService->make<TGraph>(10, abscissa, ordinate); string name = "Graph_ev" + intToString(naiveEvtNum_) + "_ic" + intToString(ic) + "_FED" + intToString(FEDid); string gainString = (gainId==1) ? "Free" : intToString(gainHuman); string title = "Event" + intToString(naiveEvtNum_) + "_lv1a" + intToString(ievt) + "_ic" + intToString(ic) + "_" + sliceName + "_gain" + gainString; float energy = 0; map<int,float>::const_iterator itr; itr = crysAndAmplitudesMap_.find(cryIndex); if(itr!=crysAndAmplitudesMap_.end()) { //edm::LogWarning("EcalMipGraphs")<< "itr->second(ampli)="<< itr->second; energy = (float) itr->second; } //else //edm::LogWarning("EcalMipGraphs") << "cry " << ic << "not found in ampMap"; title+="_Energy"+floatToString(round(energy*1000)); oneGraph->SetTitle(title.c_str()); oneGraph->SetName(name.c_str()); oneGraph->GetXaxis()->SetTitle("sample"); oneGraph->GetYaxis()->SetTitle("ADC"); return oneGraph; }
void EcalMipGraphs::selectHits | ( | edm::Handle< EcalRecHitCollection > | hits, |
int | ievt, | ||
edm::ESHandle< CaloTopology > | caloTopo | ||
) | [private] |
Definition at line 260 of file EcalMipGraphs.cc.
References allFedsTimingHist_, timingPdfMaker::can, crysAndAmplitudesMap_, EcalElectronicsId::dccId(), ecalElectronicsMap_, CaloRecHit::energy(), L1Comparator_cfi::FEDid, FEDsAndTimingHists_, spr::find(), getEEIndex(), EcalElectronicsMapping::getElectronicsId(), CaloNavigator< T >::home(), i, EcalRecHit::id(), initHists(), intToString(), j, maskedChannels_, maskedFEDs_, minTimingAmp_, naiveEvtNum_, mergeVDriftHistosByStation::name, names, CaloNavigator< T >::offsetBy(), query::result, seedCrys_, seedFrequencyMap_, selectDigi(), side_, threshold_, CaloRecHit::time(), and indexGen::title.
Referenced by analyze().
{ for (EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr) { EcalRecHit hit = (*hitItr); DetId det = hit.id(); EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(det); int FEDid = 600+elecId.dccId(); bool isBarrel = true; if(FEDid < 610 || FEDid > 645) isBarrel = false; int cryIndex = isBarrel ? ((EBDetId)det).hashedIndex() : ((EEDetId)det).hashedIndex(); int ic = isBarrel ? ((EBDetId)det).ic() : getEEIndex(elecId); float ampli = hit.energy(); vector<int>::iterator result; result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid); if(result != maskedFEDs_.end()) { //LogWarning("EcalMipGraphs") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli; continue; } result = find(maskedChannels_.begin(), maskedChannels_.end(), cryIndex); if (result != maskedChannels_.end()) { //LogWarning("EcalMipGraphs") << "skipping uncalRecHit for channel: " << cryIndex << " in fed: " << FEDid << " with amplitude " << ampli ; continue; } bool cryIsInList = false; result = find(seedCrys_.begin(), seedCrys_.end(), cryIndex); if (result != seedCrys_.end()) cryIsInList = true; // Either we must have a user-requested cry (in which case there is no amplitude selection) // Or we pick all crys that pass the amplitude cut (in which case there is no fixed crystal selection) if(cryIsInList || (seedCrys_.empty() && ampli > threshold_)) { // We have a winner! crysAndAmplitudesMap_[cryIndex] = ampli; string name = "Event" + intToString(naiveEvtNum_) + "_ic" + intToString(ic) + "_FED" + intToString(FEDid); string title = "Digis"; string seed = "ic" + intToString(ic) + "_FED" + intToString(FEDid); int freq=1; pair<map<string,int>::iterator,bool> pair = seedFrequencyMap_.insert(make_pair(seed,freq)); if(!pair.second) { ++(pair.first->second); } TCanvas can(name.c_str(),title.c_str(),200,50,900,900); can.Divide(side_,side_); TGraph* myGraph; int canvasNum = 1; CaloNavigator<DetId> cursor = CaloNavigator<DetId>(det,caloTopo->getSubdetectorTopology(det)); //Now put each graph in one by one for(int j=side_/2; j>=-side_/2; --j) { for(int i=-side_/2; i<=side_/2; ++i) { cursor.home(); cursor.offsetBy(i,j); can.cd(canvasNum); myGraph = selectDigi(*cursor,ievt); myGraph->Draw("A*"); canvasNum++; } } can.Write(); names->push_back(name); } TH1F* timingHist = FEDsAndTimingHists_[FEDid]; if(timingHist==0) { initHists(FEDid); timingHist = FEDsAndTimingHists_[FEDid]; } if(ampli > minTimingAmp_) { timingHist->Fill(hit.time()); allFedsTimingHist_->Fill(hit.time()); } } }
void EcalMipGraphs::writeGraphs | ( | ) | [private] |
int EcalMipGraphs::abscissa[10] [private] |
Definition at line 100 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs(), and selectDigi().
TH1F* EcalMipGraphs::allFedsTimingHist_ [private] |
Definition at line 116 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs(), and selectHits().
TTree* EcalMipGraphs::canvasNames_ [private] |
Definition at line 119 of file EcalMipGraphs.h.
std::map<int,float> EcalMipGraphs::crysAndAmplitudesMap_ [private] |
Definition at line 112 of file EcalMipGraphs.h.
Referenced by selectDigi(), and selectHits().
edm::InputTag EcalMipGraphs::EBDigis_ [private] |
Definition at line 85 of file EcalMipGraphs.h.
Referenced by analyze().
Definition at line 89 of file EcalMipGraphs.h.
Referenced by analyze(), and selectDigi().
Definition at line 83 of file EcalMipGraphs.h.
Referenced by analyze().
const EcalElectronicsMapping* EcalMipGraphs::ecalElectronicsMap_ [private] |
Definition at line 121 of file EcalMipGraphs.h.
Referenced by beginRun(), selectDigi(), and selectHits().
edm::InputTag EcalMipGraphs::EEDigis_ [private] |
Definition at line 86 of file EcalMipGraphs.h.
Referenced by analyze().
Definition at line 90 of file EcalMipGraphs.h.
Referenced by analyze(), and selectDigi().
Definition at line 84 of file EcalMipGraphs.h.
Referenced by analyze().
EcalFedMap* EcalMipGraphs::fedMap_ [private] |
Definition at line 120 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs(), initHists(), and selectDigi().
std::map<int,EcalDCCHeaderBlock> EcalMipGraphs::FEDsAndDCCHeaders_ [private] |
Definition at line 113 of file EcalMipGraphs.h.
Referenced by analyze(), and selectDigi().
std::map<int,TH1F*> EcalMipGraphs::FEDsAndTimingHists_ [private] |
Definition at line 111 of file EcalMipGraphs.h.
Referenced by initHists(), and selectHits().
TFile* EcalMipGraphs::file_ [private] |
Definition at line 118 of file EcalMipGraphs.h.
edm::Service< TFileService > EcalMipGraphs::fileService [static, private] |
Definition at line 104 of file EcalMipGraphs.h.
Referenced by analyze(), EcalMipGraphs(), initHists(), and selectDigi().
float EcalMipGraphs::gainRatio = { 1., 2. , 12. } [static, private] |
Definition at line 103 of file EcalMipGraphs.h.
Referenced by selectDigi().
edm::InputTag EcalMipGraphs::headerProducer_ [private] |
Definition at line 87 of file EcalMipGraphs.h.
Referenced by analyze().
std::set<EBDetId> EcalMipGraphs::listEBChannels [private] |
Definition at line 97 of file EcalMipGraphs.h.
Referenced by analyze().
std::set<EEDetId> EcalMipGraphs::listEEChannels [private] |
Definition at line 98 of file EcalMipGraphs.h.
Referenced by analyze().
std::vector<int> EcalMipGraphs::maskedChannels_ [private] |
Definition at line 107 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs(), endJob(), and selectHits().
std::vector<std::string> EcalMipGraphs::maskedEBs_ [private] |
Definition at line 110 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs().
std::vector<int> EcalMipGraphs::maskedFEDs_ [private] |
Definition at line 108 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs(), endJob(), and selectHits().
double EcalMipGraphs::minTimingAmp_ [private] |
Definition at line 95 of file EcalMipGraphs.h.
Referenced by selectHits().
int EcalMipGraphs::naiveEvtNum_ [private] |
Definition at line 123 of file EcalMipGraphs.h.
Referenced by analyze(), EcalMipGraphs(), selectDigi(), and selectHits().
std::vector<std::string>* EcalMipGraphs::names [private] |
Definition at line 106 of file EcalMipGraphs.h.
Referenced by analyze(), and selectHits().
int EcalMipGraphs::ordinate[10] [private] |
Definition at line 101 of file EcalMipGraphs.h.
Referenced by selectDigi().
int EcalMipGraphs::runNum_ [private] |
Definition at line 92 of file EcalMipGraphs.h.
Referenced by analyze().
std::vector<int> EcalMipGraphs::seedCrys_ [private] |
Definition at line 109 of file EcalMipGraphs.h.
Referenced by EcalMipGraphs(), and selectHits().
std::map<std::string,int> EcalMipGraphs::seedFrequencyMap_ [private] |
Definition at line 114 of file EcalMipGraphs.h.
Referenced by endJob(), and selectHits().
int EcalMipGraphs::side_ [private] |
Definition at line 93 of file EcalMipGraphs.h.
Referenced by selectHits().
double EcalMipGraphs::threshold_ [private] |
Definition at line 94 of file EcalMipGraphs.h.
Referenced by selectHits().