CMS 3D CMS Logo

EBBeamCaloClient.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBBeamCaloClient.cc
00003  *
00004  * $Date: 2008/08/11 07:24:13 $
00005  * $Revision: 1.89 $
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 <math.h>
00016 
00017 #include "TCanvas.h"
00018 #include "TStyle.h"
00019 
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 
00022 #include "OnlineDB/EcalCondDB/interface/MonOccupancyDat.h"
00023 
00024 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00025 
00026 #include "DQM/EcalCommon/interface/UtilsClient.h"
00027 #include "DQM/EcalCommon/interface/LogicID.h"
00028 #include "DQM/EcalCommon/interface/Numbers.h"
00029 
00030 #include <DQM/EcalBarrelMonitorClient/interface/EBBeamCaloClient.h>
00031 
00032 using namespace cms;
00033 using namespace edm;
00034 using namespace std;
00035 
00036 EBBeamCaloClient::EBBeamCaloClient(const ParameterSet& ps) {
00037 
00038   // cloneME switch
00039   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00040 
00041   // verbose switch
00042   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00043 
00044   // debug switch
00045   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00046 
00047   // prefixME path
00048   prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00049 
00050   // enableCleanup_ switch
00051   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00052 
00053   // vector of selected Super Modules (Defaults to all 36).
00054   superModules_.reserve(36);
00055   for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00056   superModules_ = ps.getUntrackedParameter<vector<int> >("superModules", superModules_);
00057 
00058   checkedSteps_.reserve(86);
00059   // there should be not more than a eta row in an autoscan
00060   minEvtNum_ = 1800;//
00061   //FIX ME, this should be configurable and change with the beam energy
00062   aveEne1_    = 1850;  E1Th_   = 900;
00063   aveEne3x3_  = 2600;  E3x3Th_ = 2600;
00064   RMSEne3x3_  = 800;
00065 
00066   ReadCryErrThr_ = 0.01;// 1%
00067   //FIX ME, this should follow the prescaling in the monitoring
00068   prescaling_ = 20;
00069 
00071   for(int u=0;u<cryInArray_;u++) {
00072     hBGains_[u] = 0;
00073     hBpulse_[u] = 0;
00074     //hBGainsMoving_[u] = 0;
00075   }
00076   hBEne1_ = 0;
00077   //hBEne1Moving_ = 0;
00078   hBAllNeededCry_ = 0;
00079   hBNumReadCry_ = 0;
00080   hBE3x3_ = 0;
00081   hBE3x3Moving_ = 0;
00082   hBCryOnBeam_ = 0;
00083   hBMaxEneCry_ = 0;
00084   hBReadCryErrors_ = 0;
00085   hBE1vsCry_ = 0;
00086   hBE3x3vsCry_ = 0;
00087   hBEntriesvsCry_ = 0;
00088   hBcryDone_ = 0;
00089   hBBeamCentered_ = 0;
00090   hbTBmoving_ = 0;
00091   hbE1MaxCry_ = 0;
00092   hbDesync_ = 0;
00093   pBCriInBeamEvents_ = 0;
00094 
00095   meEBBCaloRedGreen_ = 0;
00096   meEBBCaloRedGreenReadCry_ = 0;
00097   meEBBCaloRedGreenSteps_ = 0;
00098 }
00099 
00100 EBBeamCaloClient::~EBBeamCaloClient() {
00101 
00102 }
00103 
00104 void EBBeamCaloClient::beginJob(DQMStore* dqmStore) {
00105 
00106   dqmStore_ = dqmStore;
00107 
00108   if ( debug_ ) cout << "EBBeamCaloClient: beginJob" << endl;
00109 
00110   ievt_ = 0;
00111   jevt_ = 0;
00112 
00113 }
00114 
00115 void EBBeamCaloClient::beginRun(void) {
00116 
00117   if ( debug_ ) cout << "EBBeamCaloClient: beginRun" << endl;
00118 
00119   jevt_ = 0;
00120 
00121   this->setup();
00122 
00123 }
00124 
00125 void EBBeamCaloClient::endJob(void) {
00126 
00127   if ( debug_ ) cout << "EBBeamCaloClient: endJob, ievt = " << ievt_ << endl;
00128 
00129   this->cleanup();
00130 
00131 }
00132 
00133 void EBBeamCaloClient::endRun(void) {
00134 
00135   if ( debug_ ) cout << "EBBeamCaloClient: endRun, jevt = " << jevt_ << endl;
00136 
00137   this->cleanup();
00138 
00139 }
00140 
00141 void EBBeamCaloClient::setup(void) {
00142 
00143   char histo[200];
00144 
00145   dqmStore_->setCurrentFolder( prefixME_ + "/EBBeamCaloClient" );
00146 
00147   if ( meEBBCaloRedGreen_ ) dqmStore_->removeElement( meEBBCaloRedGreen_->getName() );
00148   sprintf(histo, "EBBCT quality");
00149   meEBBCaloRedGreen_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00150 
00151   meEBBCaloRedGreen_->Reset();
00152 
00153   for ( int ie = 1; ie <= 85; ie++ ) {
00154     for ( int ip = 1; ip <= 20; ip++ ) {
00155 
00156       meEBBCaloRedGreen_ ->setBinContent( ie, ip, 2. );
00157 
00158     }
00159   }
00160 
00161   if ( meEBBCaloRedGreenReadCry_ ) dqmStore_->removeElement( meEBBCaloRedGreenReadCry_->getName() );
00162   sprintf(histo, "EBBCT quality read crystal errors");
00163   meEBBCaloRedGreenReadCry_ = dqmStore_->book2D(histo, histo, 1, 0., 1., 1, 0., 1.);
00164   meEBBCaloRedGreenReadCry_->Reset();
00165   meEBBCaloRedGreenReadCry_ ->setBinContent( 1, 1, 2. );
00166 
00167   if( meEBBCaloRedGreenSteps_ ) dqmStore_->removeElement( meEBBCaloRedGreenSteps_->getName() );
00168   sprintf(histo, "EBBCT quality entries or read crystals errors");
00169   meEBBCaloRedGreenSteps_ = dqmStore_->book2D(histo, histo, 86, 1., 87., 1, 0., 1.);
00170   meEBBCaloRedGreenSteps_->setAxisTitle("step in the scan");
00171   meEBBCaloRedGreenSteps_->Reset();
00172   for( int bin=1; bin <87; bin++) { meEBBCaloRedGreenSteps_->setBinContent( bin, 1, 2. );}
00173 
00174 }
00175 
00176 void EBBeamCaloClient::cleanup(void) {
00177   if ( ! enableCleanup_ ) return;
00178   if ( cloneME_ ) {
00179     for(int u=0;u<cryInArray_;u++) {
00180       if(hBGains_[u]) delete hBGains_[u];
00181       if(hBpulse_[u]) delete hBpulse_[u];
00182       //if(hBGainsMoving_[u])delete hBGainsMoving_[u];
00183     }
00184     if(hBEne1_) delete hBEne1_;
00185     //    if(hBEne1Moving_) delete hBEne1Moving_;
00186     if(hBAllNeededCry_) delete hBAllNeededCry_;
00187     if(hBNumReadCry_) delete hBNumReadCry_;
00188     if(hBE3x3_) delete hBE3x3_;
00189     if(hBE3x3Moving_) delete hBE3x3Moving_;
00190     if(hBCryOnBeam_) delete hBCryOnBeam_;
00191     if(hBMaxEneCry_) delete hBMaxEneCry_;
00192     if(hBReadCryErrors_) delete hBReadCryErrors_;
00193     if(hBE1vsCry_) delete hBE1vsCry_;
00194     if(hBE3x3vsCry_) delete hBE3x3vsCry_;
00195     if(hBEntriesvsCry_) delete hBEntriesvsCry_;
00196     if(hBcryDone_) delete hBcryDone_;
00197     if(hBBeamCentered_) delete hBBeamCentered_;
00198     if(hbTBmoving_) delete hbTBmoving_;
00199     if(hbE1MaxCry_) delete hbE1MaxCry_;
00200     if(hbDesync_) delete hbDesync_;
00201     if(pBCriInBeamEvents_) delete pBCriInBeamEvents_;
00202   }
00203 
00204   for(int u=0;u<cryInArray_;u++) {
00205     hBGains_[u] = 0;
00206     hBpulse_[u] = 0;
00207     //hBGainsMoving_[u] = 0;
00208   }
00209   hBEne1_ = 0;
00210   //hBEne1Moving_ = 0;
00211   hBAllNeededCry_ = 0;
00212   hBNumReadCry_ = 0;
00213   hBE3x3_ = 0;
00214   hBE3x3Moving_ = 0;
00215   hBCryOnBeam_ = 0;
00216   hBMaxEneCry_ = 0;
00217   hBReadCryErrors_ = 0;
00218   hBE1vsCry_ = 0;
00219   hBE3x3vsCry_ = 0;
00220   hBEntriesvsCry_ = 0;
00221   hBcryDone_ = 0;
00222   hBBeamCentered_ = 0;
00223   hbTBmoving_ = 0;
00224   hbE1MaxCry_ = 0;
00225   hbDesync_ = 0;
00226   pBCriInBeamEvents_ =0;
00227 
00228   dqmStore_->setCurrentFolder( prefixME_ + "/EBBeamCaloClient" );
00229 
00230   if ( meEBBCaloRedGreen_) dqmStore_->removeElement( meEBBCaloRedGreen_->getName() );
00231   meEBBCaloRedGreen_ = 0;
00232   if ( meEBBCaloRedGreenReadCry_) dqmStore_->removeElement( meEBBCaloRedGreenReadCry_->getName() );
00233   meEBBCaloRedGreenReadCry_ = 0;
00234   if( meEBBCaloRedGreenSteps_ ) dqmStore_->removeElement (  meEBBCaloRedGreenSteps_->getName() );
00235   meEBBCaloRedGreenSteps_ = 0;
00236 }
00237 
00238 bool EBBeamCaloClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status, bool flag) {
00239 
00240   status = true;
00241 
00242   if ( ! flag ) return false;
00243 
00244   EcalLogicID ecid;
00245 
00246   MonOccupancyDat o;
00247   map<EcalLogicID, MonOccupancyDat> dataset;
00248 
00249   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00250 
00251     int ism = superModules_[i];
00252 
00253     if ( verbose_ ) {
00254       cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << endl;
00255       cout << endl;
00256     }
00257 
00258     const float n_min_tot = 1000.;
00259 
00260     float num01, num02;
00261     float mean01;
00262 
00263     for ( int ie = 1; ie <= 85; ie++ ) {
00264       for ( int ip = 1; ip <= 20; ip++ ) {
00265 
00266         num01 = num02 = -1.;
00267         mean01 = -1.;
00268 
00269         bool update_channel = false;
00270 
00271         if ( hBCryOnBeam_ && hBCryOnBeam_->GetEntries() >= n_min_tot ) {
00272           num01 = hBCryOnBeam_->GetBinContent(ie, ip);
00273           update_channel = true;
00274         }
00275 
00276         if ( hBMaxEneCry_ && hBMaxEneCry_->GetEntries() >= n_min_tot ) {
00277           num02 = hBMaxEneCry_->GetBinContent(ie, ip);
00278           update_channel = true;
00279         }
00280 
00281         mean01 = 0.;
00282         //int cry = ip+20*(ie-1);
00283         int ic = (ip-1) + 20*(ie-1) + 1;
00284         int step = 0;
00285         if (hBcryDone_) { step = (int) hBcryDone_->GetBinContent(ic);}
00286         if( step > 0 && step < 86) {
00287         //if(hBE3x3vsCry_) {mean01 = hBE3x3vsCry_->GetBinContent(step);}// E in the 3x3
00288         if( hBE1vsCry_ ) {mean01 = hBE1vsCry_->GetBinContent(ic);} // E1
00289         }
00290 
00291         if ( update_channel ) {
00292 
00293           if ( Numbers::icEB(ism, ie, ip) == 1 ) {
00294 
00295             if ( verbose_ ) {
00296               cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << endl;
00297               cout << "CryOnBeam (" << ie << "," << ip << ") " << num01  << endl;
00298               cout << "MaxEneCry (" << ie << "," << ip << ") " << num02  << endl;
00299               cout << "E1 ("        << ie << "," << ip << ") " << mean01 << endl;
00300               cout << endl;
00301             }
00302 
00303           }
00304 
00305           o.setEventsOverHighThreshold(int(num01));
00306           o.setEventsOverLowThreshold(int(num02));
00307 
00308           o.setAvgEnergy(mean01);
00309 
00310           if ( econn ) {
00311             ecid = LogicID::getEcalLogicID("EB_crystal_number", Numbers::iSM(ism, EcalBarrel), ic);
00312             dataset[ecid] = o;
00313           }
00314 
00315         }
00316 
00317       }
00318     }
00319 
00320   }
00321 
00322   if ( econn ) {
00323     try {
00324       if ( verbose_ ) cout << "Inserting MonOccupancyDat ..." << endl;
00325       if ( dataset.size() != 0 ) econn->insertDataArraySet(&dataset, moniov);
00326       if ( verbose_ ) cout << "done." << endl;
00327     } catch (runtime_error &e) {
00328       cerr << e.what() << endl;
00329     }
00330   }
00331 
00332   return true;
00333 
00334 }
00335 
00336 void EBBeamCaloClient::analyze(void) {
00337 
00338   ievt_++;
00339   jevt_++;
00340   if ( ievt_ % 10 == 0 ) {
00341     if ( debug_ ) cout << "EBBeamCaloClient: ievt/jevt = " << ievt_ << "/" << jevt_ << endl;
00342   }
00343 
00344   char histo[200];
00345 
00346   MonitorElement* me = 0;
00347 
00348   // MonitorElement* meCD;
00349   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystals done").c_str());
00350   //meCD = dqmStore_->get(histo);
00351   me = dqmStore_->get(histo);
00352   hBcryDone_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBcryDone_ );
00353 
00354   //MonitorElement* meCryInBeam;
00355   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystal on beam").c_str());
00356   //meCryInBeam = dqmStore_->get(histo);
00357   me = dqmStore_->get(histo);
00358   hBCryOnBeam_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hBCryOnBeam_);
00359 
00360   //MonitorElement* allNeededCry;
00361   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT all needed crystals readout").c_str());
00362   //allNeededCry= dqmStore_->get(histo);
00363   me = dqmStore_->get(histo);
00364   hBAllNeededCry_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBAllNeededCry_);
00365 
00366   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT readout crystals number").c_str());
00367   //allNeededCry= dqmStore_->get(histo);
00368   me = dqmStore_->get(histo);
00369   hBNumReadCry_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBNumReadCry_);
00370 
00371   //MonitorElement* RecEne3x3;
00372   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT rec Ene sum 3x3").c_str());
00373   //RecEne3x3= dqmStore_->get(histo);
00374   me = dqmStore_->get(histo);
00375   hBE3x3_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBE3x3_);
00376 
00377   //MonitorElement* ErrRedCry;
00378   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT readout crystals errors").c_str());
00379   //ErrRedCry = dqmStore_->get(histo);
00380   me = dqmStore_->get(histo);
00381   hBReadCryErrors_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBReadCryErrors_);
00382 
00383   //  MonitorElement* RecEne1;
00384   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT rec energy cry 5").c_str());
00385   //RecEne1= dqmStore_->get(histo);
00386   me = dqmStore_->get(histo);
00387   hBEne1_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBEne1_);
00388 
00389   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystal with maximum rec energy").c_str());
00390   me = dqmStore_->get(histo);
00391   hBMaxEneCry_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hBMaxEneCry_);
00392 
00393   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT average rec energy in the 3x3 array").c_str());
00394   me = dqmStore_->get(histo);
00395   hBE3x3vsCry_ = UtilsClient::getHisto<TProfile*>( me, cloneME_, hBE3x3vsCry_);
00396 
00397   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT average rec energy in the single crystal").c_str());
00398   me = dqmStore_->get(histo);
00399   hBE1vsCry_ = UtilsClient::getHisto<TProfile*>( me, cloneME_, hBE1vsCry_);
00400 
00401   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT number of entries").c_str());
00402   me = dqmStore_->get(histo);
00403   hBEntriesvsCry_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBEntriesvsCry_);
00404 
00405   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT energy deposition in the 3x3").c_str());
00406   me = dqmStore_->get(histo);
00407   hBBeamCentered_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hBBeamCentered_);
00408 
00409   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT table is moving").c_str());
00410   me = dqmStore_->get(histo);
00411   hbTBmoving_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hbTBmoving_);
00412 
00413   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT crystal in beam vs event").c_str());
00414   me = dqmStore_->get(histo);
00415   pBCriInBeamEvents_ =  UtilsClient::getHisto<TProfile*>( me, cloneME_, pBCriInBeamEvents_);
00416 
00417   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT E1 in the max cry").c_str());
00418   me = dqmStore_->get(histo);
00419   hbE1MaxCry_ =  UtilsClient::getHisto<TH1F*>( me, cloneME_, hbE1MaxCry_);
00420 
00421   sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT Desynchronization vs step").c_str());
00422   me = dqmStore_->get(histo);
00423   hbDesync_ =  UtilsClient::getHisto<TH1F*>( me, cloneME_, hbDesync_);
00424 
00425   for(int ind = 0; ind < cryInArray_; ind ++) {
00426     sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT pulse profile in G12 cry %01d").c_str(), ind+1);
00427     me = dqmStore_->get(histo);
00428     hBpulse_[ind] = UtilsClient::getHisto<TProfile*>( me, cloneME_, hBpulse_[ind]);
00429 
00430     sprintf(histo, (prefixME_ + "/EBBeamCaloTask/EBBCT found gains cry %01d").c_str(), ind+1);
00431     me = dqmStore_->get(histo);
00432     hBGains_[ind] = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBGains_[ind]);
00433   }
00434 
00435   int DoneCry = 0;//if it stays 1 the run is not an autoscan
00436   if (hBcryDone_) {
00437     for(int cry=1 ; cry<1701 ; cry ++) {
00438       int step = (int) hBcryDone_->GetBinContent(cry);
00439       if( step>0 ) {//this crystal has been scanned or is being scanned
00440         DoneCry++;
00441         float E3x3RMS = -1, E3x3 =-1, E1=-1;
00442         if(hBE3x3vsCry_) {
00443           //E3x3RMS = hBE3x3vsCry_->GetBinError(step);
00444           //E3x3 = hBE3x3vsCry_->GetBinContent(step);
00445           E3x3RMS = hBE3x3vsCry_->GetBinError(cry);
00446           E3x3 = hBE3x3vsCry_->GetBinContent(cry);
00447         }
00448         //if( hBE1vsCry_) {E1=hBE1vsCry_->GetBinContent(step);}
00449         if( hBE1vsCry_) {E1=hBE1vsCry_->GetBinContent(cry);}
00450         bool RMS3x3  =  (  E3x3RMS < RMSEne3x3_ && E3x3RMS >= 0 );
00451         bool Mean3x3 =  ( fabs( E3x3 - aveEne3x3_ ) < E3x3Th_);
00452         bool Mean1   =  ( fabs( E1 - aveEne1_ ) < E1Th_ );
00453         int ieta = ( cry - 1)/20 + 1 ;//+1 for the bin
00454         int iphi = ( cry - 1)%20 + 1 ;//+1 for the bin
00455         //fill the RedGreen histo
00456         if(ieta >0 && iphi >0 ) {
00457           if(RMS3x3 && Mean3x3 && Mean1) {meEBBCaloRedGreen_->setBinContent(ieta,iphi,1.);}
00458           else {meEBBCaloRedGreen_->setBinContent(ieta,iphi,0.);}
00459         }
00460 
00461         float Entries = -1;
00462         //if ( hBEntriesvsCry_ ) {Entries = hBEntriesvsCry_->GetBinContent(step);}
00463         if ( hBEntriesvsCry_ ) {Entries = hBEntriesvsCry_->GetBinContent(cry);}
00464         bool Nent = ( Entries * prescaling_  > minEvtNum_ );
00465         bool readCryOk = true;
00466         if( hBReadCryErrors_ ) {
00467           int step_bin = hBReadCryErrors_->GetXaxis()->FindFixBin(step);
00468           if ( step_bin > 0 && step_bin < hBReadCryErrors_->GetNbinsX() ) {
00469             if ( hBReadCryErrors_->GetBinContent(step_bin) <= Entries*ReadCryErrThr_ ) {readCryOk = true;}
00470             else {readCryOk = false;}
00471           }
00472         }
00473 
00474         if(Nent && readCryOk ) { meEBBCaloRedGreenSteps_->setBinContent(step,1,1.);}
00475         else{ meEBBCaloRedGreenSteps_->setBinContent(step,1,0.);}
00476 
00477         if (readCryOk &&  meEBBCaloRedGreenReadCry_->getBinContent(1,1) != 0.) { meEBBCaloRedGreenReadCry_->setBinContent(1,1, 1.);}
00478         else if ( !readCryOk ) { meEBBCaloRedGreenReadCry_->setBinContent(1,1, 0.);}
00479       }// end of if (step>0)
00480     }//end of loop over cry
00481   }//end of if(hBcryDone_)
00482 
00483   if(DoneCry == 1) {//this is probably not an auotscan or it is the first crystal
00484     float nEvt = 0;
00485     if(hBE3x3_) {nEvt = hBE3x3_->GetEntries();}
00486     if(nEvt > 1*prescaling_ && hBE3x3_ && hBEne1_ && hBCryOnBeam_ && meEBBCaloRedGreen_) {//check for mean and RMS
00487       bool RMS3x3  =  ( hBE3x3_->GetRMS() < RMSEne3x3_ );
00488       bool Mean3x3 =  ( fabs( hBE3x3_->GetMean() - aveEne3x3_ ) < E3x3Th_ );
00489       bool Mean1   =  ( fabs( hBEne1_->GetMean() - aveEne1_ ) < E1Th_ );
00490       //fill the RedGreen histo
00491       int ieta=0,iphi=0;
00492       float found =0; //there should be just one bin filled but...
00493       for (int b_eta =1; b_eta<86; b_eta++) {
00494         for (int b_phi =1; b_phi<21; b_phi++) {
00495           float bc = hBCryOnBeam_->GetBinContent(b_eta,b_phi);//FIX ME check if this is the correct binning
00496           if(bc > found) { found =bc; ieta = b_eta; iphi= b_phi;}
00497         }
00498       }
00499       if(ieta >0 && iphi >0 ) {
00500         if(RMS3x3 && Mean3x3 && Mean1) {meEBBCaloRedGreen_->setBinContent(ieta,iphi,1.);}
00501         else {meEBBCaloRedGreen_->setBinContent(ieta,iphi,0.);}
00502       }
00503     }
00504     if(hBReadCryErrors_) {
00505       float nErr = hBReadCryErrors_->GetBinContent(1);// for a non autoscan just the first bin should be filled
00506       if( nErr > nEvt*ReadCryErrThr_ ) { meEBBCaloRedGreenReadCry_->setBinContent(1,1,0.);}
00507       else { meEBBCaloRedGreenReadCry_->setBinContent(1,1,1.);}
00508     }
00509   }
00510 
00511   //   // was done using me instead of histos
00512   //   if(DoneCry == 0) {//this is probably not an auotscan
00513   //     float nEvt = RecEne3x3->getEntries();
00514   //     if(nEvt > 1000*prescaling_) {//check for mean and RMS
00515   //       bool RMS3x3  =  ( RecEne3x3->getRMS() < RMSEne3x3_ );
00516   //       bool Mean3x3 =  ( (RecEne3x3->getMean() - aveEne3x3_) < E3x3Th_);
00517   //       bool Mean1   =  ( (RecEne1->getMean() < aveEne1_) < E1Th_ );
00518   //       //fill the RedGreen histo
00519   //       int ieta=0,iphi=0;
00520   //       float found =0; //there should be just one bin filled but...
00521   //       for (int b_eta =1; b_eta<86; b_eta++) {
00522   //         for (int b_phi =1; b_phi<21; b_phi++) {
00523   //           float bc = meCryInBeam->getBinContent(b_eta,b_phi);//FIX ME check if this is the correct binning
00524   //           if(bc > found) { found =bc; ieta = b_eta; iphi= b_phi;}
00525   //         }
00526   //       }
00527   //       if(ieta >0 && iphi >0 ) {
00528   //         if(RMS3x3 && Mean3x3 && Mean1) {meEBBCaloRedGreen_->setBinContent(ieta,iphi,1.);}
00529   //         else {meEBBCaloRedGreen_->setBinContent(ieta,iphi,0.);}
00530   //       }
00531   //     }
00532   //     float nErr = ErrRedCry->getBinContent(1);// for a non autoscan just the first bin should be filled
00533   //     if( nErr > nEvt*ReadCryErrThr_ ) { meEBBCaloRedGreenReadCry_->setBinContent(1,1,0.);}
00534   //     else { meEBBCaloRedGreenReadCry_->setBinContent(1,1,1.);}
00535   //   }
00536 
00537 
00538 }
00539 
00540 void EBBeamCaloClient::softReset(bool flag) {
00541 
00542 }
00543 
00544 void EBBeamCaloClient::htmlOutput(int run, string& htmlDir, string& htmlName) {
00545 
00546   if ( verbose_ ) cout << "Preparing EBBeamCaloClient html output ..." << endl;
00547 
00548   ofstream htmlFile;
00549 
00550   htmlFile.open((htmlDir + htmlName).c_str());
00551 
00552   // html page header
00553   htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">  " << endl;
00554   htmlFile << "<html>  " << endl;
00555   htmlFile << "<head>  " << endl;
00556   htmlFile << "  <meta content=\"text/html; charset=ISO-8859-1\"  " << endl;
00557   htmlFile << " https-equiv=\"content-type\">  " << endl;
00558   htmlFile << "  <title>Monitor:BeamTask output</title> " << endl;
00559   htmlFile << "</head>  " << endl;
00560   htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << endl;
00561   htmlFile << "<body>  " << endl;
00562   htmlFile << "<br>  " << endl;
00563   htmlFile << "<h2>Run:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << endl;
00564   htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span " << endl;
00565   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << run << "</span></h2>" << endl;
00566   htmlFile << "<h2>Monitoring task:&nbsp;&nbsp;&nbsp;&nbsp; <span " << endl;
00567   htmlFile << " style=\"color: rgb(0, 0, 153);\">BeamCalo</span></h2> " << endl;
00568   htmlFile << "<hr>" << endl;
00569   //  htmlFile << "<table border=1><tr><td bgcolor=red>channel has problems in this task</td>" << endl;
00570   //  htmlFile << "<td bgcolor=lime>channel has NO problems</td>" << endl;
00571   //  htmlFile << "<td bgcolor=yellow>channel is missing</td></table>" << endl;
00572   //  htmlFile << "<hr>" << endl;
00573 
00574 
00575   htmlFile <<  "<a href=\"#qua_plots\"> Quality plots </a>" << endl;
00576   htmlFile << "<p>" << endl;
00577   htmlFile <<  "<a href=\"#gen_plots\"> General plots </a>" << endl;
00578   htmlFile << "<p>" << endl;
00579   htmlFile <<  "<a href=\"#fix_plots\"> Plots for the fixed crystal runs </a>" << endl;
00580   htmlFile << "<p>" << endl;
00581   htmlFile <<  "<a href=\"#aut_plots\"> Plots for the autoscan runs </a>" << endl;
00582   htmlFile << "<p>" << endl;
00583 
00584   htmlFile << "<hr>" << endl;
00585   htmlFile << "<p>" << endl;
00586 
00587 
00588 
00589   // Produce the plots to be shown as .png files from existing histograms
00590 
00591 
00592   const int csize = 250;
00593   //  const double histMax = 1.e15;
00594 
00595   int pCol3[7] = { 301, 302, 303, 304, 305, 306, 307 };
00596 
00597   TH2C dummy( "dummy", "dummy for sm", 85, 0., 85., 20, 0., 20. );
00598   for ( int i = 0; i < 68; i++ ) {
00599     int a = 2 + ( i/4 ) * 5;
00600     int b = 2 + ( i%4 ) * 5;
00601     dummy.Fill( a, b, i+1 );
00602   }
00603   dummy.SetMarkerSize(2);
00604   dummy.SetMinimum(0.1);
00605 
00606   TH2I dummyStep( "dummyStep", "dummy2 for sm", 86, 1., 87., 1, 0., 1. );
00607   if(hBcryDone_) {
00608     for(int cry=1 ; cry<1701 ; cry ++) {
00609       int step = (int) hBcryDone_->GetBinContent(cry);
00610       if (step >0 ) {dummyStep.SetBinContent( step+1, 1, cry );}
00611     }
00612   }
00613   //dummyStep.SetBinContent( 6, 1, 1699 );
00614   //dummyStep.SetBinContent( 85, 1, 1698 );
00615   dummyStep.SetMarkerSize(2);
00616   dummyStep.SetMinimum(0.1);
00617 
00618   //useful for both autoscan and non autoscan
00619   string RedGreenSMImg,RedGreenImg,RedGreenAutoImg, numCryReadImg, cryReadErrImg, E1MaxCryImg, DesyncImg;
00620   string cryOnBeamImg, cryMaxEneImg, ratioImg;
00621   // useful for non autoscan
00622   string ene1Img, ene3x3Img, EBBeamCentered;
00623   string pulseshapeImg, gainImg;
00624   //useful for autoscan
00625   string cryDoneImg, EntriesVScryImg, E1vsCryImg, E3x3vsCryImg;
00626   string cryVSeventImg, TBmoving;
00627 
00628   string meName,imgName1,imgName2,imgName3;
00629   TH2F* obj2f = 0;
00630   TH1F* obj1f = 0;
00631   TProfile* objp1 = 0;
00632 
00634   htmlFile << "<br>" << endl;
00635   htmlFile <<  "<a name=\"qua_plots\"> <B> Quality plots </B> </a> " << endl;
00636   htmlFile << "</br>" << endl;
00638 
00640   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
00641   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
00642   htmlFile << "<tr align=\"center\">" << endl;
00643   // quality red-green histo
00644   obj2f = UtilsClient::getHisto<TH2F*>( meEBBCaloRedGreen_ );
00645   if ( obj2f ) {
00646 
00647     TCanvas* can = new TCanvas("can", "Temp", 2*csize, csize);
00648     meName = obj2f->GetName();
00649 
00650     replace(meName.begin(), meName.end(), ' ', '_');
00651     RedGreenSMImg = meName + ".png";
00652     imgName1 = htmlDir + RedGreenSMImg;
00653 
00654     can->cd();
00655     gStyle->SetOptStat(" ");
00656     gStyle->SetPalette(7, pCol3);
00657     obj2f->GetXaxis()->SetNdivisions(17);
00658     obj2f->GetYaxis()->SetNdivisions(4);
00659     can->SetGridx();
00660     can->SetGridy();
00661     obj2f->SetMinimum(-0.00000001);
00662     obj2f->SetMaximum(7.0);
00663     obj2f->Draw("col");
00664     dummy.Draw("text,same");
00665     can->Update();
00666     can->SaveAs(imgName1.c_str());
00667     delete can;
00668   }
00669   if ( imgName1.size() != 0 )
00670     htmlFile << "<td><img src=\"" << RedGreenSMImg  << "\"></td>" << endl;
00671   else
00672     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00673 
00674   //red-green pad
00675   obj2f = UtilsClient::getHisto<TH2F*>( meEBBCaloRedGreenReadCry_ );
00676   if ( obj2f ) {
00677 
00678     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00679     meName = obj2f->GetName();
00680 
00681     replace(meName.begin(), meName.end(), ' ', '_');
00682     RedGreenImg = meName + ".png";
00683     imgName1 = htmlDir + RedGreenImg;
00684 
00685     can->cd();
00686     gStyle->SetOptStat(" ");
00687     gStyle->SetPalette(7, pCol3);
00688     obj2f->GetXaxis()->SetNdivisions(0);
00689     obj2f->GetYaxis()->SetNdivisions(0);
00690     obj2f->SetMinimum(-0.00000001);
00691     obj2f->SetMaximum(7.0);
00692     obj2f->Draw("col");
00693     can->Update();
00694     can->SaveAs(imgName1.c_str());
00695     delete can;
00696   }
00697   if ( imgName1.size() != 0 )
00698     htmlFile << "<td><img src=\"" << RedGreenImg << "\"></td>" << endl;
00699   else
00700     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00701 
00702   htmlFile << "</tr>" << endl;
00703   htmlFile << "</table>" << endl;
00704   htmlFile << "<br>" << endl;
00707   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
00708   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
00709   htmlFile << "<tr align=\"center\">" << endl;
00710   // quality entries and read cry red-green histo for autoscan
00711   obj2f = UtilsClient::getHisto<TH2F*>( meEBBCaloRedGreenSteps_ );
00712   if ( obj2f ) {
00713 
00714     TCanvas* can = new TCanvas("can", "Temp", 5*csize, csize);
00715     meName = obj2f->GetName();
00716 
00717     replace(meName.begin(), meName.end(), ' ', '_');
00718     RedGreenAutoImg = meName + ".png";
00719     imgName1 = htmlDir + RedGreenAutoImg;
00720 
00721     can->cd();
00722     gStyle->SetOptStat(" ");
00723     gStyle->SetPalette(7, pCol3);
00724     obj2f->GetXaxis()->SetNdivisions(86);
00725     obj2f->GetYaxis()->SetNdivisions(0);
00726     can->SetGridx();
00727     //can->SetGridy();
00728     obj2f->SetMinimum(-0.00000001);
00729     obj2f->SetMaximum(7.0);
00730     obj2f->Draw("col");
00731     dummyStep.Draw("text90,same");
00732     can->Update();
00733     can->SaveAs(imgName1.c_str());
00734     delete can;
00735   }
00736   if ( imgName1.size() != 0 )
00737     htmlFile << "<td><img src=\"" << RedGreenAutoImg  << "\"></td>" << endl;
00738   else
00739     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00740 
00741   htmlFile << "</tr>" << endl;
00742   htmlFile << "</table>" << endl;
00743   htmlFile << "<br>" << endl;
00744 
00746 
00748   htmlFile << "<br>" << endl;
00749   htmlFile <<  "<a name=\"gen_plots\"> <B> General plots </B> </a>" << endl;
00750   htmlFile << "</br>" << endl;
00752 
00754   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
00755   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
00756   htmlFile << "<tr align=\"center\">" << endl;
00757   // number of readout crystals : numCryReadImg
00758   obj1f = hBNumReadCry_;
00759   if ( obj1f ) {
00760     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00761     meName = obj1f->GetName();
00762 
00763     replace(meName.begin(), meName.end(), ' ', '_');
00764     numCryReadImg = meName + ".png";
00765     imgName1 = htmlDir + numCryReadImg;
00766 
00767     can->cd();
00768     obj1f->SetStats(kTRUE);
00769     gStyle->SetOptStat(1110);
00770     AdjustRange(obj1f);
00771     obj1f->Draw();
00772     can->Update();
00773     can->SaveAs(imgName1.c_str());
00774     delete can;
00775   }
00776   if ( imgName1.size() != 0 )
00777     htmlFile << "<td><img src=\"" << numCryReadImg << "\"></td>" << endl;
00778   else
00779     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00780 
00781   // error: reading less than the 7x7: cryReadErrImg;
00782   obj1f = hBReadCryErrors_;
00783   if ( obj1f ) {
00784     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00785     meName = obj1f->GetName();
00786 
00787     replace(meName.begin(), meName.end(), ' ', '_');
00788     cryReadErrImg = meName + ".png";
00789     imgName1 = htmlDir + cryReadErrImg;
00790 
00791     can->cd();
00792     obj1f->SetStats(kTRUE);
00793     gStyle->SetOptStat("e");
00794     AdjustRange(obj1f);
00795     obj1f->Draw();
00796     can->Update();
00797     can->SaveAs(imgName1.c_str());
00798     delete can;
00799   }
00800   if ( imgName1.size() != 0 )
00801     htmlFile << "<td><img src=\"" << cryReadErrImg << "\"></td>" << endl;
00802   else
00803     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00804 
00805 
00806  // E1 of the max cry: cryReadErrImg;
00807   obj1f = hbE1MaxCry_;
00808   if ( obj1f ) {
00809     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00810     meName = obj1f->GetName();
00811 
00812     replace(meName.begin(), meName.end(), ' ', '_');
00813     E1MaxCryImg = meName + ".png";
00814     imgName1 = htmlDir +  E1MaxCryImg;
00815 
00816     can->cd();
00817     obj1f->SetStats(kTRUE);
00818     gStyle->SetOptStat("e");
00819     AdjustRange(obj1f);
00820     obj1f->Draw();
00821     can->Update();
00822     can->SaveAs(imgName1.c_str());
00823     delete can;
00824   }
00825   if ( imgName1.size() != 0 )
00826     htmlFile << "<td><img src=\"" <<  E1MaxCryImg << "\"></td>" << endl;
00827   else
00828     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00829 
00830  // Desynchronization
00831   obj1f = hbDesync_;
00832   if ( obj1f ) {
00833     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00834     meName = obj1f->GetName();
00835 
00836     replace(meName.begin(), meName.end(), ' ', '_');
00837     DesyncImg = meName + ".png";
00838     imgName1 = htmlDir +  DesyncImg;
00839 
00840     can->cd();
00841     obj1f->SetStats(kTRUE);
00842     gStyle->SetOptStat("e");
00843     AdjustRange(obj1f);
00844     obj1f->Draw();
00845     can->Update();
00846     can->SaveAs(imgName1.c_str());
00847     delete can;
00848   }
00849   if ( imgName1.size() != 0 )
00850     htmlFile << "<td><img src=\"" << DesyncImg  << "\"></td>" << endl;
00851   else
00852     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00853 
00854   htmlFile << "</tr>" << endl;
00855   htmlFile << "</table>" << endl;
00856   htmlFile << "<br>" << endl;
00859   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
00860   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
00861   htmlFile << "<tr align=\"center\">" << endl;
00862   //  crystal on beam: cryOnBeamImg
00863   obj2f =  hBCryOnBeam_;
00864   if ( obj2f ) {
00865 
00866     TCanvas* can = new TCanvas("can", "Temp", 2*csize, csize);
00867     meName = obj2f->GetName();
00868 
00869     replace(meName.begin(), meName.end(), ' ', '_');
00870     cryOnBeamImg = meName + ".png";
00871     imgName1 = htmlDir + cryOnBeamImg;
00872 
00873     can->cd();
00874     gStyle->SetOptStat(" ");
00875     gStyle->SetPalette(1);
00876     obj2f->GetXaxis()->SetNdivisions(17);
00877     obj2f->GetYaxis()->SetNdivisions(4);
00878     can->SetGridx();
00879     can->SetGridy();
00880     obj2f->SetMinimum(0.00000001);
00881     //obj2f->SetMaximum(2.0);
00882     obj2f->Draw("colz");
00883     dummy.Draw("text,same");
00884     can->Update();
00885     can->SaveAs(imgName1.c_str());
00886     delete can;
00887   }
00888   if ( imgName1.size() != 0 )
00889     htmlFile << "<td><img src=\"" << cryOnBeamImg << "\"></td>" << endl;
00890   else
00891     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00892 
00893   //cryMaxEneImg
00894 
00895   obj2f = hBMaxEneCry_;
00896   if ( obj2f ) {
00897 
00898     TCanvas* can = new TCanvas("can", "Temp", 2*csize, csize);
00899     meName = obj2f->GetName();
00900 
00901     replace(meName.begin(), meName.end(), ' ', '_');
00902     cryMaxEneImg = meName + ".png";
00903     imgName1 = htmlDir + cryMaxEneImg;
00904 
00905     can->cd();
00906     gStyle->SetOptStat(" ");
00907     gStyle->SetPalette(1);
00908     obj2f->GetXaxis()->SetNdivisions(17);
00909     obj2f->GetYaxis()->SetNdivisions(4);
00910     can->SetGridx();
00911     can->SetGridy();
00912     obj2f->SetMinimum(0.00000001);
00913     obj2f->Draw("colz");
00914     dummy.Draw("text,same");
00915     can->Update();
00916     can->SaveAs(imgName1.c_str());
00917     delete can;
00918   }
00919   if ( imgName1.size() != 0 )
00920     htmlFile << "<td><img src=\"" << cryMaxEneImg << "\"></td>" << endl;
00921   else
00922     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00923 
00924   // ratioImg still to be done
00925   htmlFile << "</tr>" << endl;
00926   htmlFile << "</table>" << endl;
00927   htmlFile << "<br>" << endl;
00929 
00931   htmlFile << "<br>" << endl;
00932   htmlFile <<  "<a name=\"fix_plots\"> <B> Plots for the fixed crystal runs </B> </a>" << endl;
00933   htmlFile << "</br>" << endl;
00935 
00937   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
00938   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
00939   htmlFile << "<tr align=\"center\">" << endl;
00940   //ene1Img, ene3x3Img, EBBeamCentered;
00941   obj1f = hBEne1_;
00942   if ( obj1f ) {
00943     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00944     meName = obj1f->GetName();
00945 
00946     replace(meName.begin(), meName.end(), ' ', '_');
00947     ene1Img = meName + ".png";
00948     imgName1 = htmlDir + ene1Img;
00949 
00950     can->cd();
00951     obj1f->SetStats(kTRUE);
00952     gStyle->SetOptStat(1110);
00953     AdjustRange(obj1f);
00954     obj1f->Draw();
00955     can->Update();
00956     can->SaveAs(imgName1.c_str());
00957     delete can;
00958   }
00959   if ( imgName1.size() != 0 )
00960     htmlFile << "<td><img src=\"" << ene1Img << "\"></td>" << endl;
00961   else
00962     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00963 
00964   //ene3x3Img
00965   obj1f = hBE3x3_;
00966   if ( obj1f ) {
00967     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00968     meName = obj1f->GetName();
00969 
00970     replace(meName.begin(), meName.end(), ' ', '_');
00971     ene3x3Img = meName + ".png";
00972     imgName1 = htmlDir + ene3x3Img;
00973 
00974     can->cd();
00975     obj1f->SetStats(kTRUE);
00976     gStyle->SetOptStat(1110);
00977     AdjustRange(obj1f);
00978     obj1f->Draw();
00979     can->Update();
00980     can->SaveAs(imgName1.c_str());
00981     delete can;
00982   }
00983   if ( imgName1.size() != 0 )
00984     htmlFile << "<td><img src=\"" << ene3x3Img << "\"></td>" << endl;
00985   else
00986     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
00987 
00988   //EBBeamCentered
00989   obj2f = hBBeamCentered_;
00990   if ( obj2f ) {
00991 
00992     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
00993     meName = obj2f->GetName();
00994 
00995     replace(meName.begin(), meName.end(), ' ', '_');
00996     EBBeamCentered = meName + ".png";
00997     imgName1 = htmlDir + EBBeamCentered;
00998 
00999     can->cd();
01000     gStyle->SetOptStat(" ");
01001     obj2f->SetLineColor(kRed);
01002     obj2f->SetFillColor(kRed);
01003 
01004     obj2f->Draw("box");
01005     can->Update();
01006     can->SaveAs(imgName1.c_str());
01007     delete can;
01008   }
01009   if ( imgName1.size() != 0 )
01010     htmlFile << "<td><img src=\"" << EBBeamCentered << "\"></td>" << endl;
01011   else
01012     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01013 
01014   htmlFile << "</tr>" << endl;
01015   htmlFile << "</table>" << endl;
01016   htmlFile << "<br>" << endl;
01018   string pulseImg[cryInArray_], gainsImg[cryInArray_], pulseImgF[cryInArray_], gainsImgF[cryInArray_];
01019   for(int ind = 0; ind < cryInArray_; ind ++) {
01020     objp1 = hBpulse_[ind];
01021     if ( objp1 ) {
01022       TCanvas* can = new TCanvas("can", "Temp", csize, csize);
01023       meName = objp1->GetName();
01024 
01025       replace(meName.begin(), meName.end(), ' ', '_');
01026       pulseImg[ind] = meName + ".png";
01027       pulseImgF[ind] = htmlDir + pulseImg[ind] ;
01028 
01029       can->cd();
01030       objp1->SetStats(kTRUE);
01031       gStyle->SetOptStat("e");
01032       objp1->Draw();
01033       can->Update();
01034       can->SaveAs( pulseImgF[ind].c_str());
01035       delete can;
01036     }
01037 
01038     obj1f = hBGains_[ind];
01039     if ( obj1f ) {
01040       TCanvas* can = new TCanvas("can", "Temp", csize, csize);
01041       meName = obj1f->GetName();
01042 
01043       replace(meName.begin(), meName.end(), ' ', '_');
01044       gainsImg[ind] = meName + ".png";
01045       gainsImgF[ind] = htmlDir + gainsImg[ind];
01046 
01047       can->cd();
01048       obj1f->SetStats(kTRUE);
01049       gStyle->SetOptStat(1110);
01050       if(obj1f->GetEntries() != 0 ) {gStyle->SetOptLogy(1);}
01051       obj1f->Draw();
01052       can->Update();
01053       can->SaveAs(gainsImgF[ind].c_str());
01054       gStyle->SetOptLogy(0);
01055       delete can;
01056     }
01057 
01058   }
01059 
01060   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01061   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01062   htmlFile << "<tr align=\"center\">" << endl;
01063   htmlFile << "<td>" << endl;
01064   int row = (int) sqrt(float(cryInArray_));
01066   htmlFile << "<table border=\"4\" cellspacing=\"0\" " << endl;
01067   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01068   htmlFile << "<tr align=\"center\">" << endl;
01069 
01070   for(int ind=0; ind < cryInArray_; ind++) {
01071     if ( pulseImgF[ind].size() != 0 )
01072       htmlFile << "<td><img src=\"" << pulseImg[ind] << "\"></td>" << endl;
01073     else
01074       htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01075     if ( (ind+1) % row == 0) {htmlFile << "</tr>" << endl;}
01076   }
01077   htmlFile << "</table>" << endl;
01078   htmlFile << "<br>" << endl;
01080   htmlFile << "</td>" << endl;
01081   htmlFile << "<td>" << endl;
01083   htmlFile << "<table border=\"4\" cellspacing=\"0\" " << endl;
01084   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01085   htmlFile << "<tr align=\"center\">" << endl;
01086 
01087   for(int ind=0; ind < cryInArray_; ind++) {
01088     if ( gainsImgF[ind].size() != 0 )
01089       htmlFile << "<td><img src=\"" << gainsImg[ind] << "\"></td>" << endl;
01090     else
01091       htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01092     if ( (ind+1) % row == 0) {htmlFile << "</tr>" << endl;}
01093   }
01094   htmlFile << "</table>" << endl;
01095   htmlFile << "<br>" << endl;
01097   htmlFile << "</td>" << endl;
01098   htmlFile << "</tr>" << endl;
01099   htmlFile << "</table>" << endl;
01100   htmlFile << "<br>" << endl;
01102 
01104   htmlFile << "<br>" << endl;
01105   htmlFile <<  "<a name=\"aut_plots\"> <B> Plots for the autoscan runs </B> </a>" << endl;
01106   htmlFile << "</br>" << endl;
01108 
01110   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01111   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01112   htmlFile << "<tr align=\"center\">" << endl;
01113   // cryDoneImg,EntriesVScryImg E1vsCryImg, E3x3vsCryImg
01114   //cryDoneImg
01115   obj1f = hBcryDone_;
01116   if ( obj1f ) {
01117     TCanvas* can = new TCanvas("can", "Temp", int(1.618*csize), csize);
01118     meName = obj1f->GetName();
01119 
01120     replace(meName.begin(), meName.end(), ' ', '_');
01121     cryDoneImg = meName + ".png";
01122     imgName1 = htmlDir + cryDoneImg;
01123 
01124     can->cd();
01125     obj1f->SetStats(kTRUE);
01126     gStyle->SetOptStat("e");
01127     AdjustRange(obj1f);
01128     obj1f->Draw();
01129     can->Update();
01130     can->SaveAs(imgName1.c_str());
01131     delete can;
01132   }
01133   if ( imgName1.size() != 0 )
01134     htmlFile << "<td><img src=\"" << cryDoneImg << "\"></td>" << endl;
01135   else
01136     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01137 
01138   //EntriesVScryImg
01139   obj1f = hBEntriesvsCry_;
01140   if ( obj1f ) {
01141     TCanvas* can = new TCanvas("can", "Temp", int(1.618*csize), csize);
01142     meName = obj1f->GetName();
01143 
01144     replace(meName.begin(), meName.end(), ' ', '_');
01145     EntriesVScryImg = meName + ".png";
01146     imgName1 = htmlDir + EntriesVScryImg;
01147 
01148     can->cd();
01149     obj1f->SetStats(kTRUE);
01150     gStyle->SetOptStat("e");
01151 
01152     if(obj1f->GetEntries() != 0 ) {gStyle->SetOptLogy(1);}
01153     AdjustRange(obj1f);
01154     obj1f->Draw();
01155     can->Update();
01156     can->SaveAs(imgName1.c_str());
01157     delete can;
01158     gStyle->SetOptLogy(0);
01159   }
01160   if ( imgName1.size() != 0 )
01161     htmlFile << "<td><img src=\"" << EntriesVScryImg << "\"></td>" << endl;
01162   else
01163     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01164 
01165 
01166   htmlFile << "</tr>" << endl;
01168   htmlFile << "<tr align=\"center\">" << endl;
01169   //E1vsCryImg
01170   objp1 = hBE1vsCry_;
01171   if ( objp1 ) {
01172     TCanvas* can = new TCanvas("can", "Temp", int(1.618*csize), csize);
01173     meName = objp1->GetName();
01174 
01175     replace(meName.begin(), meName.end(), ' ', '_');
01176     E1vsCryImg = meName + ".png";
01177     imgName1 = htmlDir +  E1vsCryImg;
01178 
01179     can->cd();
01180     objp1->SetStats(kTRUE);
01181     gStyle->SetOptStat("e");
01182     AdjustRange(objp1);
01183     objp1->Draw();
01184     can->Update();
01185     can->SaveAs(imgName1.c_str());
01186     delete can;
01187   }
01188   if ( imgName1.size() != 0 )
01189     htmlFile << "<td><img src=\"" <<  E1vsCryImg << "\"></td>" << endl;
01190   else
01191     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01192 
01193   //E3x3vsCryImg
01194   objp1 = hBE3x3vsCry_;
01195   if ( objp1 ) {
01196     TCanvas* can = new TCanvas("can", "Temp", int(1.618*csize), csize);
01197     meName = objp1->GetName();
01198 
01199     replace(meName.begin(), meName.end(), ' ', '_');
01200     E3x3vsCryImg = meName + ".png";
01201     imgName1 = htmlDir +  E3x3vsCryImg;
01202 
01203     can->cd();
01204     objp1->SetStats(kTRUE);
01205     gStyle->SetOptStat("e");
01206     AdjustRange(objp1);
01207     objp1->Draw();
01208     can->Update();
01209     can->SaveAs(imgName1.c_str());
01210     delete can;
01211   }
01212   if ( imgName1.size() != 0 )
01213     htmlFile << "<td><img src=\"" <<  E3x3vsCryImg << "\"></td>" << endl;
01214   else
01215     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01216 
01217 
01218   htmlFile << "</tr>" << endl;
01219   htmlFile << "</table>" << endl;
01220   htmlFile << "<br>" << endl;
01223   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01224   htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01225   htmlFile << "<tr align=\"center\">" << endl;
01226   // cryVSeventImg, TBmoving;
01227   objp1 = pBCriInBeamEvents_;
01228   if ( objp1 ) {
01229     TCanvas* can = new TCanvas("can", "Temp", 3*csize, csize);
01230     meName = objp1->GetName();
01231 
01232     replace(meName.begin(), meName.end(), ' ', '_');
01233     cryVSeventImg = meName + ".png";
01234     imgName1 = htmlDir +  cryVSeventImg;
01235 
01236     can->cd();
01237     //objp1->SetStats(kTRUE);
01238     //gStyle->SetOptStat("e");
01239 
01240     float dd=0;
01241     int mbin =0;
01242     for( int bin=1; bin < objp1->GetNbinsX()+1; bin++ ) {
01243       float temp = objp1->GetBinContent(bin);
01244       if(temp>0) { dd= temp+0.01; mbin=bin; break;}
01245     }
01246     if(mbin >0) { objp1->Fill(20*mbin-1,dd);}
01247 
01248     AdjustRange(objp1);
01249     float Ymin = 1701, Ymax =0;
01250     for( int bin=1; bin < objp1->GetNbinsX()+1; bin++ ) {
01251       float temp = objp1->GetBinContent(bin);
01252       if(temp >0) {
01253         if(temp < Ymin) {Ymin=temp;}
01254         if(temp > Ymax) {Ymax=temp;}
01255       }
01256     }
01257     if( Ymin < Ymax+1 ) {
01258        for( int bin=1; bin < objp1->GetNbinsX()+1; bin++ ) {
01259          if( objp1->GetBinError(bin) >0 ) {
01260            objp1->SetBinContent(bin, (Ymin+Ymax)/2.*objp1->GetBinEntries(bin) );
01261          }
01262        }
01263        objp1->GetYaxis()->SetRangeUser(Ymin-1. , Ymax+1.);
01264     }
01265 
01266     objp1->Draw("e");
01267     can->Update();
01268     can->SaveAs(imgName1.c_str());
01269     delete can;
01270   }
01271   if ( imgName1.size() != 0 )
01272     htmlFile << "<td><img src=\"" <<  cryVSeventImg << "\"></td>" << endl;
01273   else
01274     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01275 
01276   // TBmoving;
01277   obj1f = hbTBmoving_;
01278   if ( obj1f ) {
01279     TCanvas* can = new TCanvas("can", "Temp", csize, csize);
01280     meName = obj1f->GetName();
01281 
01282     replace(meName.begin(), meName.end(), ' ', '_');
01283     TBmoving = meName + ".png";
01284     imgName1 = htmlDir +  TBmoving;
01285 
01286     can->cd();
01287     obj1f->SetStats(kTRUE);
01288     gStyle->SetOptStat("e");
01289     obj1f->Draw();
01290     can->Update();
01291     can->SaveAs(imgName1.c_str());
01292     delete can;
01293   }
01294   if ( imgName1.size() != 0 )
01295     htmlFile << "<td><img src=\"" <<  TBmoving << "\"></td>" << endl;
01296   else
01297     htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01298 
01299 
01300 
01301   // html page footer
01302   htmlFile << "</body> " << endl;
01303   htmlFile << "</html> " << endl;
01304 
01305   htmlFile.close();
01306 
01307 }
01308 
01309 template<class T> void EBBeamCaloClient::AdjustRange( T obj) {
01310   if (obj->GetEntries() == 0) {return;}
01311   int first_bin = -1, last_bin=-1;
01312   for( int bin=1; bin < obj->GetNbinsX()+1; bin++ ) {
01313     if( obj->GetBinContent(bin) > 0) {
01314       if(first_bin == -1) {first_bin = bin;}
01315       last_bin = bin;
01316     }
01317   }
01318 
01319   if(first_bin < 1 || last_bin < 1) {return;}
01320   if(first_bin > 3) {first_bin -= 3;}
01321   if(last_bin < obj->GetNbinsX() ) {last_bin += 3;}
01322 
01323   obj->GetXaxis()->SetRange(first_bin, last_bin);
01324 }
01325 

Generated on Tue Jun 9 17:32:42 2009 for CMSSW by  doxygen 1.5.4