Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7_0_X Change DataMixer to merge CSC Strip Digis instead of adding duplic... #4324

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 77 additions & 6 deletions SimGeneral/DataMixingModule/plugins/DataMixingMuonWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,85 @@ namespace edm
// Get the iterators over the digis associated with this LayerId
const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;

//std::cout << " merging CSC layer " << (*CSLayerIt).first << std::endl;
std::vector<CSCStripDigi> NewDigiList;

//for(CSCStripDigiCollection::const_iterator dtdigi=range.first; dtdigi!=range.second; dtdigi++){
// std::cout << "Digi " << (*dtdigi) << std::endl;
//}
std::vector<int> StripList;
std::vector<CSCStripDigiCollection::const_iterator> StripPointer;

for(CSCStripDigiCollection::const_iterator dtdigi=range.first; dtdigi!=range.second; ++dtdigi){
//std::cout << "Digi " << (*dtdigi).getStrip() << std::endl;
StripList.push_back( (*dtdigi).getStrip() );
StripPointer.push_back( dtdigi );
}

int PrevStrip = -1;
std::vector<int> DuplicateList;

std::vector<CSCStripDigiCollection::const_iterator>::const_iterator StripPtr = StripPointer.begin();

for( std::vector<int>::const_iterator istrip = StripList.begin(); istrip !=StripList.end(); ++istrip) {

const int CurrentStrip = *(istrip);

if(CurrentStrip > PrevStrip) {
PrevStrip = CurrentStrip;

int dupl_count;
dupl_count = std::count(StripList.begin(), StripList.end(), CurrentStrip);
if(dupl_count > 1) {
std::vector<int>::const_iterator duplicate = istrip;
++duplicate;
std::vector<CSCStripDigiCollection::const_iterator>::const_iterator DuplPointer = StripPtr;
++DuplPointer;
for( ; duplicate!=StripList.end(); ++duplicate) {
if( (*duplicate) == CurrentStrip ) {

// std::cout << " Duplicate of current " << CurrentStrip << " found at " << (duplicate - StripList.begin()) << std::endl;

DuplicateList.push_back(CurrentStrip);

std::vector<int> pileup_adc = (**DuplPointer).getADCCounts();
std::vector<int> signal_adc = (**StripPtr).getADCCounts();

std::vector<int>::const_iterator minplace;

minplace = std::min_element(pileup_adc.begin(), pileup_adc.end());

int minvalue = (*minplace);

std::vector<int> new_adc;

std::vector<int>::const_iterator newsig = signal_adc.begin();

for(std::vector<int>::const_iterator ibin = pileup_adc.begin(); ibin!=pileup_adc.end(); ++ibin) {
new_adc.push_back((*newsig)+(*ibin)-minvalue);

++newsig;
}

CSCStripDigi newDigi(CurrentStrip, new_adc);
NewDigiList.push_back(newDigi);
}
++DuplPointer;
}
}
else { NewDigiList.push_back(**StripPtr); }
} // if strips monotonically increasing... Haven't hit duplicates yet
else { // reached end of signal digis, or there was no overlap
PrevStrip = 1000; // now into pileup signals, stop looking forward for duplicates

// check if this digi was in the duplicate list
int check;
check = std::count(DuplicateList.begin(), DuplicateList.end(), CurrentStrip);
if(check == 0) NewDigiList.push_back(**StripPtr);
}
++StripPtr;
}

CSCStripDigiCollection::Range stripRange(NewDigiList.begin(), NewDigiList.end());

CSCStripDigiMerge->put(stripRange, layerId);

CSCStripDigiMerge->put(range, layerId);

}
// Loop over CSCStrip digis, copying them from our own local storage

Expand Down