Changeset 12195
- Timestamp:
- 10/18/11 11:10:55 (13 years ago)
- Location:
- fact/tools/rootmacros
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/discriminator.C
r12169 r12195 11 11 // it needs a threshold and the length of the falling edge 12 12 13 typedef struct 14 { 15 int begin; 16 int maxPos; 17 int end; 18 float maxVal; 19 } 20 DiscOut; 13 #include "discriminator.h" 21 14 22 15 vector<DiscOut> * discriminator( … … 26 19 { 27 20 28 vector<DiscOut> result;21 vector<DiscOut> * result = new vector<DiscOut>; 29 22 DiscOut disc; 30 23 disc.begin = 0; … … 36 29 37 30 38 bool debug = true; // switch to true in order to generate some output.31 bool debug = false; // switch to true in order to generate some output. 39 32 40 // chech if by chance the first slice is already over thr 41 if ( input[0] > thr ) 42 start_under_thr = false; 43 else 44 start_under_thr = true; 45 33 for ( int sl = 0; sl < input.size() ; sl++ ){ 46 34 47 48 for ( int sl = 1; sl < input.size() ; sl++ ){49 35 50 // normal case51 // if ( start_under_thr )52 {53 36 if ( input[sl] > thr ) { 54 37 … … 68 51 disc.end = sl; 69 52 70 result .push_back(disc);53 result->push_back(disc); 71 54 disc.begin = 0; 72 55 disc.end = 0; … … 76 59 } 77 60 } 78 } 79 // else // if we were already over thr, when starting. 80 { 61 } // end of for llop over all slices 81 62 82 }83 84 } // end of for llop over all slices85 63 if (debug){ // output the vector 86 for (int p=0; p<result .size(); p++ ){64 for (int p=0; p<result->size(); p++ ){ 87 65 cout << p << ":\t"; 88 cout << result [p].begin << "\t";89 cout << result [p].end << "\t";90 cout << result [p].maxPos << "\t";91 cout << result [p].maxVal << endl;66 cout << result->at(p).begin << "\t"; 67 cout << result->at(p).end << "\t"; 68 cout << result->at(p).maxPos << "\t"; 69 cout << result->at(p).maxVal << endl; 92 70 } 93 71 } 94 72 95 return NULL; 73 DiscOut last; 74 vector<DiscOut> * realresult = new vector<DiscOut>; 75 76 if (result->size() > 0) { 77 while (!result->empty()){ 78 79 last.begin = result->back().begin; 80 last.end = result->back().end; 81 last.maxPos = result->back().maxPos; 82 last.maxVal = result->back().maxVal; 83 result->pop_back(); 84 85 if (result->empty()){ 86 if (last.maxPos > 0) 87 realresult->push_back(last); 88 break; 89 } 90 if (last.maxPos - result->back().maxPos > fallingEdge) 91 realresult->push_back(last); 92 } 93 } 94 /* 95 vector<vector<DiscOut>::iterator> toBeDeleted; 96 97 for (vector<DiscOut>::iterator it=result->begin(); it != result->end()-1; ++it ){ 98 if ( (*it).begin==0 ){ 99 toBeDeleted.push_back(it); 100 } 101 if ( ((*(it+1)).maxPos - (*it).maxPos) < fallingEdge ){ 102 toBeDeleted.push_back(it); 103 } 104 } 105 106 for (int i=0; i<toBeDeleted.size(); i++) { 107 result->erase(toBeDeleted[i]); 108 if (debug) 109 cout << "erased peak at:" << (*toBeDeleted[i]).maxPos << endl; 110 } 111 */ 112 113 delete result; 114 return realresult; 96 115 97 116 } // end of function - discriminator
Note:
See TracChangeset
for help on using the changeset viewer.