100 edm::LogInfo(
"UnifiedSC") <<
">>>>> Entering UnifiedSCCollectionProducer <<<<<";
130 int uncleanSize = pUncleanSC->size();
131 int cleanSize = pCleanSC->size();
133 LogTrace(
"UnifiedSC") <<
"Size of Clean Collection: " << cleanSize <<
", uncleanSize: " << uncleanSize;
136 std::vector<int> inUncleanOnlyInd;
137 std::vector<int> inCleanInd;
138 std::vector<int> inCleanOnlyInd;
139 std::vector<DetId> scUncleanSeedDetId;
140 std::vector<DetId> scCleanSeedDetId;
143 std::vector<std::pair<int, int> > basicClusterOwner;
144 std::vector<std::pair<int, int> > basicClusterOwnerUncleanOnly;
146 std::vector<int> uncleanBasicClusterIsSeed;
149 for (
int isc = 0; isc < uncleanSize; ++isc) {
151 const std::vector<std::pair<DetId, float> >& uhits = unscRef->hitsAndFractions();
152 int uhitsSize = uhits.size();
153 bool foundTheSame =
false;
154 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
156 const std::vector<std::pair<DetId, float> >& chits = cscRef->hitsAndFractions();
157 int chitsSize = chits.size();
158 foundTheSame =
false;
159 if (unscRef->seed()->seed() == cscRef->seed()->seed() && chitsSize == uhitsSize) {
164 for (
int i = 0;
i < chitsSize; ++
i) {
166 foundTheSame =
false;
173 inUncleanOnlyInd.push_back(0);
174 inCleanInd.push_back(jsc);
175 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
180 basicClusters.push_back(**bciter);
182 basicClusterOwner.push_back(std::make_pair(isc, 0));
187 if (not foundTheSame) {
189 inUncleanOnlyInd.push_back(1);
190 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
194 basicClustersUncleanOnly.push_back(**bciter);
195 basicClusterOwnerUncleanOnly.push_back(std::make_pair(isc, 0));
200 int inCleanSize = inCleanInd.size();
204 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
206 bool takenAlready =
false;
207 for (
int j = 0;
j < inCleanSize; ++
j) {
208 if (jsc == inCleanInd[
j]) {
214 inCleanOnlyInd.push_back(0);
215 scCleanSeedDetId.push_back(
DetId(0));
218 inCleanOnlyInd.push_back(1);
220 scCleanSeedDetId.push_back(cscRef->seed()->seed());
223 basicClusters.push_back(**bciter);
224 basicClusterOwner.push_back(std::make_pair(jsc, 1));
235 for (reco::BasicClusterCollection::const_iterator bc = pCleanBC->begin(); bc != pCleanBC->end(); ++bc) {
236 bool foundTheSame =
false;
237 for (reco::BasicClusterCollection::const_iterator cleanonly_bc = basicClusters.begin();
238 cleanonly_bc != basicClusters.end();
240 const std::vector<std::pair<DetId, float> >& chits = bc->hitsAndFractions();
241 int chitsSize = chits.size();
243 const std::vector<std::pair<DetId, float> >& uhits = cleanonly_bc->hitsAndFractions();
244 int uhitsSize = uhits.size();
246 if (cleanonly_bc->seed() == bc->seed() && chitsSize == uhitsSize) {
248 for (
int i = 0;
i < chitsSize; ++
i) {
250 foundTheSame =
false;
261 basicClusters.push_back(*bc);
262 LogTrace(
"UnifiedSC") <<
"found BC to add that was not associated to any SC";
271 int bcSize = (
int)basicClusterOwner.size();
272 int bcSizeUncleanOnly = (
int)basicClustersUncleanOnly.size();
274 LogTrace(
"UnifiedSC") <<
"Found cleaned SC: " << cleanSize <<
" uncleaned SC: " << uncleanSize;
277 auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
278 basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
281 edm::LogWarning(
"MissingInput") <<
"could not handle the new BasicClusters!";
286 LogTrace(
"UnifiedSC") <<
"Got the BasicClusters from the event again";
289 auto basicClustersUncleanOnly_p = std::make_unique<reco::BasicClusterCollection>();
290 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(), basicClustersUncleanOnly.end());
293 if (!(bccHandleUncleanOnly.
isValid())) {
294 edm::LogWarning(
"MissingInput") <<
"could not handle the new BasicClusters (Unclean Only)!";
298 LogTrace(
"UnifiedSC") <<
"Got the BasicClusters from the event again (Unclean Only)";
306 for (
int isc = 0; isc < uncleanSize; ++isc) {
310 if (inUncleanOnlyInd[isc] == 1) {
311 for (
int jbc = 0; jbc < bcSizeUncleanOnly; ++jbc) {
312 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
313 if (theBcOwner.first == isc && theBcOwner.second == 0) {
316 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
323 for (
int jbc = 0; jbc < bcSize; ++jbc) {
324 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
325 if (theBcOwner.first == isc && theBcOwner.second == 0) {
328 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
338 if (inUncleanOnlyInd[isc] == 1) {
341 superClustersUncleanOnly.push_back(newSC);
357 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
360 if (inCleanOnlyInd[jsc] == 0)
365 for (
int jbc = 0; jbc < bcSize; ++jbc) {
366 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
367 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
370 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
384 LogTrace(
"UnifiedSC") <<
"New SC collection was created";
386 auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
391 LogTrace(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
393 auto superClustersUncleanOnly_p = std::make_unique<reco::SuperClusterCollection>();
394 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(), superClustersUncleanOnly.end());
402 LogTrace(
"UnifiedSC") <<
"Clean Collection SC ";
403 for (
int i = 0;
i < cleanSize; ++
i) {
405 LogTrace(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy() <<
" eta: " << cscRef->eta()
406 <<
" sc seed detid: " << cscRef->seed()->seed().rawId() << std::endl;
409 LogTrace(
"UnifiedSC") <<
"Unclean Collection SC ";
410 for (
int i = 0;
i < uncleanSize; ++
i) {
412 LogTrace(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy() <<
" eta: " << uscRef->eta()
413 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
416 LogTrace(
"UnifiedSC") <<
"The new SC clean collection with size " <<
superClusters.size() << std::endl;
418 int new_unclean = 0, new_clean = 0;
421 LogTrace(
"UnifiedSC") <<
"SC was got" << std::endl
422 <<
" ---> energy: " << nsc.
energy() << std::endl
423 <<
" ---> eta: " << nsc.
eta() << std::endl
424 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
425 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
426 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy() <<
" eta: " << nsc.
eta()
428 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
435 LogTrace(
"UnifiedSC") <<
"The new SC unclean only collection with size " << superClustersUncleanOnly.size();
436 for (
int i = 0;
i < (
int)superClustersUncleanOnly.size(); ++
i) {
438 LogTrace(
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy() <<
" eta: " << nsc.
eta()
440 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
446 if ((new_unclean != uncleanSize) || (new_clean != cleanSize)) {
447 LogTrace(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= " << new_unclean <<
" / " << uncleanSize
448 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;