9 #include <dqm_core/AlgorithmConfig.h> 
   26 #include <dqm_core/AlgorithmManager.h> 
   55                         const TObject & 
object, 
 
   56                                                 const dqm_core::AlgorithmConfig & 
config )
 
   59   const TH2* 
histo = 
dynamic_cast<const TH2*
> (&
object);
 
   61     throw dqm_core::BadConfig(ERS_HERE, 
name, 
"Input object is not a TH2");
 
   63   TH1* histo_medians = getMedian(
histo);
 
   68   std::map<int, std::vector<int> > dead_chambers_map;
 
   70   std::map<int, int> lbn_occupancy;
 
   72   double median_threshold;
 
   82   catch ( dqm_core::Exception & ex ) {
 
   83     throw dqm_core::BadConfig( ERS_HERE, 
name, ex.what(), ex );
 
   86   double suppress_thresh=0;
 
   88   double suppress_chamber=0;
 
   93   catch ( dqm_core::Exception & ex ) {
 
   98   for(
int ibinx = 1; ibinx != 
histo->GetNbinsX()+1; ++ibinx){
 
   99     float median = histo_medians->GetBinContent(ibinx);
 
  103       lbn_occupancy[ibinx] = 
histo->GetNbinsY();
 
  108     int ndead_chambers = 0;
 
  109     for(
int ibiny = 1; ibiny != 
histo->GetNbinsY()+1; ++ibiny){
 
  115     std::map<int, std::vector<int> >
::iterator itr = dead_chambers_map.find(ibiny);
 
  116     if(itr == dead_chambers_map.end()) {
 
  117       std::vector<int> lbns;
 
  118       lbns.push_back(ibinx);
 
  119       dead_chambers_map.insert( std::make_pair(ibiny, lbns) );
 
  121     else (*itr).second.push_back( ibinx );
 
  123       lbn_occupancy[ibinx] = ndead_chambers;
 
  129   std::map<std::string,double> 
tags;
 
  132   if(suppress_chamber==
false){
 
  133     for(std::map<
int, std::vector<int> >::const_iterator itr = dead_chambers_map.begin(); itr != dead_chambers_map.end(); ++itr){
 
  134       const std::vector<int> &lbns = (*itr).second;
 
  136       if(writes>100) 
break;
 
  137       if( (
int) lbns.size() == active_lbns ){
 
  145     std::stringstream 
ss;
 
  147     int last_binx = 
start;
 
  148     for(
unsigned int ii = 0; ii != lbns.size(); ++ii){
 
  149       int ibinx = lbns[ii];
 
  153         ss << 
histo->GetXaxis()->GetBinLowEdge(ibinx) << 
" - ";
 
  156       if(ibinx > last_binx+1){
 
  157         ss << 
histo->GetXaxis()->GetBinLowEdge(last_binx)+
histo->GetXaxis()->GetBinWidth(last_binx) << 
", ";
 
  158         ss << 
histo->GetXaxis()->GetBinLowEdge(ibinx) << 
" - ";
 
  163       if(ii+1 == lbns.size()){
 
  165         ss << 
histo->GetXaxis()->GetBinLowEdge(ibinx)+
histo->GetXaxis()->GetBinWidth(ibinx) << 
", ";
 
  175   int start_bin_id = -1;
 
  179   for(std::map<int, int>::const_iterator itr = lbn_occupancy.begin(); itr != lbn_occupancy.end(); ++itr, ++
counter){
 
  180     int bin_id = (*itr).first;
 
  181     int current_lbn = 
histo->GetXaxis()->GetBinLowEdge(bin_id);
 
  183     if(start_bin_id > -1) start_lbn = 
histo->GetXaxis()->GetBinLowEdge(start_bin_id);
 
  188     int lbn_width = 
histo->GetXaxis()->GetBinWidth(bin_id);
 
  190     float percentage_alive = 100*(1-(*itr).second*1./
histo->GetNbinsY());
 
  191     float last_percentage_alive = 100*(1-last_ndead*1./
histo->GetNbinsY());
 
  194     if(percentage_alive < rthreshold){
 
  195       if((*itr).second != 
histo->GetNbinsY()) dead_lbns++; 
 
  202     if(start_bin_id == -1) {
 
  203       start_bin_id = bin_id;
 
  205       last_ndead = (*itr).second;
 
  209     if(last_ndead != (*itr).second || 
counter+1 == (
int) lbn_occupancy.size()){
 
  211     if(
counter+1 == (
int) lbn_occupancy.size() && percentage_alive < suppress_thresh) {
 
  213       tags[
TString::Format(
"%i-%i", start_lbn, current_lbn+lbn_width).Data()] = percentage_alive;
 
  215     else if(last_percentage_alive < suppress_thresh) {
 
  220     start_bin_id = bin_id;
 
  222     last_ndead = (*itr).second;
 
  252   for(
int ibinx = 1; ibinx != 
histo->GetNbinsX()+1; ++ibinx){
 
  253     std::vector<float> y_bin_vals;
 
  254     for(
int ibiny = 1; ibiny != 
histo->GetNbinsY()+1; ++ibiny){
 
  255       y_bin_vals.push_back(
histo->GetBinContent(ibinx, ibiny));
 
  258     std::sort( y_bin_vals.begin(), y_bin_vals.end());
 
  259     int size = y_bin_vals.size();
 
  261       h->SetBinContent(ibinx, 0);
 
  265     h->SetBinContent(ibinx, 
median);
 
  272   char char16 = 
histo->GetName()[16];
 
  276   if (
found!=std::string::npos){
 
  277     char16 = 
histo->GetName()[24];
 
  278     crate = 
hname.substr(22,4);        
 
  279   }  
else        crate = 
hname.substr(14,4);    
 
  280   if(
m_name == 
"MDT" && char16 != 
'0' ) 
return getMDTChamberName(
histo, biny);
 
  281   if(
m_name == 
"MDT" && char16 == 
'0' ) 
return getMDTChamberNameByCrate(biny, crate);
 
  282   if(std::string(
histo->GetYaxis()->GetBinLabel(biny)).size()) 
return histo->GetYaxis()->GetBinLabel(biny);
 
  283   std::stringstream 
ss;
 
  293   std::string 
name = 
histo->GetYaxis()->GetBinLabel(biny);
 
  296   while(
name.size() == 0 && biny-
count >= 1){
 
  309   else if(
name == 
"BO1" && 
side == 
'A'){
 
  314   int phiStat = 
count+1;
 
  315   char stat_type = 
'0';
 
  322     else if(
name[1] == 
'I') {
 
  324     if(phiStat%2 == 0 && phiStat <= 10) stat_type = 
'S';
 
  325     else if(phiStat%2 == 1 && phiStat <= 10) stat_type = 
'L';
 
  326     else if(phiStat == 11 || phiStat == 16) stat_type = 
'R';
 
  327     else if(phiStat == 12 || phiStat == 17) stat_type = 
'M';
 
  328     else if(phiStat == 13 || phiStat == 15 || phiStat == 18) stat_type = 
'S';
 
  329     else if(phiStat == 14) stat_type = 
'L';
 
  331     if (phiStat > 16) phiStat-=2;
 
  332     else if (phiStat <=16 && phiStat > 11) phiStat--;
 
  334       else if(etaStat == 6){
 
  335     if(phiStat%2 == 0) stat_type = 
'S';
 
  336     else if(phiStat%2 == 1) stat_type = 
'L';
 
  337     if( phiStat == 11 || phiStat == 15) stat_type = 
'R';
 
  344     else if(
name[1] == 
'M') {
 
  345         if(phiStat%2==0) stat_type = 
'S';
 
  346         if(phiStat%2==1) stat_type = 
'L';
 
  347         if(etaStat==6 && phiStat>12) phiStat = phiStat+1; 
 
  349         if(phiStat==12 || phiStat==14){ 
 
  350             if(etaStat%2==0) stat_type=
'G';
 
  355                 if(etaStat==3) etaStat=2;
 
  356                 if(etaStat==5) etaStat=3;
 
  364     phiStat = (phiStat == 1? 12 : 14);
 
  367       else if(etaStat <=6){
 
  368     if(phiStat%2==0) stat_type=
'S';
 
  369     else stat_type = 
'L';
 
  371     if(etaStat%2==0 && (phiStat==12||phiStat==14) ) stat_type = 
'G';
 
  372     else if(etaStat%2==1 && (phiStat==12||phiStat==14)) stat_type = 
'F';
 
  375     etaStat = (phiStat > 2? 8 : 7);
 
  376     stat_type = (etaStat== 7 ? 
'F' : 
'G');
 
  377     phiStat = (phiStat%2 == 1? 12 : 14);
 
  385       etaStat = (phiStat > 3? 2: 1);
 
  387     if(phiStat == 1) phiStat = 5;
 
  388     else if(phiStat%2 == 0) phiStat = 11;
 
  392     if(phiStat == 1) phiStat = 5;
 
  393     else if(phiStat%2==0) phiStat = 13;
 
  397     else if(
name[1] == 
'I'){
 
  399     if(phiStat%2==0) stat_type = 
'S';
 
  400     else if(phiStat%2==1) stat_type = 
'L';  
 
  409     phiStat = (phiStat == 1? 1 : 9);
 
  413       if(phiStat%2==0) stat_type = 
'S';
 
  414       else stat_type = 
'L';
 
  419   if(phiStat_str.size() == 1) phiStat_str = std::string(
"0")+phiStat_str;
 
  433   std::string chamber_str = 
"xxx";
 
  435   if(crate.substr(0,1) == 
'B' && crate.substr(2,2) == 
"01"){
 
  438         etaStat = (biny+1 - 61)/2;
 
  439         phiStat =  2*(biny - 2*etaStat - 61) +4;
 
  440     } 
else if( (biny-49) > 0){ 
 
  442         etaStat = (biny+1 - 49)/2;
 
  443         phiStat =  2*(biny - 49 - 2*etaStat)+ 3;
 
  444     } 
else if( (biny-37) > 0){ 
 
  446         etaStat = (biny+1 - 37)/2;
 
  447         phiStat =  2*(biny - 2*etaStat - 37) + 4;
 
  448     } 
else if ( (biny-25) > 0){ 
 
  450         etaStat = (biny+1 - 25)/2;
 
  451         phiStat =  2*(biny - 25 - 2*etaStat) +3;
 
  452     } 
else if ( (biny-24) > 0){ 
 
  456     } 
else if ( (biny-12) > 0){ 
 
  458         etaStat = (biny+1 - 12)/2;
 
  459         phiStat =  2*(biny - 2*etaStat - 12) + 4;
 
  460     } 
else if ( (biny) > 0){ 
 
  462         etaStat = (biny+1)/2;
 
  463         phiStat =  2*(biny - 2*etaStat) + 3;
 
  465   }
else if (crate.substr(0,1) == 
"B" && crate.substr(2,2) == 
"02"){
 
  468         etaStat = (biny+1 - 60)/2;
 
  469         phiStat =  2*(biny - 2*etaStat - 60) + 8;
 
  470     } 
else if ( (biny-48) > 0){ 
 
  472         etaStat = (biny+1 - 48)/2;
 
  473         phiStat =  2*(biny - 2*etaStat - 48) + 7;
 
  474     } 
else if ( (biny-36) > 0){ 
 
  476         etaStat = (biny+1 - 36)/2;
 
  477         phiStat =  2*(biny - 2*etaStat - 36) + 8;
 
  478     } 
else if ( (biny-24) > 0){ 
 
  480         etaStat = (biny+1 - 24)/2;
 
  481         phiStat =  2*(biny - 2*etaStat - 24) + 7;
 
  482     } 
else if ( (biny-12) > 0){ 
 
  484         etaStat = (biny+1 - 12)/2;
 
  485         phiStat =  2*(biny - 2*etaStat - 12) + 8;
 
  486     } 
else if ( (biny) > 0){ 
 
  488         etaStat = (biny+1)/2;
 
  489         phiStat =  2*(biny - 2*etaStat) + 7;
 
  491   } 
else if(crate.substr(0,1) == 
"B" && crate.substr(2,2) == 
"03"){
 
  493     if (crate.substr(1,1) == 
"C"){ cOffset = 1;}
 
  494     if( (biny-74 + cOffset) > 0) { 
 
  496         etaStat = (biny - 74 + cOffset);
 
  498     } 
else if ( (biny-62 + cOffset) > 0){ 
 
  500         etaStat = (biny+1 - 62 + cOffset)/2;
 
  501         phiStat =  2*(biny - 2*etaStat - 62 + cOffset) + 11;
 
  502     } 
else if ( (biny - 57 ) > 0){
 
  504         etaStat = 2*(biny - 57) - 2 + 2*cOffset;
 
  506     } 
else if ( (biny-53) > 0){
 
  508         etaStat = 2*(biny - 53) - 1;
 
  510     } 
else if( (biny-47) > 0){ 
 
  514     } 
else if ( (biny-35) > 0){ 
 
  516         etaStat = (biny+1 - 35)/2;
 
  517         phiStat =  2*(biny - 2*etaStat - 35) + 11;
 
  518     } 
else if ( (biny - 32) > 0){ 
 
  520         etaStat = (biny - 32)*2 ; 
 
  522     } 
else if ( (biny - 29) > 0){ 
 
  526     } 
else if ( (biny-17) > 0){ 
 
  528         etaStat = (biny+1 - 17)/2;
 
  529         phiStat =  2*(biny - 2*etaStat - 17) + 12;
 
  530     } 
else if ( (biny-11) > 0){ 
 
  534     } 
else if ( (biny-6) > 0){ 
 
  538     } 
else if ( (biny) > 0){ 
 
  543   } 
else if(crate.substr(0,1) == 
"B" && crate.substr(2,2) == 
"04"){
 
  545     if (crate.substr(1,1) == 
"C"){ cOffset = 1;}
 
  546     if( (biny-74 + cOffset) > 0) { 
 
  548         etaStat = (biny - 74 + cOffset);
 
  550     } 
else if ( (biny-61 + cOffset) > 0){ 
 
  552         etaStat = (biny+1 - 61 + cOffset)/2;
 
  553         phiStat =  2*(biny - 2*etaStat - 61 + cOffset) + 15;
 
  554     } 
else if ( (biny - 56 ) > 0){
 
  556         etaStat = 2*(biny - 56) - 2 + 2*cOffset;
 
  558     } 
else if ( (biny-52) > 0){
 
  560         etaStat = 2*(biny - 52) - 1;
 
  562     } 
else if( (biny-46) > 0){ 
 
  566     } 
else if ( (biny - 45) > 0){
 
  570     } 
else if ( (biny-35) > 0){ 
 
  572         etaStat = (biny+1 - 35)/2;
 
  573         phiStat =  2*(biny - 2*etaStat - 35) + 15;
 
  574     } 
else if ( (biny - 32) > 0){ 
 
  576         etaStat = (biny - 32)*2;
 
  578     } 
else if ( (biny - 29) > 0){ 
 
  582     } 
else if ( (biny-17) > 0){ 
 
  584         etaStat = (biny+1 - 17)/2;
 
  585         phiStat =  2*(biny - 2*etaStat - 17) + 16;
 
  586     } 
else if ( (biny-11) > 0){ 
 
  590     } 
else if ( (biny-6) > 0){ 
 
  594     } 
else if ( (biny) > 0){ 
 
  599   } 
else if(crate.substr(0,1) == 
"E" && (crate.substr(2,2) == 
"01" || crate.substr(2,2) == 
"03") ){
 
  601     if (crate.substr(2,2) == 
"03"){ cOffset = 8;}
 
  604         etaStat = (biny+1 - 61)/2;
 
  605         phiStat =  2*(biny - 2*etaStat - 61) + 4 + cOffset;
 
  606     } 
else if ( (biny-49) > 0){ 
 
  608         etaStat = (biny+1 - 49)/2;
 
  609         phiStat =  2*(biny - 2*etaStat - 49) + 3 + cOffset;
 
  610     } 
else if ( (biny - 39 ) > 0){ 
 
  612         etaStat = (biny+1 - 39)/2;
 
  613         phiStat =  2*(biny - 2*etaStat - 39) + 4 + cOffset;
 
  614     } 
else if ( (biny-29) > 0){ 
 
  616         etaStat = (biny+1 - 29)/2;
 
  617         phiStat =  2*(biny - 2*etaStat - 29) + 3 + cOffset;
 
  618     } 
else if( (biny-25) > 0){ 
 
  620         etaStat = (biny+1 - 25)/2;
 
  621         phiStat =  2*(biny - 2*etaStat - 25) + 4 + cOffset;
 
  622     } 
else if ( (biny - 16) > 0){ 
 
  624         etaStat = (biny+1 - 16)/2;
 
  625         phiStat =  2*(biny - 2*etaStat - 16) + 3 + cOffset;
 
  626     } 
else if ( (biny-12) > 0){ 
 
  628         etaStat = (biny+1 - 12)/2;
 
  629         phiStat =  2*(biny - 2*etaStat - 12) + 4 + cOffset;
 
  630     } 
else if ( (biny - 8) > 0){ 
 
  632         etaStat = (biny+1 - 8)/2;
 
  633         phiStat =  2*(biny - 2*etaStat - 8 ) + 3 + cOffset;
 
  634     } 
else if ( (biny-4) > 0){ 
 
  636         etaStat = (biny+1 - 4)/2 + 6;
 
  637         phiStat =  2*(biny - 2*(etaStat-6) - 4) + 4 + cOffset;
 
  638     } 
else if ( (biny) > 0){ 
 
  640         etaStat = (biny+1)/2;
 
  641         phiStat =  2*(biny - 2*etaStat) + 4 + cOffset;
 
  643   } 
else if(crate.substr(0,1) == 
"E" && (crate.substr(2,2) == 
"02" || crate.substr(2,2) == 
"04") ){
 
  644     int cOffset = 0; 
int phiOffset = 0;
 
  645     if (crate.substr(2,2) == 
"04"){
 
  646             cOffset = 1; phiOffset = 8;
 
  648     if( (biny-59 - cOffset) > 0) { 
 
  650         etaStat = (biny+1 - 59 - cOffset)/2;
 
  651         phiStat =  2*(biny - 2*etaStat - 59 - cOffset) + 8 + phiOffset;
 
  652     } 
else if ( (biny-47 - cOffset) > 0){ 
 
  654         etaStat = (biny+1 - 47 - cOffset)/2;
 
  655         phiStat =  2*(biny - 2*etaStat - 47 - cOffset) + 7 + phiOffset;
 
  656     } 
else if ( (biny - 37 - cOffset ) > 0){ 
 
  658         etaStat = (biny+1 - 37 - cOffset)/2;
 
  659         phiStat =  2*(biny - 2*etaStat - 37 - cOffset) + 8 + phiOffset;
 
  660     } 
else if ( (biny-27 - cOffset) > 0){ 
 
  662         etaStat = (biny+1 - 27 - cOffset)/2;
 
  663         phiStat =  2*(biny - 2*etaStat - 27 - cOffset) + 7 + phiOffset;
 
  664     } 
else if( (biny-23 - cOffset) > 0){ 
 
  666         etaStat = (biny+1 - 23 - cOffset)/2;
 
  667         phiStat =  2*(biny - 2*etaStat - 23 - cOffset) + 8 + phiOffset;
 
  668     } 
else if ( (biny - 15 - cOffset) > 0){ 
 
  670         etaStat = (biny+1 - 15 - cOffset)/2;
 
  671         phiStat =  2*(biny - 2*etaStat - 15 - cOffset) + 7 + phiOffset;
 
  672     } 
else if ( (biny-11 - cOffset) > 0){ 
 
  674         etaStat = (biny+1 - 11 - cOffset)/2;
 
  675         phiStat =  2*(biny - 2*etaStat - 11 - cOffset) + 8 + phiOffset;
 
  676     } 
else if ( (biny - 8) > 0){ 
 
  678         etaStat = (biny+1 - 8)/2;
 
  679         phiStat =  2*(biny - 2*etaStat - 8 ) + 7 + phiOffset;
 
  680         if(cOffset == 0 && etaStat == 2){phiStat = 7;}
 
  681     } 
else if ( (biny-4) > 0){ 
 
  683         etaStat = (biny+1 - 4)/2 + 6;
 
  684         phiStat =  2*(biny - 2*(etaStat-6) - 4) + 8 + phiOffset;
 
  685     } 
else if ( (biny) > 0){ 
 
  687         etaStat = (biny+1)/2;
 
  688         phiStat =  2*(biny - 2*etaStat) + 8 + phiOffset;
 
  692   if(phiStat_str.size() == 1) phiStat_str = std::string(
"0")+phiStat_str;
 
  694   std::string 
chamber_name = chamber_str + etaStat_c + crate.substr(1,1) + phiStat_str;
 
  695   if(chamber_str == 
"BOG" && etaStat == 0){
 
  696     chamber_name = chamber_str + etaStat_c + 
"B" + phiStat_str;