CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Validation/GlobalDigis/src/GlobalDigisAnalyzer.cc

Go to the documentation of this file.
00001 
00010 #include "Validation/GlobalDigis/interface/GlobalDigisAnalyzer.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 
00013 GlobalDigisAnalyzer::GlobalDigisAnalyzer(const edm::ParameterSet& iPSet) :
00014   fName(""), verbosity(0), frequency(0), label(""), getAllProvenances(false),
00015   printProvenanceInfo(false), hitsProducer(""), theCSCStripPedestalSum(0),
00016   theCSCStripPedestalCount(0), count(0)
00017 {
00018   std::string MsgLoggerCat = "GlobalDigisAnalyzer_GlobalDigisAnalyzer";
00019 
00020   // get information from parameter set
00021   fName = iPSet.getUntrackedParameter<std::string>("Name");
00022   verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00023   frequency = iPSet.getUntrackedParameter<int>("Frequency");
00024   edm::ParameterSet m_Prov =
00025     iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
00026   getAllProvenances = 
00027     m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
00028   printProvenanceInfo = 
00029     m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
00030   hitsProducer = iPSet.getParameter<std::string>("hitsProducer");
00031   
00032   //get Labels to use to extract information
00033   ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
00034   ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
00035   ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
00036   HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
00037   HCalDigi_ = iPSet.getParameter<edm::InputTag>("HCalDigi");
00038   SiStripSrc_ = iPSet.getParameter<edm::InputTag>("SiStripSrc"); 
00039   SiPxlSrc_ = iPSet.getParameter<edm::InputTag>("SiPxlSrc");
00040   MuDTSrc_ = iPSet.getParameter<edm::InputTag>("MuDTSrc");
00041   MuCSCStripSrc_ = iPSet.getParameter<edm::InputTag>("MuCSCStripSrc");
00042   MuCSCWireSrc_ = iPSet.getParameter<edm::InputTag>("MuCSCWireSrc");
00043   MuRPCSrc_ = iPSet.getParameter<edm::InputTag>("MuRPCSrc");
00044   
00045   // use value of first digit to determine default output level (inclusive)
00046   // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
00047   verbosity %= 10;
00048   
00049   // print out Parameter Set information being used
00050   if (verbosity >= 0) {
00051     edm::LogInfo(MsgLoggerCat) 
00052       << "\n===============================\n"
00053       << "Initialized as EDAnalyzer with parameter values:\n"
00054       << "    Name          = " << fName << "\n"
00055       << "    Verbosity     = " << verbosity << "\n"
00056       << "    Frequency     = " << frequency << "\n"
00057       << "    GetProv       = " << getAllProvenances << "\n"
00058       << "    PrintProv     = " << printProvenanceInfo << "\n"
00059       << "    ECalEBSrc     = " << ECalEBSrc_.label() 
00060       << ":" << ECalEBSrc_.instance() << "\n"
00061       << "    ECalEESrc     = " << ECalEESrc_.label() 
00062       << ":" << ECalEESrc_.instance() << "\n"
00063       << "    ECalESSrc     = " << ECalESSrc_.label() 
00064       << ":" << ECalESSrc_.instance() << "\n"
00065       << "    HCalSrc       = " << HCalSrc_.label() 
00066       << ":" << HCalSrc_.instance() << "\n"
00067       << "    HCalDigi       = " << HCalDigi_.label() 
00068       << ":" << HCalDigi_.instance() << "\n"
00069       << "    SiStripSrc    = " << SiStripSrc_.label() 
00070       << ":" << SiStripSrc_.instance() << "\n" 
00071       << "    SiPixelSrc    = " << SiPxlSrc_.label()
00072       << ":" << SiPxlSrc_.instance() << "\n"
00073       << "    MuDTSrc       = " << MuDTSrc_.label()
00074       << ":" << MuDTSrc_.instance() << "\n"
00075       << "    MuCSCStripSrc = " << MuCSCStripSrc_.label()
00076       << ":" << MuCSCStripSrc_.instance() << "\n"
00077       << "    MuCSCWireSrc  = " << MuCSCWireSrc_.label()
00078       << ":" << MuCSCWireSrc_.instance() << "\n"
00079       << "    MuRPCSrc      = " << MuRPCSrc_.label()
00080       << ":" << MuRPCSrc_.instance() << "\n"
00081       << "===============================\n";
00082   }
00083   
00084   //Put in analyzer stuff here.... Pasted from Rec Hits... 
00085   
00086   dbe = 0;
00087   dbe = edm::Service<DQMStore>().operator->();
00088   if (dbe) {
00089     if (verbosity > 0 ) {
00090       dbe->setVerbose(1);
00091     } else {
00092       dbe->setVerbose(0);
00093     }
00094   }
00095   if (dbe) {
00096     if (verbosity > 0 ) dbe->showDirStructure();
00097   }
00098   
00099   Char_t hname[100];
00100   Char_t htitle[100];
00101   
00102   //monitor elements 
00103   
00104   //Si Strip
00105   if (dbe) {
00106     std::string SiStripString[19] = {"TECW1", "TECW2", "TECW3", "TECW4", 
00107                                      "TECW5", "TECW6", "TECW7", "TECW8", 
00108                                      "TIBL1", "TIBL2", "TIBL3", "TIBL4", 
00109                                      "TIDW1", "TIDW2", "TIDW3", "TOBL1", 
00110                                      "TOBL2", "TOBL3", "TOBL4"};
00111     for(int i = 0; i<19; ++i) {
00112       mehSiStripn[i]=0;
00113       mehSiStripADC[i]=0;
00114       mehSiStripStrip[i]=0;
00115     }
00116     std::string hcharname, hchartitle;
00117     dbe->setCurrentFolder("GlobalDigisV/SiStrips");
00118     for(int amend = 0; amend < 19; ++amend) { 
00119       hcharname = "hSiStripn_"+SiStripString[amend];
00120       hchartitle= SiStripString[amend]+"  Digis";
00121       sprintf(hname, hcharname.c_str());
00122       sprintf(htitle, hchartitle.c_str());
00123       mehSiStripn[amend] = dbe->book1D(hname,htitle,5000,0.,10000.);
00124       mehSiStripn[amend]->setAxisTitle("Number of Digis",1);
00125       mehSiStripn[amend]->setAxisTitle("Count",2);
00126       
00127       hcharname = "hSiStripADC_"+SiStripString[amend];
00128       hchartitle= SiStripString[amend]+" ADC";
00129       sprintf(hname, hcharname.c_str());
00130       sprintf(htitle, hchartitle.c_str());
00131       mehSiStripADC[amend] = dbe->book1D(hname,htitle,150,0.0,300.);
00132       mehSiStripADC[amend]->setAxisTitle("ADC",1);
00133       mehSiStripADC[amend]->setAxisTitle("Count",2);
00134       
00135       hcharname = "hSiStripStripADC_"+SiStripString[amend];
00136       hchartitle= SiStripString[amend]+" Strip";
00137       sprintf(hname, hcharname.c_str());
00138       sprintf(htitle, hchartitle.c_str());
00139       mehSiStripStrip[amend] = dbe->book1D(hname,htitle,200,0.0,800.);
00140       mehSiStripStrip[amend]->setAxisTitle("Strip Number",1);
00141       mehSiStripStrip[amend]->setAxisTitle("Count",2);
00142     }
00143     
00144     //HCal
00145     std::string HCalString[4] = {"HB", "HE", "HO","HF"}; 
00146     float calnUpper[4] = {30000.,30000.,30000.,20000.}; 
00147     float calnLower[4]={0.,0.,0.,0.}; 
00148     float SHEUpper[4]={1.,1.,1.,1.};
00149     float SHEvAEEUpper[4] = {5000, 5000, 5000, 5000}; 
00150     float SHEvAEELower[4] = {-5000, -5000, -5000, -5000}; 
00151     int SHEvAEEnBins[4] = {200,200,200,200};
00152     double ProfileUpper[4] = {1.,1.,1.,1.};  
00153     
00154     for(int i =0; i<4; ++i) {
00155       mehHcaln[i]=0;
00156       mehHcalAEE[i]=0;
00157       mehHcalSHE[i]=0;
00158       mehHcalAEESHE[i]=0;
00159       mehHcalSHEvAEE[i]=0;
00160     }
00161     dbe->setCurrentFolder("GlobalDigisV/HCals");
00162     
00163     for(int amend = 0; amend < 4; ++amend) {
00164       hcharname = "hHcaln_"+HCalString[amend];
00165       hchartitle= HCalString[amend]+"  digis";
00166       sprintf(hname, hcharname.c_str());
00167       sprintf(htitle, hchartitle.c_str());
00168       mehHcaln[amend] = dbe->book1D(hname,htitle, 10000, calnLower[amend], 
00169                                     calnUpper[amend]);
00170       mehHcaln[amend]->setAxisTitle("Number of Digis",1);
00171       mehHcaln[amend]->setAxisTitle("Count",2);
00172 
00173       hcharname = "hHcalAEE_"+HCalString[amend];
00174       hchartitle= HCalString[amend]+"Cal AEE";
00175       sprintf(hname, hcharname.c_str());
00176       sprintf(htitle, hchartitle.c_str());
00177       mehHcalAEE[amend] = dbe->book1D(hname,htitle, 60, -10., 50.);
00178       mehHcalAEE[amend]->setAxisTitle("Analog Equivalent Energy",1);
00179       mehHcalAEE[amend]->setAxisTitle("Count",2);
00180 
00181       hcharname = "hHcalSHE_"+HCalString[amend];
00182       hchartitle= HCalString[amend]+"Cal SHE";
00183       sprintf(hname, hcharname.c_str());
00184       sprintf(htitle, hchartitle.c_str());
00185       mehHcalSHE[amend] = dbe->book1D(hname,htitle, 1000, 0.0, 
00186                                       SHEUpper[amend]);
00187       mehHcalSHE[amend]->setAxisTitle("Simulated Hit Energy",1);
00188       mehHcalSHE[amend]->setAxisTitle("Count",2);
00189 
00190       hcharname = "hHcalAEESHE_"+HCalString[amend];
00191       hchartitle= HCalString[amend]+"Cal AEE/SHE";
00192       sprintf(hname, hcharname.c_str());
00193       sprintf(htitle, hchartitle.c_str());
00194       mehHcalAEESHE[amend] = dbe->book1D(hname, htitle, SHEvAEEnBins[amend], 
00195                                          SHEvAEELower[amend], 
00196                                          SHEvAEEUpper[amend]);
00197       mehHcalAEESHE[amend]->setAxisTitle("ADC / SHE",1);
00198       mehHcalAEESHE[amend]->setAxisTitle("Count",2);
00199       
00200       hcharname = "hHcalSHEvAEE_"+HCalString[amend];
00201       hchartitle= HCalString[amend]+"Cal SHE vs. AEE";
00202       sprintf(hname, hcharname.c_str());
00203       sprintf(htitle, hchartitle.c_str());
00204       mehHcalSHEvAEE[amend] = dbe->bookProfile(hname,htitle, 60, -10., 
00205                                                50., 100, 0., 
00206                                                (float)ProfileUpper[amend],"");
00207       mehHcalSHEvAEE[amend]->setAxisTitle("AEE / SHE",1);
00208       mehHcalSHEvAEE[amend]->setAxisTitle("SHE",2);
00209 
00210     }
00211     
00212     //Ecal
00213     std::string ECalString[2] = {"EB","EE"}; 
00214     
00215     for(int i =0; i<2; ++i) {
00216       mehEcaln[i]=0;
00217       mehEcalAEE[i]=0;
00218       mehEcalSHE[i]=0;
00219       mehEcalMaxPos[i]=0;
00220       mehEcalMultvAEE[i]=0;
00221       mehEcalSHEvAEESHE[i]=0;
00222     }
00223     dbe->setCurrentFolder("GlobalDigisV/ECals");
00224     
00225     for(int amend = 0; amend < 2; ++amend) {
00226       hcharname = "hEcaln_"+ECalString[amend];
00227       hchartitle= ECalString[amend]+"  digis";
00228       sprintf(hname, hcharname.c_str());
00229       sprintf(htitle, hchartitle.c_str());
00230       mehEcaln[amend] = dbe->book1D(hname,htitle, 3000, 0., 40000.);
00231       mehEcaln[amend]->setAxisTitle("Number of Digis",1);
00232       mehEcaln[amend]->setAxisTitle("Count",2);
00233 
00234       hcharname = "hEcalAEE_"+ECalString[amend];
00235       hchartitle= ECalString[amend]+"Cal AEE";
00236       sprintf(hname, hcharname.c_str());
00237       sprintf(htitle, hchartitle.c_str());
00238       mehEcalAEE[amend] = dbe->book1D(hname,htitle, 1000, 0., 100.);
00239       mehEcalAEE[amend]->setAxisTitle("Analog Equivalent Energy",1);
00240       mehEcalAEE[amend]->setAxisTitle("Count",2);
00241 
00242       hcharname = "hEcalSHE_"+ECalString[amend];
00243       hchartitle= ECalString[amend]+"Cal SHE";
00244       sprintf(hname, hcharname.c_str());
00245       sprintf(htitle, hchartitle.c_str());
00246       mehEcalSHE[amend] = dbe->book1D(hname,htitle, 500, 0., 50.);
00247       mehEcalSHE[amend]->setAxisTitle("Simulated Hit Energy",1);
00248       mehEcalSHE[amend]->setAxisTitle("Count",2);
00249 
00250       hcharname = "hEcalMaxPos_"+ECalString[amend];
00251       hchartitle= ECalString[amend]+"Cal MaxPos";
00252       sprintf(hname, hcharname.c_str());
00253       sprintf(htitle, hchartitle.c_str());
00254       mehEcalMaxPos[amend] = dbe->book1D(hname,htitle,10, 0., 10.);
00255       mehEcalMaxPos[amend]->setAxisTitle("Maximum Position",1);
00256       mehEcalMaxPos[amend]->setAxisTitle("Count",2);
00257       
00258       hcharname = "hEcalSHEvAEESHE_"+ECalString[amend];
00259       hchartitle= ECalString[amend]+"Cal SHE vs. AEE/SHE";
00260       sprintf(hname, hcharname.c_str());
00261       sprintf(htitle, hchartitle.c_str());
00262       mehEcalSHEvAEESHE[amend] = dbe->bookProfile(hname,htitle,1000, 0., 100., 
00263                                                   500, 0., 50.,"");
00264       mehEcalSHEvAEESHE[amend]->setAxisTitle("AEE / SHE",1);
00265       mehEcalSHEvAEESHE[amend]->setAxisTitle("SHE",2);
00266 
00267       hcharname = "hEcalMultvAEE_"+ECalString[amend];
00268       hchartitle= ECalString[amend]+"Cal Multi vs. AEE";
00269       sprintf(hname, hcharname.c_str());
00270       sprintf(htitle, hchartitle.c_str());
00271       mehEcalMultvAEE[amend] = dbe->bookProfile(hname,htitle, 1000, 0., 100., 
00272                                                 4000, 0., 40000.,"");
00273       mehEcalMultvAEE[amend]->setAxisTitle("Analog Equivalent Energy",1);
00274       mehEcalMultvAEE[amend]->setAxisTitle("Number of Digis",2);      
00275     }
00276     mehEScaln = 0;
00277 
00278     hcharname = "hEcaln_ES";
00279     hchartitle= "ESCAL  digis";
00280     sprintf(hname, hcharname.c_str());
00281     sprintf(htitle, hchartitle.c_str());
00282     mehEScaln = dbe->book1D(hname,htitle, 1000, 0., 5000.);
00283     mehEScaln->setAxisTitle("Number of Digis",1);
00284     mehEScaln->setAxisTitle("Count",2);
00285 
00286     std::string ADCNumber[3] = {"0", "1", "2"};
00287     for(int i =0; i<3; ++i) {
00288       mehEScalADC[i] = 0;
00289       hcharname = "hEcalADC"+ADCNumber[i]+"_ES";
00290       hchartitle= "ESCAL  ADC"+ADCNumber[i];
00291       sprintf(hname, hcharname.c_str());
00292       sprintf(htitle, hchartitle.c_str());
00293       mehEScalADC[i] = dbe->book1D(hname,htitle, 1500, 0., 1500.);
00294       mehEScalADC[i]->setAxisTitle("ADC"+ADCNumber[i],1);
00295       mehEScalADC[i]->setAxisTitle("Count",2);
00296     }
00297     
00298     //Si Pixels ***DONE***  
00299     std::string SiPixelString[7] = {"BRL1", "BRL2", "BRL3", "FWD1n", "FWD1p", 
00300                                     "FWD2n", "FWD2p"};
00301     for(int j =0; j<7; ++j) {
00302       mehSiPixeln[j]=0;
00303       mehSiPixelADC[j]=0;
00304       mehSiPixelRow[j]=0;
00305       mehSiPixelCol[j]=0;
00306     }
00307     
00308     dbe->setCurrentFolder("GlobalDigisV/SiPixels");
00309     for(int amend = 0; amend < 7; ++amend) {
00310       hcharname = "hSiPixeln_"+SiPixelString[amend];
00311       hchartitle= SiPixelString[amend]+" Digis";
00312       sprintf(hname, hcharname.c_str());
00313       sprintf(htitle, hchartitle.c_str());
00314       if(amend<3) mehSiPixeln[amend] = dbe->book1D(hname,htitle,500,0.,1000.);
00315       else mehSiPixeln[amend] = dbe->book1D(hname,htitle,500,0.,1000.);
00316       mehSiPixeln[amend]->setAxisTitle("Number of Digis",1);
00317       mehSiPixeln[amend]->setAxisTitle("Count",2);
00318       
00319       hcharname = "hSiPixelADC_"+SiPixelString[amend];
00320       hchartitle= SiPixelString[amend]+" ADC";
00321       sprintf(hname, hcharname.c_str());
00322       sprintf(htitle, hchartitle.c_str());
00323       mehSiPixelADC[amend] = dbe->book1D(hname,htitle,150,0.0,300.);
00324       mehSiPixelADC[amend]->setAxisTitle("ADC",1);
00325       mehSiPixelADC[amend]->setAxisTitle("Count",2);
00326 
00327       hcharname = "hSiPixelRow_"+SiPixelString[amend];
00328       hchartitle= SiPixelString[amend]+" Row";
00329       sprintf(hname, hcharname.c_str());
00330       sprintf(htitle, hchartitle.c_str());
00331       mehSiPixelRow[amend] = dbe->book1D(hname,htitle,100,0.0,100.);
00332       mehSiPixelRow[amend]->setAxisTitle("Row Number",1);
00333       mehSiPixelRow[amend]->setAxisTitle("Count",2);
00334 
00335       hcharname = "hSiPixelColumn_"+SiPixelString[amend];
00336       hchartitle= SiPixelString[amend]+" Column";
00337       sprintf(hname, hcharname.c_str());
00338       sprintf(htitle, hchartitle.c_str());
00339       mehSiPixelCol[amend] = dbe->book1D(hname,htitle,200,0.0,500.);
00340       mehSiPixelCol[amend]->setAxisTitle("Column Number",1);
00341       mehSiPixelCol[amend]->setAxisTitle("Count",2);
00342     }
00343 
00344     //Muons
00345     dbe->setCurrentFolder("GlobalDigisV/Muons");
00346 
00347     //DT
00348     std::string MuonString[4] = {"MB1", "MB2", "MB3", "MB4"};
00349     
00350     for(int i =0; i < 4; ++i) {
00351       mehDtMuonn[i] = 0;
00352       mehDtMuonLayer[i] = 0;
00353       mehDtMuonTime[i] = 0;
00354       mehDtMuonTimevLayer[i] = 0;
00355     }
00356     
00357     for(int j = 0; j < 4; ++j) {
00358       hcharname = "hDtMuonn_"+MuonString[j];
00359       hchartitle= MuonString[j]+"  digis";
00360       sprintf(hname,hcharname.c_str());
00361       sprintf(htitle,hchartitle.c_str());
00362       mehDtMuonn[j] = dbe->book1D(hname,htitle,250, 0., 500.);
00363       mehDtMuonn[j]->setAxisTitle("Number of Digis",1);
00364       mehDtMuonn[j]->setAxisTitle("Count",2);
00365 
00366       hcharname = "hDtLayer_"+MuonString[j];
00367       hchartitle= MuonString[j]+"  Layer";
00368       sprintf(hname,hcharname.c_str());
00369       sprintf(htitle,hchartitle.c_str());
00370       mehDtMuonLayer[j] = dbe->book1D(hname,htitle,12, 1., 13.);
00371       mehDtMuonLayer[j]->setAxisTitle("4 * (SuperLayer - 1) + Layer",1);
00372       mehDtMuonLayer[j]->setAxisTitle("Count",2);
00373 
00374       hcharname = "hDtMuonTime_"+MuonString[j];
00375       hchartitle= MuonString[j]+"  Time";
00376       sprintf(hname,hcharname.c_str());
00377       sprintf(htitle,hchartitle.c_str());
00378       mehDtMuonTime[j] = dbe->book1D(hname,htitle,300, 400., 1000.);
00379       mehDtMuonTime[j]->setAxisTitle("Time",1);
00380       mehDtMuonTime[j]->setAxisTitle("Count",2);
00381 
00382       hcharname = "hDtMuonTimevLayer_"+MuonString[j];
00383       hchartitle= MuonString[j]+"  Time vs. Layer";
00384       sprintf(hname,hcharname.c_str());
00385       sprintf(htitle,hchartitle.c_str());
00386       mehDtMuonTimevLayer[j] = dbe->bookProfile(hname,htitle,12, 1., 13., 300, 
00387                                                 400., 1000.,"");
00388       mehDtMuonTimevLayer[j]->setAxisTitle("4 * (SuperLayer - 1) + Layer",1);
00389       mehDtMuonTimevLayer[j]->setAxisTitle("Time",2);
00390     }
00391 
00392     //CSC 
00393     mehCSCStripn = 0;
00394     hcharname = "hCSCStripn";
00395     hchartitle = "CSC Strip digis";
00396     sprintf(hname,hcharname.c_str());
00397     sprintf(htitle,hchartitle.c_str());
00398     mehCSCStripn = dbe->book1D(hname,htitle,250, 0., 500.);
00399     mehCSCStripn->setAxisTitle("Number of Digis",1);
00400     mehCSCStripn->setAxisTitle("Count",2);
00401     
00402     mehCSCStripADC = 0;
00403     hcharname = "hCSCStripADC";
00404     hchartitle = "CSC Strip ADC";
00405     sprintf(hname,hcharname.c_str());
00406     sprintf(htitle,hchartitle.c_str());
00407     mehCSCStripADC = dbe->book1D(hname,htitle, 110, 0., 1100.);
00408     mehCSCStripADC->setAxisTitle("ADC",1);
00409     mehCSCStripADC->setAxisTitle("Count",2);
00410     
00411     mehCSCWiren = 0;
00412     hcharname = "hCSCWiren";
00413     hchartitle = "CSC Wire digis";
00414     sprintf(hname,hcharname.c_str());
00415     sprintf(htitle,hchartitle.c_str());
00416     mehCSCWiren = dbe->book1D(hname,htitle,250, 0., 500.);
00417     mehCSCWiren->setAxisTitle("Number of Digis",1);
00418     mehCSCWiren->setAxisTitle("Count",2);
00419     
00420     mehCSCWireTime = 0;
00421     hcharname = "hCSCWireTime";
00422     hchartitle = "CSC Wire Time";
00423     sprintf(hname,hcharname.c_str());
00424     sprintf(htitle,hchartitle.c_str());
00425     mehCSCWireTime = dbe->book1D(hname,htitle,10, 0., 10.);
00426     mehCSCWireTime->setAxisTitle("Time",1);
00427     mehCSCWireTime->setAxisTitle("Count",2);
00428     
00429     // RPC 
00430     mehRPCMuonn = 0;
00431     hcharname = "hRPCMuonn";
00432     hchartitle = "RPC digis";
00433     sprintf(hname,hcharname.c_str());
00434     sprintf(htitle,hchartitle.c_str());
00435     mehCSCStripn = dbe->book1D(hname,htitle,250, 0., 500.);
00436     mehCSCStripn->setAxisTitle("Number of Digis",1);
00437     mehCSCStripn->setAxisTitle("Count",2);
00438 
00439     std::string MuonRPCString[5] = {"Wmin2", "Wmin1", "W0", "Wpu1", "Wpu2"};
00440     for(int i =0; i < 5; ++i) {
00441       mehRPCRes[i] = 0;
00442     }
00443 
00444     for(int j = 0; j < 5; ++j) {    
00445       hcharname = "hRPCRes_"+MuonRPCString[j];
00446       hchartitle= MuonRPCString[j]+"  Digi - Sim";   
00447       sprintf(hname,hcharname.c_str());
00448       sprintf(htitle,hchartitle.c_str());
00449       mehRPCRes[j] = dbe->book1D(hname,htitle,200, -8., 8.);
00450       mehRPCRes[j]->setAxisTitle("Digi - Sim center of strip x",1);
00451       mehRPCRes[j]->setAxisTitle("Count",2);
00452     }
00453   }
00454 
00455   // set default constants
00456   // ECal
00457   
00458   ECalgainConv_[0] = 0.;
00459   ECalgainConv_[1] = 1.;
00460   ECalgainConv_[2] = 2.;
00461   ECalgainConv_[3] = 12.;  
00462   ECalbarrelADCtoGeV_ = 0.035;
00463   ECalendcapADCtoGeV_ = 0.06;
00464 }
00465  
00466 GlobalDigisAnalyzer::~GlobalDigisAnalyzer() {}
00467 
00468 void GlobalDigisAnalyzer::beginJob( void )
00469 {
00470   std::string MsgLoggerCat = "GlobalDigisAnalyzer_beginJob";
00471   
00472   EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
00473   
00474   ECalgainConv_[0] = 0.;
00475   ECalgainConv_[1] = 1.;
00476   ECalgainConv_[2] = defaultRatios->gain12Over6() ;
00477   ECalgainConv_[3] = ECalgainConv_[2]*(defaultRatios->gain6Over1()) ;
00478   
00479   delete defaultRatios;
00480   
00481   if (verbosity >= 0) {
00482     edm::LogInfo(MsgLoggerCat) 
00483       << "Modified Calorimeter gain constants: g0 = " << ECalgainConv_[0]
00484       << ", g1 = " << ECalgainConv_[1] << ", g2 = " << ECalgainConv_[2]
00485       << ", g3 = " << ECalgainConv_[3];
00486   }
00487   
00488   return;
00489 }
00490 
00491 
00492 void GlobalDigisAnalyzer::endJob()
00493 {
00494   std::string MsgLoggerCat = "GlobalDigisAnalyzer_endJob";
00495   if (verbosity >= 0)
00496     edm::LogInfo(MsgLoggerCat) 
00497       << "Terminating having processed " << count << " events.";
00498   return;
00499 }
00500 
00501 void GlobalDigisAnalyzer::analyze(const edm::Event& iEvent, 
00502                                   const edm::EventSetup& iSetup)
00503 {
00504   std::string MsgLoggerCat = "GlobalDigisAnalyzer_analyze";
00505   
00506   // keep track of number of events processed
00507   ++count;
00508 
00509 
00510   
00511   // THIS BLOCK MIGRATED HERE FROM beginJob:
00512   // setup calorimeter constants from service
00513   edm::ESHandle<EcalADCToGeVConstant> pAgc;
00514   iSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
00515   const EcalADCToGeVConstant* agc = pAgc.product();
00516   ECalbarrelADCtoGeV_ = agc->getEBValue();
00517   ECalendcapADCtoGeV_ = agc->getEEValue();
00518   if (verbosity >= 0) {
00519     edm::LogInfo(MsgLoggerCat)
00520       << "Modified Calorimeter ADCtoGeV constants: barrel = " 
00521       << ECalbarrelADCtoGeV_ << ", endcap = " << ECalendcapADCtoGeV_;
00522   }
00523   
00524 
00525 
00526   // get event id information
00527   int nrun = iEvent.id().run();
00528   int nevt = iEvent.id().event();
00529   
00530   if (verbosity > 0) {
00531     edm::LogInfo(MsgLoggerCat)
00532       << "Processing run " << nrun << ", event " << nevt
00533       << " (" << count << " events total)";
00534   } else if (verbosity == 0) {
00535     if (nevt%frequency == 0 || nevt == 1) {
00536       edm::LogInfo(MsgLoggerCat)
00537         << "Processing run " << nrun << ", event " << nevt
00538         << " (" << count << " events total)";
00539     }
00540   }
00541     
00542   // look at information available in the event
00543   if (getAllProvenances) {
00544     
00545     std::vector<const edm::Provenance*> AllProv;
00546     iEvent.getAllProvenance(AllProv);
00547     
00548     if (verbosity >= 0)
00549       edm::LogInfo(MsgLoggerCat)
00550         << "Number of Provenances = " << AllProv.size();
00551     
00552     if (printProvenanceInfo && (verbosity >= 0)) {
00553       TString eventout("\nProvenance info:\n");      
00554       
00555       for (unsigned int i = 0; i < AllProv.size(); ++i) {
00556         eventout += "\n       ******************************";
00557         eventout += "\n       Module       : ";
00558         eventout += AllProv[i]->moduleLabel();
00559         eventout += "\n       ProductID    : ";
00560         eventout += AllProv[i]->productID().id();
00561         eventout += "\n       ClassName    : ";
00562         eventout += AllProv[i]->className();
00563         eventout += "\n       InstanceName : ";
00564         eventout += AllProv[i]->productInstanceName();
00565         eventout += "\n       BranchName   : ";
00566         eventout += AllProv[i]->branchName();
00567       }
00568       eventout += "\n       ******************************\n";
00569       edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00570       printProvenanceInfo = false;
00571     }
00572     getAllProvenances = false;
00573   }
00574   
00575   // call fill functions
00576   // gather Ecal information from event
00577   fillECal(iEvent,  iSetup);
00578   // gather Hcal information from event
00579   fillHCal(iEvent, iSetup);
00580   // gather Track information from event
00581   fillTrk(iEvent,  iSetup);
00582   // gather Muon information from event
00583   fillMuon(iEvent,  iSetup);
00584   
00585   if (verbosity > 0)
00586     edm::LogInfo (MsgLoggerCat)
00587       << "Done gathering data from event.";
00588   
00589   if (verbosity > 2)
00590     edm::LogInfo (MsgLoggerCat)
00591       << "Saving event contents:";
00592     
00593   return;
00594 }
00595 
00596 void GlobalDigisAnalyzer::fillECal(const edm::Event& iEvent, 
00597                                    const edm::EventSetup& iSetup)
00598 {
00599   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillECal";
00600   
00601   TString eventout;
00602   if (verbosity > 0)
00603     eventout = "\nGathering info:";  
00604   
00605   // extract crossing frame from event
00606   edm::Handle<CrossingFrame<PCaloHit> > crossingFrame;
00607   
00609   //extract EB information
00611   bool isBarrel = true;
00612   edm::Handle<EBDigiCollection> EcalDigiEB;  
00613   const EBDigiCollection *EBdigis = 0;
00614   iEvent.getByLabel(ECalEBSrc_, EcalDigiEB);
00615   bool validDigiEB = true;
00616   if (!EcalDigiEB.isValid()) {
00617     LogDebug(MsgLoggerCat)
00618       << "Unable to find EcalDigiEB in event!";
00619     validDigiEB = false;
00620   }  
00621   if (validDigiEB) {
00622     EBdigis = EcalDigiEB.product();
00623     if ( EcalDigiEB->size() == 0) isBarrel = false;
00624     
00625     if (isBarrel) {
00626       
00627       // loop over simhits
00628       MapType ebSimMap;
00629       const std::string barrelHitsName(hitsProducer+"EcalHitsEB");
00630       iEvent.getByLabel("mix",barrelHitsName,crossingFrame);
00631       bool validXFrame = true;
00632       if (!crossingFrame.isValid()) {
00633         LogDebug(MsgLoggerCat)
00634           << "Unable to find cal barrel crossingFrame in event!";
00635         validXFrame = false;
00636       }
00637       if (validXFrame) {
00638         std::auto_ptr<MixCollection<PCaloHit> >
00639           barrelHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00640         
00641         // keep track of sum of simhit energy in each crystal
00642         for (MixCollection<PCaloHit>::MixItr hitItr 
00643                = barrelHits->begin();
00644              hitItr != barrelHits->end();
00645              ++hitItr) {
00646           
00647           EBDetId ebid = EBDetId(hitItr->id());
00648           
00649           uint32_t crystid = ebid.rawId();
00650           ebSimMap[crystid] += hitItr->energy();
00651         }
00652       }
00653 
00654       // loop over digis
00655       const EBDigiCollection *barrelDigi = EcalDigiEB.product();
00656       
00657       std::vector<double> ebAnalogSignal;
00658       std::vector<double> ebADCCounts;
00659       std::vector<double> ebADCGains;
00660       ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES);
00661       ebADCCounts.reserve(EBDataFrame::MAXSAMPLES);
00662       ebADCGains.reserve(EBDataFrame::MAXSAMPLES);
00663       
00664       int i = 0;
00665       for (unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
00666         
00667         ++i;
00668         
00669         EBDataFrame ebdf = (*barrelDigi)[digis];
00670         int nrSamples = ebdf.size();
00671         
00672         EBDetId ebid = ebdf.id () ;
00673         
00674         double Emax = 0;
00675         int Pmax = 0;
00676         double pedestalPreSample = 0.;
00677         double pedestalPreSampleAnalog = 0.;
00678         
00679         for (int sample = 0 ; sample < nrSamples; ++sample) {
00680           ebAnalogSignal[sample] = 0.;
00681           ebADCCounts[sample] = 0.;
00682           ebADCGains[sample] = -1.;
00683         }
00684         
00685         // calculate maximum energy and pedestal
00686         for (int sample = 0 ; sample < nrSamples; ++sample) {
00687           
00688           EcalMGPASample thisSample = ebdf[sample];
00689           ebADCCounts[sample] = (thisSample.adc());
00690           ebADCGains[sample]  = (thisSample.gainId());
00691           ebAnalogSignal[sample] = 
00692             (ebADCCounts[sample] * ECalgainConv_[(int)ebADCGains[sample]]
00693              * ECalbarrelADCtoGeV_);
00694           if (Emax < ebAnalogSignal[sample]) {
00695             Emax = ebAnalogSignal[sample];
00696             Pmax = sample;
00697           }
00698           if ( sample < 3 ) {
00699             pedestalPreSample += ebADCCounts[sample] ;
00700             pedestalPreSampleAnalog += 
00701               ebADCCounts[sample] * ECalgainConv_[(int)ebADCGains[sample]]
00702               * ECalbarrelADCtoGeV_ ;
00703           }
00704           
00705         }
00706         pedestalPreSample /= 3. ; 
00707         pedestalPreSampleAnalog /= 3. ; 
00708         
00709         // calculate pedestal subtracted digi energy in the crystal
00710         double Erec = Emax - pedestalPreSampleAnalog
00711           * ECalgainConv_[(int)ebADCGains[Pmax]];
00712         
00713         // gather necessary information
00714         mehEcalMaxPos[0]->Fill(Pmax);
00715         mehEcalSHE[0]->Fill(ebSimMap[ebid.rawId()]);
00716         mehEcalAEE[0]->Fill(Erec);
00717         //Adding protection against FPE
00718         if (ebSimMap[ebid.rawId()]!=0) {
00719           mehEcalSHEvAEESHE[0]->Fill(Erec/ebSimMap[ebid.rawId()],
00720                                      ebSimMap[ebid.rawId()]);
00721         }
00722         //else {
00723         //  std::cout<<"Would have been an FPE! with ebSimMap[ebid.rawId()]==0\n";
00724         //}
00725 
00726         mehEcalMultvAEE[0]->Fill(Pmax,(float)i);
00727       }
00728       
00729       if (verbosity > 1) {
00730         eventout += "\n          Number of EBDigis collected:.............. ";
00731         eventout += i;
00732       }
00733       mehEcaln[0]->Fill((float)i);
00734     }
00735   }
00736   
00738   //extract EE information
00740   bool isEndCap = true;
00741   edm::Handle<EEDigiCollection> EcalDigiEE;  
00742   const EEDigiCollection *EEdigis = 0;
00743   iEvent.getByLabel(ECalEESrc_, EcalDigiEE);
00744   bool validDigiEE = true;
00745   if (!EcalDigiEE.isValid()) {
00746     LogDebug(MsgLoggerCat)
00747       << "Unable to find EcalDigiEE in event!";
00748     validDigiEE = false;
00749   }  
00750   if (validDigiEE) {
00751     EEdigis = EcalDigiEE.product();
00752     if (EcalDigiEE->size() == 0) isEndCap = false;
00753     
00754     if (isEndCap) {
00755       
00756       // loop over simhits
00757       MapType eeSimMap;
00758       const std::string endcapHitsName(hitsProducer+"EcalHitsEE");
00759       iEvent.getByLabel("mix",endcapHitsName,crossingFrame);
00760       bool validXFrame = true;
00761       if (!crossingFrame.isValid()) {
00762         LogDebug(MsgLoggerCat)
00763           << "Unable to find cal endcap crossingFrame in event!";
00764         validXFrame = false;
00765       }
00766       if (validXFrame) {
00767         std::auto_ptr<MixCollection<PCaloHit> >
00768           endcapHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00769         
00770         // keep track of sum of simhit energy in each crystal
00771         for (MixCollection<PCaloHit>::MixItr hitItr 
00772                = endcapHits->begin();
00773              hitItr != endcapHits->end();
00774              ++hitItr) {
00775           
00776           EEDetId eeid = EEDetId(hitItr->id());
00777           
00778           uint32_t crystid = eeid.rawId();
00779           eeSimMap[crystid] += hitItr->energy();
00780         }
00781       }
00782 
00783       // loop over digis
00784       const EEDigiCollection *endcapDigi = EcalDigiEE.product();
00785       
00786       std::vector<double> eeAnalogSignal;
00787       std::vector<double> eeADCCounts;
00788       std::vector<double> eeADCGains;
00789       eeAnalogSignal.reserve(EEDataFrame::MAXSAMPLES);
00790       eeADCCounts.reserve(EEDataFrame::MAXSAMPLES);
00791       eeADCGains.reserve(EEDataFrame::MAXSAMPLES);
00792       
00793       int inc = 0;
00794       for (unsigned int digis=0; digis<EcalDigiEE->size(); ++digis){ 
00795         
00796         ++inc;
00797         
00798         EEDataFrame eedf = (*endcapDigi)[digis];
00799         int nrSamples = eedf.size();
00800         
00801         EEDetId eeid = eedf.id () ;
00802         
00803         double Emax = 0;
00804         int Pmax = 0;
00805         double pedestalPreSample = 0.;
00806         double pedestalPreSampleAnalog = 0.;
00807         
00808         for (int sample = 0 ; sample < nrSamples; ++sample) {
00809           eeAnalogSignal[sample] = 0.;
00810           eeADCCounts[sample] = 0.;
00811           eeADCGains[sample] = -1.;
00812         }
00813         
00814         // calculate maximum enery and pedestal
00815         for (int sample = 0 ; sample < nrSamples; ++sample) {
00816           
00817           EcalMGPASample thisSample = eedf[sample];
00818           
00819           eeADCCounts[sample] = (thisSample.adc());
00820           eeADCGains[sample]  = (thisSample.gainId());
00821           eeAnalogSignal[sample] = 
00822             (eeADCCounts[sample] * ECalgainConv_[(int)eeADCGains[sample]]
00823              * ECalbarrelADCtoGeV_);
00824           if (Emax < eeAnalogSignal[sample]) {
00825             Emax = eeAnalogSignal[sample];
00826             Pmax = sample;
00827           }
00828           if ( sample < 3 ) {
00829             pedestalPreSample += eeADCCounts[sample] ;
00830             pedestalPreSampleAnalog += 
00831               eeADCCounts[sample] * ECalgainConv_[(int)eeADCGains[sample]]
00832               * ECalbarrelADCtoGeV_ ;
00833           }
00834           
00835         }
00836         pedestalPreSample /= 3. ; 
00837         pedestalPreSampleAnalog /= 3. ; 
00838         
00839         // calculate pedestal subtracted digi energy in the crystal
00840         double Erec = Emax - pedestalPreSampleAnalog
00841           * ECalgainConv_[(int)eeADCGains[Pmax]];
00842         
00843         // gather necessary information
00844         mehEcalMaxPos[1]->Fill(Pmax);
00845         mehEcalSHE[1]->Fill(eeSimMap[eeid.rawId()]);
00846         mehEcalAEE[1]->Fill(Erec);
00847         //Adding protection against FPE
00848         if (eeSimMap[eeid.rawId()]!=0){
00849           mehEcalSHEvAEESHE[1]->Fill(Erec/eeSimMap[eeid.rawId()],
00850                                      eeSimMap[eeid.rawId()]);
00851         }
00852         //else{
00853         //  std::cout<<"Would have been an FPE! with eeSimMap[eeid.rawId()]==0\n"; 
00854         //}
00855         mehEcalMultvAEE[1]->Fill(Pmax,(float)inc);
00856         
00857       }
00858       
00859       if (verbosity > 1) {
00860         eventout += "\n          Number of EEDigis collected:.............. ";
00861         eventout += inc;
00862       }
00863       
00864       mehEcaln[1]->Fill((float)inc);
00865     }
00866   }
00867 
00869   //extract ES information
00871   bool isPreshower = true;
00872   edm::Handle<ESDigiCollection> EcalDigiES;  
00873   const ESDigiCollection *ESdigis = 0;
00874   iEvent.getByLabel(ECalESSrc_, EcalDigiES);
00875   bool validDigiES = true;
00876   if (!EcalDigiES.isValid()) {
00877     LogDebug(MsgLoggerCat)
00878       << "Unable to find EcalDigiES in event!";
00879     validDigiES = false;
00880   } 
00881   
00882   // ONLY WHILE GEOMETRY IS REMOVED
00883   validDigiES = false;
00884  
00885   if (validDigiES) {
00886     ESdigis = EcalDigiES.product();
00887     if (EcalDigiES->size() == 0) isPreshower = false;
00888     
00889     if (isPreshower) {
00890       
00891       // loop over simhits
00892       const std::string preshowerHitsName(hitsProducer+"EcalHitsES");
00893       iEvent.getByLabel("mix",preshowerHitsName,crossingFrame);
00894       bool validXFrame = true;
00895       if (!crossingFrame.isValid()) {
00896         LogDebug(MsgLoggerCat)
00897           << "Unable to find cal preshower crossingFrame in event!";
00898         validXFrame = false;
00899       }
00900       if (validXFrame) {
00901         std::auto_ptr<MixCollection<PCaloHit> >
00902           preshowerHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00903         
00904         // keep track of sum of simhit energy in each crystal
00905         MapType esSimMap;
00906         for (MixCollection<PCaloHit>::MixItr hitItr 
00907                = preshowerHits->begin();
00908              hitItr != preshowerHits->end();
00909              ++hitItr) {
00910           
00911           ESDetId esid = ESDetId(hitItr->id());
00912           
00913           uint32_t crystid = esid.rawId();
00914           esSimMap[crystid] += hitItr->energy();
00915         }
00916       }
00917 
00918       // loop over digis
00919       const ESDigiCollection *preshowerDigi = EcalDigiES.product();
00920       
00921       std::vector<double> esADCCounts;
00922       esADCCounts.reserve(ESDataFrame::MAXSAMPLES);
00923       
00924       int i = 0;
00925       for (unsigned int digis=0; digis<EcalDigiES->size(); ++digis) {
00926         
00927         ++i;
00928         
00929         
00930         ESDataFrame esdf = (*preshowerDigi)[digis];
00931         int nrSamples = esdf.size();
00932         
00933         ESDetId esid = esdf.id () ;
00934         // ESDetId esid = digis->id();
00935         
00936         for (int sample = 0 ; sample < nrSamples; ++sample) {
00937           esADCCounts[sample] = 0.;
00938         }
00939         
00940         // gether ADC counts
00941         for (int sample = 0 ; sample < nrSamples; ++sample) {
00942           
00943           ESSample thisSample = esdf[sample];
00944           esADCCounts[sample] = (thisSample.adc());
00945         }
00946         
00947         mehEScalADC[0]->Fill(esADCCounts[0]);
00948         mehEScalADC[1]->Fill(esADCCounts[1]);
00949         mehEScalADC[2]->Fill(esADCCounts[2]);
00950         
00951       }
00952       
00953       if (verbosity > 1) {
00954         eventout += "\n          Number of ESDigis collected:.............. ";
00955         eventout += i;
00956       }
00957       
00958       mehEScaln->Fill((float)i);
00959     }
00960   }
00961   if (verbosity > 0)
00962     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00963   
00964   return;
00965 }
00966 
00967 
00968 void GlobalDigisAnalyzer::fillHCal(const edm::Event& iEvent, 
00969                                    const edm::EventSetup& iSetup)
00970 {
00971   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillHCal";
00972   
00973   TString eventout;
00974   if (verbosity > 0)
00975     eventout = "\nGathering info:";  
00976   
00977   // get calibration info
00978   edm::ESHandle<HcalDbService> HCalconditions;
00979   iSetup.get<HcalDbRecord>().get(HCalconditions);
00980   if (!HCalconditions.isValid()) {
00981     edm::LogWarning(MsgLoggerCat)
00982       << "Unable to find HCalconditions in event!";
00983     return;
00984   } 
00985   const HcalQIEShape *shape = HCalconditions->getHcalShape();
00986   //HcalCalibrations calibrations;
00987   CaloSamples tool;
00988   
00990   // extract simhit info
00992   edm::Handle<edm::PCaloHitContainer> hcalHits;
00993   iEvent.getByLabel(HCalSrc_,hcalHits);
00994   bool validhcalHits = true;
00995   if (!hcalHits.isValid()) {
00996     LogDebug(MsgLoggerCat)
00997       << "Unable to find hcalHits in event!";
00998     validhcalHits = false;
00999   }  
01000   MapType fHBEnergySimHits;
01001   MapType fHEEnergySimHits;
01002   MapType fHOEnergySimHits;
01003   MapType fHFEnergySimHits;
01004   if (validhcalHits) {
01005     const edm::PCaloHitContainer *simhitResult = hcalHits.product();
01006     
01007     for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin();
01008          simhits != simhitResult->end();
01009          ++simhits) {
01010       
01011       HcalDetId detId(simhits->id());
01012       uint32_t cellid = detId.rawId();
01013       
01014       if (detId.subdet() == sdHcalBrl){  
01015         fHBEnergySimHits[cellid] += simhits->energy(); 
01016       }
01017       if (detId.subdet() == sdHcalEC){  
01018         fHEEnergySimHits[cellid] += simhits->energy(); 
01019       }    
01020       if (detId.subdet() == sdHcalOut){  
01021         fHOEnergySimHits[cellid] += simhits->energy(); 
01022       }    
01023       if (detId.subdet() == sdHcalFwd){  
01024         fHFEnergySimHits[cellid] += simhits->energy(); 
01025       }    
01026     } 
01027   }
01028 
01030   // get HBHE information
01032   edm::Handle<edm::SortedCollection<HBHEDataFrame> > hbhe;
01033   iEvent.getByLabel(HCalDigi_,hbhe);
01034   bool validHBHE = true;
01035   if (!hbhe.isValid()) {
01036     LogDebug(MsgLoggerCat)
01037       << "Unable to find HBHEDataFrame in event!";
01038     validHBHE = false;
01039   }    
01040 
01041   if (validHBHE) {
01042     edm::SortedCollection<HBHEDataFrame>::const_iterator ihbhe;
01043     
01044     int iHB = 0;
01045     int iHE = 0; 
01046     for (ihbhe = hbhe->begin(); ihbhe != hbhe->end(); ++ihbhe) {
01047       HcalDetId cell(ihbhe->id()); 
01048       
01049       if ((cell.subdet() == sdHcalBrl) || (cell.subdet() == sdHcalEC)) {
01050         
01051         //HCalconditions->makeHcalCalibration(cell, &calibrations);
01052         const HcalCalibrations& calibrations = 
01053           HCalconditions->getHcalCalibrations(cell);
01054         const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
01055         HcalCoderDb coder(*channelCoder, *shape);
01056         coder.adc2fC(*ihbhe, tool);
01057         
01058         // get HB info
01059         if (cell.subdet() == sdHcalBrl) {
01060           
01061           ++iHB;
01062           float fDigiSum = 0.0;
01063           for  (int ii = 0; ii < tool.size(); ++ii) {
01064             // default ped is 4.5
01065             int capid = (*ihbhe)[ii].capid();
01066             fDigiSum += (tool[ii] - calibrations.pedestal(capid));
01067           }
01068           
01069           mehHcalSHE[0]->Fill(fHFEnergySimHits[cell.rawId()]);
01070           mehHcalAEE[0]->Fill(fDigiSum);
01071           //Adding protection against FPE
01072           if (fHFEnergySimHits[cell.rawId()]!=0){
01073             mehHcalAEESHE[0]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01074           }
01075           //else {
01076           //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01077           //}
01078           mehHcalSHEvAEE[0]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01079         }
01080         
01081         // get HE info
01082         if (cell.subdet() == sdHcalEC) {
01083           
01084           ++iHE;
01085           float fDigiSum = 0.0;
01086           for  (int ii = 0; ii < tool.size(); ++ii) {
01087             int capid = (*ihbhe)[ii].capid();
01088             fDigiSum += (tool[ii]-calibrations.pedestal(capid));
01089           }
01090           
01091           mehHcalSHE[1]->Fill(fHFEnergySimHits[cell.rawId()]);
01092           mehHcalAEE[1]->Fill(fDigiSum);
01093           //Adding protection against FPE
01094           if (fHFEnergySimHits[cell.rawId()]!=0){
01095             mehHcalAEESHE[1]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01096           }
01097           //else{
01098           //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01099           //}
01100           mehHcalSHEvAEE[1]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01101         }
01102       }
01103     }
01104   
01105     if (verbosity > 1) {
01106       eventout += "\n          Number of HBDigis collected:.............. ";
01107       eventout += iHB;
01108     }
01109     mehHcaln[0]->Fill((float)iHB);
01110     
01111     if (verbosity > 1) {
01112       eventout += "\n          Number of HEDigis collected:.............. ";
01113       eventout += iHE;
01114     }
01115     mehHcaln[1]->Fill((float)iHE);
01116   }
01117 
01119   // get HO information
01121   edm::Handle<edm::SortedCollection<HODataFrame> > ho;
01122   iEvent.getByLabel(HCalDigi_,ho);
01123   bool validHO = true;
01124   if (!ho.isValid()) {
01125     LogDebug(MsgLoggerCat)
01126       << "Unable to find HODataFrame in event!";
01127     validHO = false;
01128   }    
01129   if (validHO) {
01130     edm::SortedCollection<HODataFrame>::const_iterator iho;
01131     
01132     int iHO = 0; 
01133     for (iho = ho->begin(); iho != ho->end(); ++iho) {
01134       HcalDetId cell(iho->id()); 
01135       
01136       if (cell.subdet() == sdHcalOut) {
01137         
01138         //HCalconditions->makeHcalCalibration(cell, &calibrations);
01139         const HcalCalibrations& calibrations = 
01140           HCalconditions->getHcalCalibrations(cell);
01141         const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
01142         HcalCoderDb coder (*channelCoder, *shape);
01143         coder.adc2fC(*iho, tool);
01144         
01145         ++iHO;
01146         float fDigiSum = 0.0;
01147         for  (int ii = 0; ii < tool.size(); ++ii) {
01148           // default ped is 4.5
01149           int capid = (*iho)[ii].capid();
01150           fDigiSum += (tool[ii] - calibrations.pedestal(capid));
01151         }
01152         
01153         mehHcalSHE[2]->Fill(fHFEnergySimHits[cell.rawId()]);
01154         mehHcalAEE[2]->Fill(fDigiSum);
01155         //Adding protection against FPE
01156         if (fHFEnergySimHits[cell.rawId()]!=0){
01157           mehHcalAEESHE[2]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01158         }
01159         //else{
01160         //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01161         //}
01162         mehHcalSHEvAEE[2]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01163       }
01164     }
01165     
01166     if (verbosity > 1) {
01167       eventout += "\n          Number of HODigis collected:.............. ";
01168       eventout += iHO;
01169     }
01170     mehHcaln[2]->Fill((float)iHO);
01171   }  
01172 
01174   // get HF information
01176   edm::Handle<edm::SortedCollection<HFDataFrame> > hf;
01177   iEvent.getByLabel(HCalDigi_,hf);
01178   bool validHF = true;
01179   if (!hf.isValid()) {
01180     LogDebug(MsgLoggerCat)
01181       << "Unable to find HFDataFrame in event!";
01182     validHF = false;
01183   }    
01184   if (validHF) {
01185     edm::SortedCollection<HFDataFrame>::const_iterator ihf;
01186     
01187     int iHF = 0; 
01188     for (ihf = hf->begin(); ihf != hf->end(); ++ihf) {
01189       HcalDetId cell(ihf->id()); 
01190       
01191       if (cell.subdet() == sdHcalFwd) {
01192         
01193         //HCalconditions->makeHcalCalibration(cell, &calibrations);
01194         const HcalCalibrations& calibrations = 
01195           HCalconditions->getHcalCalibrations(cell);
01196         const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
01197         HcalCoderDb coder (*channelCoder, *shape);
01198         coder.adc2fC(*ihf, tool);
01199         
01200         ++iHF;
01201         float fDigiSum = 0.0;
01202         for  (int ii = 0; ii < tool.size(); ++ii) {
01203           // default ped is 1.73077
01204           int capid = (*ihf)[ii].capid();
01205           fDigiSum += (tool[ii] - calibrations.pedestal(capid));
01206         }
01207         
01208         mehHcalSHE[3]->Fill(fHFEnergySimHits[cell.rawId()]);
01209         mehHcalAEE[3]->Fill(fDigiSum);
01210         //Adding protection against FPE
01211         if (fHFEnergySimHits[cell.rawId()]!=0){
01212           mehHcalAEESHE[3]->Fill(fDigiSum/fHFEnergySimHits[cell.rawId()]);
01213         }
01214         //else{
01215         //  std::cout<<"It would have been an FPE! with fHFEnergySimHits[cell.rawId()]==0!\n";
01216         //}
01217         mehHcalSHEvAEE[3]->Fill(fDigiSum, fHFEnergySimHits[cell.rawId()]);
01218       }
01219     }
01220   
01221     if (verbosity > 1) {
01222       eventout += "\n          Number of HFDigis collected:.............. ";
01223       eventout += iHF;
01224     }
01225     mehHcaln[3]->Fill((float)iHF);
01226   }
01227 
01228   if (verbosity > 0)
01229     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01230   
01231   return;
01232 }
01233 
01234 void GlobalDigisAnalyzer::fillTrk(const edm::Event& iEvent, 
01235                                   const edm::EventSetup& iSetup)
01236 {
01237   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillTrk";
01238   
01239   TString eventout;
01240   if (verbosity > 0)
01241     eventout = "\nGathering info:";  
01242   
01243   // get strip information
01244   edm::Handle<edm::DetSetVector<SiStripDigi> > stripDigis;  
01245   iEvent.getByLabel(SiStripSrc_, stripDigis);
01246   bool validstripDigis = true;
01247   if (!stripDigis.isValid()) {
01248     LogDebug(MsgLoggerCat)
01249       << "Unable to find stripDigis in event!";
01250     validstripDigis = false;
01251   }  
01252   
01253   if (validstripDigis) {
01254     int nStripBrl = 0, nStripFwd = 0;
01255     edm::DetSetVector<SiStripDigi>::const_iterator DSViter;
01256     for (DSViter = stripDigis->begin(); DSViter != stripDigis->end(); 
01257          ++DSViter) {
01258       unsigned int id = DSViter->id;
01259       DetId detId(id);
01260       edm::DetSet<SiStripDigi>::const_iterator begin = DSViter->data.begin();
01261       edm::DetSet<SiStripDigi>::const_iterator end = DSViter->data.end();
01262       edm::DetSet<SiStripDigi>::const_iterator iter;
01263       
01264       // get TIB
01265       if (detId.subdetId() == sdSiTIB) {
01266         TIBDetId tibid(id);
01267         for (iter = begin; iter != end; ++iter) {
01268           ++nStripBrl;
01269           if (tibid.layer() == 1) {
01270             mehSiStripADC[0]->Fill((*iter).adc());
01271             mehSiStripStrip[0]->Fill((*iter).strip());
01272           }
01273           if (tibid.layer() == 2) {
01274             mehSiStripADC[1]->Fill((*iter).adc());
01275             mehSiStripStrip[1]->Fill((*iter).strip());
01276           }     
01277           if (tibid.layer() == 3) {
01278             mehSiStripADC[2]->Fill((*iter).adc());
01279             mehSiStripStrip[2]->Fill((*iter).strip());
01280           }
01281           if (tibid.layer() == 4) {
01282             mehSiStripADC[3]->Fill((*iter).adc());
01283             mehSiStripStrip[3]->Fill((*iter).strip());
01284           }
01285         }
01286       }
01287       
01288       // get TOB
01289       if (detId.subdetId() == sdSiTOB) {
01290         TOBDetId tobid(id);
01291         for (iter = begin; iter != end; ++iter) {
01292           ++nStripBrl;
01293           if (tobid.layer() == 1) {
01294             mehSiStripADC[4]->Fill((*iter).adc());
01295             mehSiStripStrip[4]->Fill((*iter).strip());
01296           }
01297           if (tobid.layer() == 2) {
01298             mehSiStripADC[5]->Fill((*iter).adc());
01299             mehSiStripStrip[5]->Fill((*iter).strip());
01300           }     
01301           if (tobid.layer() == 3) {
01302             mehSiStripADC[6]->Fill((*iter).adc());
01303             mehSiStripStrip[6]->Fill((*iter).strip());
01304           }
01305           if (tobid.layer() == 4) {
01306             mehSiStripADC[7]->Fill((*iter).adc());
01307             mehSiStripStrip[7]->Fill((*iter).strip());
01308           }
01309         }
01310       }    
01311       
01312       // get TID
01313       if (detId.subdetId() == sdSiTID) {
01314         TIDDetId tidid(id);
01315         for (iter = begin; iter != end; ++iter) {
01316           ++nStripFwd;
01317           if (tidid.wheel() == 1) {
01318             mehSiStripADC[8]->Fill((*iter).adc());
01319             mehSiStripStrip[8]->Fill((*iter).strip());
01320           }
01321           if (tidid.wheel() == 2) {
01322             mehSiStripADC[9]->Fill((*iter).adc());
01323             mehSiStripStrip[9]->Fill((*iter).strip());
01324           }
01325           if (tidid.wheel() == 3) {
01326             mehSiStripADC[10]->Fill((*iter).adc());
01327             mehSiStripStrip[10]->Fill((*iter).strip());
01328           }
01329         }
01330       }   
01331       
01332       // get TEC
01333       if (detId.subdetId() == sdSiTEC) {
01334         TECDetId tecid(id);
01335         for (iter = begin; iter != end; ++iter) {
01336           ++nStripFwd;
01337           if (tecid.wheel() == 1) {
01338             mehSiStripADC[11]->Fill((*iter).adc());
01339             mehSiStripStrip[11]->Fill((*iter).strip());
01340           }
01341           if (tecid.wheel() == 2) {
01342             mehSiStripADC[12]->Fill((*iter).adc());
01343             mehSiStripStrip[12]->Fill((*iter).strip());
01344           }
01345           if (tecid.wheel() == 3) {
01346             mehSiStripADC[13]->Fill((*iter).adc());
01347             mehSiStripStrip[13]->Fill((*iter).strip());
01348           }
01349           if (tecid.wheel() == 4) {
01350             mehSiStripADC[14]->Fill((*iter).adc());
01351             mehSiStripStrip[14]->Fill((*iter).strip());
01352           }
01353           if (tecid.wheel() == 5) {
01354             mehSiStripADC[15]->Fill((*iter).adc());
01355             mehSiStripStrip[15]->Fill((*iter).strip());
01356           }
01357           if (tecid.wheel() == 6) {
01358             mehSiStripADC[16]->Fill((*iter).adc());
01359             mehSiStripStrip[16]->Fill((*iter).strip());
01360           }
01361           if (tecid.wheel() == 7) {
01362             mehSiStripADC[17]->Fill((*iter).adc());
01363             mehSiStripStrip[17]->Fill((*iter).strip());
01364           }
01365           if (tecid.wheel() == 8) {
01366             mehSiStripADC[18]->Fill((*iter).adc());
01367             mehSiStripStrip[18]->Fill((*iter).strip());
01368           }
01369         }
01370       }     
01371     } // end loop over DataSetVector
01372     
01373     if (verbosity > 1) {
01374       eventout += "\n          Number of BrlStripDigis collected:........ ";
01375       eventout += nStripBrl;
01376     }
01377     for(int i = 0; i < 8; ++i) {
01378       mehSiStripn[i]->Fill((float)nStripBrl);
01379     }
01380     
01381     if (verbosity > 1) {
01382       eventout += "\n          Number of FrwdStripDigis collected:....... ";
01383       eventout += nStripFwd;
01384     }
01385     for(int i = 8; i < 19; ++i) {
01386       mehSiStripn[i]->Fill((float)nStripFwd);
01387     }
01388   }
01389 
01390   // get pixel information
01391   edm::Handle<edm::DetSetVector<PixelDigi> > pixelDigis;  
01392   iEvent.getByLabel(SiPxlSrc_, pixelDigis);
01393   bool validpixelDigis = true;
01394   if (!pixelDigis.isValid()) {
01395     LogDebug(MsgLoggerCat)
01396       << "Unable to find pixelDigis in event!";
01397     validpixelDigis = false;
01398   }  
01399   if (validpixelDigis) {
01400     int nPxlBrl = 0, nPxlFwd = 0;
01401     edm::DetSetVector<PixelDigi>::const_iterator DPViter;
01402     for (DPViter = pixelDigis->begin(); DPViter != pixelDigis->end(); 
01403          ++DPViter) {
01404       unsigned int id = DPViter->id;
01405       DetId detId(id);
01406       edm::DetSet<PixelDigi>::const_iterator begin = DPViter->data.begin();
01407       edm::DetSet<PixelDigi>::const_iterator end = DPViter->data.end();
01408       edm::DetSet<PixelDigi>::const_iterator iter;
01409       
01410       // get Barrel pixels
01411       if (detId.subdetId() == sdPxlBrl) {
01412         PXBDetId bdetid(id);
01413         for (iter = begin; iter != end; ++iter) {
01414           ++nPxlBrl;
01415           if (bdetid.layer() == 1) {
01416             mehSiPixelADC[0]->Fill((*iter).adc());
01417             mehSiPixelRow[0]->Fill((*iter).row());
01418             mehSiPixelCol[0]->Fill((*iter).column());
01419           }
01420           if (bdetid.layer() == 2) {
01421             mehSiPixelADC[1]->Fill((*iter).adc());
01422             mehSiPixelRow[1]->Fill((*iter).row());
01423             mehSiPixelCol[1]->Fill((*iter).column());
01424           }
01425           if (bdetid.layer() == 3) {
01426             mehSiPixelADC[2]->Fill((*iter).adc());
01427             mehSiPixelRow[2]->Fill((*iter).row());
01428             mehSiPixelCol[2]->Fill((*iter).column());
01429           }
01430         }
01431       }
01432       
01433       // get Forward pixels
01434       if (detId.subdetId() == sdPxlFwd) {
01435         PXFDetId fdetid(id);
01436         for (iter = begin; iter != end; ++iter) {
01437           ++nPxlFwd;
01438           if (fdetid.disk() == 1) {
01439             if (fdetid.side() == 1) {
01440               mehSiPixelADC[4]->Fill((*iter).adc());
01441               mehSiPixelRow[4]->Fill((*iter).row());
01442               mehSiPixelCol[4]->Fill((*iter).column());
01443             }
01444             if (fdetid.side() == 2) {
01445               mehSiPixelADC[3]->Fill((*iter).adc());
01446               mehSiPixelRow[3]->Fill((*iter).row());
01447               mehSiPixelCol[3]->Fill((*iter).column());
01448             }
01449           }
01450           if (fdetid.disk() == 2) {
01451             if (fdetid.side() == 1) {
01452               
01453               mehSiPixelADC[6]->Fill((*iter).adc());
01454               mehSiPixelRow[6]->Fill((*iter).row());
01455               mehSiPixelCol[6]->Fill((*iter).column());
01456             }
01457             if (fdetid.side() == 2) {
01458               mehSiPixelADC[5]->Fill((*iter).adc());
01459               mehSiPixelRow[5]->Fill((*iter).row());
01460               mehSiPixelCol[5]->Fill((*iter).column());
01461             }
01462           }
01463         }
01464       }
01465     }
01466     
01467     if (verbosity > 1) {
01468       eventout += "\n          Number of BrlPixelDigis collected:........ ";
01469       eventout += nPxlBrl;
01470     }
01471     for(int i = 0; i < 3; ++i) {
01472       mehSiPixeln[i]->Fill((float)nPxlBrl);
01473     }
01474     
01475     if (verbosity > 1) {
01476       eventout += "\n          Number of FrwdPixelDigis collected:....... ";
01477       eventout += nPxlFwd;
01478     }
01479     
01480     for(int i = 3; i < 7; ++i) {
01481       mehSiPixeln[i]->Fill((float)nPxlFwd);
01482     }
01483   }
01484 
01485   if (verbosity > 0)
01486     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01487   
01488   return;
01489 }
01490 
01491 void GlobalDigisAnalyzer::fillMuon(const edm::Event& iEvent, 
01492                                    const edm::EventSetup& iSetup)
01493 {
01494   std::string MsgLoggerCat = "GlobalDigisAnalyzer_fillMuon";
01495   
01496   TString eventout;
01497   if (verbosity > 0)
01498     eventout = "\nGathering info:";  
01499   
01500   // get DT information
01501   edm::Handle<DTDigiCollection> dtDigis;  
01502   iEvent.getByLabel(MuDTSrc_, dtDigis);
01503   bool validdtDigis = true;
01504   if (!dtDigis.isValid()) {
01505     LogDebug(MsgLoggerCat)
01506       << "Unable to find dtDigis in event!";
01507     validdtDigis = false;
01508   }  
01509   if (validdtDigis) {
01510     int nDt0 = 0; int nDt1 = 0; int nDt2 = 0; int nDt3 = 0;
01511     int nDt = 0;
01512     DTDigiCollection::DigiRangeIterator detUnitIt;
01513     for (detUnitIt = dtDigis->begin(); detUnitIt != dtDigis->end(); 
01514          ++detUnitIt) {
01515       
01516       const DTLayerId& id = (*detUnitIt).first;
01517       const DTDigiCollection::Range& range = (*detUnitIt).second;
01518       for (DTDigiCollection::const_iterator digiIt = range.first;
01519            digiIt != range.second;
01520            ++digiIt) {
01521         
01522         ++nDt;
01523         
01524         DTWireId wireId(id,(*digiIt).wire());
01525         if (wireId.station() == 1) {
01526           mehDtMuonLayer[0]->Fill(id.layer());
01527           mehDtMuonTime[0]->Fill((*digiIt).time());
01528           mehDtMuonTimevLayer[0]->Fill(id.layer(),(*digiIt).time());
01529           ++nDt0;
01530         }
01531         if (wireId.station() == 2) {
01532           mehDtMuonLayer[1]->Fill(id.layer());
01533           mehDtMuonTime[1]->Fill((*digiIt).time());
01534           mehDtMuonTimevLayer[1]->Fill(id.layer(),(*digiIt).time());
01535           ++nDt1;
01536         }
01537         if (wireId.station() == 3) {
01538           mehDtMuonLayer[2]->Fill(id.layer());
01539           mehDtMuonTime[2]->Fill((*digiIt).time());
01540           mehDtMuonTimevLayer[2]->Fill(id.layer(),(*digiIt).time());
01541           ++nDt2;
01542         }
01543         if (wireId.station() == 4) {
01544           mehDtMuonLayer[3]->Fill(id.layer());
01545           mehDtMuonTime[3]->Fill((*digiIt).time());
01546           mehDtMuonTimevLayer[3]->Fill(id.layer(),(*digiIt).time());
01547           ++nDt3;
01548         }
01549       }
01550     }
01551     mehDtMuonn[0]->Fill((float)nDt0);
01552     mehDtMuonn[1]->Fill((float)nDt1);
01553     mehDtMuonn[2]->Fill((float)nDt2);
01554     mehDtMuonn[3]->Fill((float)nDt3);
01555     
01556     
01557     if (verbosity > 1) {
01558       eventout += "\n          Number of DtMuonDigis collected:.......... ";
01559       eventout += nDt;
01560     }
01561   }
01562 
01563   // get CSC Strip information
01564   edm::Handle<CSCStripDigiCollection> strips;  
01565   iEvent.getByLabel(MuCSCStripSrc_, strips);
01566   bool validstrips = true;
01567   if (!strips.isValid()) {
01568     LogDebug(MsgLoggerCat)
01569       << "Unable to find muon strips in event!";
01570     validstrips = false;
01571   }
01572   
01573   if (validstrips) {
01574     int nStrips = 0;
01575     for (CSCStripDigiCollection::DigiRangeIterator j = strips->begin();
01576          j != strips->end();
01577          ++j) {
01578       
01579       std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
01580       std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
01581       
01582       for ( ; digiItr != last; ++digiItr) {
01583         ++nStrips;
01584         
01585         // average pedestals
01586         std::vector<int> adcCounts = digiItr->getADCCounts();
01587         theCSCStripPedestalSum += adcCounts[0];
01588         theCSCStripPedestalSum += adcCounts[1];
01589         theCSCStripPedestalCount += 2;
01590         
01591         // if there are enough pedestal statistics
01592         if (theCSCStripPedestalCount > 100) {
01593           float pedestal = theCSCStripPedestalSum / theCSCStripPedestalCount;
01594           if (adcCounts[5] > (pedestal + 100)) 
01595             mehCSCStripADC->Fill(adcCounts[4] - pedestal);
01596         }
01597       }
01598     }
01599     
01600     if (verbosity > 1) {
01601       eventout += "\n          Number of CSCStripDigis collected:........ ";
01602       eventout += nStrips;
01603     }
01604     mehCSCStripn->Fill((float)nStrips);
01605   }
01606 
01607   // get CSC Wire information
01608   edm::Handle<CSCWireDigiCollection> wires;  
01609   iEvent.getByLabel(MuCSCWireSrc_, wires);
01610   bool validwires = true;
01611   if (!wires.isValid()) {
01612     LogDebug(MsgLoggerCat)
01613       << "Unable to find muon wires in event!";
01614     validwires = false;
01615   }  
01616   
01617   if (validwires) {
01618     int nWires = 0;
01619     for (CSCWireDigiCollection::DigiRangeIterator j = wires->begin();
01620          j != wires->end();
01621          ++j) {
01622       
01623       std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
01624       std::vector<CSCWireDigi>::const_iterator endDigi = (*j).second.second;
01625       
01626       for ( ; digiItr != endDigi; ++digiItr) {
01627         ++nWires;
01628         mehCSCWireTime->Fill(digiItr->getTimeBin());
01629       }
01630     }
01631     
01632     if (verbosity > 1) {
01633       eventout += "\n          Number of CSCWireDigis collected:......... ";
01634       eventout += nWires;
01635     }
01636     mehCSCWiren->Fill((float)nWires); 
01637   }
01638 
01639   // get RPC information
01640   // Get the RPC Geometry
01641   edm::ESHandle<RPCGeometry> rpcGeom;
01642   iSetup.get<MuonGeometryRecord>().get(rpcGeom);
01643   if (!rpcGeom.isValid()) {
01644     edm::LogWarning(MsgLoggerCat)
01645       << "Unable to find RPCGeometryRecord in event!";
01646     return;
01647   }
01648   
01649   edm::Handle<edm::PSimHitContainer> rpcsimHit;
01650   iEvent.getByLabel("g4SimHits", "MuonRPCHits", rpcsimHit);
01651   bool validrpcsim = true;
01652   if (!rpcsimHit.isValid()) {
01653     LogDebug(MsgLoggerCat)
01654       << "Unable to find rpcsimHit in event!";
01655     validrpcsim = false;
01656   }   
01657   
01658   edm::Handle<RPCDigiCollection> rpcDigis;  
01659   iEvent.getByLabel(MuRPCSrc_, rpcDigis);
01660   bool validrpcdigi = true;
01661   if (!rpcDigis.isValid()) {
01662     LogDebug(MsgLoggerCat)
01663       << "Unable to find rpcDigis in event!";
01664     validrpcdigi = false;
01665   } 
01666 
01667   // ONLY UNTIL PROBLEM WITH RPC DIGIS IS FIGURED OUT
01668   validrpcdigi = false;
01669 
01670   // Loop on simhits
01671   edm::PSimHitContainer::const_iterator rpcsimIt;
01672   std::map<RPCDetId, std::vector<double> > allsims;
01673 
01674   if (validrpcsim) {
01675     for (rpcsimIt = rpcsimHit->begin(); rpcsimIt != rpcsimHit->end(); 
01676          rpcsimIt++) {
01677       RPCDetId Rsid = (RPCDetId)(*rpcsimIt).detUnitId();
01678       int ptype = rpcsimIt->particleType();
01679       
01680       if (ptype == 13 || ptype == -13) {
01681         std::vector<double> buff;
01682         if (allsims.find(Rsid) != allsims.end() ){
01683           buff= allsims[Rsid];
01684         }
01685         buff.push_back(rpcsimIt->localPosition().x());
01686         allsims[Rsid]=buff;
01687       }
01688     }
01689   }
01690 
01691   // CRASH HAPPENS SOMEWHERE HERE IN FOR DECLARATION
01692   // WHAT IS WRONG WITH rpcDigis?????
01693   if (validrpcdigi) {
01694     int nRPC = 0;
01695     RPCDigiCollection::DigiRangeIterator rpcdetUnitIt;
01696     for (rpcdetUnitIt = rpcDigis->begin(); rpcdetUnitIt != rpcDigis->end(); 
01697          ++rpcdetUnitIt) {
01698       
01699       const RPCDetId Rsid = (*rpcdetUnitIt).first;      
01700       const RPCRoll* roll = 
01701         dynamic_cast<const RPCRoll* >( rpcGeom->roll(Rsid));   
01702       const RPCDigiCollection::Range& range = (*rpcdetUnitIt).second;
01703       
01704       std::vector<double> sims;
01705       if (allsims.find(Rsid) != allsims.end() ){
01706         sims = allsims[Rsid];
01707       }
01708       
01709       int ndigi = 0;
01710       for (RPCDigiCollection::const_iterator rpcdigiIt = range.first;
01711            rpcdigiIt != range.second;
01712            ++rpcdigiIt) {
01713         
01714         ++ndigi;
01715         ++nRPC;
01716       }
01717       
01718       if (sims.size() == 1 && ndigi == 1){
01719         double dis = roll->centreOfStrip(range.first->strip()).x()-sims[0];
01720         
01721         if (Rsid.region() == 0 ){
01722           if (Rsid.ring() == -2)
01723             mehRPCRes[0]->Fill((float)dis);
01724           else if (Rsid.ring() == -1)
01725             mehRPCRes[1]->Fill((float)dis);
01726           else if (Rsid.ring() == 0)
01727             mehRPCRes[2]->Fill((float)dis);
01728           else if (Rsid.ring() == 1)
01729             mehRPCRes[3]->Fill((float)dis);
01730           else if (Rsid.ring() == 2)
01731             mehRPCRes[4]->Fill((float)dis);
01732         }  
01733       }
01734     }
01735     
01736     if (verbosity > 1) {
01737       eventout += "\n          Number of RPCDigis collected:.............. ";
01738       eventout += nRPC;
01739     }
01740     mehRPCMuonn->Fill(float(nRPC));
01741   }
01742   
01743   if (verbosity > 0)
01744     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01745   
01746   return;
01747 }