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

Public Member Functions

 EcalPulseShapeGrapher (const edm::ParameterSet &)
 
 ~EcalPulseShapeGrapher ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

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

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

Definition at line 47 of file EcalPulseShapeGrapher.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file EcalPulseShapeGrapher.cc.

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

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

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 97 of file EcalPulseShapeGrapher.cc.

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

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

References ampHistMap_, cutAmpHistMap_, file_, firstSampleHistMap_, listChannels_, rawPulseShapeHistMap_, and rootFilename_.

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

Definition at line 290 of file EcalPulseShapeGrapher.cc.

Referenced by EcalPulseShapeGrapher().

291 {
292  using namespace std;
293  ostringstream myStream;
294  myStream << num << flush;
295  return(myStream.str()); //returns the string form of the stringstream object
296 }
long long int num
Definition: procUtils.cc:71

Member Data Documentation

int EcalPulseShapeGrapher::abscissa[10]
private

Definition at line 64 of file EcalPulseShapeGrapher.h.

Referenced by EcalPulseShapeGrapher().

int EcalPulseShapeGrapher::ampCut_
private

Definition at line 73 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

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

Definition at line 67 of file EcalPulseShapeGrapher.h.

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

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

Definition at line 71 of file EcalPulseShapeGrapher.h.

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

edm::InputTag EcalPulseShapeGrapher::EBDigis_
private

Definition at line 60 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

edm::InputTag EcalPulseShapeGrapher::EBUncalibratedRecHitCollection_
private

Definition at line 59 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

edm::InputTag EcalPulseShapeGrapher::EEDigis_
private

Definition at line 62 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

edm::InputTag EcalPulseShapeGrapher::EEUncalibratedRecHitCollection_
private

Definition at line 61 of file EcalPulseShapeGrapher.h.

Referenced by analyze().

EcalFedMap* EcalPulseShapeGrapher::fedMap_
private

Definition at line 78 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), and EcalPulseShapeGrapher().

TFile* EcalPulseShapeGrapher::file_
private

Definition at line 76 of file EcalPulseShapeGrapher.h.

Referenced by endJob().

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

Definition at line 69 of file EcalPulseShapeGrapher.h.

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

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

Definition at line 66 of file EcalPulseShapeGrapher.h.

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

int EcalPulseShapeGrapher::ordinate[10]
private

Definition at line 65 of file EcalPulseShapeGrapher.h.

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

Definition at line 68 of file EcalPulseShapeGrapher.h.

Referenced by analyze(), and EcalPulseShapeGrapher().

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

Definition at line 70 of file EcalPulseShapeGrapher.h.

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

std::string EcalPulseShapeGrapher::rootFilename_
private

Definition at line 74 of file EcalPulseShapeGrapher.h.

Referenced by endJob().