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
EcalMatacqAnalyzer Class Reference

#include <EcalMatacqAnalyzer.h>

Inheritance diagram for EcalMatacqAnalyzer:
edm::EDAnalyzer

Public Types

enum  VarCol { iBlue, iRed, nColor }
 
enum  VarSide { iSide0, iSide1, nSide }
 
- 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 ()
 
 EcalMatacqAnalyzer (const edm::ParameterSet &iConfig)
 
virtual void endJob ()
 
 ~EcalMatacqAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

double _cutwindow
 
int _debug
 
int _fedid
 
unsigned int _highlev
 
unsigned int _lowlev
 
unsigned int _nevlasers
 
unsigned int _noiseCut
 
unsigned int _nsamplesaftmax
 
unsigned int _nsamplesshape
 
unsigned int _parabnaftmax
 
unsigned int _parabnbefmax
 
double _presample
 
unsigned int _presampleshape
 
unsigned int _slide
 
unsigned int _thres
 
unsigned int _timeaftmax
 
unsigned int _timebefmax
 
double ampl
 
int color
 
std::vector< int > colors
 
int dccID
 
std::string digiCollection_
 
std::string digiProducer_
 
int event
 
std::string eventHeaderCollection_
 
std::string eventHeaderProducer_
 
int fedID
 
double fit
 
double fw20
 
double fw80
 
double fwhm
 
int iEvent
 
bool isThereMatacq
 
int laserEvents
 
int lightside
 
double matacq [2560]
 
int maxsamp
 
TTree * meanTree [nColor]
 
TMTQMTQ [nColor][nSide]
 
TTree * mtqShape
 
int nsamples
 
unsigned int nSides
 
std::string outfile
 
TFile * outFile
 
double peak
 
double ped
 
double pedsig
 
std::string resdir_
 
int runNum
 
int runType
 
std::string sampfile
 
TFile * sampFile
 
double sigma
 
double sliding
 
int status
 
TTree * tree
 
double trise
 
double tt
 
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 14 of file EcalMatacqAnalyzer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 40 of file EcalMatacqAnalyzer.cc.

References digiCollection_, digiProducer_, eventHeaderCollection_, eventHeaderProducer_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and resdir_.

42  :
43 
44 iEvent(0),
45 
46 // framework parameters with default values
47 
48 _presample( iConfig.getUntrackedParameter< double >( "nPresamples", 6.7 ) ),
49 _nsamplesaftmax(iConfig.getUntrackedParameter< unsigned int >( "nSamplesAftMax", 80 ) ),
50 _noiseCut( iConfig.getUntrackedParameter< unsigned int >( "noiseCut", 7 ) ),
51 _parabnbefmax( iConfig.getUntrackedParameter< unsigned int >( "paraBeforeMax", 8 ) ),
52 _parabnaftmax( iConfig.getUntrackedParameter< unsigned int >( "paraAfterMax", 7 ) ),
53 _thres( iConfig.getUntrackedParameter< unsigned int >( "threshold", 10 ) ),
54 _lowlev( iConfig.getUntrackedParameter< unsigned int >( "lowLevel", 20 ) ),
55 _highlev( iConfig.getUntrackedParameter< unsigned int >( "highLevel", 80 ) ),
56 _nevlasers( iConfig.getUntrackedParameter< unsigned int >( "nEventLaser", 600 ) ),
57 _timebefmax( iConfig.getUntrackedParameter< unsigned int >( "timeBefMax", 100 ) ),
58 _timeaftmax( iConfig.getUntrackedParameter< unsigned int >( "timeAftMax", 250 ) ),
59 _cutwindow( iConfig.getUntrackedParameter< double >( "cutWindow", 0.1 ) ),
60 _nsamplesshape( iConfig.getUntrackedParameter< unsigned int >( "nSamplesShape", 250 ) ),
61 _presampleshape(iConfig.getUntrackedParameter< unsigned int >( "nPresamplesShape",50 ) ),
62 _slide( iConfig.getUntrackedParameter< unsigned int >( "nSlide", 100 ) ),
63 _fedid( iConfig.getUntrackedParameter< int >( "fedID", -999 ) ),
64 _debug( iConfig.getUntrackedParameter< int >( "debug", 0 ) ),
65 nSides(NSIDES), lightside(0), runType(-1), runNum(0),
66 event(0), color(-1), maxsamp(0), nsamples(0), tt(0)
67 
68  //========================================================================
69 {
70 
71 
72  //now do what ever initialization is needed
73 
74  resdir_ = iConfig.getUntrackedParameter<std::string>("resDir");
75 
76  digiCollection_ = iConfig.getParameter<std::string>("digiCollection");
77  digiProducer_ = iConfig.getParameter<std::string>("digiProducer");
78 
79  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
80  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
81 
82 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define NSIDES
unsigned int _presampleshape
unsigned int _nsamplesshape
std::string eventHeaderProducer_
unsigned int _timebefmax
std::string eventHeaderCollection_
unsigned int _parabnaftmax
unsigned int _timeaftmax
std::string digiCollection_
unsigned int _nsamplesaftmax
unsigned int _parabnbefmax
EcalMatacqAnalyzer::~EcalMatacqAnalyzer ( )

Definition at line 85 of file EcalMatacqAnalyzer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 147 of file EcalMatacqAnalyzer.cc.

References _debug, _fedid, EcalMatacqDigi::adcCount(), edm::SortedCollection< T, SORT >::begin(), dtNoiseDBValidation_cfg::cerr, color, colors, gather_cfg::cout, dccID, digiCollection_, digiProducer_, edm::SortedCollection< T, SORT >::end(), eventHeaderCollection_, eventHeaderProducer_, cppFunctionSkipper::exception, fedID, spr::find(), edm::Event::getByLabel(), i, iEvent, isThereMatacq, EcalDCCHeaderBlock::LASER_DELAY_SCAN, EcalDCCHeaderBlock::LASER_GAP, EcalDCCHeaderBlock::LASER_POWER_SCAN, EcalDCCHeaderBlock::LASER_STD, laserEvents, lightside, matacq, max(), maxsamp, nsamples, edm::Handle< T >::product(), runNum, runType, EcalMatacqDigi::size(), tree, tt, EcalMatacqDigi::tTrig(), and EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength.

147  {
148 //========================================================================
149 
150  ++iEvent;
151 
152  if (_debug==1 )std::cout << "-- debug test -- Entering Analyze -- event= "<<iEvent<< std::endl;
153 
154  // retrieving MATACQ :
156  const EcalMatacqDigiCollection* matacqDigi=0;
157  try {
158  e.getByLabel(digiProducer_,digiCollection_, pmatacqDigi);
159  matacqDigi=pmatacqDigi.product();
160  if (_debug==1 )std::cout << "-- debug test -- Matacq Digis Found -- "<< std::endl;
161 
162  }catch ( std::exception& ex ) {
163  std::cerr << "Error! can't get the product EcalMatacqDigi producer:" << digiProducer_.c_str()<<" collection:"<<digiCollection_.c_str() << std::endl;
164  if (_debug==1 )std::cout << "-- debug test -- No Matacq Digis Found -- "<< std::endl;
165  return;
166  }
167 
168  // retrieving DCC header
169 
171  const EcalRawDataCollection* DCCHeader=0;
172  try {
174  DCCHeader=pDCCHeader.product();
175  }catch ( std::exception& ex ) {
176  std::cerr << "Error! can't get the product EcalRawData producer:" << eventHeaderProducer_.c_str()<<" collection:"<<eventHeaderCollection_.c_str() << std::endl;
177  return;
178  }
179 
180  // ====================================
181  // Decode Basic DCCHeader Information
182  // ====================================
183 
184  if (_debug==1) std::cout <<"-- debug test -- Before header -- "<< std::endl;
185 
186  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeader->begin();headerItr != DCCHeader->end();
187  ++headerItr ) {
188 
189  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
190  color = (int) settings.wavelength;
191  if( color<0 ) return;
192 
193  // Get run type and run number
194 
195  int fed = headerItr->fedId();
196 
197  if(fed!=_fedid && _fedid!=-999) continue;
198 
199  runType=headerItr->getRunType();
200  runNum=headerItr->getRunNumber();
201  event=headerItr->getLV1();
202 
203  if (_debug==1) std::cout <<"-- debug test -- runtype:"<<runType<<" event:"<<event <<" runNum:"<<runNum <<std::endl;
204 
205  dccID=headerItr->getDccInTCCCommand();
206  fedID=headerItr->fedId();
207  lightside=headerItr->getRtHalf();
208 
209  //assert (lightside<2 && lightside>=0);
210 
211  if( lightside!=1 && lightside!=0 ) {
212  std::cout << "Unexpected lightside: "<< lightside<<" for event "<<iEvent << std::endl;
213  return;
214  }
215  if (_debug==1) {
216  std::cout <<"-- debug test -- Inside header before fed cut -- color="<<color<< ", dcc="<<dccID<<", fed="<< fedID<<", lightside="<<lightside<<", runType="<<runType<< std::endl;
217  }
218 
219  // take event only if the fed corresponds to the DCC in TCC
220  if( 600+dccID != fedID ) continue;
221 
222  if (_debug==1) {
223  std::cout <<"-- debug test -- Inside header after fed cut -- color="<<color<< ", dcc="<<dccID<<", fed="<< fedID<<", lightside="<<lightside<<", runType="<<runType<< std::endl;
224  }
225 
226  // Cut on runType
227 
229 
230 
231  std::vector<int>::iterator iter= find( colors.begin(), colors.end(), color );
232  if( iter==colors.end() ){
233  colors.push_back( color );
234  std::cout <<" new color found "<< color<<" "<< colors.size()<< std::endl;
235  }
236 
237  }
238 
239  if (_debug==1) std::cout <<"-- debug test -- Before digis -- Event:"<<iEvent<< std::endl;
240 
241  // Count laser events
242  laserEvents++;
243 
244 
245 
246 // ===========================
247 // Decode Matacq Information
248 // ===========================
249 
250  int iCh=0;
251  double max=0;
252 
253  for(EcalMatacqDigiCollection::const_iterator it = matacqDigi->begin(); it!=matacqDigi->end(); ++it){ // Loop on matacq channel
254 
255  //
256  const EcalMatacqDigi& digis = *it;
257 
258  //if(digis.size()==0 || iCh>=N_channels) continue;
259  if (_debug==1) {
260  std::cout <<"-- debug test -- Inside digis -- digi size="<<digis.size()<< std::endl;
261  }
262 
263  if(digis.size()== 0 ) continue;
264  else isThereMatacq=true;
265 
266  max=0;
267  maxsamp=0;
268  nsamples=digis.size();
269  tt=digis.tTrig();
270 
271  for(int i=0; i<digis.size(); ++i){ // Loop on matacq samples
272  matacq[i]=-digis.adcCount(i);
273  if(matacq[i]>max) {
274  max=matacq[i];
275  maxsamp=i;
276  }
277  }
278  if (_debug==1) {
279  std::cout <<"-- debug test -- Inside digis -- nsamples="<<nsamples<< ", max="<<max<< std::endl;
280  }
281 
282  iCh++;
283  }
284 
285  if (_debug==1)std::cout <<"-- debug test -- After digis -- Event: "<<iEvent<< std::endl;
286  tree->Fill();
287 
288 } // analyze
int i
Definition: DBlmapReader.cc:9
std::vector< int > colors
std::vector< T >::const_iterator const_iterator
float tTrig() const
std::string eventHeaderProducer_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const float adcCount(const int &i) const
std::string eventHeaderCollection_
const T & max(const T &a, const T &b)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const_iterator end() const
T const * product() const
Definition: Handle.h:74
int size() const
tuple cout
Definition: gather_cfg.py:121
std::string digiCollection_
const_iterator begin() const
void EcalMatacqAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 96 of file EcalMatacqAnalyzer.cc.

References color, event, isThereMatacq, laserEvents, lightside, matacq, maxsamp, prof2calltree::namefile, nsamples, outfile, resdir_, sampfile, sampFile, tree, and tt.

96  {
97 //========================================================================
98 
99 // Define temporary file name
100 
102  sampfile+="/TmpTreeMatacqAnalyzer.root";
103 
104  sampFile = new TFile(sampfile.c_str(),"RECREATE");
105 
106 
107  // declaration of the tree to fill
108 
109  tree = new TTree("MatacqTree","MatacqTree");
110 
111 
112  //List of branches
113 
114  tree->Branch( "event", &event, "event/I" );
115  tree->Branch( "color", &color , "color/I" );
116  tree->Branch( "matacq", &matacq , "matacq[2560]/D" );
117  tree->Branch( "nsamples", &nsamples , "nsamples/I" );
118  tree->Branch( "maxsamp", &maxsamp , "maxsamp/I" );
119  tree->Branch( "tt", &tt , "tt/D" );
120  tree->Branch( "lightside", &lightside , "lightside/I" );
121 
122  tree->SetBranchAddress( "event", &event );
123  tree->SetBranchAddress( "color", &color );
124  tree->SetBranchAddress( "matacq", matacq );
125  tree->SetBranchAddress( "nsamples", &nsamples );
126  tree->SetBranchAddress( "maxsamp", &maxsamp );
127  tree->SetBranchAddress( "tt", &tt );
128  tree->SetBranchAddress( "lightside", &lightside );
129 
130 
131 
132  // Define output results files' names
133 
134  std::stringstream namefile;
135  namefile << resdir_ <<"/MATACQ.root";
136  outfile=namefile.str();
137 
138 
139  // Laser events counter
140  laserEvents=0;
141  isThereMatacq=false;
142 
143 }
void EcalMatacqAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 292 of file EcalMatacqAnalyzer.cc.

References _cutwindow, _debug, _highlev, _lowlev, _nevlasers, _noiseCut, _nsamplesaftmax, _nsamplesshape, _parabnaftmax, _parabnbefmax, _presample, _presampleshape, _slide, _thres, _timeaftmax, _timebefmax, revisionDML::addEntry(), ampl, color, colors, TMatacq::compute_trise(), gather_cfg::cout, TMatacq::doFit(), event, TMatacq::findPeak(), fit, fw20, fw80, fwhm, TMTQ::get(), TMatacq::getAmpl(), TMatacq::getBaseLine(), TMatacq::getFwhm(), TMatacq::getsigBaseLine(), TMatacq::getsigTimpeak(), TMatacq::getSlide(), TMatacq::getTimax(), TMatacq::getTimpeak(), TMatacq::getTrise(), TMatacq::getWidth20(), TMatacq::getWidth80(), i, TMTQ::iAmpl, TMTQ::iFit, TMTQ::iFw20, TMTQ::iFw80, TMTQ::iFwhm, TMTQ::iPeak, TMTQ::iPed, TMTQ::iPedsig, TMTQ::iSigma, TMTQ::iSlide, isThereMatacq, TMTQ::iTrise, lightside, matacq, maxsamp, meanTree, MTQ, mtqShape, nColor, TMTQ::nOutVar, nsamples, nSide, nSides, outfile, outFile, peak, ped, pedsig, q1, q2, TMatacq::rawPulseAnalysis(), sampfile, sampFile, RooFit::Sigma(), sigma, sliding, status, run_regression::test, tree, trise, tt, and ttrig.

293 {
294 
295  // Don't do anything if there is no events
296  if( !isThereMatacq ) {
297 
298  std::cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
299  std::cout << "\t+=+ WARNING! NO MATACQ +=+" << std::endl;
300  std::cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
301 
302 
303  // Remove temporary file
304  FILE *test;
305  test = fopen(sampfile.c_str(),"r");
306  if (test){
307  std::stringstream del2;
308  del2 << "rm " <<sampfile;
309  system(del2.str().c_str());
310  }
311  return;
312  }
313 
314  assert( colors.size()<= nColor );
315  unsigned int nCol=colors.size();
316 
317  for(unsigned int iCol=0;iCol<nCol;iCol++){
318  for(unsigned int iSide=0;iSide<nSide;iSide++){
319  MTQ[iCol][iSide]=new TMTQ();
320  }
321  }
322 
323  outFile = new TFile(outfile.c_str(),"RECREATE");
324 
325  TProfile *shapeMat = new TProfile("shapeLaser","shapeLaser",_nsamplesshape,-0.5,double(_nsamplesshape)-0.5);
326  TProfile *shapeMatTmp = new TProfile("shapeLaserTmp","shapeLaserTmp",_timeaftmax+_timebefmax,-0.5,double(_timeaftmax+_timebefmax)-0.5);
327 
328  std::cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
329  std::cout << "\t+=+ Analyzing MATACQ data +=+" << std::endl;
330 
331 
332  //
333  // create output ntuple
334  //
335 
336  mtqShape = new TTree("MatacqShape","MatacqShape");
337 
338  // list of branches
339  // keep Patrice's notations
340 
341  mtqShape->Branch( "event", &event, "event/I" );
342  mtqShape->Branch( "color", &color, "color/I" );
343  mtqShape->Branch( "status", &status, "status/I" );
344  mtqShape->Branch( "peak", &peak , "peak/D" );
345  mtqShape->Branch( "sigma", &sigma , "sigma/D" );
346  mtqShape->Branch( "fit", &fit , "fit/D" );
347  mtqShape->Branch( "ampl", &ampl , "ampl/D" );
348  mtqShape->Branch( "trise", &trise , "trise/D" );
349  mtqShape->Branch( "fwhm", &fwhm , "fwhm/D" );
350  mtqShape->Branch( "fw20", &fw20 , "fw20/D" );
351  mtqShape->Branch( "fw80", &fw80 , "fw80/D" );
352  mtqShape->Branch( "ped", &ped , "ped/D" );
353  mtqShape->Branch( "pedsig", &pedsig , "pedsig/D" );
354  mtqShape->Branch( "ttrig", &ttrig , "ttrig/D" );
355  mtqShape->Branch( "sliding", &sliding , "sliding/D" );
356 
357  mtqShape->SetBranchAddress( "event", &event );
358  mtqShape->SetBranchAddress( "color", &color );
359  mtqShape->SetBranchAddress( "status", &status );
360  mtqShape->SetBranchAddress( "peak", &peak );
361  mtqShape->SetBranchAddress( "sigma", &sigma );
362  mtqShape->SetBranchAddress( "fit", &fit );
363  mtqShape->SetBranchAddress( "ampl", &ampl );
364  mtqShape->SetBranchAddress( "fwhm", &fwhm );
365  mtqShape->SetBranchAddress( "fw20", &fw20 );
366  mtqShape->SetBranchAddress( "fw80", &fw80 );
367  mtqShape->SetBranchAddress( "trise", &trise );
368  mtqShape->SetBranchAddress( "ped", &ped );
369  mtqShape->SetBranchAddress( "pedsig", &pedsig );
370  mtqShape->SetBranchAddress( "ttrig", &ttrig );
371  mtqShape->SetBranchAddress( "sliding", &sliding );
372 
373 
374  unsigned int endsample;
375  unsigned int presample;
376 
377 
378 
379  // loop over the entries of the tree
380  TChain* fChain = (TChain*)tree;
381  Long64_t nentries = fChain->GetEntriesFast();
382  Long64_t nbytes = 0, nb = 0;
383 
384  for( Long64_t jentry=0; jentry<nentries; jentry++ )
385  {
386  // load the event
387  Long64_t ientry = fChain->LoadTree(jentry);
388  if (ientry < 0) break;
389  nb = fChain->GetEntry( jentry ); nbytes += nb;
390 
391  status = 0;
392  peak = -1;
393  sigma = 0;
394  fit = -1;
395  ampl = -1;
396  trise = -1;
397  ttrig = tt;
398  fwhm = 0;
399  fw20 = 0;
400  fw80 = 0;
401  ped = 0;
402  pedsig = 0;
403  sliding = 0;
404 
405 
406  if (_debug==1)std::cout <<"-- debug test -- inside loop 1 -- jentry:"<<jentry<<" over nentries="<<nentries<< std::endl;
407 
408  // create the object for Matacq data analysis
409 
410  endsample = maxsamp+_nsamplesaftmax;
411  presample=int(_presample*nsamples/100.);
412  TMatacq* mtq = new TMatacq( nsamples, presample, endsample,
415  _nevlasers , _slide);
416 
417  if (_debug==1)std::cout <<"-- debug test -- inside loop 2 -- "<< std::endl;
418 
419  // analyse the Matacq data
420  if( mtq->rawPulseAnalysis( nsamples, &matacq[0] )==0 )
421  {
422  status = 1;
423  ped = mtq->getBaseLine();
424  pedsig = mtq->getsigBaseLine();
425 
426  if (_debug==1)std::cout <<"-- debug test -- inside loop 3 -- ped:"<<ped << std::endl;
427  if( mtq->findPeak()==0 )
428  {
429  peak = mtq->getTimpeak();
430  sigma = mtq->getsigTimpeak();
431  }
432  if (_debug==1)std::cout <<"-- debug test -- inside loop 4 -- peak:"<<peak<< std::endl;
433  if( mtq->doFit()==0 )
434  {
435  fit = mtq->getTimax();
436  ampl = mtq->getAmpl();
437  fwhm = mtq->getFwhm();
438  fw20 = mtq->getWidth20();
439  fw80 = mtq->getWidth80();
440  sliding = mtq->getSlide();
441  }
442  if (_debug==1)std::cout <<"-- debug test -- inside loop 4 -- ampl:"<<ampl<< std::endl;
443  if( mtq->compute_trise()==0 )
444  {
445  trise = mtq->getTrise();
446  }
447  if (_debug==1)std::cout <<"-- debug test -- inside loop 5 -- trise:"<<trise<< std::endl;
448  }
449 
450  if (_debug==1)std::cout <<"-- debug test -- inside loop 6 -- status:"<<status<< std::endl;
451 
452  if( status == 1 && mtq->findPeak()==0 ){
453 
454  int firstS=int(peak-double(_timebefmax));
455  int lastS=int(peak+double(_timeaftmax));
456 
457 
458  // Fill histo if there are enough samples
459  if (_debug==1)std::cout <<"-- debug test -- inside loop 7 -- firstS:"<<firstS<<", nsamples:"<< nsamples<< std::endl;
460 
461  if(firstS>=0 && lastS<=nsamples){
462 
463  for (int i=firstS;i<lastS;i++){
464  shapeMatTmp->Fill(double(i)-firstS,matacq[i]);
465  }
466 
467 
468  }else{ // else extrapolate
469 
470 
471  int firstSBis;
472 
473  if(firstS<0){ // fill first bins with 0
474 
475  double thisped;
476  thisped=(matacq[0]+matacq[1]+matacq[2]+matacq[4]+matacq[5])/5.0;
477 
478  for(int i=firstS;i<0;i++){
479  shapeMatTmp->Fill(double(i)-firstS,thisped);
480 
481  }
482  firstSBis=0;
483 
484  }else{
485  firstSBis=firstS;
486  }
487 
488  if(lastS>nsamples){
489 
490  for(int i=firstSBis;i<int(nsamples);i++){
491  shapeMatTmp->Fill(double(i)-firstS,matacq[i]);
492  }
493 
494  //extrapolate with expo tail
495 
496  double expb=0.998;
497  double matacqval=expb*matacq[nsamples-1];
498 
499  for(int i=nsamples;i<lastS;i++){
500  shapeMatTmp->Fill(double(i)-firstS,matacqval);
501  matacqval*=expb;
502  }
503 
504  }else{
505  for (int i=firstSBis;i<lastS;i++){
506  shapeMatTmp->Fill(double(i)-firstS,matacq[i]);
507  }
508  }
509  }
510 
511  }
512  if (_debug==1)std::cout <<"-- debug test -- inside loop 8"<< std::endl;
513 
514  // get back color
515 
516  int iCol=nCol;
517  for(unsigned int i=0;i<nCol;i++){
518  if(color==colors[i]) {
519  iCol=i;
520  i=nCol;
521  }
522  }
523  if (_debug==1)std::cout <<"-- debug test -- inside loop 8bis color:"<<color<<" iCol:"<<iCol<<" nCol:"<< nCol<< std::endl;
524 
525  // fill TMTQ
526 
527  if(status == 1 && mtq->findPeak()==0 && mtq->doFit()==0 && mtq->compute_trise()==0 ) MTQ[iCol][lightside]->addEntry(peak, sigma, fit, ampl, trise, fwhm, fw20, fw80, ped, pedsig, sliding);
528 
529  // fill the output tree
530 
531  if (_debug==1)std::cout <<"-- debug test -- inside loop 9"<< std::endl;
532  mtqShape->Fill();
533 
534  // clean up
535  delete mtq;
536  }
537 
538  if (_debug==1)std::cout <<"-- debug test -- after loop "<< std::endl;
539  sampFile->Close();
540 
541  double Peak[6], Sigma[6], Fit[6], Ampl[6], Trise[6], Fwhm[6], Fw20[6], Fw80[6], Ped[6], Pedsig[6], Sliding[6];
542  int Side;
543 
544  for (unsigned int iColor=0;iColor<nCol;iColor++){
545 
546  std::stringstream nametree;
547  nametree <<"MatacqCol"<<colors[iColor];
548  meanTree[iColor]= new TTree(nametree.str().c_str(),nametree.str().c_str());
549  meanTree[iColor]->Branch( "side", &Side , "Side/I" );
550  meanTree[iColor]->Branch( "peak", &Peak , "Peak[6]/D" );
551  meanTree[iColor]->Branch( "sigma", &Sigma , "Sigma[6]/D" );
552  meanTree[iColor]->Branch( "fit", &Fit , "Fit[6]/D" );
553  meanTree[iColor]->Branch( "ampl", &Ampl , "Ampl[6]/D" );
554  meanTree[iColor]->Branch( "trise", &Trise , "Trise[6]/D" );
555  meanTree[iColor]->Branch( "fwhm", &Fwhm , "Fwhm[6]/D" );
556  meanTree[iColor]->Branch( "fw20", &Fw20 , "Fw20[6]/D" );
557  meanTree[iColor]->Branch( "fw80", &Fw80 , "Fw80[6]/D" );
558  meanTree[iColor]->Branch( "ped", &Ped , "Ped[6]/D" );
559  meanTree[iColor]->Branch( "pedsig", &Pedsig , "Pedsig[6]/D" );
560  meanTree[iColor]->Branch( "sliding", &Sliding , "Sliding[6]/D" );
561 
562  meanTree[iColor]->SetBranchAddress( "side", &Side );
563  meanTree[iColor]->SetBranchAddress( "peak", Peak );
564  meanTree[iColor]->SetBranchAddress( "sigma", Sigma );
565  meanTree[iColor]->SetBranchAddress( "fit", Fit );
566  meanTree[iColor]->SetBranchAddress( "ampl", Ampl );
567  meanTree[iColor]->SetBranchAddress( "fwhm", Fwhm );
568  meanTree[iColor]->SetBranchAddress( "fw20", Fw20 );
569  meanTree[iColor]->SetBranchAddress( "fw80", Fw80 );
570  meanTree[iColor]->SetBranchAddress( "trise", Trise );
571  meanTree[iColor]->SetBranchAddress( "ped", Ped );
572  meanTree[iColor]->SetBranchAddress( "pedsig", Pedsig );
573  meanTree[iColor]->SetBranchAddress( "sliding", Sliding );
574 
575  }
576 
577  for(unsigned int iCol=0;iCol<nCol;iCol++){
578  for(unsigned int iSide=0;iSide<nSides;iSide++){
579 
580  Side=iSide;
581  std::vector<double> val[TMTQ::nOutVar];
582 
583  for(int iVar=0;iVar<TMTQ::nOutVar;iVar++){
584  val[iVar] = MTQ[iCol][iSide]->get(iVar);
585 
586  for(unsigned int i=0;i<val[iVar].size();i++){
587 
588  switch (iVar){
589 
590  case TMTQ::iPeak: Peak[i]=val[iVar].at(i);
591  case TMTQ::iSigma: Sigma[i]=val[iVar].at(i);
592  case TMTQ::iFit: Fit[i]=val[iVar].at(i);
593  case TMTQ::iAmpl: Ampl[i]=val[iVar].at(i);
594  case TMTQ::iFwhm: Fwhm[i]=val[iVar].at(i);
595  case TMTQ::iFw20: Fw20[i]=val[iVar].at(i);
596  case TMTQ::iFw80: Fw80[i]=val[iVar].at(i);
597  case TMTQ::iTrise: Trise[i]=val[iVar].at(i);
598  case TMTQ::iPed: Ped[i]=val[iVar].at(i);
599  case TMTQ::iPedsig: Pedsig[i]=val[iVar].at(i);
600  case TMTQ::iSlide: Sliding[i]=val[iVar].at(i);
601  }
602  }
603  }
604  meanTree[iCol]->Fill();
605  if (_debug==1)std::cout <<"-- debug test -- inside final loop "<< std::endl;
606  }
607  }
608 
609  // Calculate maximum with pol 2
610 
611  int im = shapeMatTmp->GetMaximumBin();
612  double q1=shapeMatTmp->GetBinContent(im-1);
613  double q2=shapeMatTmp->GetBinContent(im);
614  double q3=shapeMatTmp->GetBinContent(im+1);
615 
616  double a2=(q3+q1)/2.0-q2;
617  double a1=q2-q1+a2*(1-2*im);
618  double a0=q2-a1*im-a2*im*im;
619 
620  double am=a0-a1*a1/(4*a2);
621 
622 
623  // Compute pedestal
624 
625  double bl=0;
626  for (unsigned int i=1; i<_presampleshape+1;i++){
627  bl+=shapeMatTmp->GetBinContent(i);
628  }
629  bl/=_presampleshape;
630 
631  // Compute and save laser shape
632 
633  if (_debug==1)std::cout <<"-- debug test -- computing shape "<< std::endl;
634 
635  int firstBin=0;
636  double height=0.0;
637 
638  for (unsigned int i=_timebefmax; i>_presampleshape;i--){
639  height=shapeMatTmp->GetBinContent(i)-bl;
640 
641  if(height<(am-bl)*_cutwindow){
642  firstBin=i;
644  }
645  }
646 
647  unsigned int lastBin=firstBin+_nsamplesshape;
648 
649  for(unsigned int i=firstBin;i<lastBin;i++){
650  shapeMat->Fill(i-firstBin,shapeMatTmp->GetBinContent(i)-bl);
651  }
652 
653  mtqShape->Write();
654  for (unsigned int iColor=0;iColor<nCol;iColor++){
655  meanTree[iColor]->Write();
656  }
657  if (_debug==1)std::cout <<"-- debug test -- writing "<< std::endl;
658  shapeMat->Write();
659 
660  // close the output file
661  outFile->Close();
662 
663  // Remove temporary file
664  FILE *test;
665  test = fopen(sampfile.c_str(),"r");
666  if (test){
667  std::stringstream del2;
668  del2 << "rm " <<sampfile;
669  system(del2.str().c_str());
670  }
671 
672  std::cout << "\t+=+ .................... done +=+" << std::endl;
673  std::cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
674 
675 }
double getWidth80()
Definition: TMatacq.h:76
int i
Definition: DBlmapReader.cc:9
Definition: TMTQ.h:8
unsigned int _presampleshape
std::vector< int > colors
unsigned int _nsamplesshape
int compute_trise()
Definition: TMatacq.cc:331
double getTimax()
Definition: TMatacq.h:71
TMTQ * MTQ[nColor][nSide]
double getBaseLine()
Definition: TMatacq.h:64
double getsigBaseLine()
Definition: TMatacq.h:65
double q2[4]
Definition: TauolaWrapper.h:88
double getFwhm()
Definition: TMatacq.h:74
TTree * meanTree[nColor]
double getsigTimpeak()
Definition: TMatacq.h:68
unsigned int _timebefmax
double getSlide()
Definition: TMatacq.h:77
Definition: Fit.h:34
std::vector< double > get(int)
Definition: TMTQ.cc:72
int doFit()
Definition: TMatacq.cc:202
double getAmpl()
Definition: TMatacq.h:70
int rawPulseAnalysis(Int_t, Double_t *)
Definition: TMatacq.cc:60
Double_t Sigma(double mHreq, TString proc)
unsigned int _parabnaftmax
double getWidth20()
Definition: TMatacq.h:75
int findPeak()
Definition: TMatacq.cc:128
double q1[4]
Definition: TauolaWrapper.h:87
double getTrise()
Definition: TMatacq.h:73
unsigned int _timeaftmax
Definition: TMatacq.h:9
tuple cout
Definition: gather_cfg.py:121
unsigned int _nsamplesaftmax
double getTimpeak()
Definition: TMatacq.h:67
unsigned int _parabnbefmax

Member Data Documentation

double EcalMatacqAnalyzer::_cutwindow
private

Definition at line 48 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

int EcalMatacqAnalyzer::_debug
private
int EcalMatacqAnalyzer::_fedid
private

Definition at line 52 of file EcalMatacqAnalyzer.h.

Referenced by analyze().

unsigned int EcalMatacqAnalyzer::_highlev
private

Definition at line 44 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_lowlev
private

Definition at line 43 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_nevlasers
private

Definition at line 45 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_noiseCut
private

Definition at line 39 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_nsamplesaftmax
private

Definition at line 38 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_nsamplesshape
private

Definition at line 49 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_parabnaftmax
private

Definition at line 41 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_parabnbefmax
private

Definition at line 40 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::_presample
private

Definition at line 37 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_presampleshape
private

Definition at line 50 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_slide
private

Definition at line 51 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_thres
private

Definition at line 42 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_timeaftmax
private

Definition at line 47 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

unsigned int EcalMatacqAnalyzer::_timebefmax
private

Definition at line 46 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::ampl
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

int EcalMatacqAnalyzer::color
private

Definition at line 81 of file EcalMatacqAnalyzer.h.

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

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

Definition at line 93 of file EcalMatacqAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalMatacqAnalyzer::dccID
private

Definition at line 71 of file EcalMatacqAnalyzer.h.

Referenced by analyze().

std::string EcalMatacqAnalyzer::digiCollection_
private

Definition at line 56 of file EcalMatacqAnalyzer.h.

Referenced by analyze(), and EcalMatacqAnalyzer().

std::string EcalMatacqAnalyzer::digiProducer_
private

Definition at line 57 of file EcalMatacqAnalyzer.h.

Referenced by analyze(), and EcalMatacqAnalyzer().

int EcalMatacqAnalyzer::event
private

Definition at line 80 of file EcalMatacqAnalyzer.h.

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

std::string EcalMatacqAnalyzer::eventHeaderCollection_
private

Definition at line 58 of file EcalMatacqAnalyzer.h.

Referenced by analyze(), and EcalMatacqAnalyzer().

std::string EcalMatacqAnalyzer::eventHeaderProducer_
private

Definition at line 59 of file EcalMatacqAnalyzer.h.

Referenced by analyze(), and EcalMatacqAnalyzer().

int EcalMatacqAnalyzer::fedID
private

Definition at line 72 of file EcalMatacqAnalyzer.h.

Referenced by analyze().

double EcalMatacqAnalyzer::fit
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::fw20
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::fw80
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::fwhm
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

int EcalMatacqAnalyzer::iEvent
private

Definition at line 31 of file EcalMatacqAnalyzer.h.

Referenced by analyze().

bool EcalMatacqAnalyzer::isThereMatacq
private

Definition at line 76 of file EcalMatacqAnalyzer.h.

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

int EcalMatacqAnalyzer::laserEvents
private

Definition at line 75 of file EcalMatacqAnalyzer.h.

Referenced by analyze(), and beginJob().

int EcalMatacqAnalyzer::lightside
private

Definition at line 68 of file EcalMatacqAnalyzer.h.

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

double EcalMatacqAnalyzer::matacq[2560]
private

Definition at line 82 of file EcalMatacqAnalyzer.h.

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

int EcalMatacqAnalyzer::maxsamp
private

Definition at line 83 of file EcalMatacqAnalyzer.h.

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

TTree* EcalMatacqAnalyzer::meanTree[nColor]
private

Definition at line 91 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

TMTQ* EcalMatacqAnalyzer::MTQ[nColor][nSide]
private

Definition at line 90 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

TTree* EcalMatacqAnalyzer::mtqShape
private

Definition at line 98 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

int EcalMatacqAnalyzer::nsamples
private

Definition at line 84 of file EcalMatacqAnalyzer.h.

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

unsigned int EcalMatacqAnalyzer::nSides
private

Definition at line 67 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

std::string EcalMatacqAnalyzer::outfile
private

Definition at line 61 of file EcalMatacqAnalyzer.h.

Referenced by beginJob(), and endJob().

TFile* EcalMatacqAnalyzer::outFile
private

Definition at line 95 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::peak
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::ped
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::pedsig
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

std::string EcalMatacqAnalyzer::resdir_
private

Definition at line 55 of file EcalMatacqAnalyzer.h.

Referenced by beginJob(), and EcalMatacqAnalyzer().

int EcalMatacqAnalyzer::runNum
private

Definition at line 70 of file EcalMatacqAnalyzer.h.

Referenced by analyze().

int EcalMatacqAnalyzer::runType
private

Definition at line 69 of file EcalMatacqAnalyzer.h.

Referenced by analyze().

std::string EcalMatacqAnalyzer::sampfile
private

Definition at line 62 of file EcalMatacqAnalyzer.h.

Referenced by beginJob(), and endJob().

TFile* EcalMatacqAnalyzer::sampFile
private

Definition at line 87 of file EcalMatacqAnalyzer.h.

Referenced by beginJob(), and endJob().

double EcalMatacqAnalyzer::sigma
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::sliding
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

int EcalMatacqAnalyzer::status
private
TTree* EcalMatacqAnalyzer::tree
private
double EcalMatacqAnalyzer::trise
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().

double EcalMatacqAnalyzer::tt
private

Definition at line 85 of file EcalMatacqAnalyzer.h.

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

double EcalMatacqAnalyzer::ttrig
private

Definition at line 97 of file EcalMatacqAnalyzer.h.

Referenced by endJob().