Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020 #include "CaloOnlineTools/EcalTools/plugins/EcalURecHitHists.h"
00021
00022 using namespace cms;
00023 using namespace edm;
00024 using namespace std;
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 EcalURecHitHists::EcalURecHitHists(const edm::ParameterSet& iConfig) :
00038 EBUncalibratedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EBUncalibratedRecHitCollection")),
00039 EEUncalibratedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EEUncalibratedRecHitCollection")),
00040 runNum_(-1),
00041 histRangeMax_ (iConfig.getUntrackedParameter<double>("histogramMaxRange",200.0)),
00042 histRangeMin_ (iConfig.getUntrackedParameter<double>("histogramMinRange",-10.0)),
00043 fileName_ (iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalURechHitHists")))
00044 {
00045 vector<int> listDefaults;
00046 listDefaults.push_back(-1);
00047
00048 maskedChannels_ = iConfig.getUntrackedParameter<vector<int> >("maskedChannels", listDefaults);
00049 maskedFEDs_ = iConfig.getUntrackedParameter<vector<int> >("maskedFEDs", listDefaults);
00050
00051 vector<string> defaultMaskedEBs;
00052 defaultMaskedEBs.push_back("none");
00053 maskedEBs_ = iConfig.getUntrackedParameter<vector<string> >("maskedEBs",defaultMaskedEBs);
00054
00055 fedMap_ = new EcalFedMap();
00056 string title1 = "Uncalib Rec Hits (ADC counts)";
00057 string name1 = "URecHitsAllFEDs";
00058 int numBins = (int)round(histRangeMax_-histRangeMin_)+1;
00059 allFedsHist_ = new TH1F(name1.c_str(),title1.c_str(),numBins,histRangeMin_,histRangeMax_);
00060 title1 = "Jitter for all FEDs";
00061 name1 = "JitterAllFEDs";
00062 allFedsTimingHist_ = new TH1F(name1.c_str(),title1.c_str(),14,-7,7);
00063
00064
00065 if(maskedFEDs_[0]==-1)
00066 {
00067
00068 if(maskedEBs_[0] != "none")
00069 {
00070 maskedFEDs_.clear();
00071 for(vector<string>::const_iterator ebItr = maskedEBs_.begin(); ebItr != maskedEBs_.end(); ++ebItr)
00072 {
00073 maskedFEDs_.push_back(fedMap_->getFedFromSlice(*ebItr));
00074 }
00075 }
00076 }
00077 }
00078
00079
00080 EcalURecHitHists::~EcalURecHitHists()
00081 {
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 void
00091 EcalURecHitHists::analyze(edm::Event const & iEvent, edm::EventSetup const & iSetup)
00092 {
00093 int ievt = iEvent.id().event();
00094 Handle<EcalUncalibratedRecHitCollection> EBhits;
00095 Handle<EcalUncalibratedRecHitCollection> EEhits;
00096
00097 iEvent.getByLabel(EBUncalibratedRecHitCollection_, EBhits);
00098 LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EBhits->size();
00099
00100 iEvent.getByLabel(EEUncalibratedRecHitCollection_, EEhits);
00101 LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EEhits->size();
00102
00103 for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EBhits->begin(); hitItr != EBhits->end(); ++hitItr)
00104 {
00105 EcalUncalibratedRecHit hit = (*hitItr);
00106 EBDetId ebDet = hit.id();
00107 int ic = ebDet.ic();
00108 int hashedIndex = ebDet.hashedIndex();
00109 EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(ebDet);
00110 int FEDid = 600+elecId.dccId();
00111 float ampli = hit.amplitude();
00112
00113 vector<int>::iterator result;
00114 result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
00115 if(result != maskedFEDs_.end())
00116 {
00117 LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
00118 continue;
00119 }
00120
00121 result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
00122 if (result != maskedChannels_.end())
00123 {
00124 LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli ;
00125 continue;
00126 }
00127
00128
00129 TH1F* uRecHist = FEDsAndHists_[FEDid];
00130 TH1F* timingHist = FEDsAndTimingHists_[FEDid];
00131 if(uRecHist==0)
00132 {
00133 initHists(FEDid);
00134 uRecHist = FEDsAndHists_[FEDid];
00135 timingHist = FEDsAndTimingHists_[FEDid];
00136 }
00137
00138 uRecHist->Fill(ampli);
00139 allFedsHist_->Fill(ampli);
00140 timingHist->Fill(hit.jitter());
00141 allFedsTimingHist_->Fill(hit.jitter());
00142 }
00143
00144
00145 for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EEhits->begin(); hitItr != EEhits->end(); ++hitItr)
00146 {
00147 EcalUncalibratedRecHit hit = (*hitItr);
00148 EEDetId eeDet = hit.id();
00149 int ic = eeDet.ic();
00150 int hashedIndex = eeDet.hashedIndex();
00151 EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(eeDet);
00152 int FEDid = 600+elecId.dccId();
00153 float ampli = hit.amplitude();
00154
00155 vector<int>::iterator result;
00156 result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
00157 if(result != maskedFEDs_.end())
00158 {
00159 LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
00160 continue;
00161 }
00162
00163 result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
00164 if (result != maskedChannels_.end())
00165 {
00166 LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli ;
00167 continue;
00168 }
00169
00170
00171 TH1F* uRecHist = FEDsAndHists_[FEDid];
00172 TH1F* timingHist = FEDsAndTimingHists_[FEDid];
00173 if(uRecHist==0)
00174 {
00175 initHists(FEDid);
00176 uRecHist = FEDsAndHists_[FEDid];
00177 timingHist = FEDsAndTimingHists_[FEDid];
00178 }
00179
00180 uRecHist->Fill(ampli);
00181 allFedsHist_->Fill(ampli);
00182 timingHist->Fill(hit.jitter());
00183 allFedsTimingHist_->Fill(hit.jitter());
00184 }
00185
00186 if(runNum_==-1)
00187 {
00188 runNum_ = iEvent.id().run();
00189 }
00190 }
00191
00192
00193
00194 void EcalURecHitHists::initHists(int FED)
00195 {
00196 using namespace std;
00197
00198 string FEDid = intToString(FED);
00199 string title1 = "Uncalib Rec Hits (ADC counts) for ";
00200 title1.append(fedMap_->getSliceFromFed(FED));
00201 string name1 = "URecHitsFED";
00202 name1.append(intToString(FED));
00203 int numBins = (int)round(histRangeMax_-histRangeMin_)+1;
00204 TH1F* hist = new TH1F(name1.c_str(),title1.c_str(), numBins, histRangeMin_, histRangeMax_);
00205 FEDsAndHists_[FED] = hist;
00206 FEDsAndHists_[FED]->SetDirectory(0);
00207
00208 title1 = "Jitter for ";
00209 title1.append(fedMap_->getSliceFromFed(FED));
00210 name1 = "JitterFED";
00211 name1.append(intToString(FED));
00212 TH1F* timingHist = new TH1F(name1.c_str(),title1.c_str(),14,-7,7);
00213 FEDsAndTimingHists_[FED] = timingHist;
00214 FEDsAndTimingHists_[FED]->SetDirectory(0);
00215 }
00216
00217
00218 void
00219 EcalURecHitHists::beginRun(edm::Run const &, edm::EventSetup const & c)
00220 {
00221 edm::ESHandle<EcalElectronicsMapping> elecHandle;
00222 c.get<EcalMappingRcd>().get(elecHandle);
00223 ecalElectronicsMap_ = elecHandle.product();
00224 }
00225
00226
00227 void
00228 EcalURecHitHists::endJob()
00229 {
00230 using namespace std;
00231 fileName_ += "-"+intToString(runNum_)+".graph.root";
00232
00233 TFile root_file_(fileName_.c_str() , "RECREATE");
00234
00235 for(map<int,TH1F*>::const_iterator itr = FEDsAndHists_.begin();
00236 itr != FEDsAndHists_.end(); ++itr)
00237 {
00238 string dir = fedMap_->getSliceFromFed(itr->first);
00239 TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
00240 FEDdir->cd();
00241
00242 TH1F* hist = itr->second;
00243 if(hist!=0)
00244 hist->Write();
00245 else
00246 {
00247 cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
00248 }
00249
00250 hist = FEDsAndTimingHists_[itr->first];
00251 if(hist!=0)
00252 hist->Write();
00253 else
00254 {
00255 cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
00256 }
00257 root_file_.cd();
00258 }
00259 allFedsHist_->Write();
00260 allFedsTimingHist_->Write();
00261 root_file_.Close();
00262
00263 std::string channels;
00264 for(std::vector<int>::const_iterator itr = maskedChannels_.begin();
00265 itr != maskedChannels_.end(); ++itr)
00266 {
00267 channels+=intToString(*itr);
00268 channels+=",";
00269 }
00270
00271 LogWarning("EcalMipGraphs") << "Masked channels are: " << channels << " and that is all!";
00272 }
00273
00274
00275 std::string EcalURecHitHists::intToString(int num)
00276 {
00277 using namespace std;
00278 ostringstream myStream;
00279 myStream << num << flush;
00280 return(myStream.str());
00281 }
00282