Skip to content
Snippets Groups Projects
Commit ed482bc1 authored by Carsten Burgard's avatar Carsten Burgard :speech_balloon:
Browse files

fixed weird c&p bug

parent b8009547
No related branches found
No related tags found
1 merge request!664analysis developments
Pipeline #2371010 failed
...@@ -117,7 +117,7 @@ namespace TSBaseActions { ...@@ -117,7 +117,7 @@ namespace TSBaseActions {
bool matchesAny(TQFolder* f,const std::vector<TString>& filters, const TString&prefix = "") const { bool matchesAny(TQFolder* f,const std::vector<TString>& filters, const TString&prefix = "") const {
bool matched = false; bool matched = false;
for(const auto& x:filters){ for(const auto& x:filters){
if(TQStringUtils::matches(f->GetName(),prefix+x)){ if(TQStringUtils::matches(f->GetName(),prefix+"."+x)){
matched = true; matched = true;
break; break;
} }
...@@ -198,7 +198,7 @@ namespace TSBaseActions { ...@@ -198,7 +198,7 @@ namespace TSBaseActions {
while(regions.hasNext()){ while(regions.hasNext()){
TQFolder* region = regions.readNext(); TQFolder* region = regions.readNext();
if(!region) continue; if(!region) continue;
if(matchesAny(region,exceptRegions,"Channel.")) continue; if(matchesAny(region,exceptRegions,"Channel")) continue;
if(verbose) manager->info(TString::Format("transferring in region '%s'",region->GetName())); if(verbose) manager->info(TString::Format("transferring in region '%s'",region->GetName()));
TQFolder* source = region->getFolder("Sample."+sourceSample); TQFolder* source = region->getFolder("Sample."+sourceSample);
if(!source){ if(!source){
...@@ -210,7 +210,7 @@ namespace TSBaseActions { ...@@ -210,7 +210,7 @@ namespace TSBaseActions {
while(samples.hasNext()){ while(samples.hasNext()){
TQFolder* sample = samples.readNext(); TQFolder* sample = samples.readNext();
if(!sample) continue; if(!sample) continue;
if(matchesAny(sample,exceptSamples,"Sample.")) continue; if(matchesAny(sample,exceptSamples,"Sample")) continue;
if(TQStringUtils::matches(sample->GetName(),"Sample."+sourceSample)) continue; if(TQStringUtils::matches(sample->GetName(),"Sample."+sourceSample)) continue;
if(verbose) manager->info(TString::Format("\tfor sample '%s'",sample->GetName())); if(verbose) manager->info(TString::Format("\tfor sample '%s'",sample->GetName()));
sample->deleteObject(".Dropped!"); sample->deleteObject(".Dropped!");
...@@ -221,7 +221,7 @@ namespace TSBaseActions { ...@@ -221,7 +221,7 @@ namespace TSBaseActions {
while(oldsystematics.hasNext()){ while(oldsystematics.hasNext()){
TQFolder* systematic = oldsystematics.readNext(); TQFolder* systematic = oldsystematics.readNext();
if(!systematic) continue; if(!systematic) continue;
if(matchesAny(systematic,exceptSystematics,systType+".") || !matchesAny(systematic,targetSystematics,systType+".")) continue; if(matchesAny(systematic,exceptSystematics,systType) || !matchesAny(systematic,targetSystematics,systType)) continue;
if(marked && !systematic->getTagBoolDefault(mark,false)) continue; if(marked && !systematic->getTagBoolDefault(mark,false)) continue;
if(verbose) manager->info(TString::Format("\t\tremoving '%s'",systematic->GetName())); if(verbose) manager->info(TString::Format("\t\tremoving '%s'",systematic->GetName()));
remove.push_back(systematic); remove.push_back(systematic);
...@@ -232,7 +232,7 @@ namespace TSBaseActions { ...@@ -232,7 +232,7 @@ namespace TSBaseActions {
delete systematic; delete systematic;
} }
{ {
TQFolderIterator newsystematics(source->getListOfFolders(systType+"*"),true); TQFolderIterator newsystematics(source->getListOfFolders(systType+".*"),true);
int j = 0; int j = 0;
while(newsystematics.hasNext()){ while(newsystematics.hasNext()){
TQFolder* systematic = newsystematics.readNext(); TQFolder* systematic = newsystematics.readNext();
...@@ -252,8 +252,8 @@ namespace TSBaseActions { ...@@ -252,8 +252,8 @@ namespace TSBaseActions {
continue; continue;
} }
} }
++j;
if(copy){ if(copy){
++j;
addToLog(log,cleanup(systematic->GetName()),sourceSample,cleanup(sample->GetName())); addToLog(log,cleanup(systematic->GetName()),sourceSample,cleanup(sample->GetName()));
sample->addFolder(copy); sample->addFolder(copy);
} }
...@@ -282,21 +282,20 @@ namespace TSBaseActions { ...@@ -282,21 +282,20 @@ namespace TSBaseActions {
} }
int i=0; int i=0;
for(const auto& channelExp:targetChannels){ for(const auto& channelExp:targetChannels){
TQFolderIterator regions(model->getListOfFolders("Channel."+channelExp),true); TQFolderIterator regions(model->getListOfFolders("Channel."+channelExp),true);
while(regions.hasNext()){ while(regions.hasNext()){
TQFolder* region = regions.readNext(); TQFolder* region = regions.readNext();
if(!region) continue; if(!region) continue;
if(region->GetName() == sourceChannel) continue; //there is no point in transfering from A to A (it would even delete some stuff!) if(region->GetName() == sourceChannel) continue; //there is no point in transfering from A to A (it would even delete some stuff!)
if(matchesAny(region,exceptRegions,"Channel.")) continue; if(matchesAny(region,exceptRegions,"Channel")) continue;
if(verbose) manager->info(TString::Format("transferring in region '%s'",region->GetName())); if(verbose) manager->info(TString::Format("transferring in region '%s'",region->GetName()));
for(const auto& sampleExp:targetSamples){ for(const auto& sampleExp:targetSamples){
TQFolderIterator samples(region->getListOfFolders("Sample."+sampleExp),true); TQFolderIterator samples(region->getListOfFolders("Sample."+sampleExp),true);
while(samples.hasNext()){ while(samples.hasNext()){
TQFolder* sample = samples.readNext(); TQFolder* sample = samples.readNext();
if(!sample) continue; if(!sample) continue;
if(matchesAny(sample,exceptSamples,"Sample.")) continue; if(matchesAny(sample,exceptSamples,"Sample")) continue;
TQFolder* sourceRegion = model->getFolder("Channel."+sourceChannel); TQFolder* sourceRegion = model->getFolder("Channel."+sourceChannel);
TQFolder* source = sourceRegion ? sourceRegion->getFolder(sample->GetName()) : NULL; TQFolder* source = sourceRegion ? sourceRegion->getFolder(sample->GetName()) : NULL;
if(!source){ if(!source){
...@@ -312,9 +311,9 @@ namespace TSBaseActions { ...@@ -312,9 +311,9 @@ namespace TSBaseActions {
while(oldsystematics.hasNext()){ while(oldsystematics.hasNext()){
TQFolder* systematic = oldsystematics.readNext(); TQFolder* systematic = oldsystematics.readNext();
if(!systematic) continue; if(!systematic) continue;
if(matchesAny(region,exceptSystematics,systType+".")) continue; if(matchesAny(region,exceptSystematics,systType)) continue;
if(marked && !systematic->getTagBoolDefault(mark,false)) continue; if(marked && !systematic->getTagBoolDefault(mark,false)) continue;
if(!matchesAny(systematic,targetSystematics,systType+".")) continue; if(!matchesAny(systematic,targetSystematics,systType)) continue;
if(verbose) manager->info(TString::Format("\t\tremoving '%s'",systematic->GetName())); if(verbose) manager->info(TString::Format("\t\tremoving '%s'",systematic->GetName()));
remove.push_back(systematic); remove.push_back(systematic);
} }
...@@ -324,23 +323,18 @@ namespace TSBaseActions { ...@@ -324,23 +323,18 @@ namespace TSBaseActions {
delete systematic; delete systematic;
} }
{ {
TQFolderIterator newsystematics(source->getListOfFolders(TQFolder::concatPaths(sample->getName(),systType+".*")),true); int j=0;
TQFolderIterator newsystematics(source->getListOfFolders(systType+".*"),true);
while(newsystematics.hasNext()){ while(newsystematics.hasNext()){
TQFolder* systematic = newsystematics.readNext(); TQFolder* systematic = newsystematics.readNext();
if(!systematic) continue; if(!systematic) continue;
if(matchesAny(region,exceptSystematics,systType+".")) continue; if(matchesAny(region,exceptSystematics,systType)) continue;
if(marked && !systematic->getTagBoolDefault(mark,false)) continue; if(marked && !systematic->getTagBoolDefault(mark,false)) continue;
if(!matchesAny(systematic,targetSystematics,systType+".")) continue; if(!matchesAny(systematic,targetSystematics,systType)) continue;
if(verbose) manager->info(TString::Format("\t\tcopying '%s'",systematic->GetName())); if(verbose) manager->info(TString::Format("\t\tcopying '%s'",systematic->GetName()));
TQFolder* copy = systematic->copy(); TQFolder* copy = systematic->copy();
copy->setTagString("transferred",source->GetName()); copy->setTagString("transferred",source->GetName());
if(systematic->hasTagString("HistoLow") && systematic->hasTagString("HistoHigh")){ if(systematic->hasTagString("HistoLow") && systematic->hasTagString("HistoHigh")){
if(!systematic->hasTagString("HistoLow") or !systematic->hasTagString("HistoHigh")){
manager->warn(TString::Format("Transfer for HistoSys only supported for imported systematics. Will instead delete %s HistoSys for region %s and sample %s",systematic->GetName(),region->GetName(),sample->GetName()));
delete copy;
continue;
}
TString nameLow = TString::Format("%s_%s_HistoLow",region->GetName(),sample->GetName()); TString nameLow = TString::Format("%s_%s_HistoLow",region->GetName(),sample->GetName());
TString nameHigh = TString::Format("%s_%s_HistoHigh",region->GetName(),sample->GetName()); TString nameHigh = TString::Format("%s_%s_HistoHigh",region->GetName(),sample->GetName());
TH1* TargetnomHist = dynamic_cast<TH1*>(histograms->getObject(sample->getTagStringDefault("Histo",""))); TH1* TargetnomHist = dynamic_cast<TH1*>(histograms->getObject(sample->getTagStringDefault("Histo","")));
...@@ -371,14 +365,14 @@ namespace TSBaseActions { ...@@ -371,14 +365,14 @@ namespace TSBaseActions {
copy->setTagString("HistoLow",TQFolder::concatPaths(histoPathLow.Data(),lowHist->GetName())); copy->setTagString("HistoLow",TQFolder::concatPaths(histoPathLow.Data(),lowHist->GetName()));
copy->setTagString("HistoHigh",TQFolder::concatPaths(histoPathHigh.Data(),highHist->GetName())); copy->setTagString("HistoHigh",TQFolder::concatPaths(histoPathHigh.Data(),highHist->GetName()));
} }
++j;
if(copy){ if(copy){
++j;
sample->addFolder(copy); sample->addFolder(copy);
addToLog(log,cleanup(systematic->GetName()),sourceChannel,cleanup(region->GetName())); addToLog(log,cleanup(systematic->GetName()),sourceChannel,cleanup(region->GetName()));
} }
} }
if(verbose && j==0){ if(verbose && j==0){
manager->warn(TString::Format("\tno systematics of type %s found in '%s' matching '%s' except '%s'!",systType.Data(),source->GetName(),TQStringUtils::concat(targetSystematics,",").Data(),TQStringUtils::concat(exceptSystematics,",").Data())); manager->warn(TString::Format("\tno systematics of type %s found in '%s/%s' matching '%s' except '%s'!",systType.Data(),sourceRegion->GetName(),source->GetName(),TQStringUtils::concat(targetSystematics,",").Data(),TQStringUtils::concat(exceptSystematics,",").Data()));
} }
i += j; i += j;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment