001
002
003
004
005 # define MAXCHIPS 14
006 # define MAXDEV 10
007 #include <iostream>
008 #include <ios>
009 #include <iomanip>
010 #include <string>
011
012 #define FIRSTTIMECHIP -999
013
014 #ifndef DEFECT_NO_NAMESPACES
015 # ifndef DEFECT_NO_IOSTREAM_NAMESPACES
016 using std::cout;
017 using std::endl;
018 using std::ifstream;
019 using std::ios;
020 using std::dec;
021 using std::hex;
022 # endif
023 #endif
024
025
026
027
028
029
030
031 #include "SvxDaqMods/SvxPedMonModule.hh"
032 #include "AbsEnv/AbsEnv.hh"
033 #include "BaBar/Cdf.hh"
034 #ifdef USE_CDFEDM2
035 #include "Edm/ConstHandle.hh"
036 #include "TrackingObjects/Storable/StorableRun2SiStripSet.hh"
037 #else
038 #include "Trybos/TRY_Ybos_Simple_Record.hh"
039 #include "TrackingObjects/Trybos/TRYRun2SiStripSet.hh"
040 #endif
041
042 #include "HepTuple/HepHBookFileManager.h"
043 #include "HepTuple/HepHist1D.h"
044 #include "HepTuple/HepNtuple.h"
045 #include "SiliconGeometry/AbsSiNumerology.hh"
046 #include "SiliconGeometry/HWSiNumerology.hh"
047
048
049
050
051
052 extern "C" {
053 void svxii_Histo_startHisto();
054 void svxii_Histo_updateHisto();
055 void svxii_Histo_initHisto2();
056 void svxii_Histo_exitHisto();
057 void svxii_Histo_saveHisto(const char* histofile);
058 void comp_ped(char *dataFile, int nchips, int flag, int pipelinecell,
059 int bunch,int Nevnt,int histid, int *data, int runnum, int histo_flag,
060 const char* histofile, int laayer, int dev, int debug);
061 void comp_pedbx(char *dataFile, int nchips, int flag, int pipelinecell,
062 int bunch,int Nevnt,int histid, int *data, int runnum, int histo_flag,
063 const char* histofile, int laayer, int dev, int debug, int val,
064 int nscanpoints);
065 void comp_thresh(char *dataFile, int nchips, int flag, int pipelinecell,
066 int bunch,int Nevnt,int histid, int *data, int runnum, int histo_flag,
067 const char* histofile, int laayer, int dev, int debug, int val,
068 int nscanpoints);
069 void comp_gain(char *dataFile, int nchips, int flag, int Nevnt,
070 char *mask, int dacval, int nscanpoints, int *data,
071 int runnum, int histo_flag, const char* histofile,
072 int histid, int laayer, int dev);
073 #include <SvxDaqMods/SvxKludge_store_stuff.h>
074 }
075
076
077
078
079 const std::string HepTupleDir="CHIP";
080
081
082
083
084
085
086
087
088
089 SvxPedMonModule::SvxPedMonModule(const char* const theName,
090 const char* const theDescription)
091 : AppModule(theName, theDescription ),
092 _debugFirst("Debug_first",this,1),
093 _debugLast("Debug_last",this,3),
094 _ttHBOOKfile("HistFile",this,"test.hist"),
095 _ttHISTOfile("HistoscopeFile",this,"test.hst"),
096 _twoDPass("2D_pass",this,true),
097 _oneDPass("1D_pass",this,false),
098 _analyseAll("Analyse_all",this,false),
099 _analyseStrip("Strip_analysis",this,false),
100 _pedEvent ("Pedestal_Events",this,1000),
101 _anaBarrelStart("anaBarrelStart",this,0),
102 _anaBarrelEnd("anaBarrelEnd",this, HWSiNumerology::N_BARRELS_MAX-1),
103 _anaHalfLadderStart("anaHalfLadderStart",this,0),
104 _anaHalfLadderEnd("anaHalfLadderEnd",this,2-1),
105 _anaPhiWedgeStart("anaPhiWedgeStart",this,0),
106 _anaPhiWedgeEnd("anaPhiWedgeEnd",this, HWSiNumerology::N_PHI_MAX-1),
107 _anaLayerStart("anaLayerStart",this,0),
108 _anaLayerEnd("anaLayerEnd",this, HWSiNumerology::N_LAYERS_MAX-1),
109 _anaLadderStart("anaLadderStart",this,0),
110 _anaLadderEnd("anaLadderEnd",this,0),
111 _anaSideStart("anaSideStart",this,0),
112 _anaSideEnd("anaSideEnd",this, HWSiNumerology::N_READOUT_SIDES_MAX-1),
113 _tManager(NULL),
114 _cell(NULL),
115 _bunchx(NULL),
116 _chip(NULL),
117 _chipall(NULL)
118 {
119 _ttHBOOKfile.addDescription("Histogram file name: Histfile set <xxx>");
120 _ttHISTOfile.addDescription("Histoscope file name: HistscopeFile set <xxx>");
121 _twoDPass.addDescription("Pass for 2-D histos: 2D_pass set true");
122 _oneDPass.addDescription("Pass for 1-D histos: 1D_pass set true");
123 _debugFirst.addDescription("First event to debug:Debug_first set <n>");
124 _debugLast.addDescription("Last event to debug:Debug_last set <n>");
125 _analyseAll.addDescription("Analyse whatever is there: Analyse_all set true");
126 _analyseStrip.addDescription("Analyse specific Strips: Strip_analysis set true");
127 _pedEvent.addDescription("Events to determine pedestal window: Pedestal_Events set <n>");
128
129 _anaBarrelStart.addDescription("First Barrel to Analyze set <n>");
130 _anaBarrelEnd.addDescription("Last Barrel to Analyze set <n>");
131 _anaHalfLadderStart.addDescription("First HalfLadder to Analyze set <n>");
132 _anaHalfLadderEnd.addDescription("Last HalfLadder to Analyze set <n>");
133 _anaPhiWedgeStart.addDescription("First PhiWedge to Analyze set <n>");
134 _anaPhiWedgeEnd.addDescription("Last PhiWedge to Analyze set <n>");
135 _anaLayerStart.addDescription("First Layer to Analyze set <n>");
136 _anaLayerEnd.addDescription("Last Layer to Analyze set <n>");
137 _anaLadderStart.addDescription("First Ladder to Analyze set <n>");
138 _anaLadderEnd.addDescription("Last Ladder to Analyze set <n>");
139 _anaSideStart.addDescription("First Side to Analyze set <n>");
140 _anaSideEnd.addDescription("Last Side to Analyze set <n>");
141
142
143 commands()->append(&_ttHBOOKfile);
144 commands()->append(&_ttHISTOfile);
145 commands()->append(&_twoDPass);
146 commands()->append(&_oneDPass);
147 commands()->append(&_debugFirst);
148 commands()->append(&_debugLast);
149 commands()->append(&_analyseStrip);
150 commands()->append(&_analyseAll);
151 commands()->append(&_pedEvent);
152
153 commands()->append(&_anaBarrelStart);
154 commands()->append(&_anaBarrelEnd);
155 commands()->append(&_anaHalfLadderStart);
156 commands()->append(&_anaHalfLadderEnd);
157 commands()->append(&_anaPhiWedgeStart);
158 commands()->append(&_anaPhiWedgeEnd);
159 commands()->append(&_anaLayerStart);
160 commands()->append(&_anaLayerEnd);
161 commands()->append(&_anaLadderStart);
162 commands()->append(&_anaLadderEnd);
163 commands()->append(&_anaSideStart);
164 commands()->append(&_anaSideEnd);
165
166
167
168
169 _init=0;
170 }
171
172
173
174
175
176 AppResult SvxPedMonModule::beginJob( AbsEvent* aJob ) {
177 _saveEventsCell = _pedEvent.value();
178 if(!SvxKludge_get_nchip(&_nChipsTotUsed)){
179 std::cout << "SvxPedMonModule::beginJob -- failed to get the number of chips"<<std::endl;
180 return AppResult::ERROR;
181 }
182
183 std::cout << "KLUDGE:Analysing " << _nChipsTotUsed << " chips" << std::endl;
184 if(!SvxKludge_get_detector(_devicenameUsed)){
185 std::cout << "SvxPedMonModule::beginJob -- failed to get the device name"<<std::endl;
186 return AppResult::ERROR;
187 }
188 std::cout << "KLUDGE:name of the device " << _devicenameUsed << ";" << std::endl;
189 if(!SvxKludge_get_comment(_commentUsed)){
190 std::cout << "SvxPedMonModule::beginJob -- failed to get the comments"<<std::endl;
191 return AppResult::ERROR;
192 }
193 std::cout << "KLUDGE: comments " << _commentUsed << ";" << std::endl;
194
195 if(!SvxKludge_get_scanType(_scanTypeUsed)){
196 std::cout << "SvxPedMonModule::beginJob -- failed to get the scan type"<<std::endl;
197 return AppResult::ERROR;
198 }
199 std::cout << "KLUDGE: scan type " << _scanTypeUsed << ";" << std::endl;
200
201
202 if(!SvxKludge_get_scanPoints(&_scanPointsUsed)){
203 std::cout << "SvxPedMonModule::beginJob -- failed to get the #scan points"<<std::endl;
204 return AppResult::ERROR;
205 }
206 std::cout << "KLUDGE: no. of scan points " << _scanPointsUsed << ";" << std::endl;
207
208
209
210
211 if (_analyseStrip.value() || _analyseAll.value()){
212
213
214
215
216
217
218
219
220 #ifdef USE_HISTOSCOPE
221 svxii_Histo_initHisto2();
222 #endif
223 std::cout << "Pedestal window determined after " <<
224 _saveEventsCell << " events" << std::endl;
225
226 const char* histofile = _ttHISTOfile.value().c_str();
227
228
229 if(_twoDPass.value()) {
230 std::cout << "scan type again " << _scanTypeUsed << ";" << std::endl;
231 if (_scanTypeUsed[0] == 'g') {
232 comp_gain(_devicenameUsed,_nChipsTotUsed,0,0,0,0,0,0,0,
233 _oneDPass.value(),histofile,0,0,0);
234
235
236
237 } else {
238 comp_ped(_devicenameUsed,_nChipsTotUsed,0,0,0,0,0,0,0,
239 _oneDPass.value(),histofile,0,0,0);
240 }
241 }
242
243
244
245
246 #ifdef USE_HISTOSCOPE
247 svxii_Histo_startHisto();
248 svxii_Histo_updateHisto();
249 #endif
250
251
252
253
254 if(!_ttHBOOKfile.value().empty() ){
255 _tManager=new HepHBookFileManager((_ttHBOOKfile.value()));
256 if (!_tManager){
257 std::cerr << "Failure to open histogram file "
258 << _ttHBOOKfile.value() << std::endl;
259 std::cerr << "Histograms will not be created!" << std::endl;
260 }
261 else{
262
263
264 std::cout << "Histogram booking" << std::endl;
265 _cell =&_tManager->hist1D("cell Distribution",
266 64, 0.0, 63.0);
267 _bunchx =&_tManager->hist1D("Bunch Crossing",
268 151, 0.0, 150.0);
269 _chipall=&_tManager->hist1D("All Chips",
270 1024,-0.5,1023.5);
271
272
273
274
275 _chip=&_tManager->ntuple("Chip Info",100);
276 _chip->setColumnWise();
277 _chip->setDiskResident();
278 _chip->columnAt("CHIP::Id",&_chipN,(Int2)1);
279 _chip->span("CHIP::Id",0,13);
280 _chip->columnAt("CHIP::Cell",&_pipeLineCell,(Int2)1);
281 _chip->span("CHIP::Cell",0,63);
282 _chip->columnAt("CHIP::Bunch",&_bunchN,(Int2)1);
283 _chip->span("CHIP::Bunch",0,163);
284 _chip->columnAt("CHIP::Chan0",&_chan0,(Float4)99.9);
285 _chip->span("CHIP::Chan0",-128,128);
286 _chip->columnAt("CHIP::Chan10",&_chan10,(Float4)99.9);
287 _chip->span("CHIP::Chan10",-128,128);
288 _chip->columnAt("CHIP::Chan50",&_chan50,(Float4)99.9);
289 _chip->span("CHIP::Chan50",-128,128);
290 _chip->columnAt("CHIP::Chan51",&_chan51,(Float4)99.9);
291 _chip->span("CHIP::Chan51",-128,128);
292 _chip->columnAt("CHIP::Chan127",&_chan127,(Float4)99.9);
293 _chip->span("CHIP::Chan127",-128,128);
294 }
295 }
296 }
297 std::cout << name() << ": Begin Job Successful" << std::endl;
298 _eventN = 0;
299 return AppResult::OK;
300 }
301
302 AppResult SvxPedMonModule::endJob( AbsEvent* aJob ){
303
304
305
306
307 if(_tManager){
308 _tManager->writeDirectory();
309 _cell->release();
310 _bunchx->release();
311 _chipall->release();
312 _chip->release();
313 _tManager->write();
314 delete _tManager;
315 }
316
317
318
319
320 const char* histofile = _ttHISTOfile.value().c_str();
321 #ifdef USE_HISTOSCOPE
322 svxii_Histo_saveHisto(histofile);
323 svxii_Histo_exitHisto();
324 #endif
325
326
327
328
329 if(_twoDPass.value()) {
330 if(!SvxKludge_get_scanType(_scanTypeUsed)){
331 std::cout << "SvxPedMonModule::eJob -- failed to get the scan type"<<std::endl;
332 return AppResult::ERROR;
333 }
334 std::cout << "devicename at end of job " << _devicenameUsed << ";" << std::endl;
335 std::cout << "scan type at end of job " << _scanTypeUsed << ";" << std::endl;
336 std::cout << "scan points at end of job " << _scanPointsUsed << ";" << std::endl;
337 if (_scanTypeUsed[0] == 'g') {
338 comp_gain(_devicenameUsed,_nChipsTotUsed,2,0,0,0,_scanPointsUsed,0,
339 AbsEnv::instance()->runNumber(),
340 _oneDPass.value(), histofile, 0,0,0);
341 } else if (_scanTypeUsed[0] == 'd') {
342 comp_pedbx(_devicenameUsed,_nChipsTotUsed,2,0,0,0,0,0,
343 AbsEnv::instance()->runNumber(),
344 _oneDPass.value(), histofile,0,0,debug,0,_scanPointsUsed);
345 } else if (_scanTypeUsed[0] == 't') {
346 comp_thresh(_devicenameUsed,_nChipsTotUsed,2,0,0,0,0,0,
347 AbsEnv::instance()->runNumber(),
348 _oneDPass.value(), histofile,0,0,debug,0,_scanPointsUsed);
349 } else {
350 comp_ped(_devicenameUsed,_nChipsTotUsed,2,0,0,0,0,0,
351 AbsEnv::instance()->runNumber(),
352 _oneDPass.value(), histofile,0,0,debug);
353 }
354 }
355 std::cout << "Goodbye from " << name() << " after "<<_eventN << " events"<<std::endl;
356 return AppResult::OK;
357 }
358
359 AppResult SvxPedMonModule::event( AbsEvent* anEvent){
360 _eventN++;
361 debug = (_eventN >= _debugFirst.value() && _eventN <= _debugLast.value());
362 if(debug)std::cout << "event called" <<std::endl;
363
364
365
366
367 if (_init==0) {
368 _init = 1;
369 }
370
371 if(debug) std::cout << "SvxPedMonModule::event: physics event " << _eventN << std::endl;
372 if (SvxPedMonModule::_process(anEvent)!=SVXPEDMONOK){
373 std::cout << "failed event processing " << _eventN << std::endl;
374 --_eventN;
375 return AppResult::ERROR;
376 }
377 return AppResult::OK;
378 }
379
380 int SvxPedMonModule::_process(AbsEvent* anEvent)
381 {
382
383
384
385
386
387 #ifdef USE_CDFEDM2
388 EventRecord::ConstIterator iter(anEvent,"StorableRun2SiStripSet");
389 #endif
390
391 const SiStripSet *myStrips=
392 #ifdef USE_CDFEDM2
393 (ConstHandle<StorableRun2SiStripSet>(iter)).operator->();
394 #else
395 new TRYRun2SiStripSet(anEvent);
396 #endif
397 int result=SVXPEDMONNOTOK;
398 if (myStrips) {
399 result=_LoadHistos(myStrips);
400 #ifndef USE_CDFEDM2
401 delete myStrips;
402 #endif
403 }
404 return result;
405 }
406
407 int SvxPedMonModule::_LoadHisto(const SiStripSet *myStrips)
408 {
409 std::cout << "this method does nothing" << std::endl;
410 return SVXPEDMONOK;
411 }
412
413 int SvxPedMonModule::_LoadHistos(const SiStripSet *myStrips)
414 {
415
416
417
418
419
420
421
422
423
424
425
426 int Data[MAXCHIPS*NSTRIPINCHIP];
427 unsigned int tchan;
428 int stval;
429
430
431
432
433
434 int histo = _analyseAll.value()== true || (_analyseStrip.value()== true);
435
436 SiDigiCode detector;
437 SiStripSet::ConstIterator s;
438 int eventNum=AbsEnv::instance()->trigNumber();
439 int chip,ig,canal;
440 int pipeLineCells[SVXKLUDGE_MAXDEV][SVXKLUDGE_MAXCHIP];
441 int bunchxs[SVXKLUDGE_MAXCHIP];
442 int nStripSeen=0;
443 int tchanInChip=0;
444 int nchipsz=0;
445 int nchipsp=0;
446 int wasChip=FIRSTTIMECHIP;
447 int histid=0;
448 int newdevice=0;
449 int lastchan=-999;
450 int newchip=0;
451 int laayer=0;
452 int iwedge,ihalfladder,ibarrel,ilayer,iside;
453 int lastlaayer=0;
454
455
456
457
458
459
460
461
462 for( ig=0; ig<NSTRIPINCHIP*MAXCHIPS; ig++ ) Data[ig]=0;
463 for (ibarrel=0;ibarrel<3;ibarrel++) {
464 for (iwedge=0;iwedge<12;iwedge++) {
465 for (ilayer=0;ilayer<5;ilayer++) {
466 for (ihalfladder=0;ihalfladder<2;ihalfladder++) {
467 for (iside=0;iside<=1;iside++) {
468 detector.setBarrel(ibarrel);
469 detector.setHalfLadder(ihalfladder);
470 detector.setPhiWedge(iwedge);
471 detector.setLayer(ilayer);
472 detector.setPnSide(iside);
473 if (debug) std::cout << ibarrel << iwedge << ilayer << ihalfladder << iside << std::endl;
474 for( s=myStrips->beginDetector(detector);
475 s!=myStrips->endDetector(detector);++s){
476
477
478
479
480
481
482
483
484
485
486 SiDigiCode detector = s.getStripKey();
487
488
489
490
491 tchan = (*s).getStripNumber();
492 tchanInChip = tchan%NSTRIPINCHIP;
493 stval = (*s).getPulseHeight();
494 histid = 10000*detector.getBarrel()+1000*detector.getPhiWedge()+100*detector.getLayer()+detector.getHalfLadder();
495 laayer = detector.getLayer();
496 chip = _strip2Chip(tchan);
497
498 if ( chip != wasChip)
499 {
500 if (iside == 0 && tchan == 0)
501 {
502 } else {
503 newchip++;
504 if (debug) {
505 std::cout << "waschip" << wasChip << std::endl;
506 std::cout << "new chip" << chip << std::endl;
507 std::cout << "tchan" << tchan << std::endl;
508 std::cout << "chip counter" << newchip << std::endl;
509 }
510 }
511 }
512
513 if (debug && (!(tchan%128))) {
514 std::cout << "lashistid" << _lasthistid << std::endl;
515 std::cout << "histid" << histid << std::endl;
516 std::cout << "newdevice" << newdevice << std::endl;
517 std::cout << "layer" << laayer << std::endl;
518 std::cout << "lastlayer" << lastlaayer << std::endl;
519 std::cout << "new chip counter" << newchip << std::endl;
520 }
521
522 if (newchip<1) newchip=0;
523 switch (laayer) {
524 case 0: nchipsz = 2; nchipsp = 2; break;
525 case 1: nchipsz = 3; nchipsp = 3; break;
526 case 2: nchipsz = 5; nchipsp = 5; break;
527 case 3: nchipsz = 4; nchipsp = 6; break;
528 case 4: nchipsz = 7; nchipsp = 7; break;
529 default: nchipsz = 0;
530 }
531 canal = tchan+iside*128*nchipsp;
532
533 if (canal>=0 && canal < MAXCHIPS*NSTRIPINCHIP) Data[canal]=stval;
534
535 if (debug && (!(tchan%128))) std::cout << "chip " << newchip << "; chan " << tchan << "; wasChip " << wasChip << "[i]" << newchip*NSTRIPINCHIP+tchanInChip << "data" << Data[canal] << "newdevice" << newdevice << std::endl;
536
537 nStripSeen++;
538
539
540 if (histid != _lasthistid && eventNum > 0 && lastchan != -999 ) {
541 if (histo){
542 if (debug) std::cout << "inside if statement; newdevice" << newdevice << " nchips" << newchip << "layer " << lastlaayer << "data0 " << Data[0] << std::endl;
543
544 if (newdevice<=SVXKLUDGE_MAXDEV)
545 for (ig=0;ig<newchip+1;ig++) {
546 pipeLineCells[newdevice][ig] = SvxKludge_get_pipes(ig,newdevice);
547 if (debug) std::cout << "pipeline[]" << pipeLineCells[newdevice][ig] << ig << std::endl;
548 }
549 if(!SvxKludge_get_bunchx(bunchxs,newchip+1)){
550 std::cout << "SvxPedMonModule::_LoadHisto failed to get pipelinecell" << std::endl;
551 return SVXPEDMONNOTOK;
552 }
553 if (newdevice<=SVXKLUDGE_MAXDEV)
554 _loadChipHistos(_lasthistid,newdevice,lastlaayer,
555 newchip+1,pipeLineCells[0],bunchxs,
556 nStripSeen,_eventN,
557 Data);
558 }
559 newchip = 0;
560 newdevice++;
561 }
562 wasChip = chip;
563 _lasthistid = histid;
564 lastchan = tchan;
565 lastlaayer = laayer;
566 }
567 }
568 }
569 }
570 }
571 }
572 if (histo){
573 if (debug) std::cout << "inside if statement; newdevice" << newdevice << " nchips" << newchip << "layer " << laayer << "data0 " << Data[0] << std::endl;
574 if (newdevice<=SVXKLUDGE_MAXDEV)
575 for (ig=0;ig<newchip+1;ig++) {
576 pipeLineCells[newdevice][ig] = SvxKludge_get_pipes(ig,newdevice);
577 if (debug) std::cout << "pipeline[]" << pipeLineCells[newdevice][ig] << ig << std::endl;
578 }
579 if(!SvxKludge_get_bunchx(bunchxs,newchip+1)){
580 std::cout << "SvxPedMonModule::_LoadHisto failed to get pipelinecell" << std::endl;
581 return SVXPEDMONNOTOK;
582 }
583
584 if (newdevice<=SVXKLUDGE_MAXDEV) _loadChipHistos(_lasthistid,newdevice,lastlaayer,
585 newchip+1,pipeLineCells[0],bunchxs,
586 nStripSeen,_eventN,Data);
587 }
588 return SVXPEDMONOK;
589 }
590
591 int SvxPedMonModule::_strip2Chip(int strip){
592 return strip/NSTRIPINCHIP;
593 }
594
595 int SvxPedMonModule::_loadChipHistos(int histid,
596 int dev,
597 int laayer,
598 int wasChip,
599 int *pipeLineCells,
600 int *bunchxs,
601 int nStripSeen,
602 int eventNum,
603 int *Data){
604 if (debug) std::cout << "N strips seen on chip " << wasChip << " are " << nStripSeen <<std::endl;
605 if (nStripSeen<=0 ) {
606 std::cout <<"SvxPedMonModule::_LoadChipHistos - Warning empty chip " << wasChip << std::endl;
607 }
608 if(!(wasChip>=0 && wasChip<=SVXKLUDGE_MAXCHIP)){
609 std::cout << std::endl << "SvxPedMonModule::_LoadChipHistos - severe error: wasChip= " << wasChip ;
610 std::cout << " out of range" << std::endl;
611 std::cout << "Should be 0 <= " << SVXKLUDGE_MAXCHIP <<std::endl;
612 return SVXPEDMONNOTOK;
613 }
614
615
616
617
618
619 int pipeLineCell=*(pipeLineCells+SVXKLUDGE_MAXCHIP*dev+1);
620
621 int bunchx=*(bunchxs+1);
622
623 if(debug) std::cout << " pipeLineCell = "<< pipeLineCell;
624
625
626 if(debug) std::cout << " ...ntuple being filled" << std::endl ;
627
628
629
630
631
632 _pipeLineCell = pipeLineCell;
633 _bunchN = bunchx;
634 _chipN = wasChip;
635
636
637
638
639
640
641 _chip->storeCapturedData();
642 _chip->clearData();
643
644 if(debug) std::cout << "...Histos Being Filled" << std::endl ;
645
646
647
648
649
650
651
652 int pass = 0;
653 if(_twoDPass.value()) {
654 const char* histofile = _ttHISTOfile.value().c_str();
655 for (int bi=0;bi< wasChip;bi++) {
656 if (debug) std::cout << "data 10 " << Data[128*bi+10] << "chip " << bi << std::endl;
657 if (debug) std::cout << "data 11 " << Data[128*bi+11] << std::endl;
658 }
659 if(!SvxKludge_get_scanType(_scanTypeUsed)){
660 std::cout << "SvxPedMonModule::runjob--failed to get the scan type"<<std::endl;
661 return AppResult::ERROR;
662 }
663 if (debug) std::cout << "scan type once again " << _scanTypeUsed << ";" << std::endl;
664 if (_scanTypeUsed[0] == 'g') {
665 if(!SvxKludge_get_calibV(&_calibVUsed)){
666 std::cout << "SvxPedMonModule::runJob--failedto get the DAC value"<<std::endl;
667 return AppResult::ERROR;
668 }
669 if(!SvxKludge_get_mask(_maskUsed)){
670 std::cout << "SvxPedMonModule::runJob -- failed to get the mask"<<std::endl;
671 return AppResult::ERROR;
672 }
673 comp_gain(_devicenameUsed,wasChip,1,eventNum,
674 _maskUsed,_calibVUsed,_scanPointsUsed,Data,
675 AbsEnv::instance()->runNumber(),
676 _oneDPass.value(), histofile, histid, laayer, dev);
677 } else if (_scanTypeUsed[0] == 'd') {
678 if(!SvxKludge_get_calibV(&_calibVUsed)){
679 std::cout << "SvxPedMonModule::runJob--failedto get the DAC value"<<std::endl;
680 return AppResult::ERROR;
681 }
682 if (debug) std::cout << "waschip,h,laayer,dev" << wasChip << histid << laayer << dev << "event " << eventNum << "bunch" << bunchx << "calibval" << _calibVUsed << std::endl;
683 comp_pedbx(_devicenameUsed,wasChip,1,pipeLineCell,
684 bunchx,eventNum,histid,Data,
685 AbsEnv::instance()->runNumber(),
686 _oneDPass.value(),histofile, laayer, dev, debug,
687 _calibVUsed,_scanPointsUsed);
688 } else if (_scanTypeUsed[0] == 't') {
689 if(!SvxKludge_get_calibV(&_calibVUsed)){
690 std::cout << "SvxPedMonModule::runJob--failedto get the DAC value"<<std::endl;
691 return AppResult::ERROR;
692 }
693 if (debug) std::cout << "waschip,h,laayer,dev" << wasChip << histid << laayer << dev << "event " << eventNum << "bunch" << bunchx << "calibval" << _calibVUsed << std::endl;
694 comp_thresh(_devicenameUsed,wasChip,1,pipeLineCell,
695 bunchx,eventNum,histid,Data,
696 AbsEnv::instance()->runNumber(),
697 _oneDPass.value(),histofile, laayer, dev, debug,
698 _calibVUsed,_scanPointsUsed);
699 } else {
700 if (debug) std::cout << "waschip,h,laayer,dev" << wasChip << histid << laayer << dev << "event " << eventNum << std::endl;
701 comp_ped(_devicenameUsed,wasChip,1,pipeLineCell,
702 bunchx,eventNum,histid,Data,
703 AbsEnv::instance()->runNumber(),
704 _oneDPass.value(),histofile, laayer, dev, debug);
705 }
706 pass++;
707 }
708 return SVXPEDMONOK;
709 }
710
711
712
713
Send problems or questions to cdfcode@fnal.gov