CMS 3D CMS Logo

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