CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQM/EcalBarrelMonitorClient/src/EBBeamCaloClient.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBBeamCaloClient.cc
00003  *
00004  * $Date: 2010/10/17 18:06:33 $
00005  * $Revision: 1.99 $
00006  * \author G. Della Ricca
00007  * \author A. Ghezzi
00008  *
00009  */
00010 
00011 #include <memory>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <algorithm>
00015 #include <cmath>
00016 #include <math.h>
00017 
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 
00022 #ifdef WITH_ECAL_COND_DB
00023 #include "OnlineDB/EcalCondDB/interface/MonOccupancyDat.h"
00024 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00025 #include "DQM/EcalCommon/interface/LogicID.h"
00026 #endif
00027 
00028 #include "DQM/EcalCommon/interface/UtilsClient.h"
00029 #include "DQM/EcalCommon/interface/Numbers.h"
00030 
00031 #include "DQM/EcalBarrelMonitorClient/interface/EBBeamCaloClient.h"
00032 
00033 EBBeamCaloClient::EBBeamCaloClient(const edm::ParameterSet& ps) {
00034 
00035   // cloneME switch
00036   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00037 
00038   // verbose switch
00039   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00040 
00041   // debug switch
00042   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00043 
00044   // prefixME path
00045   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00046 
00047   // enableCleanup_ switch
00048   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00049 
00050   // vector of selected Super Modules (Defaults to all 36).
00051   superModules_.reserve(36);
00052   for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00053   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00054 
00055   checkedSteps_.reserve(86);
00056   // there should be not more than a eta row in an autoscan
00057   minEvtNum_ = 1800;//
00058   //FIX ME, this should be configurable and change with the beam energy
00059   aveEne1_    = 1850;  E1Th_   = 900;
00060   aveEne3x3_  = 2600;  E3x3Th_ = 2600;
00061   RMSEne3x3_  = 800;
00062 
00063   ReadCryErrThr_ = 0.01;// 1%
00064   //FIX ME, this should follow the prescaling in the monitoring
00065   prescaling_ = 20;
00066 
00068   for(int u=0;u<cryInArray_;u++) {
00069     hBGains_[u] = 0;
00070     hBpulse_[u] = 0;
00071     //hBGainsMoving_[u] = 0;
00072   }
00073   hBEne1_ = 0;
00074   //hBEne1Moving_ = 0;
00075   hBAllNeededCry_ = 0;
00076   hBNumReadCry_ = 0;
00077   hBE3x3_ = 0;
00078   hBE3x3Moving_ = 0;
00079   hBCryOnBeam_ = 0;
00080   hBMaxEneCry_ = 0;
00081   hBReadCryErrors_ = 0;
00082   hBE1vsCry_ = 0;
00083   hBE3x3vsCry_ = 0;
00084   hBEntriesvsCry_ = 0;
00085   hBcryDone_ = 0;
00086   hBBeamCentered_ = 0;
00087   hbTBmoving_ = 0;
00088   hbE1MaxCry_ = 0;
00089   hbDesync_ = 0;
00090   pBCriInBeamEvents_ = 0;
00091 
00092   meEBBCaloRedGreen_ = 0;
00093   meEBBCaloRedGreenReadCry_ = 0;
00094   meEBBCaloRedGreenSteps_ = 0;
00095 }
00096 
00097 EBBeamCaloClient::~EBBeamCaloClient() {
00098 
00099 }
00100 
00101 void EBBeamCaloClient::beginJob(void) {
00102 
00103   dqmStore_ = edm::Service<DQMStore>().operator->();
00104 
00105   if ( debug_ ) std::cout << "EBBeamCaloClient: beginJob" << std::endl;
00106 
00107   ievt_ = 0;
00108   jevt_ = 0;
00109 
00110 }
00111 
00112 void EBBeamCaloClient::beginRun(void) {
00113 
00114   if ( debug_ ) std::cout << "EBBeamCaloClient: beginRun" << std::endl;
00115 
00116   jevt_ = 0;
00117 
00118   this->setup();
00119 
00120 }
00121 
00122 void EBBeamCaloClient::endJob(void) {
00123 
00124   if ( debug_ ) std::cout << "EBBeamCaloClient: endJob, ievt = " << ievt_ << std::endl;
00125 
00126   this->cleanup();
00127 
00128 }
00129 
00130 void EBBeamCaloClient::endRun(void) {
00131 
00132   if ( debug_ ) std::cout << "EBBeamCaloClient: endRun, jevt = " << jevt_ << std::endl;
00133 
00134   this->cleanup();
00135 
00136 }
00137 
00138 void EBBeamCaloClient::setup(void) {
00139 
00140   char histo[200];
00141 
00142   dqmStore_->setCurrentFolder( prefixME_ + "/EBBeamCaloClient" );
00143 
00144   if ( meEBBCaloRedGreen_ ) dqmStore_->removeElement( meEBBCaloRedGreen_->getName() );
00145   sprintf(histo, "EBBCT quality");
00146   meEBBCaloRedGreen_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00147 
00148   meEBBCaloRedGreen_->Reset();
00149 
00150   for ( int ie = 1; ie <= 85; ie++ ) {
00151     for ( int ip = 1; ip <= 20; ip++ ) {
00152 
00153       meEBBCaloRedGreen_ ->setBinContent( ie, ip, 2. );
00154 
00155     }
00156   }
00157 
00158   if ( meEBBCaloRedGreenReadCry_ ) dqmStore_->removeElement( meEBBCaloRedGreenReadCry_->getName() );
00159   sprintf(histo, "EBBCT quality read crystal errors");
00160   meEBBCaloRedGreenReadCry_ = dqmStore_->book2D(histo, histo, 1, 0., 1., 1, 0., 1.);
00161   meEBBCaloRedGreenReadCry_->Reset();
00162   meEBBCaloRedGreenReadCry_ ->setBinContent( 1, 1, 2. );
00163 
00164   if( meEBBCaloRedGreenSteps_ ) dqmStore_->removeElement( meEBBCaloRedGreenSteps_->getName() );
00165   sprintf(histo, "EBBCT quality entries or read crystals errors");
00166   meEBBCaloRedGreenSteps_ = dqmStore_->book2D(histo, histo, 86, 1., 87., 1, 0., 1.);
00167   meEBBCaloRedGreenSteps_->setAxisTitle("step in the scan");
00168   meEBBCaloRedGreenSteps_->Reset();
00169   for( int bin=1; bin <87; bin++) { meEBBCaloRedGreenSteps_->setBinContent( bin, 1, 2. );}
00170 
00171 }
00172 
00173 void EBBeamCaloClient::cleanup(void) {
00174   if ( ! enableCleanup_ ) return;
00175   if ( cloneME_ ) {
00176     for(int u=0;u<cryInArray_;u++) {
00177       if(hBGains_[u]) delete hBGains_[u];
00178       if(hBpulse_[u]) delete hBpulse_[u];
00179       //if(hBGainsMoving_[u])delete hBGainsMoving_[u];
00180     }
00181     if(hBEne1_) delete hBEne1_;
00182     //    if(hBEne1Moving_) delete hBEne1Moving_;
00183     if(hBAllNeededCry_) delete hBAllNeededCry_;
00184     if(hBNumReadCry_) delete hBNumReadCry_;
00185     if(hBE3x3_) delete hBE3x3_;
00186     if(hBE3x3Moving_) delete hBE3x3Moving_;
00187     if(hBCryOnBeam_) delete hBCryOnBeam_;
00188     if(hBMaxEneCry_) delete hBMaxEneCry_;
00189     if(hBReadCryErrors_) delete hBReadCryErrors_;
00190     if(hBE1vsCry_) delete hBE1vsCry_;
00191     if(hBE3x3vsCry_) delete hBE3x3vsCry_;
00192     if(hBEntriesvsCry_) delete hBEntriesvsCry_;
00193     if(hBcryDone_) delete hBcryDone_;
00194     if(hBBeamCentered_) delete hBBeamCentered_;
00195     if(hbTBmoving_) delete hbTBmoving_;
00196     if(hbE1MaxCry_) delete hbE1MaxCry_;
00197     if(hbDesync_) delete hbDesync_;
00198     if(pBCriInBeamEvents_) delete pBCriInBeamEvents_;
00199   }
00200 
00201   for(int u=0;u<cryInArray_;u++) {
00202     hBGains_[u] = 0;
00203     hBpulse_[u] = 0;
00204     //hBGainsMoving_[u] = 0;
00205   }
00206   hBEne1_ = 0;
00207   //hBEne1Moving_ = 0;
00208   hBAllNeededCry_ = 0;
00209   hBNumReadCry_ = 0;
00210   hBE3x3_ = 0;
00211   hBE3x3Moving_ = 0;
00212   hBCryOnBeam_ = 0;
00213   hBMaxEneCry_ = 0;
00214   hBReadCryErrors_ = 0;
00215   hBE1vsCry_ = 0;
00216   hBE3x3vsCry_ = 0;
00217   hBEntriesvsCry_ = 0;
00218   hBcryDone_ = 0;
00219   hBBeamCentered_ = 0;
00220   hbTBmoving_ = 0;
00221   hbE1MaxCry_ = 0;
00222   hbDesync_ = 0;
00223   pBCriInBeamEvents_ =0;
00224 
00225   dqmStore_->setCurrentFolder( prefixME_ + "/EBBeamCaloClient" );
00226 
00227   if ( meEBBCaloRedGreen_) dqmStore_->removeElement( meEBBCaloRedGreen_->getName() );
00228   meEBBCaloRedGreen_ = 0;
00229   if ( meEBBCaloRedGreenReadCry_) dqmStore_->removeElement( meEBBCaloRedGreenReadCry_->getName() );
00230   meEBBCaloRedGreenReadCry_ = 0;
00231   if( meEBBCaloRedGreenSteps_ ) dqmStore_->removeElement (  meEBBCaloRedGreenSteps_->getName() );
00232   meEBBCaloRedGreenSteps_ = 0;
00233 }
00234 
00235 #ifdef WITH_ECAL_COND_DB
00236 bool EBBeamCaloClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00237 
00238   status = true;
00239 
00240   EcalLogicID ecid;
00241 
00242   MonOccupancyDat o;
00243   std::map<EcalLogicID, MonOccupancyDat> dataset;
00244 
00245   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00246 
00247     int ism = superModules_[i];
00248 
00249     if ( verbose_ ) {
00250       std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00251       std::cout << std::endl;
00252     }
00253 
00254     const float n_min_tot = 1000.;
00255 
00256     float num01, num02;
00257     float mean01;
00258 
00259     for ( int ie = 1; ie <= 85; ie++ ) {
00260       for ( int ip = 1; ip <= 20; ip++ ) {
00261 
00262         num01 = num02 = -1.;
00263         mean01 = -1.;
00264 
00265         bool update_channel = false;
00266 
00267         if ( hBCryOnBeam_ && hBCryOnBeam_->GetEntries() >= n_min_tot ) {
00268           num01 = hBCryOnBeam_->GetBinContent(ie, ip);
00269           update_channel = true;
00270         }
00271 
00272         if ( hBMaxEneCry_ && hBMaxEneCry_->GetEntries() >= n_min_tot ) {
00273           num02 = hBMaxEneCry_->GetBinContent(ie, ip);
00274           update_channel = true;
00275         }
00276 
00277         mean01 = 0.;
00278         //int cry = ip+20*(ie-1);
00279         int ic = (ip-1) + 20*(ie-1) + 1;
00280         int step = 0;
00281         if (hBcryDone_) { step = (int) hBcryDone_->GetBinContent(ic);}
00282         if( step > 0 && step < 86) {
00283         //if(hBE3x3vsCry_) {mean01 = hBE3x3vsCry_->GetBinContent(step);}// E in the 3x3
00284         if( hBE1vsCry_ ) {mean01 = hBE1vsCry_->GetBinContent(ic);} // E1
00285         }
00286 
00287         if ( update_channel ) {
00288 
00289           if ( Numbers::icEB(ism, ie, ip) == 1 ) {
00290 
00291             if ( verbose_ ) {
00292               std::cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00293               std::cout << "CryOnBeam (" << ie << "," << ip << ") " << num01  << std::endl;
00294               std::cout << "MaxEneCry (" << ie << "," << ip << ") " << num02  << std::endl;
00295               std::cout << "E1 ("        << ie << "," << ip << ") " << mean01 << std::endl;
00296               std::cout << std::endl;
00297             }
00298 
00299           }
00300 
00301           o.setEventsOverHighThreshold(int(num01));
00302           o.setEventsOverLowThreshold(int(num02));
00303 
00304           o.setAvgEnergy(mean01);
00305 
00306           if ( econn ) {
00307             ecid = LogicID::getEcalLogicID("EB_crystal_number", Numbers::iSM(ism, EcalBarrel), ic);
00308             dataset[ecid] = o;
00309           }
00310 
00311         }
00312 
00313       }
00314     }
00315 
00316   }
00317 
00318   if ( econn ) {
00319     try {
00320       if ( verbose_ ) std::cout << "Inserting MonOccupancyDat ..." << std::endl;
00321       if ( dataset.size() != 0 ) econn->insertDataArraySet(&dataset, moniov);
00322       if ( verbose_ ) std::cout << "done." << std::endl;
00323     } catch (std::runtime_error &e) {
00324       std::cerr << e.what() << std::endl;
00325     }
00326   }
00327 
00328   return true;
00329 
00330 }
00331 #endif
00332 
00333 void EBBeamCaloClient::analyze(void) {
00334 
00335   ievt_++;
00336   jevt_++;
00337   if ( ievt_ % 10 == 0 ) {
00338     if ( debug_ ) std::cout << "EBBeamCaloClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00339   }
00340 
00341   char histo[200];
00342 
00343   MonitorElement* me = 0;
00344 
00345   // MonitorElement* meCD;
00346   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystals done").c_str());
00347   //meCD = dqmStore_->get(histo);
00348   me = dqmStore_->get(histo);
00349   hBcryDone_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBcryDone_ );
00350 
00351   //MonitorElement* meCryInBeam;
00352   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystal on beam").c_str());
00353   //meCryInBeam = dqmStore_->get(histo);
00354   me = dqmStore_->get(histo);
00355   hBCryOnBeam_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hBCryOnBeam_);
00356 
00357   //MonitorElement* allNeededCry;
00358   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT all needed crystals readout").c_str());
00359   //allNeededCry= dqmStore_->get(histo);
00360   me = dqmStore_->get(histo);
00361   hBAllNeededCry_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBAllNeededCry_);
00362 
00363   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT readout crystals number").c_str());
00364   //allNeededCry= dqmStore_->get(histo);
00365   me = dqmStore_->get(histo);
00366   hBNumReadCry_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBNumReadCry_);
00367 
00368   //MonitorElement* RecEne3x3;
00369   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT rec Ene sum 3x3").c_str());
00370   //RecEne3x3= dqmStore_->get(histo);
00371   me = dqmStore_->get(histo);
00372   hBE3x3_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBE3x3_);
00373 
00374   //MonitorElement* ErrRedCry;
00375   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT readout crystals errors").c_str());
00376   //ErrRedCry = dqmStore_->get(histo);
00377   me = dqmStore_->get(histo);
00378   hBReadCryErrors_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBReadCryErrors_);
00379 
00380   //  MonitorElement* RecEne1;
00381   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT rec energy cry 5").c_str());
00382   //RecEne1= dqmStore_->get(histo);
00383   me = dqmStore_->get(histo);
00384   hBEne1_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBEne1_);
00385 
00386   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystal with maximum rec energy").c_str());
00387   me = dqmStore_->get(histo);
00388   hBMaxEneCry_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hBMaxEneCry_);
00389 
00390   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT average rec energy in the 3x3 array").c_str());
00391   me = dqmStore_->get(histo);
00392   hBE3x3vsCry_ = UtilsClient::getHisto<TProfile*>( me, cloneME_, hBE3x3vsCry_);
00393 
00394   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT average rec energy in the single crystal").c_str());
00395   me = dqmStore_->get(histo);
00396   hBE1vsCry_ = UtilsClient::getHisto<TProfile*>( me, cloneME_, hBE1vsCry_);
00397 
00398   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT number of entries").c_str());
00399   me = dqmStore_->get(histo);
00400   hBEntriesvsCry_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBEntriesvsCry_);
00401 
00402   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT energy deposition in the 3x3").c_str());
00403   me = dqmStore_->get(histo);
00404   hBBeamCentered_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hBBeamCentered_);
00405 
00406   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT table is moving").c_str());
00407   me = dqmStore_->get(histo);
00408   hbTBmoving_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hbTBmoving_);
00409 
00410   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystal in beam vs event").c_str());
00411   me = dqmStore_->get(histo);
00412   pBCriInBeamEvents_ =  UtilsClient::getHisto<TProfile*>( me, cloneME_, pBCriInBeamEvents_);
00413 
00414   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT E1 in the max cry").c_str());
00415   me = dqmStore_->get(histo);
00416   hbE1MaxCry_ =  UtilsClient::getHisto<TH1F*>( me, cloneME_, hbE1MaxCry_);
00417 
00418   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT Desynchronization vs step").c_str());
00419   me = dqmStore_->get(histo);
00420   hbDesync_ =  UtilsClient::getHisto<TH1F*>( me, cloneME_, hbDesync_);
00421 
00422   for(int ind = 0; ind < cryInArray_; ind ++) {
00423     sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT pulse profile in G12 cry %01d").c_str(), ind+1);
00424     me = dqmStore_->get(histo);
00425     hBpulse_[ind] = UtilsClient::getHisto<TProfile*>( me, cloneME_, hBpulse_[ind]);
00426 
00427     sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT found gains cry %01d").c_str(), ind+1);
00428     me = dqmStore_->get(histo);
00429     hBGains_[ind] = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBGains_[ind]);
00430   }
00431 
00432   int DoneCry = 0;//if it stays 1 the run is not an autoscan
00433   if (hBcryDone_) {
00434     for(int cry=1 ; cry<1701 ; cry ++) {
00435       int step = (int) hBcryDone_->GetBinContent(cry);
00436       if( step>0 ) {//this crystal has been scanned or is being scanned
00437         DoneCry++;
00438         float E3x3RMS = -1, E3x3 =-1, E1=-1;
00439         if(hBE3x3vsCry_) {
00440           //E3x3RMS = hBE3x3vsCry_->GetBinError(step);
00441           //E3x3 = hBE3x3vsCry_->GetBinContent(step);
00442           E3x3RMS = hBE3x3vsCry_->GetBinError(cry);
00443           E3x3 = hBE3x3vsCry_->GetBinContent(cry);
00444         }
00445         //if( hBE1vsCry_) {E1=hBE1vsCry_->GetBinContent(step);}
00446         if( hBE1vsCry_) {E1=hBE1vsCry_->GetBinContent(cry);}
00447         bool RMS3x3  =  (  E3x3RMS < RMSEne3x3_ && E3x3RMS >= 0 );
00448         bool Mean3x3 =  ( std::abs( E3x3 - aveEne3x3_ ) < E3x3Th_);
00449         bool Mean1   =  ( std::abs( E1 - aveEne1_ ) < E1Th_ );
00450         int ieta = ( cry - 1)/20 + 1 ;//+1 for the bin
00451         int iphi = ( cry - 1)%20 + 1 ;//+1 for the bin
00452         //fill the RedGreen histo
00453         if(ieta >0 && iphi >0 ) {
00454           if(RMS3x3 && Mean3x3 && Mean1) {meEBBCaloRedGreen_->setBinContent(ieta,iphi,1.);}
00455           else {meEBBCaloRedGreen_->setBinContent(ieta,iphi,0.);}
00456         }
00457 
00458         float Entries = -1;
00459         //if ( hBEntriesvsCry_ ) {Entries = hBEntriesvsCry_->GetBinContent(step);}
00460         if ( hBEntriesvsCry_ ) {Entries = hBEntriesvsCry_->GetBinContent(cry);}
00461         bool Nent = ( Entries * prescaling_  > minEvtNum_ );
00462         bool readCryOk = true;
00463         if( hBReadCryErrors_ ) {
00464           int step_bin = hBReadCryErrors_->GetXaxis()->FindFixBin(step);
00465           if ( step_bin > 0 && step_bin < hBReadCryErrors_->GetNbinsX() ) {
00466             if ( hBReadCryErrors_->GetBinContent(step_bin) <= Entries*ReadCryErrThr_ ) {readCryOk = true;}
00467             else {readCryOk = false;}
00468           }
00469         }
00470 
00471         if(Nent && readCryOk ) { meEBBCaloRedGreenSteps_->setBinContent(step,1,1.);}
00472         else{ meEBBCaloRedGreenSteps_->setBinContent(step,1,0.);}
00473 
00474         if (readCryOk &&  meEBBCaloRedGreenReadCry_->getBinContent(1,1) != 0.) { meEBBCaloRedGreenReadCry_->setBinContent(1,1, 1.);}
00475         else if ( !readCryOk ) { meEBBCaloRedGreenReadCry_->setBinContent(1,1, 0.);}
00476       }// end of if (step>0)
00477     }//end of loop over cry
00478   }//end of if(hBcryDone_)
00479 
00480   if(DoneCry == 1) {//this is probably not an auotscan or it is the first crystal
00481     float nEvt = 0;
00482     if(hBE3x3_) {nEvt = hBE3x3_->GetEntries();}
00483     if(nEvt > 1*prescaling_ && hBE3x3_ && hBEne1_ && hBCryOnBeam_ && meEBBCaloRedGreen_) {//check for mean and RMS
00484       bool RMS3x3  =  ( hBE3x3_->GetRMS() < RMSEne3x3_ );
00485       bool Mean3x3 =  ( std::abs( hBE3x3_->GetMean() - aveEne3x3_ ) < E3x3Th_ );
00486       bool Mean1   =  ( std::abs( hBEne1_->GetMean() - aveEne1_ ) < E1Th_ );
00487       //fill the RedGreen histo
00488       int ieta=0,iphi=0;
00489       float found =0; //there should be just one bin filled but...
00490       for (int b_eta =1; b_eta<86; b_eta++) {
00491         for (int b_phi =1; b_phi<21; b_phi++) {
00492           float bc = hBCryOnBeam_->GetBinContent(b_eta,b_phi);//FIX ME check if this is the correct binning
00493           if(bc > found) { found =bc; ieta = b_eta; iphi= b_phi;}
00494         }
00495       }
00496       if(ieta >0 && iphi >0 ) {
00497         if(RMS3x3 && Mean3x3 && Mean1) {meEBBCaloRedGreen_->setBinContent(ieta,iphi,1.);}
00498         else {meEBBCaloRedGreen_->setBinContent(ieta,iphi,0.);}
00499       }
00500     }
00501     if(hBReadCryErrors_) {
00502       float nErr = hBReadCryErrors_->GetBinContent(1);// for a non autoscan just the first bin should be filled
00503       if( nErr > nEvt*ReadCryErrThr_ ) { meEBBCaloRedGreenReadCry_->setBinContent(1,1,0.);}
00504       else { meEBBCaloRedGreenReadCry_->setBinContent(1,1,1.);}
00505     }
00506   }
00507 
00508   //   // was done using me instead of histos
00509   //   if(DoneCry == 0) {//this is probably not an auotscan
00510   //     float nEvt = RecEne3x3->getEntries();
00511   //     if(nEvt > 1000*prescaling_) {//check for mean and RMS
00512   //       bool RMS3x3  =  ( RecEne3x3->getRMS() < RMSEne3x3_ );
00513   //       bool Mean3x3 =  ( (RecEne3x3->getMean() - aveEne3x3_) < E3x3Th_);
00514   //       bool Mean1   =  ( (RecEne1->getMean() < aveEne1_) < E1Th_ );
00515   //       //fill the RedGreen histo
00516   //       int ieta=0,iphi=0;
00517   //       float found =0; //there should be just one bin filled but...
00518   //       for (int b_eta =1; b_eta<86; b_eta++) {
00519   //         for (int b_phi =1; b_phi<21; b_phi++) {
00520   //           float bc = meCryInBeam->getBinContent(b_eta,b_phi);//FIX ME check if this is the correct binning
00521   //           if(bc > found) { found =bc; ieta = b_eta; iphi= b_phi;}
00522   //         }
00523   //       }
00524   //       if(ieta >0 && iphi >0 ) {
00525   //         if(RMS3x3 && Mean3x3 && Mean1) {meEBBCaloRedGreen_->setBinContent(ieta,iphi,1.);}
00526   //         else {meEBBCaloRedGreen_->setBinContent(ieta,iphi,0.);}
00527   //       }
00528   //     }
00529   //     float nErr = ErrRedCry->getBinContent(1);// for a non autoscan just the first bin should be filled
00530   //     if( nErr > nEvt*ReadCryErrThr_ ) { meEBBCaloRedGreenReadCry_->setBinContent(1,1,0.);}
00531   //     else { meEBBCaloRedGreenReadCry_->setBinContent(1,1,1.);}
00532   //   }
00533 
00534 
00535 }
00536