CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalPulseShapeGrapher Class Reference

#include <EcalPulseShapeGrapher.h>

Inheritance diagram for EcalPulseShapeGrapher:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 EcalPulseShapeGrapher (const edm::ParameterSet &)
 
 ~EcalPulseShapeGrapher ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void endJob ()
 
std::string intToString (int)
 

Private Attributes

int abscissa [10]
 
int ampCut_
 
std::map< int, TH1F * > ampHistMap_
 
std::map< int, TH1F * > cutAmpHistMap_
 
edm::InputTag EBDigis_
 
edm::InputTag EBUncalibratedRecHitCollection_
 
edm::InputTag EEDigis_
 
edm::InputTag EEUncalibratedRecHitCollection_
 
EcalFedMapfedMap_
 
TFile * file_
 
std::map< int, TH1F * > firstSampleHistMap_
 
std::vector< int > listChannels_
 
int ordinate [10]
 
std::map< int, TH2F * > pulseShapeHistMap_
 
std::map< int, TH2F * > rawPulseShapeHistMap_
 
std::string rootFilename_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 46 of file EcalPulseShapeGrapher.h.

Constructor & Destructor Documentation

EcalPulseShapeGrapher::EcalPulseShapeGrapher ( const edm::ParameterSet iConfig)
explicit

Definition at line 32 of file EcalPulseShapeGrapher.cc.

References abscissa, ampHistMap_, cutAmpHistMap_, fedMap_, firstSampleHistMap_, edm::ParameterSet::getUntrackedParameter(), i, intToString(), listChannels_, mergeVDriftHistosByStation::name, pulseShapeHistMap_, rawPulseShapeHistMap_, AlCaHLTBitMon_QueryRunRegistry::string, and indexGen::title.

32  :
33 EBUncalibratedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EBUncalibratedRecHitCollection")),
34 EBDigis_ (iConfig.getParameter<edm::InputTag>("EBDigiCollection")),
35 EEUncalibratedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EEUncalibratedRecHitCollection")),
36 EEDigis_ (iConfig.getParameter<edm::InputTag>("EEDigiCollection")),
37 ampCut_ (iConfig.getUntrackedParameter<int>("AmplitudeCutADC", 13)),
38 rootFilename_ (iConfig.getUntrackedParameter<std::string>("rootFilename","pulseShapeGrapher"))
39 {
40  //now do what ever initialization is needed
41 
42  std::vector<int> listDefaults;
43  listDefaults.push_back(-1);
44  listChannels_ = iConfig.getUntrackedParameter<std::vector<int> >("listChannels", listDefaults);
45 
46  for(std::vector<int>::const_iterator itr = listChannels_.begin(); itr != listChannels_.end(); ++itr)
47  {
48  std::string title = "Amplitude of cry "+intToString(*itr);
49  std::string name = "ampOfCry"+intToString(*itr);
50  ampHistMap_[*itr] = new TH1F(name.c_str(),title.c_str(),100,0,100);
51  ampHistMap_[*itr]->GetXaxis()->SetTitle("ADC");
52 
53  title = "Amplitude (over 13 ADC) of cry "+intToString(*itr);
54  name = "cutAmpOfCry"+intToString(*itr);
55  cutAmpHistMap_[*itr] = new TH1F(name.c_str(),title.c_str(),100,0,100);
56  cutAmpHistMap_[*itr]->GetXaxis()->SetTitle("ADC");
57 
58  title = "Pulse shape of cry "+intToString(*itr);
59  name = "PulseShapeCry"+intToString(*itr);
60  pulseShapeHistMap_[*itr] = new TH2F(name.c_str(),title.c_str(),10,0,10,220,-20,2);
61  pulseShapeHistMap_[*itr]->GetXaxis()->SetTitle("sample");
62 
63  title = "Raw Pulse shape of cry "+intToString(*itr);
64  name = "RawPulseShapeCry"+intToString(*itr);
65  rawPulseShapeHistMap_[*itr] = new TH2F(name.c_str(),title.c_str(),10,0,10,500,0,500);
66  rawPulseShapeHistMap_[*itr]->GetXaxis()->SetTitle("sample");
67 
68  title = "Amplitude of first sample, cry "+intToString(*itr);
69  name = "AmpOfFirstSampleCry"+intToString(*itr);
70  firstSampleHistMap_[*itr] = new TH1F(name.c_str(),title.c_str(),300,100,400);
71  firstSampleHistMap_[*itr]->GetXaxis()->SetTitle("ADC");
72  }
73 
74  fedMap_ = new EcalFedMap();
75 
76  for (int i=0; i<10; i++)
77  abscissa[i] = i;
78 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::InputTag EBUncalibratedRecHitCollection_
edm::InputTag EEUncalibratedRecHitCollection_
std::vector< int > listChannels_
std::map< int, TH1F * > ampHistMap_
std::map< int, TH2F * > rawPulseShapeHistMap_
std::map< int, TH1F * > firstSampleHistMap_
std::map< int, TH1F * > cutAmpHistMap_
std::map< int, TH2F * > pulseShapeHistMap_
EcalPulseShapeGrapher::~EcalPulseShapeGrapher ( )

Definition at line 81 of file EcalPulseShapeGrapher.cc.

82 {
83 
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 
87 }

Member Function Documentation

void EcalPulseShapeGrapher::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 96 of file EcalPulseShapeGrapher.cc.

References EcalMGPASample::adc(), ampCut_, ampHistMap_, EcalUncalibratedRecHit::amplitude(), cutAmpHistMap_, EcalElectronicsId::dccId(), EBDigis_, EBUncalibratedRecHitCollection_, EEDigis_, EEUncalibratedRecHitCollection_, fedMap_, firstSampleHistMap_, EcalMGPASample::gainId(), edm::Event::getByLabel(), EcalFedMap::getSliceFromFed(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), i, EcalUncalibratedRecHit::id(), listChannels_, pulseShapeHistMap_, rawPulseShapeHistMap_, EcalDataFrame::sample(), and findQualityFiles::size.

97 {
98  using namespace edm;
99  using namespace std;
100 
101  int numHitsWithActivity = 0;
102 
103  //int eventNum = iEvent.id().event();
104  //vector<EcalUncalibratedRecHit> sampleHitsPastCut;
105 
110  //cout << "event: " << eventNum << " sample hits collection size: " << sampleHits->size() << endl;
111  //Handle<EcalUncalibratedRecHitCollection> fittedHits;
112  //iEvent.getByLabel(FittedUncalibratedRecHitCollection_, fittedHits);
113  Handle<EBDigiCollection> EBdigis;
114  iEvent.getByLabel(EBDigis_, EBdigis);
115  Handle<EEDigiCollection> EEdigis;
116  iEvent.getByLabel(EEDigis_, EEdigis);
117  //cout << "event: " << eventNum << " digi collection size: " << digis->size() << endl;
118 
119  auto_ptr<EcalElectronicsMapping> ecalElectronicsMap(new EcalElectronicsMapping);
120 
121  // Loop over the hits
122  for(EcalUncalibratedRecHitCollection::const_iterator hitItr = EBHits->begin(); hitItr != EBHits->end(); ++hitItr)
123  {
124  EcalUncalibratedRecHit hit = (*hitItr);
125  float amplitude = hit.amplitude();
126  EBDetId hitDetId = hit.id();
127 
128  // Get the Fedid
129  EcalElectronicsId elecId = ecalElectronicsMap->getElectronicsId(hitDetId);
130  int FEDid = 600+elecId.dccId();
131  string SMname = fedMap_->getSliceFromFed(FEDid);
132 
133  vector<int>::const_iterator itr = listChannels_.begin();
134  while(itr != listChannels_.end() && (*itr) != hitDetId.hashedIndex())
135  {
136  itr++;
137  }
138  if(itr==listChannels_.end())
139  continue;
140 
141  ampHistMap_[hitDetId.hashedIndex()]->Fill(amplitude);
142  //cout << "Cry hash:" << hitDetId.hashedIndex() << " amplitude: " << amplitude << endl;
143  if(amplitude < ampCut_)
144  continue;
145 
146  cutAmpHistMap_[hitDetId.hashedIndex()]->Fill(amplitude);
147  numHitsWithActivity++;
148  EBDigiCollection::const_iterator digiItr= EBdigis->begin();
149  while(digiItr != EBdigis->end() && digiItr->id() != hitItr->id())
150  {
151  digiItr++;
152  }
153  if(digiItr == EBdigis->end())
154  continue;
155 
156  double sampleADC[10];
157  EBDataFrame df(*digiItr);
158  double pedestal = 200;
159 
160  if(df.sample(0).gainId()!=1 || df.sample(1).gainId()!=1) continue; //goes to the next digi
161  else {
162  sampleADC[0] = df.sample(0).adc();
163  sampleADC[1] = df.sample(1).adc();
164  pedestal = (double)(sampleADC[0]+sampleADC[1])/(double)2;
165  }
166 
167  for (int i=0; (unsigned int)i< digiItr->size(); ++i ) {
168  EBDataFrame df(*digiItr);
169  double gain = 12.;
170  if(df.sample(i).gainId()==1)
171  gain = 1.;
172  else if(df.sample(i).gainId()==2)
173  gain = 2.;
174  sampleADC[i] = pedestal+(df.sample(i).adc()-pedestal)*gain;
175  }
176 
177  //cout << "1) maxsample amp:" << maxSampleAmp << " maxSampleIndex:" << maxSampleIndex << endl;
178  for(int i=0; i<10;++i)
179  {
180  //cout << "Filling hist for:" << hitDetId.hashedIndex() << " with sample:" << i
181  //<< " amp:" <<(float)(df.sample(i).adc()-baseline)/(maxSampleAmp-baseline) << endl;
182  //cout << "ADC of sample:" << df.sample(i).adc() << " baseline:" << baseline << " maxSampleAmp:"
183  //<< maxSampleAmp << endl << endl;
184  pulseShapeHistMap_[hitDetId.hashedIndex()]->Fill(i, (float)(sampleADC[i]-pedestal)/amplitude);
185  rawPulseShapeHistMap_[hitDetId.hashedIndex()]->Fill(i, (float)(sampleADC[i]));
186  }
187  firstSampleHistMap_[hitDetId.hashedIndex()]->Fill(sampleADC[0]);
188  }
189 
190  // Now do the same for the EE hits
191  for(EcalUncalibratedRecHitCollection::const_iterator hitItr = EEHits->begin(); hitItr != EEHits->end(); ++hitItr)
192  {
193  EcalUncalibratedRecHit hit = (*hitItr);
194  float amplitude = hit.amplitude();
195  EEDetId hitDetId = hit.id();
196 
197  // Get the Fedid
198  EcalElectronicsId elecId = ecalElectronicsMap->getElectronicsId(hitDetId);
199  int FEDid = 600+elecId.dccId();
200  string SMname = fedMap_->getSliceFromFed(FEDid);
201 
202  vector<int>::const_iterator itr = listChannels_.begin();
203  while(itr != listChannels_.end() && (*itr) != hitDetId.hashedIndex())
204  {
205  itr++;
206  }
207  if(itr==listChannels_.end())
208  continue;
209 
210  ampHistMap_[hitDetId.hashedIndex()]->Fill(amplitude);
211  //cout << "Cry hash:" << hitDetId.hashedIndex() << " amplitude: " << amplitude << endl;
212  if(amplitude < ampCut_)
213  continue;
214 
215  cutAmpHistMap_[hitDetId.hashedIndex()]->Fill(amplitude);
216  numHitsWithActivity++;
217  EEDigiCollection::const_iterator digiItr= EEdigis->begin();
218  while(digiItr != EEdigis->end() && digiItr->id() != hitItr->id())
219  {
220  digiItr++;
221  }
222  if(digiItr == EEdigis->end())
223  continue;
224 
225  double sampleADC[10];
226  EEDataFrame df(*digiItr);
227  double pedestal = 200;
228 
229  if(df.sample(0).gainId()!=1 || df.sample(1).gainId()!=1) continue; //goes to the next digi
230  else {
231  sampleADC[0] = df.sample(0).adc();
232  sampleADC[1] = df.sample(1).adc();
233  pedestal = (double)(sampleADC[0]+sampleADC[1])/(double)2;
234  }
235 
236  for (int i=0; (unsigned int)i< digiItr->size(); ++i ) {
237  EEDataFrame df(*digiItr);
238  double gain = 12.;
239  if(df.sample(i).gainId()==1)
240  gain = 1.;
241  else if(df.sample(i).gainId()==2)
242  gain = 2.;
243  sampleADC[i] = pedestal+(df.sample(i).adc()-pedestal)*gain;
244  }
245 
246  //cout << "1) maxsample amp:" << maxSampleAmp << " maxSampleIndex:" << maxSampleIndex << endl;
247  for(int i=0; i<10;++i)
248  {
249  //cout << "Filling hist for:" << hitDetId.hashedIndex() << " with sample:" << i
250  //<< " amp:" <<(float)(df.sample(i).adc()-baseline)/(maxSampleAmp-baseline) << endl;
251  //cout << "ADC of sample:" << df.sample(i).adc() << " baseline:" << baseline << " maxSampleAmp:"
252  //<< maxSampleAmp << endl << endl;
253  pulseShapeHistMap_[hitDetId.hashedIndex()]->Fill(i, (float)(sampleADC[i]-pedestal)/amplitude);
254  rawPulseShapeHistMap_[hitDetId.hashedIndex()]->Fill(i, (float)(sampleADC[i]));
255  }
256  firstSampleHistMap_[hitDetId.hashedIndex()]->Fill(sampleADC[0]);
257  }
258 }
int i
Definition: DBlmapReader.cc:9
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
edm::InputTag EBUncalibratedRecHitCollection_
std::vector< EcalUncalibratedRecHit >::const_iterator const_iterator
edm::InputTag EEUncalibratedRecHitCollection_
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:93
std::vector< int > listChannels_
std::map< int, TH1F * > ampHistMap_
std::map< int, TH2F * > rawPulseShapeHistMap_
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
int hashedIndex() const
Definition: EEDetId.h:182
std::map< int, TH1F * > firstSampleHistMap_
std::map< int, TH1F * > cutAmpHistMap_
std::map< int, TH2F * > pulseShapeHistMap_
tuple size
Write out results.
void EcalPulseShapeGrapher::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 263 of file EcalPulseShapeGrapher.cc.

References ampHistMap_, cutAmpHistMap_, file_, firstSampleHistMap_, listChannels_, rawPulseShapeHistMap_, rootFilename_, and reco::t2.

263  {
264 
265  rootFilename_+=".root";
266  file_ = new TFile(rootFilename_.c_str(),"RECREATE");
267  TH1::AddDirectory(false);
268 
269  for(std::vector<int>::const_iterator itr = listChannels_.begin(); itr != listChannels_.end(); ++itr)
270  {
271  ampHistMap_[*itr]->Write();
272  cutAmpHistMap_[*itr]->Write();
273  firstSampleHistMap_[*itr]->Write();
274 
275  rawPulseShapeHistMap_[*itr]->Write();
276  TProfile* t2 = (TProfile*) (rawPulseShapeHistMap_[*itr]->ProfileX());
277  t2->Write();
278  //TODO: fix the normalization so these are correct
279  //pulseShapeHistMap_[*itr]->Write();
280  //TProfile* t1 = (TProfile*) (pulseShapeHistMap_[*itr]->ProfileX());
281  //t1->Write();
282  }
283 
284 
285  file_->Write();
286  file_->Close();
287 }
std::vector< int > listChannels_
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
std::map< int, TH1F * > ampHistMap_
std::map< int, TH2F * > rawPulseShapeHistMap_
std::map< int, TH1F * > firstSampleHistMap_
std::map< int, TH1F * > cutAmpHistMap_
std::string EcalPulseShapeGrapher::intToString ( int  num)
private

Definition at line 289 of file EcalPulseShapeGrapher.cc.

Referenced by EcalPulseShapeGrapher().

290 {
291  using namespace std;
292  ostringstream myStream;
293  myStream << num << flush;
294  return(myStream.str()); //returns the string form of the stringstream object
295 }

Member Data Documentation

int EcalPulseShapeGrapher::abscissa[10]
private

Definition at line 63 of file EcalPulseShapeGrapher.h.

Referenced by EcalPulseShapeGrapher().

int EcalPulseShapeGrapher::ampCut_
private

Definition at line 72 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

std::map<int,TH1F*> EcalPulseShapeGrapher::ampHistMap_
private

Definition at line 66 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), EcalPulseShapeGrapher(), and endJob().

std::map<int,TH1F*> EcalPulseShapeGrapher::cutAmpHistMap_
private

Definition at line 70 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), EcalPulseShapeGrapher(), and endJob().

edm::InputTag EcalPulseShapeGrapher::EBDigis_
private

Definition at line 59 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

edm::InputTag EcalPulseShapeGrapher::EBUncalibratedRecHitCollection_
private

Definition at line 58 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

edm::InputTag EcalPulseShapeGrapher::EEDigis_
private

Definition at line 61 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

edm::InputTag EcalPulseShapeGrapher::EEUncalibratedRecHitCollection_
private

Definition at line 60 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

EcalFedMap* EcalPulseShapeGrapher::fedMap_
private

Definition at line 77 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), and EcalPulseShapeGrapher().

TFile* EcalPulseShapeGrapher::file_
private

Definition at line 75 of file EcalPulseShapeGrapher.h.

Referenced by endJob().

std::map<int,TH1F*> EcalPulseShapeGrapher::firstSampleHistMap_
private

Definition at line 68 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), EcalPulseShapeGrapher(), and endJob().

std::vector<int> EcalPulseShapeGrapher::listChannels_
private

Definition at line 65 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), EcalPulseShapeGrapher(), and endJob().

int EcalPulseShapeGrapher::ordinate[10]
private

Definition at line 64 of file EcalPulseShapeGrapher.h.

std::map<int,TH2F*> EcalPulseShapeGrapher::pulseShapeHistMap_
private

Definition at line 67 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), and EcalPulseShapeGrapher().

std::map<int,TH2F*> EcalPulseShapeGrapher::rawPulseShapeHistMap_
private

Definition at line 69 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), EcalPulseShapeGrapher(), and endJob().

std::string EcalPulseShapeGrapher::rootFilename_
private

Definition at line 73 of file EcalPulseShapeGrapher.h.

Referenced by endJob().