Changeset 240 in Idarraga
- Timestamp:
- Oct 10, 2011, 11:56:47 AM (13 years ago)
- Location:
- mafalda
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
mafalda/AnalysisCore/MediPixAnalysisManager.h
r222 r240 18 18 #include <fstream> 19 19 #include <string> 20 #include <map> 20 21 21 22 #include "MediPixAnalysisCore.h" … … 96 97 }; 97 98 99 std::map<int,int> GetTOTMap() 100 {return analysisCore->m_frameXC;}; 101 98 102 inline Int_t GetnEntriesPad() 99 103 {return analysisCore->m_nEntriesPad;}; -
mafalda/MAFTools/MAFTools.cpp
r239 r240 13 13 #include "MPXAlgo/MediPixAlgo.h" 14 14 15 #include "BlobsFinder/BlobsFinder.h"15 //#include "BlobsFinder/BlobsFinder.h" 16 16 17 17 #include <set> … … 252 252 } 253 253 254 255 /** 256 * All clustering stuff 257 * 258 */ 259 bool StartBlob(int xi, int yi, Int_t disctTolerance, AllBlobsContainer * blobsContainer, blob * oneBlob, int maxx, int maxy, std::map<int,int> totmap){ 260 261 // I will recluster here on a cluster already found (if discontinuity > 0). 262 // I will have to rewind the internal iterator so the search is possible again. 263 //(*oneBlob.blobItr).second = 0; 264 265 pair<Int_t, Int_t> startPoint = make_pair(xi, yi); 266 267 ///////////////////////////////////////////////////////////////////////////////////// 268 // Check if a blob containing this point has already been saved 269 // I only need to find the 'startPoint' in 'bloblContentSet' in each blob 270 vector<blob>::iterator blobsItr = blobsContainer->allBlobs.begin(); 271 set< pair<Int_t, Int_t> >::iterator itr; 272 for( ; blobsItr != blobsContainer->allBlobs.end() ; blobsItr++) 273 { 274 itr = (*blobsItr).blobContentSet.find(startPoint); 275 if(itr != (*blobsItr).blobContentSet.end()) // point found in previous blob !!! 276 return false; 277 } 278 279 // If we hit this point we are ready to start a new blob 280 // Insert in <set>, push_back in <list>, first time 281 oneBlob->blobContentSet.insert( startPoint ); 282 oneBlob->blobContent.push_back( pair< pair<Int_t, Int_t>, Int_t > (startPoint, __CENTER)); 283 oneBlob->blobItr = oneBlob->blobContent.begin(); 284 285 // Follow 286 steerSpiral spiral; 287 FollowBlob(oneBlob, &spiral, disctTolerance, maxx, maxy, totmap); 288 289 return true; 290 } 291 292 /** 293 * Using recursion to follow a blob up to its end. 294 * 295 */ 296 bool FollowBlob(blob * oneBlob, steerSpiral * spiral, int disctTolerance, int maxx, int maxy, std::map<int,int> totmap){ 297 298 //cout << " +++ looking at = " << (*(oneBlob->blobItr)).first.first << ", " << (*(oneBlob->blobItr)).first.second << endl; 299 300 Int_t spiralEnds = GetLengthOfSpiral(disctTolerance); 301 302 // test insertion in the set 303 pair< set < pair<Int_t, Int_t> >::iterator , bool> rtest; 304 305 // spiral starts, i.e. search through the neighbors 306 RewindSpiral(spiral); 307 308 // spiral starts at 309 pair<Int_t, Int_t> nextNeighbor = (*oneBlob->blobItr).first; 310 311 (*oneBlob->blobItr).second = 0; 312 //cout << " +++ iterator = " << (*oneBlob->blobItr).second << ", " << spiralEnds << endl; 313 314 while((*oneBlob->blobItr).second < spiralEnds) { 315 316 // try current position, next neighbor 317 //nextNeighbor = GetNextPosition( (*oneBlob.blobItr).first ); 318 nextNeighbor = GetNextPosition( nextNeighbor, spiral ); 319 320 //cout << "next: " << nextNeighbor.first << " , " << nextNeighbor.second << " : " << totmap[ nextNeighbor.second * maxx + nextNeighbor.first ] << endl; 321 322 // see if the next position does not fall in the pad 323 /* 324 if(IsUnsafePosition(nextNeighbor, maxx, maxy)) { 325 // increment neighbor counter, and skip the rest withing the while loop 326 (*oneBlob.blobItr).second++; 327 continue; 328 } 329 */ 330 //Log << MSG::LOOP_DEBUG << "next: " << nextNeighbor.first << " , " << nextNeighbor.second << " ---> " 331 //<< GetMatrixElement(nextNeighbor) << endreq; 332 333 // if there is something 334 if(totmap[ nextNeighbor.second * maxx + nextNeighbor.first ] != 0) 335 { 336 //Log << MSG::LOOP_DEBUG << "next: " << nextNeighbor.first << " , " << nextNeighbor.second << " ---> " 337 // << GetMatrixElement(nextNeighbor) << endreq; 338 339 //cout << "next: " << nextNeighbor.first << " , " << nextNeighbor.second << " ---> " 340 //<< totmap[ nextNeighbor.second * maxx + nextNeighbor.first ] << endl; 341 342 // check the Set see if it existed 343 rtest = oneBlob->blobContentSet.insert( nextNeighbor ); 344 // if insertion is possible it means this point didn't exist. So, push_back new entry in the list 345 if(rtest.second == true) { 346 oneBlob->blobContent.push_back( pair< pair<Int_t, Int_t>, Int_t > (nextNeighbor, __CENTER) ); 347 } 348 349 } 350 351 // increment neighbor counter 352 (*oneBlob->blobItr).second++; 353 } 354 355 // go to the next in the list, if there are any left 356 if(++oneBlob->blobItr != oneBlob->blobContent.end()) { 357 FollowBlob(oneBlob, spiral, disctTolerance, maxx, maxy, totmap); 358 } 359 360 return true; 361 } 362 363 /** 364 * Calculate length of the spiral through the formula : 365 * (2*tolerancePixels + 2)*4 + recursive_call(--tolerancePixels) 366 * 367 * disc --> length 368 * 0 8 369 * 1 24 370 * 2 48 371 * 3 80 372 * and so on ... 373 * 374 */ 375 Int_t GetLengthOfSpiral(Int_t tolerancePixels){ 376 377 if(tolerancePixels == -1) 378 return 0; 379 else 380 return (2*tolerancePixels + 2)*4 + 381 GetLengthOfSpiral(--tolerancePixels); 382 383 } 384 385 /** 386 * Follows a spiral shape around a pixel 387 * 388 */ 389 pair<Int_t, Int_t> GetNextPosition(pair<Int_t, Int_t> current, steerSpiral * spiral) { 390 391 pair<Int_t, Int_t> newPos; 392 393 if(spiral->xySwitch == X_STEP) 394 { 395 newPos.first = current.first - spiral->dir; 396 newPos.second = current.second; 397 spiral->xCntr++; 398 399 if(spiral->xCntr > spiral->localMax) 400 spiral->xySwitch = Y_STEP; 401 } 402 else if(spiral->xySwitch == Y_STEP) 403 { 404 newPos.second = current.second - spiral->dir; 405 newPos.first = current.first; 406 spiral->yCntr++; 407 408 if(spiral->yCntr > spiral->localMax) 409 { 410 spiral->xySwitch = X_STEP; 411 spiral->localMax++; 412 spiral->xCntr = 1; 413 spiral->yCntr = 1; 414 spiral->dir *= -1; // change direction 415 } 416 } 417 418 return newPos; 419 } 420 421 void RewindSpiral(steerSpiral * spiral){ 422 423 spiral->xySwitch = X_STEP; 424 spiral->localMax = 1; 425 spiral->xCntr = 1; 426 spiral->yCntr = 1; 427 spiral->dir = 1; 428 429 } 430 431 /** 432 * Check if the position we are about to step in is safe, i.e. see if 433 * it falls inside the pad. 434 * 435 */ 436 bool IsUnsafePosition(pair<Int_t, Int_t> pos, int maxx, int maxy){ 437 438 if(pos.first < 0 || pos.second < 0) 439 return true; 440 if(pos.first > maxx-1 || pos.second > maxy-1) 441 return true; 442 443 return false; 444 } 445 446 void ClearOneBlobData(blob * oneBlob){ 447 448 // clean up 449 oneBlob->blobContent.clear(); 450 oneBlob->blobContentSet.clear(); 451 452 oneBlob->bP.nPixels = 0; 453 oneBlob->bP.totalCharge = 0; 454 oneBlob->bP.width_x = 0; 455 oneBlob->bP.width_y = 0; 456 oneBlob->bP.geoCenter_x = 0; 457 oneBlob->bP.geoCenter_y = 0; 458 oneBlob->bP.weightedCenter_x = 0; 459 oneBlob->bP.weightedCenter_y = 0; 460 oneBlob->bP.boxArea = 0; 461 oneBlob->bP.circleArea = 0.; 462 oneBlob->bP.minToGeoCenter = 0.; 463 oneBlob->bP.maxToGeoCenter = 0.; 464 465 oneBlob->bP.lvl1.clear(); 466 467 } 468 469 int DigitalBlobReclustering(int discontinuityTolerance, AllBlobsContainer * bContainer, blob bl, 470 int maxx, int maxy, std::map<int,int> totmap){ 471 472 // Start point of a blob 473 // This clustering runs on the contents of an existing blob 474 set< pair<Int_t, Int_t> > bCSet = bl.GetContentSet(); 475 set< pair<Int_t, Int_t> >::iterator bCSetItr = bCSet.begin(); 476 477 // Blob structure to find 478 blob * oneBlob = new blob; 479 ClearOneBlobData(oneBlob); 480 481 for ( ; bCSetItr != bCSet.end() ; bCSetItr++) { 482 483 int xi = (*bCSetItr).first; 484 int yi = (*bCSetItr).second; 485 486 if( StartBlob(xi, yi, discontinuityTolerance, bContainer, oneBlob, maxx, maxy, totmap) ){ 487 bContainer->allBlobs.push_back(*oneBlob); 488 ClearOneBlobData(oneBlob); 489 } 490 491 } 492 493 delete oneBlob; 494 495 return 0; 496 } 497 254 498 } 255 499 -
mafalda/MAFTools/MAFTools.h
r239 r240 12 12 #include <TROOT.h> 13 13 14 class blob; 14 #include "BlobsFinder/BlobsFinder.h" 15 16 //class blob; 15 17 class MediPixAlgo; 18 //class AllBlobsContainer; 19 //typedef struct steerSpiral; 16 20 17 21 using namespace std; … … 56 60 Bool_t BlobAtADistanceFromEdges(blob, vector<pair<Float_t, Float_t> >, Int_t, Int_t, Int_t, Int_t); 57 61 62 /** 63 * Clustering stuff 64 */ 65 int DigitalBlobReclustering(int, AllBlobsContainer *, blob, int, int, std::map<int,int>); 66 bool StartBlob(int, int, int, AllBlobsContainer *, blob *, int, int, std::map<int,int>); 67 bool FollowBlob(blob *, steerSpiral *, int, int, int, std::map<int,int>); 68 void RewindSpiral(steerSpiral *); 69 Int_t GetLengthOfSpiral(Int_t); 70 pair<Int_t, Int_t> GetNextPosition(pair<Int_t, Int_t>, steerSpiral *); 71 bool IsUnsafePosition(pair<Int_t, Int_t>, int, int); 72 void ClearOneBlobData(blob *); 58 73 59 /* Dump contents of a blob l*/74 /* Dump contents of a blob */ 60 75 void DumpBlobContents(blob); 61 76 -
mafalda/MPXAlgo/MediPixAlgo.cpp
r179 r240 210 210 Int_t MediPixAlgo::GetMatrixElement(Int_t col, Int_t row){ 211 211 return m_myManager->GetMatrixElement(col, row); 212 } 213 214 std::map<int,int> MediPixAlgo::GetTOTMap(){ 215 return m_myManager->GetTOTMap(); 212 216 } 213 217 -
mafalda/MPXAlgo/MediPixAlgo.h
r222 r240 66 66 Int_t GetMatrixWidth(){return GetMatrixXdim();}; // same 67 67 Int_t GetWidth(){return GetMatrixXdim();}; // same 68 69 std::map<int,int> GetTOTMap(); 68 70 69 71 Int_t GetMatrixYdim(); -
mafalda/ShallowAngleFEIX/ShallowAngleFEIX.cpp
r239 r240 42 42 getMyTree()->Branch("segmentedTrack", &m_segmentedTrack, "segmentedTrack/I"); 43 43 getMyTree()->Branch("clusterSize", &m_clusterSize, "clusterSize/I"); 44 getMyTree()->Branch("clusterSize_X", &m_clusterSize_X, "clusterSize_X/I"); 44 45 getMyTree()->Branch("clusterHeight", &m_clusterHeight, "clusterHeight/I"); 45 46 getMyTree()->Branch("mipThetaAngle", &m_mipThetaAngle, "mipThetaAngle/D"); … … 123 124 m_mipLength.push_back( totalLength ); // mm 124 125 m_mipLength_X.push_back( TMath::Abs ( limitPixels[__HEAD_INDX].first * m_pixSizeX 125 - limitPixels[__TAIL_INDX].first * m_pixSizeX ) ); 126 - limitPixels[__TAIL_INDX].first * m_pixSizeX ) ); // [mm] 127 m_clusterSize_X = TMath::Abs ( limitPixels[__HEAD_INDX].first - limitPixels[__TAIL_INDX].first ); // [pixels] 126 128 m_totalMIPsLength += totalLength; 127 129 Log << MSG::DEBUG << "Integrated mips length = " << m_totalMIPsLength << " [mm]" << endreq; … … 145 147 m_mipThetaAngle = (*blobsItr).GetBlobProperties().rotAngle; 146 148 147 // check discontinuitis if any 148 if ( MAFTools::FindDiscontinuity(*blobsItr) == 1 ) { 149 m_segmentedTrack = 1; 150 } else { 151 m_segmentedTrack = 0; 152 } 149 // check discontinuities if any 150 // For this I will run the clustering again with discontinuity tolerance = 0; 151 int nInnerClusters = CheckDiscontinuity(*blobsItr, 0); 152 m_segmentedTrack = nInnerClusters; 153 153 154 154 // Find the limit pixels to add-up the charge per column. … … 168 168 Log << MSG::INFO << " y:" << inity << " , " << endy << endreq; 169 169 170 // some infor about this blob after clustering 170 /* 171 // Some info about this blob after clustering 171 172 // get the content set x,y 172 173 set< pair<Int_t, Int_t> > cs = (*blobsItr).GetContentSet(); … … 177 178 << GetMatrixElement(*csItr) << endreq; 178 179 } 180 */ 179 181 180 182 m_clusterHeight = (*blobsItr).GetBlobProperties().width_y; … … 351 353 } 352 354 355 int ShallowAngleFEIX::CheckDiscontinuity(blob bl, int discontinuityTolerance){ 356 357 // new object containing all the blobs, ready to go to StoreGate when's ready 358 AllBlobsContainer * reclusteringContainer = new AllBlobsContainer((MediPixAlgo *) this); 359 Log << MSG::INFO << "Reclustering container --> " << reclusteringContainer << endreq; 360 361 std::map<int,int> totmap = GetTOTMap(); 362 MAFTools::DigitalBlobReclustering(discontinuityTolerance, reclusteringContainer, bl, GetMatrixWidth(), GetMatrixHeight(), totmap); 363 364 Log << MSG::INFO << "Reclustering ... found " << reclusteringContainer->GetBlobsVector().size() << " clusters in the blob" << endreq; 365 366 return reclusteringContainer->GetBlobsVector().size(); 367 } 368 353 369 #endif -
mafalda/ShallowAngleFEIX/ShallowAngleFEIX.h
r239 r240 19 19 public: 20 20 21 22 21 ShallowAngleFEIX(); 22 virtual ~ShallowAngleFEIX() { }; 23 23 24 25 26 27 28 29 24 // You ought to implement Init(), Execute() and Finalize() 25 // when you inherit from MediPixAlgo. This model gives you 26 // direct access to data and services. 27 void Init(); 28 void Execute(); 29 void Finalize(); 30 30 31 vector<pair<Float_t, Float_t> > FindLimitPixels(blob); 32 Int_t GuessNumberOfDeltaRaysFromUnbalance(Int_t &, Int_t &); 31 vector<pair<Float_t, Float_t> > FindLimitPixels(blob); 32 Int_t GuessNumberOfDeltaRaysFromUnbalance(Int_t &, Int_t &); 33 int CheckDiscontinuity(blob, int); 33 34 34 35 private: 35 36 36 37 38 39 40 41 42 43 37 AllBlobsContainer * m_aB; 38 Int_t m_minNPixels; 39 Int_t m_guardDistanceX; 40 Int_t m_guardDistanceY; 41 Float_t m_pixSizeX; 42 Float_t m_pixSizeY; 43 Float_t m_dRayBalSearch; 44 Int_t m_minXWidth; 44 45 45 // for output 46 vector<Float_t> m_distanceToCenter; 47 Int_t m_clusterSize; 48 vector<Float_t> m_mipLength; 49 vector<Float_t> m_mipLength_X; 50 Double_t m_totalMIPsLength; 51 Int_t m_clusterHeight; 52 Double_t m_mipThetaAngle; 53 Int_t m_segmentedTrack; 46 // for output 47 vector<Float_t> m_distanceToCenter; 48 Int_t m_clusterSize; 49 Int_t m_clusterSize_X; 50 vector<Float_t> m_mipLength; 51 vector<Float_t> m_mipLength_X; 52 Double_t m_totalMIPsLength; 53 Int_t m_clusterHeight; 54 Double_t m_mipThetaAngle; 55 Int_t m_segmentedTrack; 54 56 55 vector<Int_t> m_totPerSegment; // Total TOT per segment/pixel 56 vector<Float_t> m_chargeWeights; // Charge weight, normalized to the total TOT of the track 57 // Container for reclustering if needed 58 AllBlobsContainer * m_reclusteringContainer; 57 59 58 ClassDef(ShallowAngleFEIX, 1) 60 vector<Int_t> m_totPerSegment; // Total TOT per segment/pixel 61 vector<Float_t> m_chargeWeights; // Charge weight, normalized to the total TOT of the track 62 63 ClassDef(ShallowAngleFEIX, 1) 59 64 }; 60 65 -
mafalda/ShallowAngleFEIX/configuration_algos_ShallowAngleFEIX.txt
r238 r240 7 7 ShallowAngleFEIX dRayBalSearch 1.4 float 8 8 BlobsFinder border 0 int 9 BlobsFinder discontinuity 0int9 BlobsFinder discontinuity 1 int 10 10 BlobsFinder lvl1cut -1 int 11 11 PRBasicSpecies nInnerPixels 2 int -
mafalda/ShallowAngleFEIX/runAngle.C
r238 r240 20 20 21 21 22 GetTree("/home/idarraga/storage/61548/slice1/MAFOutput_MPXNtuple_USBPIXI4_22.root", 23 "ShallowAngleFEIX", "Lub4", 1.0); 22 GetTree("/home/idarraga/analysis/mafalda/MAFOutput_MPXNtuple_USBPIXI4_23_61417.root", 23 "ShallowAngleFEIX", "61417 3D-SCC87 p-5E15", 1.0); 24 25 GetTree("/home/idarraga/analysis/mafalda/MAFOutput_MPXNtuple_USBPIXI4_22_61548.root", 26 "ShallowAngleFEIX", "61548 Planar-LUB4 n-5E15", 1.0); 24 27 25 28 //GetTree("/storage1/idarraga/Testbeam_September_CERN_2011/KEK_20V_200V_4deg/MAFOutput/MAFOutput_MPXNtuple_USBPIXI4_21.root", … … 45 48 opts.markerStyle = 3; 46 49 opts.setLogY = false; 47 drawNormalized = false;50 opts.drawNormalized = false; 48 51 49 52 ActionFlags afl; … … 68 71 opts.doLegend = true; 69 72 opts.constructorStr = "(40,0,5)"; 70 TH1 * h_first = (TH1 *) DrawAll("mipLength_X", " ", opts, afl);73 TH1 * h_first = (TH1 *) DrawAll("mipLength_X", "clusterHeight < 3 && TMath::Abs(mipThetaAngle) < 0.17", opts, afl); 71 74 //h_first->GetXaxis()->SetRangeUser(0, 10); 72 75 h_first->GetXaxis()->SetTitle("mip length [mm]"); -
mafalda/ShallowAngleFEIX/runNewAlgo.C
r238 r240 17 17 TChain * T1 = new TChain("ShallowAngleFEIX"); 18 18 19 T1->Add("/home/idarraga/analysis/mafalda/MAFOutput_MPXNtuple_USBPIXI4_23 .root");20 TString titleT = " 3D SCC87";19 T1->Add("/home/idarraga/analysis/mafalda/MAFOutput_MPXNtuple_USBPIXI4_23_61417.root"); 20 TString titleT = ""; 21 21 22 22 //T1->Add("/home/idarraga/storage/61548/slice1/MAFOutput_MPXNtuple_USBPIXI4_22.root"); … … 36 36 TCanvas * c10 = new TCanvas(); 37 37 38 TGraphErrors * g1 = GetGraph(T1, " planar", ndiv, fulldiv, plotType);38 TGraphErrors * g1 = GetGraph(T1, "3D", 7, 7, plotType); 39 39 c10->cd(); 40 40 g1->Draw("A*"); … … 49 49 lt1->DrawLatex(0.050, 9, "backside"); 50 50 lt1->DrawLatex(0.050, 13, "frontside"); 51 lt1->DrawLatex(0.06, 4, titleT);51 //lt1->DrawLatex(0.06, 4, titleT); 52 52 53 53 TLatex * lt2 = new TLatex(); … … 55 55 lt2->DrawLatex(0.06, 1, "MAFalda, idarraga@cern.ch"); 56 56 57 return;58 59 57 ///////////////////////////////////////////////////////////////////////////////////// 60 58 61 59 TChain * T2 = new TChain("ShallowAngleFEIX"); 62 T2->Add("/ storage1/idarraga/Testbeam_July_CERN_2011/KEK_100V_4deg/MAFOutput/MAFOutput_MPXNtuple_USBPIXI4_21_100V.root");60 T2->Add("/home/idarraga/analysis/mafalda/MAFOutput_MPXNtuple_USBPIXI4_22_61548.root"); 63 61 //T2->Add("/home/idarraga/analysis/mafalda/MAFOutput_MPXNtuple_AllPix_det_200_shallowAngle_3D.root"); 64 62 65 TGraphErrors * g2 = GetGraph(T2, " 3D", 10, fulldiv, plotType);63 TGraphErrors * g2 = GetGraph(T2, "Planar", 6, 6, plotType); 66 64 // fix last point 67 65 c10->cd(); … … 73 71 ///////////////////////////////////////////////////////////////////////////////////// 74 72 TLegend * l1 = new TLegend(0.5, 0.7, 0.9, 0.9); 75 l1->AddEntry(g1, " Planar Simulation", "P");76 l1->AddEntry(g2, " Planar real data", "P");73 l1->AddEntry(g1, "61417 3D-SCC87 p-5E15", "P"); 74 l1->AddEntry(g2, "61548 Planar-LUB4 n-5E15", "P"); 77 75 l1->Draw(); 78 76 l1->SetBorderSize(1); … … 111 109 112 110 int partitionCntr = 0; 113 for (int indx = __NDIV-1 ; indx >= 0 ; indx--) {114 //for (indx = 0 ; indx < __NDIV ; indx++) {111 //for (int indx = __NDIV-1 ; indx >= 0 ; indx--) { 112 for (int indx = 0 ; indx < __NDIV ; indx++) { 115 113 116 114 wordDraw = "totPerSegment["; … … 130 128 c1->cd(indx+1); 131 129 TString cutS = "clusterHeight < 3 "; 132 cutS += " && clusterSize == ";130 cutS += " && clusterSize_X == "; 133 131 cutS += __NDIV; 134 cutS += " && mipThetaAngle< 0.17"; // ~10 deg132 cutS += " && TMath::Abs(mipThetaAngle) < 0.17"; // ~10 deg 135 133 TCut cutC = cutS; 136 134 T->Draw(wordDraw, cutC);
Note: See TracChangeset
for help on using the changeset viewer.