CMS 3D CMS Logo

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

#include <EcalPerEvtLaserAnalyzer.h>

Inheritance diagram for EcalPerEvtLaserAnalyzer:
edm::EDAnalyzer

Public Types

enum  VarCol { iBlue, iRed, nColor }
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &c)
 
virtual void beginJob ()
 
 EcalPerEvtLaserAnalyzer (const edm::ParameterSet &iConfig)
 
virtual void endJob ()
 
 ~EcalPerEvtLaserAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

unsigned int _channel
 
std::string _ecalPart
 
int _fedid
 
unsigned int _firstsample
 
unsigned int _firstsamplePN
 
unsigned int _lastsample
 
unsigned int _lastsamplePN
 
unsigned int _niter
 
unsigned int _nsamples
 
unsigned int _nsamplesPN
 
unsigned int _presample
 
unsigned int _presamplePN
 
unsigned int _samplemax
 
unsigned int _samplemin
 
unsigned int _timingcuthigh
 
unsigned int _timingcutlow
 
unsigned int _tower
 
double adc [10]
 
std::string ADCfile
 
TFile * ADCFile
 
int adcG [10]
 
TTree * ADCtrees
 
std::string alphafile
 
double apdAmpl
 
std::string APDfile
 
TFile * APDFile
 
double apdTime
 
TTree * APDtrees
 
int channelNumber
 
int colMat
 
int color
 
std::vector< int > colors
 
int dccID
 
std::string digiCollection_
 
std::string digiPNCollection_
 
std::string digiProducer_
 
int doesRefFileExist
 
int eta
 
int event
 
std::string eventHeaderCollection_
 
std::string eventHeaderProducer_
 
int evtMat
 
int fedID
 
TTree * header [2]
 
int iEvent
 
int IsFileCreated
 
int IsHeaderFilled [nColor]
 
int IsThereDataADC [nColor]
 
int lightside
 
TFile * matacqFile
 
TTree * matacqTree
 
unsigned int nCh
 
unsigned int nCrys
 
unsigned int nSides
 
unsigned int nTT
 
double peak
 
double peakMat
 
int phi
 
double pn [50]
 
double pn0
 
double pn1
 
double pnAmpl
 
std::string refalphabeta_
 
std::string resdir_
 
std::string resfile
 
int runNum
 
int runType
 
double tt
 
double ttMat
 
double ttrig
 

Additional Inherited Members

- 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

Definition at line 35 of file EcalPerEvtLaserAnalyzer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 48 of file EcalPerEvtLaserAnalyzer.cc.

References _ecalPart, digiCollection_, digiPNCollection_, digiProducer_, eventHeaderCollection_, eventHeaderProducer_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), nCrys, NCRYSEB, NCRYSEE, nTT, NTTEB, NTTEE, refalphabeta_, and resdir_.

50  :
51 iEvent(0),
52 
53 // framework parameters with default values
54 _nsamples( iConfig.getUntrackedParameter< unsigned int >( "nSamples", 10 ) ),
55 _presample( iConfig.getUntrackedParameter< unsigned int >( "nPresamples", 3 ) ),
56 _firstsample( iConfig.getUntrackedParameter< unsigned int >( "firstSample", 1 ) ),
57 _lastsample( iConfig.getUntrackedParameter< unsigned int >( "lastSample", 2 ) ),
58 _samplemin( iConfig.getUntrackedParameter< unsigned int >( "sampleMin", 3 ) ),
59 _samplemax( iConfig.getUntrackedParameter< unsigned int >( "sampleMax", 9 ) ),
60 _nsamplesPN( iConfig.getUntrackedParameter< unsigned int >( "nSamplesPN", 50 ) ),
61 _presamplePN( iConfig.getUntrackedParameter< unsigned int >( "nPresamplesPN", 6 ) ),
62 _firstsamplePN( iConfig.getUntrackedParameter< unsigned int >( "firstSamplePN", 7 ) ),
63 _lastsamplePN( iConfig.getUntrackedParameter< unsigned int >( "lastSamplePN", 8 ) ),
64 _timingcutlow( iConfig.getUntrackedParameter< unsigned int >( "timingCutLow", 3 ) ),
65 _timingcuthigh( iConfig.getUntrackedParameter< unsigned int >( "timingCutHigh", 7 ) ),
66 _niter( iConfig.getUntrackedParameter< unsigned int >( "nIter", 3 ) ),
67 _fedid( iConfig.getUntrackedParameter< unsigned int >( "fedID", 0 ) ),
68 _tower( iConfig.getUntrackedParameter< unsigned int >( "tower", 1 ) ),
69 _channel( iConfig.getUntrackedParameter< unsigned int >( "channel", 1 ) ),
70 _ecalPart( iConfig.getUntrackedParameter< std::string >( "ecalPart", "EB" ) ),
71 nCrys( NCRYSEB),
72 nTT( NTTEB),
73 nSides( NSIDES),
74 IsFileCreated(0), nCh(0),
75 runType(-1), runNum(0), dccID(-1), lightside(2), doesRefFileExist(0),
76 ttMat(-1), peakMat(-1), peak(-1), evtMat(-1), colMat(-1)
77  //========================================================================
78 
79 {
80 
81  //now do what ever initialization is needed
82 
83  resdir_ = iConfig.getUntrackedParameter<std::string>("resDir");
84  refalphabeta_ = iConfig.getUntrackedParameter<std::string>("refAlphaBeta");
85 
86  digiCollection_ = iConfig.getParameter<std::string>("digiCollection");
87  digiPNCollection_ = iConfig.getParameter<std::string>("digiPNCollection");
88  digiProducer_ = iConfig.getParameter<std::string>("digiProducer");
89 
90  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
91  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
92 
93  // Define geometrical constants
94 
95  if (_ecalPart == "EB") {
96  nCrys = NCRYSEB;
97  nTT = NTTEB;
98  } else {
99  nCrys = NCRYSEE;
100  nTT = NTTEE;
101  }
102 
103 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define NTTEB
#define NSIDES
#define NTTEE
#define NCRYSEE
#define NCRYSEB
EcalPerEvtLaserAnalyzer::~EcalPerEvtLaserAnalyzer ( )

Definition at line 106 of file EcalPerEvtLaserAnalyzer.cc.

106  {
107  //========================================================================
108 
109 
110  // do anything here that needs to be done at desctruction time
111  // (e.g. close files, deallocate resources etc.)
112 
113 }

Member Function Documentation

void EcalPerEvtLaserAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 168 of file EcalPerEvtLaserAnalyzer.cc.

References _channel, _ecalPart, _fedid, _firstsamplePN, _lastsamplePN, _nsamples, _nsamplesPN, _presample, _presamplePN, _timingcuthigh, _timingcutlow, _tower, adc, adcG, ADCtrees, edm::SortedCollection< T, SORT >::begin(), edm::DataFrameContainer::begin(), dtNoiseDBValidation_cfg::cerr, EcalElectronicsId::channelId(), channelNumber, colMat, color, colors, gather_cfg::cout, MEEEGeom::crystal(), dccID, digiCollection_, digiPNCollection_, digiProducer_, doesRefFileExist, MEEBGeom::electronic_channel(), edm::SortedCollection< T, SORT >::end(), edm::DataFrameContainer::end(), eta, event, eventHeaderCollection_, eventHeaderProducer_, evtMat, cppFunctionSkipper::exception, fedID, spr::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalElectronicsMapping::getElectronicsId(), i, iEvent, init, IsFileCreated, gen::k, EcalDCCHeaderBlock::LASER_GAP, EcalDCCHeaderBlock::LASER_STD, lightside, MEEEGeom::lmmod(), MEEBGeom::lmmod(), MEEBGeom::localCoord(), matacqFile, matacqTree, siStripFEDMonitor_P5_cff::Max, prof2calltree::namefile, nCrys, peak, peakMat, phi, MEEBGeom::pn(), MEEEGeom::pn(), pn, pn0, pn1, pnAmpl, edm::Handle< T >::product(), edm::ESHandle< class >::product(), resdir_, resfile, runNum, runType, MEEBGeom::side(), strip(), EcalElectronicsId::stripId(), run_regression::test, EcalElectronicsId::towerId(), ttMat, ttrig, EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength, and EcalElectronicsId::xtalId().

168  {
169  //========================================================================
170 
171  ++iEvent;
172 
173  // retrieving DCC header
175  const EcalRawDataCollection* DCCHeader=0;
176  try {
178  DCCHeader=pDCCHeader.product();
179  }catch ( std::exception& ex ) {
180  std::cerr << "Error! can't get the product retrieving DCC header" << eventHeaderCollection_.c_str() << std::endl;
181  }
182 
183  // retrieving crystal data from Event
185  const EBDigiCollection* EBDigi=0;
187  const EEDigiCollection* EEDigi=0;
188 
189  if (_ecalPart == "EB") {
190  try {
192  EBDigi=pEBDigi.product();
193  }catch ( std::exception& ex ) {
194  std::cerr << "Error! can't get the product retrieving EB crystal data " << digiCollection_.c_str() << std::endl;
195  }
196  } else {
197  try {
199  EEDigi=pEEDigi.product();
200  }catch ( std::exception& ex ) {
201  std::cerr << "Error! can't get the product retrieving EE crystal data " << digiCollection_.c_str() << std::endl;
202  }
203  }
204 
205 
206  // retrieving crystal PN diodes from Event
208  const EcalPnDiodeDigiCollection* PNDigi=0;
209  try {
211  PNDigi=pPNDigi.product();
212  }catch ( std::exception& ex ) {
213  std::cerr << "Error! can't get the product " << digiPNCollection_.c_str() << std::endl;
214  }
215 
216  // retrieving electronics mapping
218  const EcalElectronicsMapping* TheMapping=0;
219  try{
220  c.get< EcalMappingRcd >().get(ecalmapping);
221  TheMapping = ecalmapping.product();
222  }catch ( std::exception& ex ) {
223  std::cerr << "Error! can't get the product EcalMappingRcd"<< std::endl;
224  }
225 
226  // ====================================
227  // Decode Basic DCCHeader Information
228  // ====================================
229 
230  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeader->begin();headerItr != DCCHeader->end();
231  ++headerItr ) {
232 
233  // Get run type and run number
234 
235  int fed = headerItr->fedId();
236 
237  if(fed!=_fedid && _fedid!=-999) continue;
238 
239  runType=headerItr->getRunType();
240  runNum=headerItr->getRunNumber();
241  event=headerItr->getLV1();
242  dccID=headerItr->getDccInTCCCommand();
243  fedID=headerItr->fedId();
244 
245  // take event only if the fed corresponds to the DCC in TCC
246  if( 600+dccID != fedID ) continue;
247 
248  // Cut on runType
250 
251  // Define output results files' names
252 
253  if (IsFileCreated==0){
254 
255  stringstream namefile2;
256  namefile2 << resdir_ <<"/APDAmpl_Run"<<runNum<<"_"<<_fedid <<"_"<<_tower<<"_"<<_channel<<".root";
257  resfile=namefile2.str();
258 
259  // Get Matacq ttrig
260 
261  stringstream namefile;
262  namefile << resdir_ <<"/Matacq-Run"<<runNum<<".root";
263 
265 
266  FILE *test;
267  test = fopen(namefile.str().c_str(),"r");
268  if (test) doesRefFileExist=1;
269 
270  if(doesRefFileExist==1){
271  matacqFile = new TFile((namefile.str().c_str()));
272  matacqTree=(TTree*)matacqFile->Get("MatacqShape");
273 
274  matacqTree->SetBranchAddress( "event", &evtMat );
275  matacqTree->SetBranchAddress( "color", &colMat );
276  matacqTree->SetBranchAddress( "peak", &peakMat );
277  matacqTree->SetBranchAddress( "ttrig", &ttMat );
278  }
279 
280  IsFileCreated=1;
281 
282  }
283 
284  // Retrieve laser color and event number
285 
286  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
287  int color = settings.wavelength;
288 
289  vector<int>::iterator iter = find( colors.begin(), colors.end(), color );
290  if( iter==colors.end() ){
291  colors.push_back( color );
292  cout <<" new color found "<< color<<" "<< colors.size()<< endl;
293  }
294 
295  }
296 
297  // cut on fedID
298 
299  if(fedID!=_fedid && _fedid!=-999) return;
300 
301 
302  // ======================
303  // Decode PN Information
304  // ======================
305 
306  TPNFit * pnfit = new TPNFit();
308 
309  double chi2pn=0;
310  double ypnrange[50];
311  double dsum=0.;
312  double dsum1=0.;
313  double bl=0.;
314  double bl1=0.;
315  double val_max=0.;
316  unsigned int samplemax=0;
317  unsigned int k;
318 
319  std::vector<double> allPNAmpl;
320 
321  for ( EcalPnDiodeDigiCollection::const_iterator pnItr = PNDigi->begin(); pnItr != PNDigi->end(); ++pnItr ) { // Loop on PNs
322 
323 
324  for ( int samId=0; samId < (*pnItr).size() ; samId++ ) { // Loop on PN samples
325  pn[samId]=(*pnItr).sample(samId).adc();
326  }
327 
328 
329  for(dsum=0.,k=0;k<_presamplePN;k++) {
330  dsum+=pn[k];
331  }
332  bl=dsum/((double) _presamplePN);
333 
334  for(val_max=0.,k=0;k<_nsamplesPN;k++) {
335  ypnrange[k]=pn[k] - bl;
336 
337  if(ypnrange[k] > val_max) {
338  val_max= ypnrange[k]; samplemax=k;
339  }
340  }
341 
342  chi2pn = pnfit -> doFit(samplemax,&ypnrange[0]);
343 
344  if(chi2pn == 101 || chi2pn == 102 || chi2pn == 103) pnAmpl=0.;
345  else pnAmpl= pnfit -> getAmpl();
346 
347  allPNAmpl.push_back(pnAmpl);
348 
349  }
350 
351  // ===========
352  // Get Matacq
353  // ===========
354 
355  ttrig=-1.;
356  peak=-1.;
357 
358  if(doesRefFileExist==1){
359  // FIXME
360  if (color==0) matacqTree->GetEntry(event-1);
361  else if(color==3) matacqTree->GetEntry(matacqTree->GetEntries("color==0")+event-1);
362  ttrig=ttMat;
363  peak=peakMat;
364 
365  }
366 
367 
368  // ===========================
369  // Decode EBDigis Information
370  // ===========================
371 
372  double yrange[10];
373  int adcGain=0;
374  int side=0;
375 
376  if (EBDigi){
377 
378  for ( EBDigiCollection::const_iterator digiItr= EBDigi->begin(); digiItr != EBDigi->end(); ++digiItr ) { // Loop on crystals
379 
380  EBDetId id_crystal(digiItr->id()) ;
381  EBDataFrame df( *digiItr );
382 
383  int etaG = id_crystal.ieta() ; // global
384  int phiG = id_crystal.iphi() ; // global
385 
386  int etaL ; // local
387  int phiL ; // local
388  std::pair<int, int> LocalCoord=MEEBGeom::localCoord( etaG , phiG );
389 
390  etaL=LocalCoord.first ;
391  phiL=LocalCoord.second ;
392 
393  eta = etaG;
394  phi = phiG;
395 
396  side=MEEBGeom::side(etaG,phiG);
397 
398  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
399 
400  int towerID=elecid_crystal.towerId();
401  // int channelID=elecid_crystal.channelId()-1; // FIXME so far for endcap only
402  int strip=elecid_crystal.stripId();
403  int xtal=elecid_crystal.xtalId();
404  int channelID= 5*(strip-1) + xtal-1; // FIXME
405 
406  int module= MEEBGeom::lmmod(etaG, phiG);
407 
408  std::pair<int,int> pnpair=MEEBGeom::pn(module);
409  unsigned int MyPn0=pnpair.first;
410  unsigned int MyPn1=pnpair.second;
411 
412  unsigned int channel=MEEBGeom::electronic_channel( etaL, phiL );
413  assert(channel < nCrys);
414 
415  double adcmax=0.0;
416 
417  if(towerID!=int(_tower) || channelID!=int(_channel) || dccID!=int(_fedid-600)) continue;
418  else channelNumber=channel;
419 
420  for (unsigned int i=0; i< (*digiItr).size() ; ++i ) { // Loop on adc samples
421 
422  EcalMGPASample samp_crystal(df.sample(i));
423  adc[i]=samp_crystal.adc() ;
424  adcG[i]=samp_crystal.gainId();
425 
426  if (i==0) adcGain=adcG[i];
427  if (i>0) adcGain=TMath::Max(adcG[i],adcGain);
428 
429  if (adc[i]>adcmax) {
430  adcmax=adc[i];
431  }
432  }
433 
434  for(dsum=0.,dsum1=0.,k=0;k<_presample;k++) {
435  dsum+=adc[k];
436  if(k<_presample-1) dsum1+=adc[k];
437  }
438 
439  bl=dsum/((double)_presample);
440  bl1=dsum1/((double)_presample-1);
441 
442  for(val_max=0.,k=0;k<_nsamples;k++) {
443  yrange[k]=adc[k] - bl;
444  if(yrange[k] > val_max) {
445  val_max= yrange[k]; samplemax=k;
446  }
447  }
448 
449  if(samplemax==4 || samplemax==5) {
450  val_max=val_max+bl-bl1;
451  for(k=0;k<_nsamples;k++) {
452  yrange[k]=yrange[k]+bl-bl1;
453  }
454  }
455 
456  for(unsigned int k=0;k<_nsamples;k++) {
457  adc[k]=yrange[k];
458  }
459 
460  pn0=allPNAmpl[MyPn0];
461  pn1=allPNAmpl[MyPn1];
462 
463  if(samplemax>=_timingcutlow && samplemax<=_timingcuthigh && lightside==side) ADCtrees->Fill();
464 
465  }
466 
467  } else {
468 
469  for ( EEDigiCollection::const_iterator digiItr= EEDigi->begin(); digiItr != EEDigi->end(); ++digiItr ) { // Loop on crystals
470 
471  EEDetId id_crystal(digiItr->id()) ;
472  EEDataFrame df( *digiItr );
473 
474  phi = id_crystal.ix()-1 ;
475  eta = id_crystal.iy()-1 ;
476  side=0; // FIXME
477 
478  // Recover the TT id and the electronic crystal numbering from EcalElectronicsMapping
479 
480  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
481 
482  int towerID=elecid_crystal.towerId();
483  int channelID=elecid_crystal.channelId()-1;
484 
485  int module=MEEEGeom::lmmod( phi, eta );
486 
487  std::pair<int,int> pnpair=MEEEGeom::pn( module, _fedid ) ;
488  unsigned int MyPn0=pnpair.first;
489  unsigned int MyPn1=pnpair.second;
490 
491  unsigned int channel=MEEEGeom::crystal( phi, eta );
492  assert(channel < nCrys);
493 
494  double adcmax=0.0;
495 
496  if(towerID!=int(_tower) || channelID!=int(_channel) || dccID!=int(_fedid-600)) continue;
497  else channelNumber=channel;
498 
499  for (unsigned int i=0; i< (*digiItr).size() ; ++i ) { // Loop on adc samples
500 
501  EcalMGPASample samp_crystal(df.sample(i));
502  adc[i]=samp_crystal.adc() ;
503  adcG[i]=samp_crystal.gainId();
504 
505  if (i==0) adcGain=adcG[i];
506  if (i>0) adcGain=TMath::Max(adcG[i],adcGain);
507 
508  if (adc[i]>adcmax) {
509  adcmax=adc[i];
510  }
511  }
512 
513  for(dsum=0.,dsum1=0.,k=0;k<_presample;k++) {
514  dsum+=adc[k];
515  if(k<_presample-1) dsum1+=adc[k];
516  }
517 
518  bl=dsum/((double)_presample);
519  bl1=dsum1/((double)_presample-1);
520 
521  for(val_max=0.,k=0;k<_nsamples;k++) {
522  yrange[k]=adc[k] - bl;
523  if(yrange[k] > val_max) {
524  val_max= yrange[k]; samplemax=k;
525  }
526  }
527 
528  if(samplemax==4 || samplemax==5) {
529  val_max=val_max+bl-bl1;
530  for(k=0;k<_nsamples;k++) {
531  yrange[k]=yrange[k]+bl-bl1;
532  }
533  }
534 
535  for(unsigned int k=0;k<_nsamples;k++) {
536  adc[k]=yrange[k];
537  }
538 
539  pn0=allPNAmpl[MyPn0];
540  pn1=allPNAmpl[MyPn1];
541 
542  if(samplemax>=_timingcutlow && samplemax<=_timingcuthigh && lightside==side) ADCtrees->Fill();
543 
544  }
545  }
546 
547 }// analyze
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:153
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
Definition: MEEEGeom.cc:93
int i
Definition: DBlmapReader.cc:9
static int crystal(CrysCoord ix, CrysCoord iy)
Definition: MEEEGeom.cc:398
int xtalId() const
get the channel id
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
int stripId() const
get the tower id
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
int init
Definition: HydjetWrapper.h:63
std::vector< T >::const_iterator const_iterator
int towerId() const
get the tower id
const_iterator begin() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static std::pair< int, int > pn(int ilmmod)
Definition: MEEBGeom.cc:483
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static std::pair< int, int > pn(int dee, int ilmod)
Definition: MEEEGeom.cc:615
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:345
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:93
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
int k[5][pyjets_maxn]
const_iterator end() const
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:114
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
const_iterator end() const
Definition: TPNFit.h:8
tuple cout
Definition: gather_cfg.py:121
Definition: vlib.h:209
int channelId() const
so far for EndCap only :
const_iterator begin() const
int adc() const
get the ADC sample (12 bits)
void EcalPerEvtLaserAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 118 of file EcalPerEvtLaserAnalyzer.cc.

References adc, ADCfile, ADCFile, ADCtrees, color, dccID, eta, event, IsFileCreated, mergeVDriftHistosByStation::name, nCh, nCrys, peak, phi, pn0, pn1, resdir_, and ttrig.

118  {
119  //========================================================================
120 
121 
122  // Define temporary files' names
123 
124  stringstream namefile1;
125  namefile1 <<resdir_<< "/ADCSamples.root" ;
126 
127  ADCfile=namefile1.str();
128 
129  // Create temporary file and trees to save adc samples
130 
131  ADCFile = new TFile(ADCfile.c_str(),"RECREATE");
132 
133 
134  stringstream name;
135  name <<"ADCTree";
136 
137  ADCtrees= new TTree(name.str().c_str(),name.str().c_str());
138 
139  ADCtrees->Branch( "iphi", &phi, "phi/I" );
140  ADCtrees->Branch( "ieta", &eta, "eta/I" );
141  ADCtrees->Branch( "dccID", &dccID, "dccID/I" );
142  ADCtrees->Branch( "event", &event, "event/I" );
143  ADCtrees->Branch( "color", &color, "color/I" );
144  ADCtrees->Branch( "adc", &adc , "adc[10]/D" );
145  ADCtrees->Branch( "ttrigMatacq", &ttrig, "ttrig/D" );
146  ADCtrees->Branch( "peakMatacq", &peak, "peak/D" );
147  ADCtrees->Branch( "pn0", &pn0, "pn0/D" );
148  ADCtrees->Branch( "pn1", &pn1, "pn1/D" );
149 
150  ADCtrees->SetBranchAddress( "ieta", &eta );
151  ADCtrees->SetBranchAddress( "iphi", &phi );
152  ADCtrees->SetBranchAddress( "dccID", &dccID );
153  ADCtrees->SetBranchAddress( "event", &event );
154  ADCtrees->SetBranchAddress( "color", &color );
155  ADCtrees->SetBranchAddress( "adc", adc );
156  ADCtrees->SetBranchAddress( "ttrigMatacq", &ttrig );
157  ADCtrees->SetBranchAddress( "peakMatacq", &peak );
158  ADCtrees->SetBranchAddress( "pn0", &pn0 );
159  ADCtrees->SetBranchAddress( "pn1", &pn1 );
160 
161  IsFileCreated=0;
162  nCh=nCrys;
163 
164 }
void EcalPerEvtLaserAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 551 of file EcalPerEvtLaserAnalyzer.cc.

References _channel, _fedid, _firstsample, _lastsample, _niter, _nsamples, _tower, adc, ADCfile, ADCFile, ADCtrees, alpha, apdAmpl, APDFile, apdTime, APDtrees, beta, channelNumber, color, colors, gather_cfg::cout, GOODCOLL_filter_cfg::cut, dccID, event, edm::service::getTime(), header, i, init, IsHeaderFilled, IsThereDataADC, nColor, peak, pn0, pn1, refalphabeta_, resfile, and ttrig.

551  {
552 //========================================================================
553 
554 
555  assert( colors.size()<= nColor );
556  unsigned int nCol=colors.size();
557 
558 
559  ADCtrees->Write();
560 
561 
562  cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
563  cout << "\t+=+ Analyzing laser data: getting per event +=+" << endl;
564  cout << "\t+=+ APD Amplitudes and ADC samples +=+"<< endl;
565  cout << "\t+=+ for fed:" <<_fedid<<", tower:"<<_tower<<", and channel:" << _channel << endl;
566 
567 
568  // Define temporary tree to save APD amplitudes
569 
570  APDFile = new TFile(resfile.c_str(),"RECREATE");
571 
572  int ieta, iphi, channelID, towerID, flag;
573  double alpha, beta;
574 
575 
576  colors.push_back( color );
577 
578  for (unsigned int i=0;i<nCol;i++){
579 
580  stringstream name1;
581  name1<<"headerCol"<<colors[i];
582 
583  header[i] = new TTree(name1.str().c_str(),name1.str().c_str());
584 
585  header[i]->Branch( "alpha", &alpha, "alpha/D" );
586  header[i]->Branch( "beta", &beta, "beta/D" );
587  header[i]->Branch( "iphi", &iphi, "iphi/I" );
588  header[i]->Branch( "ieta", &ieta, "ieta/I" );
589  header[i]->Branch( "dccID", &dccID, "dccID/I" );
590  header[i]->Branch( "towerID", &towerID, "towerID/I" );
591  header[i]->Branch( "channelID", &channelID, "channelID/I" );
592 
593  header[i]->SetBranchAddress( "alpha", &alpha );
594  header[i]->SetBranchAddress( "beta", &beta );
595  header[i]->SetBranchAddress( "iphi", &iphi );
596  header[i]->SetBranchAddress( "ieta", &ieta );
597  header[i]->SetBranchAddress( "dccID", &dccID );
598  header[i]->SetBranchAddress( "towerID", &towerID );
599  header[i]->SetBranchAddress( "channelID", &channelID );
600 
601  }
602 
603  stringstream name2;
604  name2<<"APDTree";
605  APDtrees= new TTree(name2.str().c_str(),name2.str().c_str());
606 
607  //List of branches
608 
609  APDtrees->Branch( "event", &event, "event/I" );
610  APDtrees->Branch( "color", &color, "color/I" );
611  APDtrees->Branch( "adc", &adc , "adc[10]/D" );
612  APDtrees->Branch( "peakMatacq", &peak , "peak/D" );
613  APDtrees->Branch( "ttrigMatacq", &ttrig , "ttrig/D" );
614  APDtrees->Branch( "apdAmpl", &apdAmpl, "apdAmpl/D" );
615  APDtrees->Branch( "apdTime", &apdTime, "apdTime/D" );
616  APDtrees->Branch( "flag", &flag, "flag/I" );
617  APDtrees->Branch( "pn0", &pn0, "pn0/D" );
618  APDtrees->Branch( "pn1", &pn1, "pn1/D" );
619 
620  APDtrees->SetBranchAddress( "event", &event );
621  APDtrees->SetBranchAddress( "color", &color );
622  APDtrees->SetBranchAddress( "adc", adc );
623  APDtrees->SetBranchAddress( "peakMatacq", &peak );
624  APDtrees->SetBranchAddress( "ttrigMatacq", &ttrig );
625  APDtrees->SetBranchAddress( "apdAmpl", &apdAmpl );
626  APDtrees->SetBranchAddress( "apdTime", &apdTime );
627  APDtrees->SetBranchAddress( "flag", &flag );
628  APDtrees->SetBranchAddress( "pn0", &pn0 );
629  APDtrees->SetBranchAddress( "pn1", &pn1 );
630 
631  // Retrieve alpha and beta for APD amplitudes calculation
632 
633 
634  TFile *alphaFile = new TFile(refalphabeta_.c_str());
635  TTree *alphaTree[2];
636 
637  Double_t alphaRun, betaRun;
638  int ietaRun, iphiRun, channelIDRun, towerIDRun, dccIDRun, flagRun;
639 
640  for( unsigned int i=0;i<nCol;i++){
641 
642  stringstream name3;
643  name3<<"ABCol"<<i;
644  alphaTree[i]=(TTree*)alphaFile->Get(name3.str().c_str());
645  alphaTree[i]->SetBranchStatus( "*", 0 );
646  alphaTree[i]->SetBranchStatus( "alpha", 1 );
647  alphaTree[i]->SetBranchStatus( "beta", 1 );
648  alphaTree[i]->SetBranchStatus( "iphi", 1 );
649  alphaTree[i]->SetBranchStatus( "ieta", 1 );
650  alphaTree[i]->SetBranchStatus( "dccID", 1 );
651  alphaTree[i]->SetBranchStatus( "towerID", 1 );
652  alphaTree[i]->SetBranchStatus( "channelID", 1 );
653  alphaTree[i]->SetBranchStatus( "flag", 1 );
654 
655  alphaTree[i]->SetBranchAddress( "alpha", &alphaRun );
656  alphaTree[i]->SetBranchAddress( "beta", &betaRun );
657  alphaTree[i]->SetBranchAddress( "iphi", &iphiRun );
658  alphaTree[i]->SetBranchAddress( "ieta", &ietaRun );
659  alphaTree[i]->SetBranchAddress( "dccID", &dccIDRun );
660  alphaTree[i]->SetBranchAddress( "towerID", &towerIDRun );
661  alphaTree[i]->SetBranchAddress( "channelID", &channelIDRun );
662  alphaTree[i]->SetBranchAddress( "flag", &flagRun );
663 
664  }
665 
666  PulseFitWithFunction * pslsfit = new PulseFitWithFunction();
667 
668  double chi2;
669 
670  for (unsigned int icol=0;icol<nCol;icol++){
671 
672  IsThereDataADC[icol]=1;
673  stringstream cut;
674  cut <<"color=="<<colors.at(icol);
675  if(ADCtrees->GetEntries(cut.str().c_str())<10) IsThereDataADC[icol]=0;
676  IsHeaderFilled[icol]=0;
677 
678  }
679 
680  // Define submodule and channel number inside the submodule (as Patrice)
681 
682 
683  Long64_t nbytes = 0, nb = 0;
684  for (Long64_t jentry=0; jentry< ADCtrees->GetEntriesFast();jentry++) { // Loop on events
685  nb = ADCtrees->GetEntry(jentry); nbytes += nb;
686 
687  int iCry=channelNumber;
688 
689  // get back color
690 
691  unsigned int iCol=0;
692  for(unsigned int i=0;i<nCol;i++){
693  if(color==colors[i]) {
694  iCol=i;
695  i=colors.size();
696  }
697  }
698 
699  alphaTree[iCol]->GetEntry(iCry);
700 
701 
702  flag=flagRun;
703  iphi=iphiRun;
704  ieta=ietaRun;
705  towerID=towerIDRun;
706  channelID=channelIDRun;
707  alpha=alphaRun;
708  beta=betaRun;
709 
710  if (IsHeaderFilled[iCol]==0){
711  header[iCol]->Fill();
712  IsHeaderFilled[iCol]=1;
713 
714  }
715  // Amplitude calculation
716 
717  apdAmpl=0;
718  apdTime=0;
719 
720  pslsfit -> init(_nsamples,_firstsample,_lastsample,_niter, alphaRun, betaRun);
721  chi2 = pslsfit -> doFit(&adc[0]);
722 
723  if( chi2 < 0. || chi2 == 102 || chi2 == 101 ) {
724 
725  apdAmpl=0;
726  apdTime=0;
727 
728  }else{
729 
730  apdAmpl = pslsfit -> getAmpl();
731  apdTime = pslsfit -> getTime();
732 
733  }
734 
735  APDtrees->Fill();
736 
737  }
738 
739  alphaFile->Close();
740 
741  ADCFile->Close();
742 
743  APDFile->Write();
744  APDFile->Close();
745 
746 
747 
748 
749  // Remove unwanted files
750 
751  stringstream del;
752  del << "rm " <<ADCfile;
753  system(del.str().c_str());
754 
755  cout << "\t+=+ .................................................. done +=+" << endl;
756  cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
757 }
const double beta
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
long int flag
Definition: mlp_lapack.h:47
int init
Definition: HydjetWrapper.h:63
static double getTime()
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

unsigned int EcalPerEvtLaserAnalyzer::_channel
private

Definition at line 71 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

std::string EcalPerEvtLaserAnalyzer::_ecalPart
private

Definition at line 72 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and EcalPerEvtLaserAnalyzer().

int EcalPerEvtLaserAnalyzer::_fedid
private

Definition at line 69 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

unsigned int EcalPerEvtLaserAnalyzer::_firstsample
private

Definition at line 58 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

unsigned int EcalPerEvtLaserAnalyzer::_firstsamplePN
private

Definition at line 64 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_lastsample
private

Definition at line 59 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

unsigned int EcalPerEvtLaserAnalyzer::_lastsamplePN
private

Definition at line 65 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_niter
private

Definition at line 68 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

unsigned int EcalPerEvtLaserAnalyzer::_nsamples
private

Definition at line 56 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

unsigned int EcalPerEvtLaserAnalyzer::_nsamplesPN
private

Definition at line 62 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_presample
private

Definition at line 57 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_presamplePN
private

Definition at line 63 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_samplemax
private

Definition at line 61 of file EcalPerEvtLaserAnalyzer.h.

unsigned int EcalPerEvtLaserAnalyzer::_samplemin
private

Definition at line 60 of file EcalPerEvtLaserAnalyzer.h.

unsigned int EcalPerEvtLaserAnalyzer::_timingcuthigh
private

Definition at line 67 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_timingcutlow
private

Definition at line 66 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::_tower
private

Definition at line 70 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

double EcalPerEvtLaserAnalyzer::adc[10]
private

Definition at line 142 of file EcalPerEvtLaserAnalyzer.h.

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

std::string EcalPerEvtLaserAnalyzer::ADCfile
private

Definition at line 86 of file EcalPerEvtLaserAnalyzer.h.

Referenced by beginJob(), and endJob().

TFile* EcalPerEvtLaserAnalyzer::ADCFile
private

Definition at line 122 of file EcalPerEvtLaserAnalyzer.h.

Referenced by beginJob(), and endJob().

int EcalPerEvtLaserAnalyzer::adcG[10]
private

Definition at line 143 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

TTree* EcalPerEvtLaserAnalyzer::ADCtrees
private

Definition at line 123 of file EcalPerEvtLaserAnalyzer.h.

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

std::string EcalPerEvtLaserAnalyzer::alphafile
private

Definition at line 85 of file EcalPerEvtLaserAnalyzer.h.

double EcalPerEvtLaserAnalyzer::apdAmpl
private

Definition at line 148 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

std::string EcalPerEvtLaserAnalyzer::APDfile
private

Definition at line 87 of file EcalPerEvtLaserAnalyzer.h.

TFile* EcalPerEvtLaserAnalyzer::APDFile
private

Definition at line 125 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

double EcalPerEvtLaserAnalyzer::apdTime
private

Definition at line 149 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

TTree* EcalPerEvtLaserAnalyzer::APDtrees
private

Definition at line 127 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

int EcalPerEvtLaserAnalyzer::channelNumber
private

Definition at line 113 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalPerEvtLaserAnalyzer::colMat
private

Definition at line 135 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

int EcalPerEvtLaserAnalyzer::color
private

Definition at line 141 of file EcalPerEvtLaserAnalyzer.h.

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

std::vector<int> EcalPerEvtLaserAnalyzer::colors
private

Definition at line 116 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalPerEvtLaserAnalyzer::dccID
private

Definition at line 109 of file EcalPerEvtLaserAnalyzer.h.

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

std::string EcalPerEvtLaserAnalyzer::digiCollection_
private

Definition at line 76 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and EcalPerEvtLaserAnalyzer().

std::string EcalPerEvtLaserAnalyzer::digiPNCollection_
private

Definition at line 77 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and EcalPerEvtLaserAnalyzer().

std::string EcalPerEvtLaserAnalyzer::digiProducer_
private

Definition at line 78 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and EcalPerEvtLaserAnalyzer().

int EcalPerEvtLaserAnalyzer::doesRefFileExist
private

Definition at line 130 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

int EcalPerEvtLaserAnalyzer::eta
private

Definition at line 139 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and beginJob().

int EcalPerEvtLaserAnalyzer::event
private

Definition at line 140 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), beginJob(), Types.EventID::cppID(), and endJob().

std::string EcalPerEvtLaserAnalyzer::eventHeaderCollection_
private

Definition at line 79 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and EcalPerEvtLaserAnalyzer().

std::string EcalPerEvtLaserAnalyzer::eventHeaderProducer_
private

Definition at line 80 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and EcalPerEvtLaserAnalyzer().

int EcalPerEvtLaserAnalyzer::evtMat
private

Definition at line 135 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

int EcalPerEvtLaserAnalyzer::fedID
private

Definition at line 110 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

TTree* EcalPerEvtLaserAnalyzer::header[2]
private

Definition at line 126 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

int EcalPerEvtLaserAnalyzer::iEvent
private

Definition at line 51 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

int EcalPerEvtLaserAnalyzer::IsFileCreated
private

Definition at line 99 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and beginJob().

int EcalPerEvtLaserAnalyzer::IsHeaderFilled[nColor]
private

Definition at line 132 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

int EcalPerEvtLaserAnalyzer::IsThereDataADC[nColor]
private

Definition at line 131 of file EcalPerEvtLaserAnalyzer.h.

Referenced by endJob().

int EcalPerEvtLaserAnalyzer::lightside
private

Definition at line 111 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

TFile* EcalPerEvtLaserAnalyzer::matacqFile
private

Definition at line 119 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

TTree* EcalPerEvtLaserAnalyzer::matacqTree
private

Definition at line 120 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtLaserAnalyzer::nCh
private

Definition at line 103 of file EcalPerEvtLaserAnalyzer.h.

Referenced by beginJob().

unsigned int EcalPerEvtLaserAnalyzer::nCrys
private

Definition at line 94 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), beginJob(), and EcalPerEvtLaserAnalyzer().

unsigned int EcalPerEvtLaserAnalyzer::nSides
private

Definition at line 96 of file EcalPerEvtLaserAnalyzer.h.

unsigned int EcalPerEvtLaserAnalyzer::nTT
private

Definition at line 95 of file EcalPerEvtLaserAnalyzer.h.

Referenced by EcalPerEvtLaserAnalyzer().

double EcalPerEvtLaserAnalyzer::peak
private

Definition at line 134 of file EcalPerEvtLaserAnalyzer.h.

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

double EcalPerEvtLaserAnalyzer::peakMat
private

Definition at line 134 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

int EcalPerEvtLaserAnalyzer::phi
private

Definition at line 139 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and beginJob().

double EcalPerEvtLaserAnalyzer::pn[50]
private

Definition at line 147 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

double EcalPerEvtLaserAnalyzer::pn0
private

Definition at line 146 of file EcalPerEvtLaserAnalyzer.h.

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

double EcalPerEvtLaserAnalyzer::pn1
private

Definition at line 146 of file EcalPerEvtLaserAnalyzer.h.

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

double EcalPerEvtLaserAnalyzer::pnAmpl
private

Definition at line 150 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

std::string EcalPerEvtLaserAnalyzer::refalphabeta_
private

Definition at line 75 of file EcalPerEvtLaserAnalyzer.h.

Referenced by EcalPerEvtLaserAnalyzer(), and endJob().

std::string EcalPerEvtLaserAnalyzer::resdir_
private

Definition at line 74 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), beginJob(), and EcalPerEvtLaserAnalyzer().

std::string EcalPerEvtLaserAnalyzer::resfile
private

Definition at line 88 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalPerEvtLaserAnalyzer::runNum
private

Definition at line 108 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

int EcalPerEvtLaserAnalyzer::runType
private

Definition at line 107 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

double EcalPerEvtLaserAnalyzer::tt
private

Definition at line 144 of file EcalPerEvtLaserAnalyzer.h.

double EcalPerEvtLaserAnalyzer::ttMat
private

Definition at line 134 of file EcalPerEvtLaserAnalyzer.h.

Referenced by analyze().

double EcalPerEvtLaserAnalyzer::ttrig
private

Definition at line 145 of file EcalPerEvtLaserAnalyzer.h.

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