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!";
285 LogTrace(
"UnifiedSC") <<
"Got the BasicClusters from the event again";
288 auto basicClustersUncleanOnly_p = std::make_unique<reco::BasicClusterCollection>();
289 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(), basicClustersUncleanOnly.end());
292 if (!(bccHandleUncleanOnly.
isValid())) {
293 edm::LogWarning(
"MissingInput") <<
"could not handle the new BasicClusters (Unclean Only)!";
296 LogTrace(
"UnifiedSC") <<
"Got the BasicClusters from the event again (Unclean Only)";
304 for (
int isc = 0; isc < uncleanSize; ++isc) {
308 if (inUncleanOnlyInd[isc] == 1) {
309 for (
int jbc = 0; jbc < bcSizeUncleanOnly; ++jbc) {
310 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
311 if (theBcOwner.first == isc && theBcOwner.second == 0) {
314 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
321 for (
int jbc = 0; jbc < bcSize; ++jbc) {
322 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
323 if (theBcOwner.first == isc && theBcOwner.second == 0) {
326 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
336 if (inUncleanOnlyInd[isc] == 1) {
339 superClustersUncleanOnly.push_back(newSC);
355 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
358 if (inCleanOnlyInd[jsc] == 0)
363 for (
int jbc = 0; jbc < bcSize; ++jbc) {
364 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
365 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
368 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
382 LogTrace(
"UnifiedSC") <<
"New SC collection was created";
384 auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
389 LogTrace(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
391 auto superClustersUncleanOnly_p = std::make_unique<reco::SuperClusterCollection>();
392 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(), superClustersUncleanOnly.end());
400 LogTrace(
"UnifiedSC") <<
"Clean Collection SC ";
401 for (
int i = 0;
i < cleanSize; ++
i) {
403 LogTrace(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy() <<
" eta: " << cscRef->eta()
404 <<
" sc seed detid: " << cscRef->seed()->seed().rawId() << std::endl;
407 LogTrace(
"UnifiedSC") <<
"Unclean Collection SC ";
408 for (
int i = 0;
i < uncleanSize; ++
i) {
410 LogTrace(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy() <<
" eta: " << uscRef->eta()
411 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
414 LogTrace(
"UnifiedSC") <<
"The new SC clean collection with size " <<
superClusters.size() << std::endl;
416 int new_unclean = 0, new_clean = 0;
419 LogTrace(
"UnifiedSC") <<
"SC was got" << std::endl
420 <<
" ---> energy: " << nsc.
energy() << std::endl
421 <<
" ---> eta: " << nsc.
eta() << std::endl
422 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
423 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
424 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy() <<
" eta: " << nsc.
eta()
426 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
433 LogTrace(
"UnifiedSC") <<
"The new SC unclean only collection with size " << superClustersUncleanOnly.size();
434 for (
int i = 0;
i < (
int)superClustersUncleanOnly.size(); ++
i) {
436 LogTrace(
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy() <<
" eta: " << nsc.
eta()
438 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
444 if ((new_unclean != uncleanSize) || (new_clean != cleanSize)) {
445 LogTrace(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= " << new_unclean <<
" / " << uncleanSize
446 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
std::string scCollection_
void push_back(Ptr< T > const &iPtr)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::Ptr< CaloCluster > CaloClusterPtr
void setFlags(uint32_t flags)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::string scCollectionUncleanOnly_
std::string bcCollection_
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::BasicClusterCollection > uncleanBcCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
edm::EDGetTokenT< reco::BasicClusterCollection > cleanBcCollection_
double energy() const
cluster energy
Log< level::Info, false > LogInfo
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
const CaloClusterPtr & seed() const
seed BasicCluster
UnifiedSCCollectionProducer(const edm::ParameterSet &ps)
double eta() const
pseudorapidity of cluster centroid
Log< level::Warning, false > LogWarning
std::string bcCollectionUncleanOnly_