00001 #include <signal.h>
00002
00003 #include <iostream>
00004 #include <sstream>
00005 #include <vector>
00006
00007 #include "UtlArguments.hh"
00008 #include "RcdArena.hh"
00009 #include "RcdCount.hh"
00010 #include "RunReader.hh"
00011 #include "SubAccessor.hh"
00012
00013 #include "MpsAnalysis.hh"
00014
00015 MpsAnalysis::MpsAnalysis(unsigned wombat, int runNumber, int bins, int low,
00016 int high, int trackingSensor) :
00017 _thresholdScanRun(false), _thresholdRun(false),
00018 _mpsBeamThresholdScan(false), _mpsBeam(false), _nBt(0),
00019 _configCount(0) {
00020 std::cout << __PRETTY_FUNCTION__ << std::endl;
00021 _runNumber = runNumber;
00022 _bins = bins;
00023 _lowEdge = low;
00024 _highEdge = high;
00025
00026 _specialSensor = trackingSensor;
00027
00028
00029 _sensorIds[0] = 95;
00030 _sensorIds[1] = 96;
00031 _sensorIds[2] = 97;
00032 _sensorIds[3] = 98;
00033 _sensorIds[4] = 99;
00034 _pmtDaqIndex = 100;
00035 }
00036
00037 MpsAnalysis::~MpsAnalysis() {
00038 std::cout << __PRETTY_FUNCTION__ << std::endl;
00039 saveToDisk();
00040 delete _rootFile;
00041 std::cout << "~MpsAnalysis(): done. Destructing."<< std::endl;
00042 }
00043
00044 void MpsAnalysis::saveToDisk() {
00045 std::cout << __PRETTY_FUNCTION__ << std::endl;
00046 writeRootFile();
00047 _rootFile->Close();
00048 }
00049
00050 void MpsAnalysis::computeEfficiencies() {
00051 std::cout << __PRETTY_FUNCTION__ << std::endl;
00052 double eff(0);
00053 for(unsigned sensor(0); sensor < 5; sensor++) {
00054 for(int thresh(0); thresh < _highEdge; thresh++) {
00055 if(_ConfirmedTracks[sensor][thresh] > 0) {
00056 eff = static_cast<double>(_ConfirmedTracks[sensor][thresh]) / _Tracks[sensor][thresh] * 100;
00057 _hEffIntegratedAllBts[sensor]->Fill(thresh, eff);
00058 }
00059 }
00060 }
00061 }
00062
00063 void MpsAnalysis::findNoisyPixels(int cut) {
00064 std::cout << std::cout << __PRETTY_FUNCTION__ << " with cut = "<< cut
00065 << std::endl;
00066 ofstream highpixels;
00067 highpixels.open("highpixels.txt");
00068 unsigned numberOfHighPixels(0);
00069
00070 for (unsigned sensor(0); sensor < 5; sensor++) {
00071 highpixels << "Sensor pseudo value: \t"<< sensor << std::endl;
00072
00073 for (unsigned x(0); x < 168; x++) {
00074 for (unsigned y(0); y < 168; y++) {
00075 double hits = _hHitPattern[sensor]->GetBinContent(x, y);
00076 _hThreshEfficacy[sensor]->Fill(hits);
00077 if (hits > cut) {
00078
00079 highpixels << x << "\t"<< y << "\t"<< hits << "\n";
00080 numberOfHighPixels++;
00081 }
00082 }
00083 }
00084 highpixels << std::endl;
00085 }
00086 std::cout << "\tFound "<< numberOfHighPixels << " high pixels"<< std::endl;
00087 highpixels.close();
00088 }
00089
00090 void MpsAnalysis::findHitDistribution() {
00091 std::cout << __PRETTY_FUNCTION__ << std::endl;
00092 for (unsigned sensor(0); sensor < 5; sensor++) {
00093 for (unsigned x(0); x < 168; x++) {
00094 for (unsigned y(0); y < 168; y++) {
00095 double hits = _hHitPattern[sensor]->GetBinContent(x, y);
00096 _hThreshEfficacy[sensor]->Fill(hits);
00097 }
00098 }
00099 }
00100 }
00101
00102 void MpsAnalysis::makeGlobalTimeStampPlot() {
00103 std::cout << __PRETTY_FUNCTION__ << std::endl;
00104 for (unsigned sensor(0); sensor < 5; sensor++) {
00105 _hGlobalTimeStamps->Add(_hTimeStampsBySensor[sensor]);
00106 }
00107 }
00108
00109 bool MpsAnalysis::determineRunType(
00110 std::vector<const IlcRunStart*> runStartHeader) {
00111
00112 assert(runStartHeader.size()==1);
00113
00114 for (unsigned i(0); i<runStartHeader.size(); i++) {
00115
00116 _runNumber = runStartHeader[i]->runNumber();
00117
00118 _thresholdScanRun=(runStartHeader[i]->runType().type()==IlcRunType::mpsThresholdScan);
00119
00120 _mpsBeamThresholdScan=(runStartHeader[i]->runType().type()==IlcRunType::mpsBeamThresholdScan);
00121
00122 _thresholdRun = (runStartHeader[i]->runType().type()==IlcRunType::mpsThreshold);
00123
00124 _mpsBeam = (runStartHeader[i]->runType().type()==IlcRunType::mpsBeam);
00125 }
00126
00127 if (_thresholdScanRun || _thresholdScanRun || _mpsBeamThresholdScan
00128 || _thresholdRun || _mpsBeam)
00129 return true;
00130
00131
00132 return false;
00133 }
00134
00135 void MpsAnalysis::populateSensorIds(SubAccessor myAccessor) {
00136 std::vector<const MpsLocationData<MpsPcb1ConfigurationData>* >
00137 v(myAccessor.access< MpsLocationData<MpsPcb1ConfigurationData> >());
00138 std::cout << __PRETTY_FUNCTION__ << std::endl;
00139
00140
00141 unsigned nWrites(0);
00142 for (unsigned i(0); i<v.size(); i++) {
00143 if (!v[i]->write()) {
00144 std::cout<< "\tSensor id for index "<< i << ":\t"
00145 << static_cast<unsigned short>(v[i]->location().sensorId()) << std::endl;
00146 if(v[i]->location().usbDaqMaster())
00147 {
00148
00149
00150 _pmtDaqIndex = i-nWrites;
00151 std::cout << "\tUsbDaqMaster is on sensor " << v[i]->location().sensorId() << ", index " << i-nWrites << std::endl;
00152 }
00153
00154 _sensorIds[i-nWrites] = v[i]->location().sensorId();
00155 } else {
00156 nWrites++;
00157 }
00158 }
00159 std::cout << "Found "<< nWrites
00160 << " writes in PCB configuration data, with v.size() = "<< v.size()
00161 << std::endl;
00162 }
00163
00164 bool MpsAnalysis::record(const RcdRecord& r) {
00165
00166
00167
00168
00169
00170
00171
00172 SubAccessor accessor(r);
00173
00174 switch (r.recordType()) {
00175
00176 case RcdHeader::runStart: {
00177
00178
00179
00180 std::vector<const IlcRunStart*> vs(accessor.access<IlcRunStart>());
00181 determineRunType(vs);
00182 break;
00183 }
00184
00185 case RcdHeader::runEnd: {
00186 if (_thresholdScanRun) {
00187
00188
00189 std::vector<const IlcRunEnd*> ve(accessor.access<IlcRunEnd>());
00190 assert(ve.size()==1);
00191 for (unsigned i(0); i<ve.size(); i++) {
00192
00193 }
00194 }
00195 break;
00196 }
00197
00198 case RcdHeader::configurationStart: {
00199 std::vector<const IlcConfigurationStart*>
00200 vs(accessor.access<IlcConfigurationStart>());
00201 assert(vs.size()==1);
00202
00203
00204 std::vector<const MpsLocationData<MpsPcb1ConfigurationData>* >
00205 v(accessor.access< MpsLocationData<MpsPcb1ConfigurationData> >());
00206
00207 if (_configCount == 0) {
00208
00209 populateSensorIds(accessor);
00210
00211 makeHistograms(_sensorIds);
00212 }
00213 _configCount++;
00214
00215
00216
00217
00218 unsigned nWrites(0);
00219 for (unsigned i(0); i<v.size(); i++) {
00220
00221
00222 if (!v[i]->write()) {
00223
00224 _shaperThreshold[i - nWrites]=v[i]->data()->region01ThresholdValue();
00225 _samplerThreshold[i - nWrites]=v[i]->data()->region23ThresholdValue();
00226 } else {
00227 nWrites++;
00228 }
00229 }
00230
00231
00232 if (_mpsBeamThresholdScan) {
00233 _thresholdScanRun = true;
00234 }
00235
00236 std::vector<const MpsLocationData<MpsUsbDaqConfigurationData>* >
00237 w(accessor.access<MpsLocationData<MpsUsbDaqConfigurationData> >());
00238
00239 _spillCycleCount = w[0]->data()->spillCycleCount();
00240
00241
00242 _nHits=0;
00243 _tHits = 0;
00244
00245
00246 break;
00247
00248 }
00249
00250 case RcdHeader::configurationEnd: {
00251 if (_thresholdScanRun) {
00252
00253
00254
00255 std::vector<const IlcConfigurationEnd*>
00256 vs(accessor.access<IlcConfigurationEnd>());
00257
00258 assert(vs.size()==1);
00259
00260 for (unsigned i(0); i<vs.size(); i++) {
00261
00262 }
00263
00264 }
00265
00266 break;
00267 }
00268
00269 case RcdHeader::bunchTrain: {
00270 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* >
00271 v(accessor.access< MpsLocationData<MpsSensor1BunchTrainData> >());
00272 handleBunchTrain(v);
00273 break;
00274 }
00275
00276 default: {
00277 break;
00278 }
00279 };
00280
00281 return true;
00282 }
00283
00284 void MpsAnalysis::handleBunchTrain(
00285 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* > v) {
00286 if (_nBt%1000== 0) {
00287 std::cout << "Processing bunch train: "<< _nBt << std::endl;
00288 }
00289 if (_mpsBeam) {
00290 handleBeamRun(v);
00291 }
00292
00293 if (_mpsBeamThresholdScan) {
00294
00295 unsigned scannedSensor(0);
00296 if ((_configCount - 1)%41!= 0) {
00297
00298 scannedSensor = static_cast<int>(((_configCount -1)%41- 1)/10);
00299 }
00300
00301 handleBeamThresholdScanRun(v, scannedSensor);
00302 }
00303
00304 if (_thresholdScanRun) {
00305 handleThresholdScanRun(v);
00306 }
00307 _nBt++;
00308 }
00309
00310 void MpsAnalysis::handleCosmicThresholdScanRun(std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* > v,
00311 unsigned scannedSensor) {
00312
00313 }
00314
00315 void MpsAnalysis::handleBeamThresholdScanRun(
00316 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* > v,
00317 unsigned scannedSensor) {
00318 memset(_timeStampsByShap, 0, 5*8192*sizeof(unsigned));
00319 memset(_timeStampsBySamp, 0, 5*8192*sizeof(unsigned));
00320
00321 for (unsigned i(0); i<v.size(); i++) {
00322 if (!v[i]->write()) {
00323 std::vector<MpsSensor1Hit> vh(v[i]->data()->hitVector());
00324 for (unsigned j(0); j<vh.size(); j++) {
00325 if (vh[j].pixelX() > 83) {
00326
00327 _timeStampsBySamp[i][vh[j].timeStamp()]++;
00328 } else {
00329
00330 _timeStampsByShap[i][vh[j].timeStamp()]++;
00331 }
00332 assert(vh[j].timeStamp() < 8192);
00333
00334 }
00335 } else {
00336 std::cout<< "RcdHeader in bunch train is a write? "<< std::endl;
00337 }
00338 }
00339
00340 unsigned nPossibleTracks(0);
00341
00342
00343 unsigned nScannedVeto(0);
00344 unsigned nScannedVetoShap(0);
00345 unsigned nScannedVetoSamp(0);
00346
00347
00348
00349
00350 unsigned nScannedVetoDispT(0);
00351 unsigned nScannedVetoShapDispT(0);
00352 unsigned nScannedVetoSampDispT(0);
00353
00354 unsigned nPossibleTracksNotSpecial(0);
00355
00356
00357 for (unsigned t(0); t < 8192; t++) {
00358 unsigned hitsInOtherSensorsShap(0);
00359 unsigned hitsInOtherSensorsSamp(0);
00360 unsigned hitsInScannedSensorShap(0);
00361 unsigned hitsInScannedSensorSamp(0);
00362
00363
00364 unsigned hitsInScannedSensorShapDispT(0);
00365 unsigned hitsInScannedSensorSampDispT(0);
00366
00367
00368 unsigned hitsInSpecialSensor(0);
00369 unsigned minHits(1);
00370
00371 for (unsigned sensor(0); sensor < 5; sensor++) {
00372 _hTimeStampsBySensor[sensor]->Fill(_timeStampsBySensor[sensor][t]);
00373 if (sensor != scannedSensor) {
00374 if (_timeStampsBySamp[sensor][t] >= minHits)
00375 hitsInOtherSensorsSamp++;
00376 if (_timeStampsByShap[sensor][t] >= minHits)
00377 hitsInOtherSensorsShap++;
00378 } else {
00379 if (_timeStampsBySamp[sensor][t] >= minHits)
00380 hitsInScannedSensorSamp++;
00381 if (_timeStampsByShap[sensor][t] >= minHits)
00382 hitsInScannedSensorShap++;
00383
00384 unsigned dispT(0);
00385 if (t >= 4096)
00386 dispT = t - 4096;
00387 else
00388 dispT = t + 4096;
00389
00390 if (_timeStampsBySamp[sensor][dispT] >= minHits)
00391 hitsInScannedSensorSampDispT++;
00392 if (_timeStampsByShap[sensor][dispT] >= minHits)
00393 hitsInScannedSensorShapDispT++;
00394
00395 }
00396 if (sensor == _specialSensor) {
00397 hitsInSpecialSensor+= _timeStampsBySamp[sensor][t]
00398 + _timeStampsByShap[sensor][t];
00399 } else {
00400 nPossibleTracksNotSpecial+= _timeStampsBySamp[sensor][t]
00401 + _timeStampsByShap[sensor][t];
00402 }
00403
00404 }
00405
00406 unsigned nTrackVertex(hitsInOtherSensorsSamp+ hitsInOtherSensorsShap);
00407
00408 unsigned nScanned(hitsInScannedSensorSamp+ hitsInScannedSensorShap);
00409
00410 unsigned nScannedDispT(hitsInScannedSensorSampDispT
00411 + hitsInScannedSensorShapDispT);
00412
00413 if (nTrackVertex > 2) {
00414
00415 nPossibleTracks++;
00416 _hTracks3VerticesInT->Fill(t);
00417
00418 if (scannedSensor == _specialSensor) {
00419 _hSoftPhotonsSpecialSensor->Fill(
00420 _shaperThreshold[scannedSensor], hitsInSpecialSensor);
00421 }
00422
00423 if (nScanned > 0) {
00424 nScannedVeto++;
00425 _hTracks4VerticesInT->Fill(t);
00426 }
00427 if (hitsInScannedSensorShap > 0)
00428 nScannedVetoShap++;
00429 if (hitsInScannedSensorSamp > 0)
00430 nScannedVetoSamp++;
00431
00432
00433 if (nScannedDispT > 0)
00434 nScannedVetoDispT++;
00435 if (hitsInScannedSensorShapDispT > 0)
00436 nScannedVetoShapDispT++;
00437 if (hitsInScannedSensorSampDispT > 0)
00438 nScannedVetoSampDispT++;
00439
00440 _hTracks3Vertices->Fill(_shaperThreshold[scannedSensor]);
00441
00442 }
00443
00444 }
00445 if (nPossibleTracks > 0) {
00446
00447
00448
00449 _Tracks[scannedSensor][_shaperThreshold[scannedSensor]] += nPossibleTracks;
00450 _ConfirmedTracks[scannedSensor][_shaperThreshold[scannedSensor]] += nScannedVeto;
00451
00452 _hEffAndThreshOverall[scannedSensor]->Fill(
00453 _shaperThreshold[scannedSensor],
00454 static_cast<double>(nScannedVeto)/(nPossibleTracks)* 100);
00455
00456 _hEffAndThreshSamp[scannedSensor]->Fill(
00457 _shaperThreshold[scannedSensor],
00458 static_cast<double>(nScannedVetoSamp)/(nPossibleTracks)*100);
00459
00460 _hEffAndThreshShap[scannedSensor]->Fill(
00461 _shaperThreshold[scannedSensor],
00462 static_cast<double>(nScannedVetoShap)/(nPossibleTracks)*100);
00463
00464 _hEffAndThreshOverallDispT[scannedSensor]->Fill(
00465 _shaperThreshold[scannedSensor],
00466 static_cast<double>(nScannedVetoDispT)/(nPossibleTracks)* 100);
00467
00468 _hEffAndThreshSampDispT[scannedSensor]->Fill(
00469 _shaperThreshold[scannedSensor],
00470 static_cast<double>(nScannedVetoSampDispT)/(nPossibleTracks)
00471 *100);
00472
00473 _hEffAndThreshShapDispT[scannedSensor]->Fill(
00474 _shaperThreshold[scannedSensor],
00475 static_cast<double>(nScannedVetoShapDispT)/(nPossibleTracks)
00476 *100);
00477
00478 }
00479
00480 }
00481
00482 void MpsAnalysis::handleBeamRun(
00483 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* > v) {
00484
00485 memset(_timeStampsBySensor, 0, 5*8192*sizeof(unsigned));
00486 memset(_allTimeStamps, 0, 8192*sizeof(unsigned));
00487 for (unsigned i(0); i<v.size(); i++) {
00488 if (!v[i]->write()) {
00489 std::vector<MpsSensor1Hit> vh(v[i]->data()->hitVector());
00490 for (unsigned j(0); j<vh.size(); j++) {
00491 _hHitPattern[i]->Fill(vh[j].pixelX(), vh[j].pixelY());
00492 assert(vh[j].timeStamp() < 8192);
00493 _timeStampsBySensor[i][vh[j].timeStamp()]++;
00494 _allTimeStamps[vh[j].timeStamp()]++;
00495
00496 }
00497 }
00498 }
00499 for (unsigned sensor(0); sensor < 5; sensor++) {
00500 for (unsigned t(0); t < 8192; t++) {
00501 _hTimeStampsBySensor[sensor]->Fill(_timeStampsBySensor[sensor][t]);
00502 if (sensor ==0)
00503 _hSimulTimeStamps->Fill(_allTimeStamps[t]);
00504 }
00505 }
00506
00507 }
00508
00509 void MpsAnalysis::handleThresholdScanRun(
00510 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* > v) {
00511
00512 for (unsigned i(0); i<v.size(); i++) {
00513 if (!v[i]->write()) {
00514
00515 _hHitsInBtByThreshold[i]->Fill(_shaperThreshold[i], v[i]->data()->numberOfRegionHits(0)+ v[i]->data()->numberOfRegionHits(1));
00516
00517 for (unsigned theRegion(0); theRegion < 4; theRegion++) {
00518
00519 unsigned allHitsA(0);
00520 unsigned allHitsB(0);
00521 unsigned wordHitsA(0);
00522 unsigned wordHitsB(0);
00523 const MpsSensor1BunchTrainDatum* rDatum =v[i]->data()->regionData(theRegion);
00524
00525 for (unsigned j(0); j < v[i]->data()->numberOfRegionHits(theRegion); j++) {
00526 for (unsigned c(0); c < 6; c++) {
00527 if (rDatum[j].channel(c) != 0&& rDatum[j].row()<84) {
00528 allHitsA++;
00529 } else if (rDatum[j].channel(c) != 0&& rDatum[j].row()
00530 > 83) {
00531 allHitsB++;
00532 }
00533 }
00534 if (rDatum[j].row() < 84)
00535 wordHitsA++;
00536 if (rDatum[j].row() > 83)
00537 wordHitsB++;
00538 _hGroupsAndRows[i][theRegion]->Fill(rDatum[j].group(),
00539 rDatum[j].row());
00540 }
00541 unsigned thresh(_shaperThreshold[i]);
00542 if (theRegion == 2|| theRegion == 3) {
00543 thresh = _samplerThreshold[i];
00544 }
00545 _hHits[i][theRegion]->Fill(thresh, allHitsA+ allHitsB);
00546 _hHitsByRegion[i][theRegion]->Fill(thresh, allHitsA+ allHitsB);
00547 _hWordHits[i][theRegion]->Fill(thresh, wordHitsA+ wordHitsB);
00548
00549 }
00550
00551 std::vector<MpsSensor1Hit> vh(v[i]->data()->hitVector());
00552
00553 for (unsigned j(0); j<vh.size(); j++) {
00554 _hHitPattern[i]->Fill(vh[j].pixelX(), vh[j].pixelY());
00555 unsigned thresh(_shaperThreshold[i]);
00556 if (vh[j].pixelX() > 83) {
00557 thresh = _samplerThreshold[i];
00558 }
00559 _hTimestampsByThreshold[i][static_cast<int>(vh[j].pixelX()/42)]->Fill(thresh, vh[j].timeStamp());
00560 assert(vh[j].timeStamp() < 8192);
00561 }
00562 } else {
00563 std::cout<< "RcdHeader in bunch train is a write? "<< std::endl;
00564 }
00565 }
00566 }
00567
00568 void MpsAnalysis::makeHistograms(int sensorIds[]) {
00569 std::cout << __PRETTY_FUNCTION__ << std::endl;
00570 std::string rootFileTitle(("MpsAnalysis_" + IntToStr(_runNumber)+ ".root").c_str());
00571 _rootFile = new TFile(rootFileTitle.c_str(),"RECREATE");
00572 _hNHitsPerConfig
00573 = new TH2I("hNHitsPerConfig", "Number of hits by threshold", _bins, _lowEdge, _highEdge, 30, 0, 30);
00574 std::cout << "\tInitialising histograms..."<< std::endl;
00575 std::cout << "\tbins: "<< _bins << ", lowEdge: "<< _lowEdge
00576 << ", _highEdge: "<< _highEdge << std::endl;
00577
00578 _hHitsInRow
00579 = new TH1F("hHitsInRow","Hits in a row over all BTs, for one thresh;Pixel",42,0,42);
00580
00581 _hGlobalTimeStamps = new TH1F("hGlobalTimeStamps", "hGlobalTimeStamps", 40, 0, 40);
00582 globals.push_back(_hGlobalTimeStamps);
00583
00584 _hSimulTimeStamps = new TH1F("hSimulTimeStamps", "hSimulTimeStamps", 40, 0, 40);
00585 globals.push_back(_hSimulTimeStamps);
00586
00587 memset(_timeStampsBySensor, 0, 5*8192*sizeof(unsigned));
00588 memset(_allTimeStamps, 0, 8192*sizeof(unsigned));
00589 memset(_Tracks, 0, 5*2010*sizeof(unsigned));
00590 memset(_ConfirmedTracks, 0, 5*2010*sizeof(unsigned));
00591
00592 _hSoftPhotonsSpecialSensor
00593 = new TH2F("hSoftPhotonsSpecialSensor", "Hits in non-tracking front sensor", _bins, _lowEdge, _highEdge, 100, 0, 100);
00594 efficiencies.push_back(_hSoftPhotonsSpecialSensor);
00595
00596 _hTracks3Vertices
00597 = new TH1F("hTracks3Vertices", "Number of tracks with 3 vertices", _bins, _lowEdge, _highEdge);
00598 efficiencies.push_back(_hTracks3Vertices);
00599
00600 _hTracks3VerticesInT = new TH1F("hTracks3VerticesInT", "Track (3VX) formation in time", 8192/32, 0, 8192);
00601 efficiencies.push_back(_hTracks3VerticesInT);
00602 _hTracks4VerticesInT = new TH1F("hTracks4VerticesInT", "Track (4VX) formation in time", 8192/32, 0, 8192);
00603 efficiencies.push_back(_hTracks4VerticesInT);
00604
00605
00606 for (unsigned s(0); s < 5; s++) {
00607 _hEffIntegratedAllBts[s] = new TH1F(("hEffIntegratedAllBts" + IntToStr(sensorIds[s])).c_str(), ("Efficiency integrated over all BTs, sensor " + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00608 efficiencies.push_back(_hEffIntegratedAllBts[s]);
00609
00610 _hTracks3VerticesInXY[s] = new TH2F(("hTracks3VerticesInXY" + IntToStr(sensorIds[s])).c_str(), ("hTracks3VerticesInXY" + IntToStr(sensorIds[s])).c_str(),168, 0, 168, 168, 0, 168);
00611 efficiencies.push_back(_hTracks3VerticesInXY[s]);
00612
00613 _hTracks4VerticesInXY[s] = new TH2F(("hTracks4VerticesInXY" + IntToStr(sensorIds[s])).c_str(), ("hTracks4VerticesInXY" + IntToStr(sensorIds[s])).c_str(),168, 0, 168, 168, 0, 168);
00614 efficiencies.push_back(_hTracks4VerticesInXY[s]);
00615
00616 _hHitPattern[s]
00617 = new TH2F(("hHitPattern" + IntToStr(sensorIds[s])).c_str(), "Integrated hit pattern;Pixel X;Pixel Y",168,0,168,168,0,168);
00618 globals.push_back(_hHitPattern[s]);
00619
00620 _hThreshEfficacy[s]
00621 = new TH1F(("hThreshEfficacy"+ IntToStr(sensorIds[s])).c_str(), "Threshold Efficacy;Hit count per pixel", 20000, 0, 20000);
00622 globals.push_back(_hThreshEfficacy[s]);
00623
00624 _hHitsInBtByThreshold[s]
00625 = new TH2F(("hHitsInBtByThreshold" + IntToStr(sensorIds[s])).c_str(), "Hits in BT by threshold;Threshold; NHits", _bins, _lowEdge, _highEdge, 100, 0, 100);
00626 globals.push_back(_hHitsInBtByThreshold[s]);
00627
00628 _hTimeStampsBySensor[s] = new TH1F(("hTimeStampsBySensor"+ IntToStr(_sensorIds[s])).c_str(), ("hTimeStampsBySensor"+ IntToStr(s)).c_str(), 40, 0, 40);
00629 globals.push_back(_hTimeStampsBySensor[s]);
00630
00631 _hEffAndThreshSamp[s] = new TProfile(("hEffAndThreshSamp" + IntToStr(sensorIds[s])).c_str(), ("hEffAndThreshSamp" + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00632 _hEffAndThreshShap[s] = new TProfile(("hEffAndThreshShap" + IntToStr(sensorIds[s])).c_str(), ("hEffAndThreshShap" + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00633 _hEffAndThreshOverall[s]= new TProfile(("pEffAndThreshOverall" + IntToStr(sensorIds[s])).c_str(), ("Overall efficiency, sensor " + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00634 efficiencies.push_back(_hEffAndThreshShap[s]);
00635 efficiencies.push_back(_hEffAndThreshSamp[s]);
00636 efficiencies.push_back(_hEffAndThreshOverall[s]);
00637
00638 _hEffAndThreshSampDispT[s] = new TProfile(("hEffAndThreshSampDispT" + IntToStr(sensorIds[s])).c_str(), ("hEffAndThreshSampDispT" + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00639 _hEffAndThreshShapDispT[s] = new TProfile(("hEffAndThreshShapDispT" + IntToStr(sensorIds[s])).c_str(), ("hEffAndThreshShapDispT" + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00640 _hEffAndThreshOverallDispT[s]= new TProfile(("pEffAndThreshOverallDispT" + IntToStr(sensorIds[s])).c_str(), ("Overall efficiency, sensor " + IntToStr(sensorIds[s])).c_str(), _bins, _lowEdge, _highEdge);
00641 efficienciesDispT.push_back(_hEffAndThreshShapDispT[s]);
00642 efficienciesDispT.push_back(_hEffAndThreshSampDispT[s]);
00643 efficienciesDispT.push_back(_hEffAndThreshOverallDispT[s]);
00644
00645 _hNHitsInBunchtrain[s] = new TH1F(("hNHitsInBunchtrain" + IntToStr(sensorIds[s])).c_str(), ("hNHitsInBunchTrain" + IntToStr(sensorIds[s])).c_str(), 1000000, 0, 1000000);
00646 dqm.push_back(_hNHitsInBunchtrain[s]);
00647
00648 for (unsigned r(0); r < 4; r++) {
00649
00650 _hHits[s][r] = new TH2F(("_hHitsRegionS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), ("hHitsRegionS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), _bins, _lowEdge, _highEdge, 400, 0, 400);
00651 hitsByRegion.push_back(_hHits[s][r]);
00652
00653 _hWordHits[s][r] = new TH2F(("_hWordHitsRegionS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), ("hWordHitsRegionS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), _bins, _lowEdge, _highEdge, 400, 0, 4000);
00654 wordsByRegion.push_back(_hWordHits[s][r]);
00655
00656 _hGroupsAndRows[s][r] = new TH2F(("_hGroupsAndRowsS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), ("hGroupsAndRowsS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), 7, -0.5, 6.5, 168, 0, 168);
00657 groupsAndRows.push_back(_hGroupsAndRows[s][r]);
00658
00659 _hHitsByRegion[s][r] = new TProfile(("_hHitsByRegionS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), ("_hHitsByRegionS" + IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), _bins, _lowEdge, _highEdge);
00660 hitsByRegion.push_back(_hHitsByRegion[s][r]);
00661
00662 _hTimestampsByThreshold[s][r] = new TH2F(("hTimestampsByThreshS"+ IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), ("hTimestampsByThreshS"+ IntToStr(sensorIds[s]) + "R" + IntToStr(r)).c_str(), _bins, _lowEdge, _highEdge, 200, 0, 200);
00663 hitsByRegion.push_back(_hTimestampsByThreshold[s][r]);
00664 }
00665 }
00666 std::cout << "\tFinishing up in " << __PRETTY_FUNCTION__ << std::endl;
00667 }
00668
00669 void MpsAnalysis::writeRootFile() {
00670 std::cout << __PRETTY_FUNCTION__ << std::endl;
00671 _rootFile->cd("/");
00672 for (tObjs::iterator it = globals.begin(); it != globals.end(); it++) {
00673 (*it)->Write();
00674 }
00675
00676 _rootFile->cd("/");
00677 _rootFile->mkdir("hitsByRegion")->cd();
00678 for (tObjs::iterator it = hitsByRegion.begin(); it!= hitsByRegion.end(); it++) {
00679 (*it)->Write();
00680 }
00681
00682 _rootFile->cd("/");
00683 _rootFile->mkdir("wordsByRegion")->cd();
00684 for (tObjs::iterator it = wordsByRegion.begin(); it!= wordsByRegion.end(); it++) {
00685 (*it)->Write();
00686 }
00687
00688 _rootFile->cd("/");
00689 _rootFile->mkdir("groupsAndRows")->cd();
00690 for (tObjs::iterator it = groupsAndRows.begin(); it!= groupsAndRows.end(); it++) {
00691 (*it)->Write();
00692 }
00693
00694 _rootFile->cd("/");
00695 _rootFile->mkdir("efficiencies")->cd();
00696 for (tObjs::iterator it = efficiencies.begin(); it!= efficiencies.end(); it++) {
00697 (*it)->Write();
00698 }
00699
00700 _rootFile->mkdir("dispTeff")->cd();
00701 for (tObjs::iterator it = efficienciesDispT.begin(); it
00702 != efficienciesDispT.end(); it++) {
00703 (*it)->Write();
00704 }
00705
00706 _rootFile->cd("/");
00707 _rootFile->mkdir("dqm")->cd();
00708 for (tObjs::iterator it = dqm.begin(); it!= dqm.end(); it++) {
00709 (*it)->Write();
00710 }
00711 }