87 edm::LogInfo(
"UnifiedSC")<<
">>>>> Entering UnifiedSCCollectionProducer <<<<<";
102 edm::LogError(
"MissingInput") <<
"could not handle clean super clusters";
110 edm::LogError(
"MissingInput")<<
"could not handle unclean super clusters!" ;
128 int uncleanSize = pUncleanSC->size();
129 int cleanSize = pCleanSC->size();
131 LogDebug(
"UnifiedSC") <<
"Size of Clean Collection: " << cleanSize
132 <<
", 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) {
163 for (
int i=0;
i< chitsSize; ++
i) {
170 inUncleanOnlyInd.push_back(0);
171 inCleanInd.push_back(jsc);
172 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
177 basicClusters.push_back(**bciter);
179 basicClusterOwner.push_back( std::make_pair(isc,0) );
184 if (not foundTheSame) {
186 inUncleanOnlyInd.push_back(1);
187 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
191 basicClustersUncleanOnly.push_back(**bciter);
192 basicClusterOwnerUncleanOnly.push_back( std::make_pair(isc,0) );
197 int inCleanSize = inCleanInd.size();
201 for (
int jsc =0; jsc< cleanSize; ++jsc) {
203 bool takenAlready =
false;
204 for (
int j=0;
j< inCleanSize; ++
j) {
205 if (jsc == inCleanInd[
j]) { takenAlready =
true ;
break;}
208 inCleanOnlyInd.push_back(0);
209 scCleanSeedDetId.push_back(
DetId(0));
212 inCleanOnlyInd.push_back(1);
214 scCleanSeedDetId.push_back(cscRef->seed()->seed());
217 basicClusters.push_back(**bciter);
218 basicClusterOwner.push_back( std::make_pair(jsc,1) );
225 int bcSize = (int) basicClusters.size();
226 int bcSizeUncleanOnly = (int) basicClustersUncleanOnly.size();
228 LogDebug(
"UnifiedSC") <<
"Found cleaned SC: " << cleanSize
229 <<
" uncleaned SC: " << uncleanSize ;
232 std::auto_ptr< reco::BasicClusterCollection>
234 basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
239 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters!";
244 LogDebug(
"UnifiedSC")<<
"Got the BasicClusters from the event again" ;
247 std::auto_ptr< reco::BasicClusterCollection>
249 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(),
250 basicClustersUncleanOnly.end());
253 if (!(bccHandleUncleanOnly.
isValid())) {
255 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters (Unclean Only)!" ;
259 LogDebug(
"UnifiedSC")<<
"Got the BasicClusters from the event again (Unclean Only)" ;
267 for (
int isc=0; isc< uncleanSize; ++isc) {
271 if (inUncleanOnlyInd[isc] == 1) {
272 for (
int jbc=0; jbc< bcSizeUncleanOnly; ++jbc) {
273 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
274 if (theBcOwner.first == isc && theBcOwner.second == 0) {
277 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
285 for (
int jbc=0; jbc< bcSize; ++jbc) {
286 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
287 if (theBcOwner.first == isc && theBcOwner.second == 0) {
290 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
299 seed, clusterPtrVector );
301 if (inUncleanOnlyInd[isc] == 1) {
304 superClustersUncleanOnly.push_back(newSC);
309 superClusters.push_back(newSC);
321 for (
int jsc=0; jsc< cleanSize; ++jsc) {
324 if (inCleanOnlyInd[jsc] == 0)
continue;
328 for (
int jbc=0; jbc< bcSize; ++jbc) {
329 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
330 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
333 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
340 seed, clusterPtrVector );
344 superClusters.push_back(newSC);
349 LogDebug(
"UnifiedSC")<<
"New SC collection was created";
351 std::auto_ptr< reco::SuperClusterCollection>
353 superClusters_p->assign(superClusters.begin(), superClusters.end());
357 LogDebug(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
359 std::auto_ptr< reco::SuperClusterCollection>
361 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(),
362 superClustersUncleanOnly.end());
370 LogDebug(
"UnifiedSC") <<
"Clean Collection SC ";
371 for (
int i=0;
i < cleanSize; ++
i) {
373 LogDebug(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy()
374 <<
" eta: " << cscRef->eta()
375 <<
" sc seed detid: " << cscRef->seed()->seed().rawId()
379 LogDebug(
"UnifiedSC") <<
"Unclean Collection SC ";
380 for (
int i=0;
i < uncleanSize; ++
i) {
382 LogDebug(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy()
383 <<
" eta: " << uscRef->eta()
384 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
387 LogDebug(
"UnifiedSC")<<
"The new SC clean collection with size "<< superClusters.size() << std::endl;
389 int new_unclean = 0, new_clean=0;
390 for (
int i=0;
i < (int) superClusters.size(); ++
i) {
392 LogDebug(
"UnifiedSC") <<
"SC was got" << std::endl
393 <<
" ---> energy: " << nsc.
energy() << std::endl
394 <<
" ---> eta: " << nsc.
eta() << std::endl
395 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
396 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
397 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
398 <<
" eta: " << nsc.
eta() <<
" isClean="
400 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
405 LogDebug(
"UnifiedSC")<<
"The new SC unclean only collection with size "<< superClustersUncleanOnly.size();
406 for (
int i=0;
i < (int) superClustersUncleanOnly.size(); ++
i) {
408 LogDebug (
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
409 <<
" eta: " << nsc.
eta() <<
" isClean="
411 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
415 if ( (new_unclean != uncleanSize) || (new_clean != cleanSize) ) {
416 LogDebug(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= "
417 << new_unclean <<
" / " << uncleanSize
418 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;
T getParameter(std::string const &) const
std::string scCollection_
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag uncleanScCollection_
void push_back(Ptr< T > const &iPtr)
edm::Ptr< CaloCluster > CaloClusterPtr
double eta() const
pseudorapidity of cluster centroid
edm::InputTag uncleanBcCollection_
void setFlags(uint32_t flags)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::string scCollectionUncleanOnly_
std::string bcCollection_
edm::InputTag cleanBcCollection_
double energy() const
cluster energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
UnifiedSCCollectionProducer(const edm::ParameterSet &ps)
const CaloClusterPtr & seed() const
seed BasicCluster
~UnifiedSCCollectionProducer()
edm::InputTag cleanScCollection_
std::string bcCollectionUncleanOnly_